summaryrefslogtreecommitdiff
path: root/chromium/device/geolocation/geolocation_service_context.h
blob: 581fd99106e294dc910cf68595d596b52d81cee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// 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.

#ifndef DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_
#define DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_

#include <memory>
#include <vector>

#include "base/macros.h"
#include "device/geolocation/geolocation_export.h"
#include "device/geolocation/public/interfaces/geolocation.mojom.h"

namespace service_manager {
struct BindSourceInfo;
}

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 {
 public:
  GeolocationServiceContext();
  virtual ~GeolocationServiceContext();

  // Creates a GeolocationServiceImpl that is weakly bound to |request|.
  void CreateService(const service_manager::BindSourceInfo& source_info,
                     mojom::GeolocationServiceRequest request);

  // Called when a service has a connection error. After this call, it is no
  // longer safe to access |service|.
  void ServiceHadConnectionError(GeolocationServiceImpl* service);

  // 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();

 private:
  std::vector<std::unique_ptr<GeolocationServiceImpl>> services_;

  std::unique_ptr<Geoposition> geoposition_override_;

  DISALLOW_COPY_AND_ASSIGN(GeolocationServiceContext);
};

}  // namespace device

#endif  // DEVICE_GEOLOCATION_GEOLOCATION_SERVICE_CONTEXT_H_