Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Side by Side Diff: device/geolocation/geolocation_provider_impl.cc

Issue 2249283003: Hooks together Geolocation Feature in the Client and Engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lai
Patch Set: Put TestingLocationArbitrator out of anonymous namespace. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/geolocation/BUILD.gn ('k') | device/geolocation/location_arbitrator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "device/geolocation/geolocation_provider_impl.h" 5 #include "device/geolocation/geolocation_provider_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "device/geolocation/geolocation_delegate.h" 19 #include "device/geolocation/geolocation_delegate.h"
20 #include "device/geolocation/location_arbitrator_impl.h" 20 #include "device/geolocation/location_arbitrator.h"
21 21
22 namespace device { 22 namespace device {
23 23
24 namespace { 24 namespace {
25 base::LazyInstance<std::unique_ptr<GeolocationDelegate>>::Leaky g_delegate = 25 base::LazyInstance<std::unique_ptr<GeolocationDelegate>>::Leaky g_delegate =
26 LAZY_INSTANCE_INITIALIZER; 26 LAZY_INSTANCE_INITIALIZER;
27 } // anonymous namespace 27 } // anonymous namespace
28 28
29 // static 29 // static
30 GeolocationProvider* GeolocationProvider::GetInstance() { 30 GeolocationProvider* GeolocationProvider::GetInstance() {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void GeolocationProviderImpl::Init() { 183 void GeolocationProviderImpl::Init() {
184 DCHECK(OnGeolocationThread()); 184 DCHECK(OnGeolocationThread());
185 185
186 if (!arbitrator_) { 186 if (!arbitrator_) {
187 LocationProvider::LocationProviderUpdateCallback callback = base::Bind( 187 LocationProvider::LocationProviderUpdateCallback callback = base::Bind(
188 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); 188 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this));
189 // Use the embedder's |g_delegate| or fall back to the default one. 189 // Use the embedder's |g_delegate| or fall back to the default one.
190 if (!g_delegate.Get()) 190 if (!g_delegate.Get())
191 g_delegate.Get().reset(new GeolocationDelegate); 191 g_delegate.Get().reset(new GeolocationDelegate);
192 192
193 arbitrator_ = 193 arbitrator_ = base::MakeUnique<LocationArbitrator>(
194 base::MakeUnique<LocationArbitratorImpl>(g_delegate.Get().get()); 194 base::WrapUnique(g_delegate.Get().get()));
195 arbitrator_->SetUpdateCallback(callback); 195 arbitrator_->SetUpdateCallback(callback);
196 } 196 }
197 } 197 }
198 198
199 void GeolocationProviderImpl::CleanUp() { 199 void GeolocationProviderImpl::CleanUp() {
200 DCHECK(OnGeolocationThread()); 200 DCHECK(OnGeolocationThread());
201 arbitrator_.reset(); 201 arbitrator_.reset();
202 } 202 }
203 203
204 } // namespace device 204 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/BUILD.gn ('k') | device/geolocation/location_arbitrator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698