Chromium Code Reviews| Index: content/browser/geolocation/geolocation_service_context.cc |
| diff --git a/content/browser/geolocation/geolocation_service_context.cc b/content/browser/geolocation/geolocation_service_context.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4effa02095498d49e995973f26e03421bd02e8da |
| --- /dev/null |
| +++ b/content/browser/geolocation/geolocation_service_context.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/geolocation/geolocation_service_context.h" |
| + |
| +namespace content { |
| + |
| +GeolocationServiceContext::GeolocationServiceContext() : paused_(false) { |
| +} |
| + |
| +GeolocationServiceContext::~GeolocationServiceContext() { |
| +} |
| + |
| +void GeolocationServiceContext::CreateService( |
| + const base::Closure& update_callback, |
| + mojo::InterfaceRequest<GeolocationService> request) { |
| + GeolocationServiceImpl* service = |
| + new GeolocationServiceImpl(this, update_callback); |
|
Charlie Reis
2014/10/21 22:28:32
Just want to make sure I follow how things work in
blundell
2014/10/22 16:05:14
Yes.
Charlie Reis
2014/10/22 16:11:55
Yes, I think that would do. I imagine we'll want
|
| + if (geoposition_override_) |
| + service->SetOverride(*geoposition_override_.get()); |
| + services_.push_back(service); |
| + mojo::WeakBindToRequest(service, &request); |
| +} |
| + |
| +void GeolocationServiceContext::ServiceHadConnectionError( |
| + GeolocationServiceImpl* service) { |
| + auto it = std::find(services_.begin(), services_.end(), service); |
| + DCHECK(it != services_.end()); |
| + services_.erase(it); |
| +} |
| + |
| +void GeolocationServiceContext::PauseUpdates() { |
| + paused_ = true; |
| + for (auto* service : services_) { |
|
Charlie Reis
2014/10/21 22:28:32
nit: No braces needed on one line body (here and b
blundell
2014/10/23 12:27:01
I'd prefer to leave the braces...loops without bra
|
| + service->PauseUpdates(); |
| + } |
| +} |
| + |
| +void GeolocationServiceContext::ResumeUpdates() { |
| + paused_ = false; |
| + for (auto* service : services_) { |
| + service->ResumeUpdates(); |
| + } |
| +} |
| + |
| +void GeolocationServiceContext::SetOverride( |
| + scoped_ptr<Geoposition> geoposition) { |
| + geoposition_override_.swap(geoposition); |
| + for (auto* service : services_) { |
| + service->SetOverride(*geoposition_override_.get()); |
| + } |
| +} |
| + |
| +void GeolocationServiceContext::ClearOverride() { |
| + for (auto* service : services_) { |
| + service->ClearOverride(); |
| + } |
| +} |
| + |
| +} // namespace content |