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

Side by Side Diff: components/gcm_driver/gcm_driver_desktop.h

Issue 320993003: [GCM] Add app handler support for connection events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add basic tests Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 virtual void AddAppHandler(const std::string& app_id, 59 virtual void AddAppHandler(const std::string& app_id,
60 GCMAppHandler* handler) OVERRIDE; 60 GCMAppHandler* handler) OVERRIDE;
61 virtual void RemoveAppHandler(const std::string& app_id) OVERRIDE; 61 virtual void RemoveAppHandler(const std::string& app_id) OVERRIDE;
62 62
63 // GCMDriver implementation: 63 // GCMDriver implementation:
64 virtual void Enable() OVERRIDE; 64 virtual void Enable() OVERRIDE;
65 virtual void Disable() OVERRIDE; 65 virtual void Disable() OVERRIDE;
66 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; 66 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE;
67 virtual bool IsStarted() const OVERRIDE; 67 virtual bool IsStarted() const OVERRIDE;
68 virtual bool IsGCMClientReady() const OVERRIDE; 68 virtual bool IsGCMClientReady() const OVERRIDE;
69 virtual bool IsConnected() const OVERRIDE;
69 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, 70 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback,
70 bool clear_logs) OVERRIDE; 71 bool clear_logs) OVERRIDE;
71 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, 72 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback,
72 bool recording) OVERRIDE; 73 bool recording) OVERRIDE;
73 virtual std::string SignedInUserName() const OVERRIDE; 74 virtual std::string SignedInUserName() const OVERRIDE;
74 75
75 protected: 76 protected:
76 // GCMDriver implementation: 77 // GCMDriver implementation:
77 virtual GCMClient::Result EnsureStarted() OVERRIDE; 78 virtual GCMClient::Result EnsureStarted() OVERRIDE;
78 virtual void RegisterImpl( 79 virtual void RegisterImpl(
(...skipping 24 matching lines...) Expand all
103 const std::string& receiver_id, 104 const std::string& receiver_id,
104 const GCMClient::OutgoingMessage& message); 105 const GCMClient::OutgoingMessage& message);
105 106
106 // Callbacks posted from IO thread to UI thread. 107 // Callbacks posted from IO thread to UI thread.
107 void MessageReceived(const std::string& app_id, 108 void MessageReceived(const std::string& app_id,
108 const GCMClient::IncomingMessage& message); 109 const GCMClient::IncomingMessage& message);
109 void MessagesDeleted(const std::string& app_id); 110 void MessagesDeleted(const std::string& app_id);
110 void MessageSendError(const std::string& app_id, 111 void MessageSendError(const std::string& app_id,
111 const GCMClient::SendErrorDetails& send_error_details); 112 const GCMClient::SendErrorDetails& send_error_details);
112 void GCMClientReady(); 113 void GCMClientReady();
114 void OnConnected(const net::IPEndPoint& ip_endpoint);
115 void OnDisconnected();
113 116
114 void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats); 117 void GetGCMStatisticsFinished(const GCMClient::GCMStatistics& stats);
115 118
116 // Flag to indicate if GCM is enabled. 119 // Flag to indicate if GCM is enabled.
117 bool gcm_enabled_; 120 bool gcm_enabled_;
118 121
119 // Flag to indicate if GCMClient is ready. 122 // Flag to indicate if GCMClient is ready.
120 bool gcm_client_ready_; 123 bool gcm_client_ready_;
121 124
125 // Flag to indicate the last known state of the GCM client. Because this
126 // flag lives on the UI thread, while the GCM client lives on the IO thread,
127 // it may be out of date while connection changes are happening.
128 bool connected_;
129
122 // The account ID that this service is responsible for. Empty when the service 130 // The account ID that this service is responsible for. Empty when the service
123 // is not running. 131 // is not running.
124 std::string account_id_; 132 std::string account_id_;
125 133
126 scoped_ptr<IdentityProvider> identity_provider_; 134 scoped_ptr<IdentityProvider> identity_provider_;
127 scoped_refptr<base::SequencedTaskRunner> ui_thread_; 135 scoped_refptr<base::SequencedTaskRunner> ui_thread_;
128 scoped_refptr<base::SequencedTaskRunner> io_thread_; 136 scoped_refptr<base::SequencedTaskRunner> io_thread_;
129 137
130 scoped_ptr<DelayedTaskController> delayed_task_controller_; 138 scoped_ptr<DelayedTaskController> delayed_task_controller_;
131 139
132 // For all the work occurring on the IO thread. Must be destroyed on the IO 140 // For all the work occurring on the IO thread. Must be destroyed on the IO
133 // thread. 141 // thread.
134 scoped_ptr<IOWorker> io_worker_; 142 scoped_ptr<IOWorker> io_worker_;
135 143
136 // Callback for GetGCMStatistics. 144 // Callback for GetGCMStatistics.
137 GetGCMStatisticsCallback request_gcm_statistics_callback_; 145 GetGCMStatisticsCallback request_gcm_statistics_callback_;
138 146
139 // Used to pass a weak pointer to the IO worker. 147 // Used to pass a weak pointer to the IO worker.
140 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_; 148 base::WeakPtrFactory<GCMDriverDesktop> weak_ptr_factory_;
141 149
142 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop); 150 DISALLOW_COPY_AND_ASSIGN(GCMDriverDesktop);
143 }; 151 };
144 152
145 } // namespace gcm 153 } // namespace gcm
146 154
147 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_ 155 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_DESKTOP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698