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

Side by Side Diff: chrome/browser/services/gcm/gcm_service.h

Issue 270873002: Extract GCMClient data types into separate gcm_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reupload Created 6 years, 7 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 CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_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/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "chrome/browser/services/gcm/default_gcm_app_handler.h" 19 #include "chrome/browser/services/gcm/default_gcm_app_handler.h"
20 #include "google_apis/gaia/identity_provider.h" 20 #include "google_apis/gaia/identity_provider.h"
21 #include "google_apis/gcm/gcm_client.h" 21 #include "google_apis/gcm/gcm_client.h"
22 #include "google_apis/gcm/public/gcm_types.h"
22 23
23 namespace extensions { 24 namespace extensions {
24 class ExtensionGCMAppHandlerTest; 25 class ExtensionGCMAppHandlerTest;
25 } 26 }
26 27
27 namespace net { 28 namespace net {
28 class URLRequestContextGetter; 29 class URLRequestContextGetter;
29 } 30 }
30 31
31 namespace gcm { 32 namespace gcm {
32 33
33 class GCMAppHandler; 34 class GCMAppHandler;
34 class GCMClientFactory; 35 class GCMClientFactory;
35 36
36 // A bridge between the GCM users in Chrome and the GCMClient layer. 37 // A bridge between the GCM users in Chrome and the GCMClient layer.
37 class GCMService : public IdentityProvider::Observer { 38 class GCMService : public IdentityProvider::Observer {
38 public: 39 public:
39 typedef base::Callback<void(const std::string& registration_id, 40 typedef base::Callback<void(const std::string& registration_id,
40 GCMClient::Result result)> RegisterCallback; 41 Result result)> RegisterCallback;
41 typedef base::Callback<void(const std::string& message_id, 42 typedef base::Callback<void(const std::string& message_id,
42 GCMClient::Result result)> SendCallback; 43 Result result)> SendCallback;
43 typedef base::Callback<void(GCMClient::Result result)> UnregisterCallback; 44 typedef base::Callback<void(Result result)> UnregisterCallback;
44 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)> 45 typedef base::Callback<void(const GCMClient::GCMStatistics& stats)>
45 GetGCMStatisticsCallback; 46 GetGCMStatisticsCallback;
46 47
47 explicit GCMService(scoped_ptr<IdentityProvider> identity_provider); 48 explicit GCMService(scoped_ptr<IdentityProvider> identity_provider);
48 virtual ~GCMService(); 49 virtual ~GCMService();
49 50
50 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory); 51 void Initialize(scoped_ptr<GCMClientFactory> gcm_client_factory);
51 52
52 void Start(); 53 void Start();
53 54
(...skipping 26 matching lines...) Expand all
80 virtual void Unregister(const std::string& app_id, 81 virtual void Unregister(const std::string& app_id,
81 UnregisterCallback callback); 82 UnregisterCallback callback);
82 83
83 // Sends a message to a given receiver. 84 // Sends a message to a given receiver.
84 // |app_id|: application ID. 85 // |app_id|: application ID.
85 // |receiver_id|: registration ID of the receiver party. 86 // |receiver_id|: registration ID of the receiver party.
86 // |message|: message to be sent. 87 // |message|: message to be sent.
87 // |callback|: to be called once the asynchronous operation is done. 88 // |callback|: to be called once the asynchronous operation is done.
88 virtual void Send(const std::string& app_id, 89 virtual void Send(const std::string& app_id,
89 const std::string& receiver_id, 90 const std::string& receiver_id,
90 const GCMClient::OutgoingMessage& message, 91 const OutgoingMessage& message,
91 SendCallback callback); 92 SendCallback callback);
92 93
93 // For testing purpose. 94 // For testing purpose.
94 GCMClient* GetGCMClientForTesting() const; 95 GCMClient* GetGCMClientForTesting() const;
95 96
96 // Returns true if the service was started. 97 // Returns true if the service was started.
97 bool IsStarted() const; 98 bool IsStarted() const;
98 99
99 // Returns true if the gcm client is ready. 100 // Returns true if the gcm client is ready.
100 bool IsGCMClientReady() const; 101 bool IsGCMClientReady() const;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // |identity_provider_| is able to supply an account ID. 135 // |identity_provider_| is able to supply an account ID.
135 void EnsureLoaded(); 136 void EnsureLoaded();
136 137
137 // Remove cached data when GCM service is stopped. 138 // Remove cached data when GCM service is stopped.
138 void RemoveCachedData(); 139 void RemoveCachedData();
139 140
140 // Checks out of GCM and erases any cached and persisted data. 141 // Checks out of GCM and erases any cached and persisted data.
141 void CheckOut(); 142 void CheckOut();
142 143
143 // Ensures that the app is ready for GCM functions and events. 144 // Ensures that the app is ready for GCM functions and events.
144 GCMClient::Result EnsureAppReady(const std::string& app_id); 145 Result EnsureAppReady(const std::string& app_id);
145 146
146 // Should be called when an app with |app_id| is trying to un/register. 147 // Should be called when an app with |app_id| is trying to un/register.
147 // Checks whether another un/registration is in progress. 148 // Checks whether another un/registration is in progress.
148 bool IsAsyncOperationPending(const std::string& app_id) const; 149 bool IsAsyncOperationPending(const std::string& app_id) const;
149 150
150 void DoRegister(const std::string& app_id, 151 void DoRegister(const std::string& app_id,
151 const std::vector<std::string>& sender_ids); 152 const std::vector<std::string>& sender_ids);
152 void DoUnregister(const std::string& app_id); 153 void DoUnregister(const std::string& app_id);
153 void DoSend(const std::string& app_id, 154 void DoSend(const std::string& app_id,
154 const std::string& receiver_id, 155 const std::string& receiver_id,
155 const GCMClient::OutgoingMessage& message); 156 const OutgoingMessage& message);
156 157
157 // Callbacks posted from IO thread to UI thread. 158 // Callbacks posted from IO thread to UI thread.
158 void RegisterFinished(const std::string& app_id, 159 void RegisterFinished(const std::string& app_id,
159 const std::string& registration_id, 160 const std::string& registration_id,
160 GCMClient::Result result); 161 Result result);
161 void UnregisterFinished(const std::string& app_id, GCMClient::Result result); 162 void UnregisterFinished(const std::string& app_id, Result result);
162 void SendFinished(const std::string& app_id, 163 void SendFinished(const std::string& app_id,
163 const std::string& message_id, 164 const std::string& message_id,
164 GCMClient::Result result); 165 Result result);
165 void MessageReceived(const std::string& app_id, 166 void MessageReceived(const std::string& app_id,
166 GCMClient::IncomingMessage message); 167 IncomingMessage message);
167 void MessagesDeleted(const std::string& app_id); 168 void MessagesDeleted(const std::string& app_id);
168 void MessageSendError(const std::string& app_id, 169 void MessageSendError(const std::string& app_id,
169 const GCMClient::SendErrorDetails& send_error_details); 170 const SendErrorDetails& send_error_details);
170 void GCMClientReady(); 171 void GCMClientReady();
171 172
172 // Returns the handler for the given app. 173 // Returns the handler for the given app.
173 GCMAppHandler* GetAppHandler(const std::string& app_id); 174 GCMAppHandler* GetAppHandler(const std::string& app_id);
174 175
175 void GetGCMStatisticsFinished(GCMClient::GCMStatistics stats); 176 void GetGCMStatisticsFinished(GCMClient::GCMStatistics stats);
176 177
177 // Flag to indicate if GCMClient is ready. 178 // Flag to indicate if GCMClient is ready.
178 bool gcm_client_ready_; 179 bool gcm_client_ready_;
179 180
(...skipping 28 matching lines...) Expand all
208 209
209 // Used to pass a weak pointer to the IO worker. 210 // Used to pass a weak pointer to the IO worker.
210 base::WeakPtrFactory<GCMService> weak_ptr_factory_; 211 base::WeakPtrFactory<GCMService> weak_ptr_factory_;
211 212
212 DISALLOW_COPY_AND_ASSIGN(GCMService); 213 DISALLOW_COPY_AND_ASSIGN(GCMService);
213 }; 214 };
214 215
215 } // namespace gcm 216 } // namespace gcm
216 217
217 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_ 218 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service_unittest.cc ('k') | chrome/browser/services/gcm/gcm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698