| 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 COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_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/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" |
| 17 #include "components/gcm_driver/gcm_client.h" | 18 #include "components/gcm_driver/gcm_client.h" |
| 19 #include "components/gcm_driver/gcm_connection_observer.h" |
| 18 #include "components/gcm_driver/gcm_driver.h" | 20 #include "components/gcm_driver/gcm_driver.h" |
| 19 | 21 |
| 20 namespace base { | 22 namespace base { |
| 21 class FilePath; | 23 class FilePath; |
| 22 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace extensions { | 27 namespace extensions { |
| 26 class ExtensionGCMAppHandlerTest; | 28 class ExtensionGCMAppHandlerTest; |
| 27 } | 29 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); | 50 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); |
| 49 virtual ~GCMDriverDesktop(); | 51 virtual ~GCMDriverDesktop(); |
| 50 | 52 |
| 51 // GCMDriver overrides: | 53 // GCMDriver overrides: |
| 52 virtual void Shutdown() OVERRIDE; | 54 virtual void Shutdown() OVERRIDE; |
| 53 virtual void OnSignedIn() OVERRIDE; | 55 virtual void OnSignedIn() OVERRIDE; |
| 54 virtual void Purge() OVERRIDE; | 56 virtual void Purge() OVERRIDE; |
| 55 virtual void AddAppHandler(const std::string& app_id, | 57 virtual void AddAppHandler(const std::string& app_id, |
| 56 GCMAppHandler* handler) OVERRIDE; | 58 GCMAppHandler* handler) OVERRIDE; |
| 57 virtual void RemoveAppHandler(const std::string& app_id) OVERRIDE; | 59 virtual void RemoveAppHandler(const std::string& app_id) OVERRIDE; |
| 60 virtual void AddConnectionObserver(GCMConnectionObserver* observer) OVERRIDE; |
| 61 virtual void RemoveConnectionObserver( |
| 62 GCMConnectionObserver* observer) OVERRIDE; |
| 58 virtual void Enable() OVERRIDE; | 63 virtual void Enable() OVERRIDE; |
| 59 virtual void Disable() OVERRIDE; | 64 virtual void Disable() OVERRIDE; |
| 60 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; | 65 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; |
| 61 virtual bool IsStarted() const OVERRIDE; | 66 virtual bool IsStarted() const OVERRIDE; |
| 62 virtual bool IsConnected() const OVERRIDE; | 67 virtual bool IsConnected() const OVERRIDE; |
| 63 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, | 68 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
| 64 bool clear_logs) OVERRIDE; | 69 bool clear_logs) OVERRIDE; |
| 65 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 70 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
| 66 bool recording) OVERRIDE; | 71 bool recording) OVERRIDE; |
| 67 virtual void UpdateAccountMapping( | 72 virtual void UpdateAccountMapping( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 bool gcm_started_; | 132 bool gcm_started_; |
| 128 | 133 |
| 129 // Flag to indicate if GCM is enabled. | 134 // Flag to indicate if GCM is enabled. |
| 130 bool gcm_enabled_; | 135 bool gcm_enabled_; |
| 131 | 136 |
| 132 // Flag to indicate the last known state of the GCM client. Because this | 137 // Flag to indicate the last known state of the GCM client. Because this |
| 133 // flag lives on the UI thread, while the GCM client lives on the IO thread, | 138 // flag lives on the UI thread, while the GCM client lives on the IO thread, |
| 134 // it may be out of date while connection changes are happening. | 139 // it may be out of date while connection changes are happening. |
| 135 bool connected_; | 140 bool connected_; |
| 136 | 141 |
| 142 // List of observers to notify when connection state changes. |
| 143 // Makes sure list is empty on destruction. |
| 144 ObserverList<GCMConnectionObserver, true> connection_observer_list_; |
| 145 |
| 137 scoped_refptr<base::SequencedTaskRunner> ui_thread_; | 146 scoped_refptr<base::SequencedTaskRunner> ui_thread_; |
| 138 scoped_refptr<base::SequencedTaskRunner> io_thread_; | 147 scoped_refptr<base::SequencedTaskRunner> io_thread_; |
| 139 | 148 |
| 140 scoped_ptr<DelayedTaskController> delayed_task_controller_; | 149 scoped_ptr<DelayedTaskController> delayed_task_controller_; |
| 141 | 150 |
| 142 // For all the work occurring on the IO thread. Must be destroyed on the IO | 151 // For all the work occurring on the IO thread. Must be destroyed on the IO |
| 143 // thread. | 152 // thread. |
| 144 scoped_ptr<IOWorker> io_worker_; | 153 scoped_ptr<IOWorker> io_worker_; |
| 145 | 154 |
| 146 // Callback for GetGCMStatistics. | 155 // Callback for GetGCMStatistics. |
| 147 GetGCMStatisticsCallback request_gcm_statistics_callback_; | 156 GetGCMStatisticsCallback request_gcm_statistics_callback_; |
| 148 | 157 |
| 149 // Used to pass a weak pointer to the IO worker. | 158 // Used to pass a weak pointer to the IO worker. |
| 150 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; | 159 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; |
| 151 | 160 |
| 152 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); | 161 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); |
| 153 }; | 162 }; |
| 154 | 163 |
| 155 } // namespace gcm | 164 } // namespace gcm |
| 156 | 165 |
| 157 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ | 166 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ |
| OLD | NEW |