blob: e320d5c25d70858e13198d30e0845740c3a62347 [file] [log] [blame]
// 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 "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "device/geolocation/geolocation_export.h"
#include "device/geolocation/public/interfaces/geolocation.mojom.h"
namespace device {
class GeolocationServiceImpl;
struct Geoposition;
// Provides information to a set of GeolocationServiceImpl instances that are
// associated with a given context. Notably, allows pausing and resuming
// geolocation on these instances.
class DEVICE_GEOLOCATION_EXPORT GeolocationServiceContext {
virtual ~GeolocationServiceContext();
// Creates a GeolocationServiceImpl that is weakly bound to |request|.
// |update_callback| will be called when services send
// location updates to their clients.
void CreateService(const base::Closure& update_callback,
mojo::InterfaceRequest<mojom::GeolocationService> request);
// Called when a service has a connection error. After this call, it is no
// longer safe to access |service|.
void ServiceHadConnectionError(GeolocationServiceImpl* service);
// Pauses and resumes geolocation. Resuming when nothing is paused is a
// no-op. If a service is added while geolocation is paused, that service
// will not get geolocation updates until geolocation is resumed.
void PauseUpdates();
void ResumeUpdates();
// Returns whether geolocation updates are currently paused.
bool paused() { return paused_; }
// Enables geolocation override. This method can be used to trigger possible
// location-specific behavior in a particular context.
void SetOverride(std::unique_ptr<Geoposition> geoposition);
// Disables geolocation override.
void ClearOverride();
ScopedVector<GeolocationServiceImpl> services_;
bool paused_;
std::unique_ptr<Geoposition> geoposition_override_;
} // namespace device