Merge revision 1117 changes:

- Fix geolocation initialization race condition.


git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1364@1118 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-03-04 21:11:32 +00:00
parent cba0ef9b96
commit e54fd9ed9f
3 changed files with 17 additions and 8 deletions

View File

@@ -142,6 +142,18 @@ CefGeolocationClient::CefGeolocationClient(CefBrowserImpl* browser)
CefGeolocationClient::~CefGeolocationClient() {} 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() { void CefGeolocationClient::geolocationDestroyed() {
DCHECK(CefThread::CurrentlyOn(CefThread::UI)); DCHECK(CefThread::CurrentlyOn(CefThread::UI));
@@ -243,14 +255,7 @@ void CefGeolocationClient::cancelPermissionRequest(
void CefGeolocationClient::OnStartUpdating(bool enable_high_accuracy) { void CefGeolocationClient::OnStartUpdating(bool enable_high_accuracy) {
DCHECK(CefThread::CurrentlyOn(CefThread::IO)); DCHECK(CefThread::CurrentlyOn(CefThread::IO));
// GeolocationArbitrator uses ContentClient to retrieve the AccessTokenStore. InitializeEnvironment();
// 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);
}
if (!location_provider_) if (!location_provider_)
location_provider_ = content::GeolocationProvider::GetInstance(); location_provider_ = content::GeolocationProvider::GetInstance();

View File

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

View File

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