aw: Rendering test harness and end-to-end smoke test
[chromium-blink-merge.git] / content / browser / geolocation / geolocation_service_context.cc
blobfc6b4aa07cd4102e2e8b2404b2ebba0f2d969c11
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"
7 namespace content {
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(this, update_callback);
20 services_.push_back(service);
21 mojo::WeakBindToRequest(service, &request);
22 if (geoposition_override_)
23 service->SetOverride(*geoposition_override_.get());
24 else
25 service->StartListeningForUpdates();
28 void GeolocationServiceContext::ServiceHadConnectionError(
29 GeolocationServiceImpl* service) {
30 auto it = std::find(services_.begin(), services_.end(), service);
31 DCHECK(it != services_.end());
32 services_.erase(it);
35 void GeolocationServiceContext::PauseUpdates() {
36 paused_ = true;
37 for (auto* service : services_) {
38 service->PauseUpdates();
42 void GeolocationServiceContext::ResumeUpdates() {
43 paused_ = false;
44 for (auto* service : services_) {
45 service->ResumeUpdates();
49 void GeolocationServiceContext::SetOverride(
50 scoped_ptr<Geoposition> geoposition) {
51 geoposition_override_.swap(geoposition);
52 for (auto* service : services_) {
53 service->SetOverride(*geoposition_override_.get());
57 void GeolocationServiceContext::ClearOverride() {
58 for (auto* service : services_) {
59 service->ClearOverride();
63 } // namespace content