OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_SERVICES_GCM_GCM_DRIVER_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_DRIVER_H_ |
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_DRIVER_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_DRIVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/memory/ref_counted.h" | |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "components/gcm_driver/default_gcm_app_handler.h" | 18 #include "components/gcm_driver/default_gcm_app_handler.h" |
18 #include "google_apis/gaia/identity_provider.h" | 19 #include "google_apis/gaia/identity_provider.h" |
19 #include "google_apis/gcm/gcm_client.h" | 20 #include "google_apis/gcm/gcm_client.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class FilePath; | 23 class FilePath; |
24 class MessageLoopProxy; | |
25 class SequencedTaskRunner; | |
23 } | 26 } |
24 | 27 |
25 namespace extensions { | 28 namespace extensions { |
26 class ExtensionGCMAppHandlerTest; | 29 class ExtensionGCMAppHandlerTest; |
27 } | 30 } |
28 | 31 |
29 namespace net { | 32 namespace net { |
30 class URLRequestContextGetter; | 33 class URLRequestContextGetter; |
31 } | 34 } |
32 | 35 |
(...skipping 10 matching lines...) Expand all Loading... | |
43 GCMClient::Result result)> RegisterCallback; | 46 GCMClient::Result result)> RegisterCallback; |
44 typedef base::Callback<void(const std::string& message_id, | 47 typedef base::Callback<void(const std::string& message_id, |
45 GCMClient::Result result)> SendCallback; | 48 GCMClient::Result result)> SendCallback; |
46 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; | 49 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; |
47 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> | 50 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> |
48 GetGCMStatisticsCallback; | 51 GetGCMStatisticsCallback; |
49 | 52 |
50 GCMDriver(scoped_ptr<GCMClientFactory> gcm_client_factory, | 53 GCMDriver(scoped_ptr<GCMClientFactory> gcm_client_factory, |
51 scoped_ptr<IdentityProvider> identity_provider, | 54 scoped_ptr<IdentityProvider> identity_provider, |
52 const base::FilePath& store_path, | 55 const base::FilePath& store_path, |
53 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 56 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
57 const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | |
58 const scoped_refptr<base::MessageLoopProxy>& ui_thread, | |
Nicolas Zea
2014/05/21 22:16:28
a MessageLoopProxy is a SequencedTaskRunner. You m
jianli
2014/05/21 23:09:34
Done.
| |
59 const scoped_refptr<base::MessageLoopProxy>& io_thread); | |
54 virtual ~GCMDriver(); | 60 virtual ~GCMDriver(); |
55 | 61 |
56 // Enables/disables GCM service. | 62 // Enables/disables GCM service. |
57 void Enable(); | 63 void Enable(); |
58 void Disable(); | 64 void Disable(); |
59 | 65 |
60 // This method must be called before destroying the GCMDriver. Once it has | 66 // This method must be called before destroying the GCMDriver. Once it has |
61 // been called, no other GCMDriver methods may be used. | 67 // been called, no other GCMDriver methods may be used. |
62 virtual void Shutdown(); | 68 virtual void Shutdown(); |
63 | 69 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 bool gcm_enabled_; | 186 bool gcm_enabled_; |
181 | 187 |
182 // Flag to indicate if GCMClient is ready. | 188 // Flag to indicate if GCMClient is ready. |
183 bool gcm_client_ready_; | 189 bool gcm_client_ready_; |
184 | 190 |
185 // The account ID that this service is responsible for. Empty when the service | 191 // The account ID that this service is responsible for. Empty when the service |
186 // is not running. | 192 // is not running. |
187 std::string account_id_; | 193 std::string account_id_; |
188 | 194 |
189 scoped_ptr<IdentityProvider> identity_provider_; | 195 scoped_ptr<IdentityProvider> identity_provider_; |
196 scoped_refptr<base::MessageLoopProxy> ui_thread_; | |
197 scoped_refptr<base::MessageLoopProxy> io_thread_; | |
190 | 198 |
191 scoped_ptr<DelayedTaskController> delayed_task_controller_; | 199 scoped_ptr<DelayedTaskController> delayed_task_controller_; |
192 | 200 |
193 // For all the work occurring on the IO thread. Must be destroyed on the IO | 201 // For all the work occurring on the IO thread. Must be destroyed on the IO |
194 // thread. | 202 // thread. |
195 scoped_ptr<IOWorker> io_worker_; | 203 scoped_ptr<IOWorker> io_worker_; |
196 | 204 |
197 // App handler map (from app_id to handler pointer). | 205 // App handler map (from app_id to handler pointer). |
198 // The handler is not owned. | 206 // The handler is not owned. |
199 GCMAppHandlerMap app_handlers_; | 207 GCMAppHandlerMap app_handlers_; |
(...skipping 15 matching lines...) Expand all Loading... | |
215 | 223 |
216 // Used to pass a weak pointer to the IO worker. | 224 // Used to pass a weak pointer to the IO worker. |
217 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 225 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
218 | 226 |
219 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 227 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
220 }; | 228 }; |
221 | 229 |
222 } // namespace gcm | 230 } // namespace gcm |
223 | 231 |
224 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_DRIVER_H_ | 232 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_DRIVER_H_ |
OLD | NEW |