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

Side by Side Diff: device/geolocation/wifi_data_provider.h

Issue 2192683003: Revert of Reland: Geolocation: move from content/browser to device/ (patchset #2 id:20001 of https:… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2810
Patch Set: Created 4 years, 4 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 | « device/geolocation/wifi_data.cc ('k') | device/geolocation/wifi_data_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_H_
6 #define DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_H_
7
8 #include <set>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h"
14 #include "device/geolocation/geolocation_export.h"
15 #include "device/geolocation/wifi_data.h"
16
17 namespace device {
18
19 class DEVICE_GEOLOCATION_EXPORT WifiDataProvider
20 : public base::RefCountedThreadSafe<WifiDataProvider> {
21 public:
22 WifiDataProvider();
23
24 // Tells the provider to start looking for data. Callbacks will start
25 // receiving notifications after this call.
26 virtual void StartDataProvider() = 0;
27
28 // Tells the provider to stop looking for data. Callbacks will stop
29 // receiving notifications after this call.
30 virtual void StopDataProvider() = 0;
31
32 // Provides whatever data the provider has, which may be nothing. Return
33 // value indicates whether this is all the data the provider could ever
34 // obtain.
35 virtual bool GetData(WifiData* data) = 0;
36
37 typedef base::Closure WifiDataUpdateCallback;
38
39 void AddCallback(WifiDataUpdateCallback* callback);
40
41 bool RemoveCallback(WifiDataUpdateCallback* callback);
42
43 bool has_callbacks() const;
44
45 protected:
46 friend class base::RefCountedThreadSafe<WifiDataProvider>;
47 virtual ~WifiDataProvider();
48
49 typedef std::set<WifiDataUpdateCallback*> CallbackSet;
50
51 // Runs all callbacks via a posted task, so we can unwind callstack here and
52 // avoid client reentrancy.
53 void RunCallbacks();
54
55 bool CalledOnClientThread() const;
56
57 scoped_refptr<base::SingleThreadTaskRunner> client_task_runner() const {
58 return client_task_runner_;
59 }
60
61 private:
62 void DoRunCallbacks();
63
64 // The task runner for the client thread, all callbacks should run on it.
65 scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_;
66
67 CallbackSet callbacks_;
68
69 DISALLOW_COPY_AND_ASSIGN(WifiDataProvider);
70 };
71
72 } // namespace device
73
74 #endif // DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_H_
OLDNEW
« no previous file with comments | « device/geolocation/wifi_data.cc ('k') | device/geolocation/wifi_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698