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

Side by Side Diff: content/browser/geolocation/wifi_data_provider.h

Issue 2192683002: Reland 2:Geolocation: move from content/browser to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ignore size_t_to_int truncation warning 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
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 CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_H_
6 #define CONTENT_BROWSER_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 "content/browser/geolocation/wifi_data.h"
15 #include "content/common/content_export.h"
16
17 namespace content {
18
19 class CONTENT_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 content
73
74 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/browser/geolocation/wifi_data.cc ('k') | content/browser/geolocation/wifi_data_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698