Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/public/browser/geolocation_provider.h

Issue 1874903002: Convert //content from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/browser/font_list_async.h ('k') | content/public/browser/host_zoom_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 6 #define CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
7 7
8 #include <memory>
9
8 #include "base/callback_list.h" 10 #include "base/callback_list.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
11 12
12 namespace content { 13 namespace content {
13 struct Geoposition; 14 struct Geoposition;
14 15
15 // This is the main API to the geolocation subsystem. The application will hold 16 // This is the main API to the geolocation subsystem. The application will hold
16 // a single instance of this class and can register multiple clients to be 17 // a single instance of this class and can register multiple clients to be
17 // notified of location changes: 18 // notified of location changes:
18 // * Callbacks are registered by AddLocationUpdateCallback() and will keep 19 // * Callbacks are registered by AddLocationUpdateCallback() and will keep
19 // receiving updates until the returned subscription object is destructed. 20 // receiving updates until the returned subscription object is destructed.
20 // The application must instantiate the GeolocationProvider on the UI thread and 21 // The application must instantiate the GeolocationProvider on the UI thread and
21 // must communicate with it on the same thread. 22 // must communicate with it on the same thread.
22 // The underlying location arbitrator will only be enabled whilst there is at 23 // The underlying location arbitrator will only be enabled whilst there is at
23 // least one registered observer or pending callback (and only after 24 // least one registered observer or pending callback (and only after
24 // UserDidOptIntoLocationServices). The arbitrator and the location providers it 25 // UserDidOptIntoLocationServices). The arbitrator and the location providers it
25 // uses run on a separate Geolocation thread. 26 // uses run on a separate Geolocation thread.
26 class GeolocationProvider { 27 class GeolocationProvider {
27 public: 28 public:
28 CONTENT_EXPORT static GeolocationProvider* GetInstance(); 29 CONTENT_EXPORT static GeolocationProvider* GetInstance();
29 30
30 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback; 31 typedef base::Callback<void(const Geoposition&)> LocationUpdateCallback;
31 typedef base::CallbackList<void(const Geoposition&)>::Subscription 32 typedef base::CallbackList<void(const Geoposition&)>::Subscription
32 Subscription; 33 Subscription;
33 34
34 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for 35 // |enable_high_accuracy| is used as a 'hint' for the provider preferences for
35 // this particular observer, however the observer could receive updates for 36 // this particular observer, however the observer could receive updates for
36 // best available locations from any active provider whilst it is registered. 37 // best available locations from any active provider whilst it is registered.
37 virtual scoped_ptr<Subscription> AddLocationUpdateCallback( 38 virtual std::unique_ptr<Subscription> AddLocationUpdateCallback(
38 const LocationUpdateCallback& callback, 39 const LocationUpdateCallback& callback,
39 bool enable_high_accuracy) = 0; 40 bool enable_high_accuracy) = 0;
40 41
41 // Calling this method indicates the user has opted into using location 42 // Calling this method indicates the user has opted into using location
42 // services, including sending network requests to [Google servers to] resolve 43 // services, including sending network requests to [Google servers to] resolve
43 // the user's location. Use this method carefully, in line with the rules in 44 // the user's location. Use this method carefully, in line with the rules in
44 // go/chrome-privacy-doc. 45 // go/chrome-privacy-doc.
45 virtual void UserDidOptIntoLocationServices() = 0; 46 virtual void UserDidOptIntoLocationServices() = 0;
46 47
47 // Overrides the current location for testing. 48 // Overrides the current location for testing.
48 // 49 //
49 // Overrides the location for automation/testing. Suppresses any further 50 // Overrides the location for automation/testing. Suppresses any further
50 // updates from the actual providers and sends an update with the overridden 51 // updates from the actual providers and sends an update with the overridden
51 // position to all registered clients. 52 // position to all registered clients.
52 // 53 //
53 // Do not use this function in unit tests. The function instantiates the 54 // Do not use this function in unit tests. The function instantiates the
54 // singleton geolocation stack in the background and manipulates it to report 55 // singleton geolocation stack in the background and manipulates it to report
55 // a fake location. Neither step can be undone, breaking unit test isolation 56 // a fake location. Neither step can be undone, breaking unit test isolation
56 // (crbug.com/125931). 57 // (crbug.com/125931).
57 virtual void OverrideLocationForTesting(const Geoposition& position) = 0; 58 virtual void OverrideLocationForTesting(const Geoposition& position) = 0;
58 59
59 protected: 60 protected:
60 virtual~GeolocationProvider() {} 61 virtual~GeolocationProvider() {}
61 }; 62 };
62 63
63 } // namespace content 64 } // namespace content
64 65
65 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_ 66 #endif // CONTENT_PUBLIC_BROWSER_GEOLOCATION_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/public/browser/font_list_async.h ('k') | content/public/browser/host_zoom_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698