chromium/services/device/geolocation/geolocation_provider_impl.h

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_
#define SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_

#include <memory>
#include <string>
#include <vector>

#include "base/compiler_specific.h"
#include "base/functional/callback_forward.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "services/device/geolocation/geolocation_provider.h"
#include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h"
#include "services/device/public/cpp/geolocation/location_provider.h"
#include "services/device/public/cpp/geolocation/location_system_permission_status.h"
#include "services/device/public/mojom/geolocation_control.mojom.h"
#include "services/device/public/mojom/geolocation_internals.mojom.h"
#include "services/device/public/mojom/geoposition.mojom.h"

namespace base {
template <typename Type>
struct DefaultSingletonTraits;
class SingleThreadTaskRunner;
}  // namespace base

namespace network {
class SharedURLLoaderFactory;
}

namespace device {

// Callback that returns the embedder's custom location provider. This callback
// is provided to the Device Service by its embedder.
CustomLocationProviderCallback;

// This class implements the GeolocationProvider interface, which is the main
// API of the geolocation subsystem. Clients subscribe for location updates
// with AddLocationUpdateCallback and cancel their subscription by destroying
// the returned subscription object.
//
// It also implements GeolocationSystemPermissionManager::PermissionObserver on
// supported platforms. Monitors system permission changes to manage the
// LocationProviderManager and report permission errors to clients.
//
// THREADING
//
// GeolocationProviderImpl is constructed on the main thread and its public
// methods (except OnLocationUpdate) must also be called on the main thread.
//
// GeolocationProviderImpl extends base::Thread. This thread, called the
// "geolocation thread", runs background tasks when acquiring new position
// estimates.
//
// GeolocationProviderImpl owns one or more LocationProvider implementations
// which generate new position estimates. LocationProviders must only run on
// the geolocation thread. Providers report new position estimates by calling
// OnLocationUpdate on the geolocation thread.
class GeolocationProviderImpl
    : public GeolocationProvider,
      public mojom::GeolocationControl,
      public mojom::GeolocationInternals,
      public base::Thread
#if BUILDFLAG(OS_LEVEL_GEOLOCATION_PERMISSION_SUPPORTED)
    ,
      public GeolocationSystemPermissionManager::PermissionObserver
#endif
{};

}  // namespace device

#endif  // SERVICES_DEVICE_GEOLOCATION_GEOLOCATION_PROVIDER_IMPL_H_