OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/browser/geolocation.h" | 5 #include "content/public/browser/geolocation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
45 GeolocationUpdateCallback io_thread_callback = base::Bind( | 45 GeolocationUpdateCallback io_thread_callback = base::Bind( |
46 &GeolocationUpdateCallbackOnIOThread, | 46 &GeolocationUpdateCallbackOnIOThread, |
47 client_callback, | 47 client_callback, |
48 client_loop); | 48 client_loop); |
49 GeolocationProvider::GetInstance()->RequestCallback(io_thread_callback); | 49 GeolocationProvider::GetInstance()->RequestCallback(io_thread_callback); |
50 } | 50 } |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
| 54 |
| 55 // ---------------------------------------------------------------------------- |
| 56 |
54 void OverrideLocationForTesting( | 57 void OverrideLocationForTesting( |
55 const Geoposition& position, | 58 const Geoposition& position, |
56 const base::Closure& completion_callback) { | 59 const base::Closure& completion_callback) { |
57 base::Closure closure = base::Bind(&OverrideLocationForTestingOnIOThread, | 60 base::Closure closure = base::Bind(&OverrideLocationForTestingOnIOThread, |
58 position, | 61 position, |
59 completion_callback, | 62 completion_callback, |
60 base::MessageLoopProxy::current()); | 63 base::MessageLoopProxy::current()); |
61 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) | 64 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) |
62 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, closure); | 65 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, closure); |
63 else | 66 else |
64 closure.Run(); | 67 closure.Run(); |
65 } | 68 } |
66 | 69 |
67 void RequestLocationUpdate(const GeolocationUpdateCallback& callback) { | 70 void RequestLocationUpdate(const GeolocationUpdateCallback& callback) { |
68 base::Closure closure = base::Bind(&RequestLocationUpdateOnIOThread, | 71 base::Closure closure = base::Bind(&RequestLocationUpdateOnIOThread, |
69 callback, | 72 callback, |
70 base::MessageLoopProxy::current()); | 73 base::MessageLoopProxy::current()); |
71 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) | 74 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) |
72 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, closure); | 75 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, closure); |
73 else | 76 else |
74 closure.Run(); | 77 closure.Run(); |
75 } | 78 } |
76 | 79 |
77 } // namespace content | 80 } // namespace content |
OLD | NEW |