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

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

Issue 2192683003: Revert of Reland: Geolocation: move from content/browser to device/ (patchset #2 id:20001 of https:… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2810
Patch Set: Created 4 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "device/geolocation/geolocation_service_context.h"
6
7 #include <utility>
8
9 #include "device/geolocation/geolocation_service_impl.h"
10
11 namespace device {
12
13 GeolocationServiceContext::GeolocationServiceContext() : paused_(false) {
14 }
15
16 GeolocationServiceContext::~GeolocationServiceContext() {
17 }
18
19 void GeolocationServiceContext::CreateService(
20 const base::Closure& update_callback,
21 mojo::InterfaceRequest<blink::mojom::GeolocationService> request) {
22 GeolocationServiceImpl* service =
23 new GeolocationServiceImpl(std::move(request), this, update_callback);
24 services_.push_back(service);
25 if (geoposition_override_)
26 service->SetOverride(*geoposition_override_.get());
27 else
28 service->StartListeningForUpdates();
29 }
30
31 void GeolocationServiceContext::ServiceHadConnectionError(
32 GeolocationServiceImpl* service) {
33 auto it = std::find(services_.begin(), services_.end(), service);
34 DCHECK(it != services_.end());
35 services_.erase(it);
36 }
37
38 void GeolocationServiceContext::PauseUpdates() {
39 paused_ = true;
40 for (auto* service : services_) {
41 service->PauseUpdates();
42 }
43 }
44
45 void GeolocationServiceContext::ResumeUpdates() {
46 paused_ = false;
47 for (auto* service : services_) {
48 service->ResumeUpdates();
49 }
50 }
51
52 void GeolocationServiceContext::SetOverride(
53 std::unique_ptr<Geoposition> geoposition) {
54 geoposition_override_.swap(geoposition);
55 for (auto* service : services_) {
56 service->SetOverride(*geoposition_override_.get());
57 }
58 }
59
60 void GeolocationServiceContext::ClearOverride() {
61 for (auto* service : services_) {
62 service->ClearOverride();
63 }
64 }
65
66 } // namespace device
OLDNEW
« no previous file with comments | « device/geolocation/geolocation_service_context.h ('k') | device/geolocation/geolocation_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698