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

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

Issue 2379253002: Remove ContentViewCore::PauseOrResumeGeolocation() (Closed)
Patch Set: comment Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_service_context.h" 5 #include "device/geolocation/geolocation_service_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "device/geolocation/geolocation_service_impl.h" 9 #include "device/geolocation/geolocation_service_impl.h"
10 10
11 namespace device { 11 namespace device {
12 12
13 GeolocationServiceContext::GeolocationServiceContext() : paused_(false) {} 13 GeolocationServiceContext::GeolocationServiceContext() {}
14 14
15 GeolocationServiceContext::~GeolocationServiceContext() {} 15 GeolocationServiceContext::~GeolocationServiceContext() {}
16 16
17 void GeolocationServiceContext::CreateService( 17 void GeolocationServiceContext::CreateService(
18 const base::Closure& update_callback, 18 const base::Closure& update_callback,
19 mojo::InterfaceRequest<mojom::GeolocationService> request) { 19 mojo::InterfaceRequest<mojom::GeolocationService> request) {
20 GeolocationServiceImpl* service = 20 GeolocationServiceImpl* service =
21 new GeolocationServiceImpl(std::move(request), this, update_callback); 21 new GeolocationServiceImpl(std::move(request), this, update_callback);
22 services_.push_back(service); 22 services_.push_back(service);
23 if (geoposition_override_) 23 if (geoposition_override_)
24 service->SetOverride(*geoposition_override_.get()); 24 service->SetOverride(*geoposition_override_.get());
25 else 25 else
26 service->StartListeningForUpdates(); 26 service->StartListeningForUpdates();
27 } 27 }
28 28
29 void GeolocationServiceContext::ServiceHadConnectionError( 29 void GeolocationServiceContext::ServiceHadConnectionError(
30 GeolocationServiceImpl* service) { 30 GeolocationServiceImpl* service) {
31 auto it = std::find(services_.begin(), services_.end(), service); 31 auto it = std::find(services_.begin(), services_.end(), service);
32 DCHECK(it != services_.end()); 32 DCHECK(it != services_.end());
33 services_.erase(it); 33 services_.erase(it);
34 } 34 }
35 35
36 void GeolocationServiceContext::PauseUpdates() {
37 paused_ = true;
38 for (auto* service : services_) {
39 service->PauseUpdates();
40 }
41 }
42
43 void GeolocationServiceContext::ResumeUpdates() {
44 paused_ = false;
45 for (auto* service : services_) {
46 service->ResumeUpdates();
47 }
48 }
49
50 void GeolocationServiceContext::SetOverride( 36 void GeolocationServiceContext::SetOverride(
51 std::unique_ptr<Geoposition> geoposition) { 37 std::unique_ptr<Geoposition> geoposition) {
52 geoposition_override_.swap(geoposition); 38 geoposition_override_.swap(geoposition);
53 for (auto* service : services_) { 39 for (auto* service : services_) {
54 service->SetOverride(*geoposition_override_.get()); 40 service->SetOverride(*geoposition_override_.get());
55 } 41 }
56 } 42 }
57 43
58 void GeolocationServiceContext::ClearOverride() { 44 void GeolocationServiceContext::ClearOverride() {
59 for (auto* service : services_) { 45 for (auto* service : services_) {
60 service->ClearOverride(); 46 service->ClearOverride();
61 } 47 }
62 } 48 }
63 49
64 } // namespace device 50 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/geolocation_service_context.h ('k') | device/geolocation/geolocation_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698