Fix geolocation initialization race condition.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1117 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-03-04 21:10:59 +00:00
parent 5b5efb5c8b
commit f250f9ccea
3 changed files with 17 additions and 8 deletions

View File

@ -142,6 +142,18 @@ CefGeolocationClient::CefGeolocationClient(CefBrowserImpl* browser)
CefGeolocationClient::~CefGeolocationClient() {}
// static
void CefGeolocationClient::InitializeEnvironment() {
// GeolocationArbitrator uses ContentClient to retrieve the AccessTokenStore.
// Simulate the necessary interfaces here.
if (!content::GetContentClient()) {
static CefContentClient content_client;
static CefContentBrowserClient browser_client;
content_client.set_browser_for_testing(&browser_client);
content::SetContentClient(&content_client);
}
}
void CefGeolocationClient::geolocationDestroyed() {
DCHECK(CefThread::CurrentlyOn(CefThread::UI));
@ -243,14 +255,7 @@ void CefGeolocationClient::cancelPermissionRequest(
void CefGeolocationClient::OnStartUpdating(bool enable_high_accuracy) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// GeolocationArbitrator uses ContentClient to retrieve the AccessTokenStore.
// Simulate the necessary interfaces here.
if (!content::GetContentClient()) {
static CefContentClient content_client;
static CefContentBrowserClient browser_client;
content_client.set_browser_for_testing(&browser_client);
content::SetContentClient(&content_client);
}
InitializeEnvironment();
if (!location_provider_)
location_provider_ = content::GeolocationProvider::GetInstance();

View File

@ -37,6 +37,8 @@ class CefGeolocationClient
explicit CefGeolocationClient(CefBrowserImpl* browser);
virtual ~CefGeolocationClient();
static void InitializeEnvironment();
private:
friend class CefGeolocationCallbackImpl;

View File

@ -6,6 +6,7 @@
#include "libcef/cef_context.h"
#include "libcef/cef_thread.h"
#include "libcef/cef_time_util.h"
#include "libcef/geolocation_client.h"
#include "base/logging.h"
#include "content/browser/geolocation/geolocation_provider.h"
#include "content/public/common/geoposition.h"
@ -66,6 +67,7 @@ bool CefGetGeolocation(CefRefPtr<CefGetGeolocationCallback> callback) {
}
if (CefThread::CurrentlyOn(CefThread::IO)) {
CefGeolocationClient::InitializeEnvironment();
content::GeolocationProvider* provider =
content::GeolocationProvider::GetInstance();
if (provider) {