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.
5 #include "content/browser/geolocation/geolocation_service_context.h"
9 GeolocationServiceContext::GeolocationServiceContext() : paused_(false) {
12 GeolocationServiceContext::~GeolocationServiceContext() {
15 void GeolocationServiceContext::CreateService(
16 const base::Closure
& update_callback
,
17 mojo::InterfaceRequest
<GeolocationService
> request
) {
18 GeolocationServiceImpl
* service
=
19 new GeolocationServiceImpl(request
.Pass(), this, update_callback
);
20 services_
.push_back(service
);
21 if (geoposition_override_
)
22 service
->SetOverride(*geoposition_override_
.get());
24 service
->StartListeningForUpdates();
27 void GeolocationServiceContext::ServiceHadConnectionError(
28 GeolocationServiceImpl
* service
) {
29 auto it
= std::find(services_
.begin(), services_
.end(), service
);
30 DCHECK(it
!= services_
.end());
34 void GeolocationServiceContext::PauseUpdates() {
36 for (auto* service
: services_
) {
37 service
->PauseUpdates();
41 void GeolocationServiceContext::ResumeUpdates() {
43 for (auto* service
: services_
) {
44 service
->ResumeUpdates();
48 void GeolocationServiceContext::SetOverride(
49 scoped_ptr
<Geoposition
> geoposition
) {
50 geoposition_override_
.swap(geoposition
);
51 for (auto* service
: services_
) {
52 service
->SetOverride(*geoposition_override_
.get());
56 void GeolocationServiceContext::ClearOverride() {
57 for (auto* service
: services_
) {
58 service
->ClearOverride();
62 } // namespace content