| Index: content/browser/geolocation/geolocation.cc
|
| diff --git a/content/browser/geolocation/geolocation.cc b/content/browser/geolocation/geolocation.cc
|
| index 920ab3130d978aee16f381eea4e4c28fc37ff391..fbc0828121eb2e100b9a7464add56e96ec7d1647 100644
|
| --- a/content/browser/geolocation/geolocation.cc
|
| +++ b/content/browser/geolocation/geolocation.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| #include "base/location.h"
|
| +#include "base/logging.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/message_loop_proxy.h"
|
| #include "content/browser/geolocation/geolocation_provider.h"
|
| @@ -21,10 +22,33 @@ void OverrideLocationForTestingOnIOThread(
|
| const Geoposition& position,
|
| const base::Closure& completion_callback,
|
| scoped_refptr<base::MessageLoopProxy> callback_loop) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| GeolocationProvider::GetInstance()->OverrideLocationForTesting(position);
|
| callback_loop->PostTask(FROM_HERE, completion_callback);
|
| }
|
|
|
| +void GeolocationUpdateCallbackOnIOThread(
|
| + const GeolocationUpdateCallback& client_callback,
|
| + scoped_refptr<base::MessageLoopProxy> client_loop,
|
| + const Geoposition& position) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + if (base::MessageLoopProxy::current() != client_loop)
|
| + client_loop->PostTask(FROM_HERE, base::Bind(client_callback, position));
|
| + else
|
| + client_callback.Run(position);
|
| +}
|
| +
|
| +void RequestLocationUpdateOnIOThread(
|
| + const GeolocationUpdateCallback& client_callback,
|
| + scoped_refptr<base::MessageLoopProxy> client_loop) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| + GeolocationUpdateCallback io_thread_callback = base::Bind(
|
| + &GeolocationUpdateCallbackOnIOThread,
|
| + client_callback,
|
| + client_loop);
|
| + GeolocationProvider::GetInstance()->RequestCallback(io_thread_callback);
|
| +}
|
| +
|
| } // namespace
|
|
|
| void OverrideLocationForTesting(
|
| @@ -34,11 +58,20 @@ void OverrideLocationForTesting(
|
| position,
|
| completion_callback,
|
| base::MessageLoopProxy::current());
|
| - if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO))
|
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, closure);
|
| + else
|
| + closure.Run();
|
| +}
|
| +
|
| +void RequestLocationUpdate(const GeolocationUpdateCallback& callback) {
|
| + base::Closure closure = base::Bind(&RequestLocationUpdateOnIOThread,
|
| + callback,
|
| + base::MessageLoopProxy::current());
|
| + if (!BrowserThread::CurrentlyOn(BrowserThread::IO))
|
| BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, closure);
|
| - } else {
|
| + else
|
| closure.Run();
|
| - }
|
| }
|
|
|
| } // namespace content
|
|
|