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

Side by Side Diff: google_apis/gcm/gcm_client.h

Issue 135903005: [GCM] Reland: Introduce GCMClientFactory to create GCMClient for GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 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 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 GOOGLE_APIS_GCM_GCM_CLIENT_H_ 5 #ifndef GOOGLE_APIS_GCM_GCM_CLIENT_H_
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_H_ 6 #define GOOGLE_APIS_GCM_GCM_CLIENT_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 "google_apis/gcm/base/gcm_export.h" 13 #include "google_apis/gcm/base/gcm_export.h"
14 14
15 namespace base {
16 class TaskRunner;
17 }
18
19 namespace gcm { 15 namespace gcm {
20 16
21 // Interface that encapsulates the network communications with the Google Cloud 17 // Interface that encapsulates the network communications with the Google Cloud
22 // Messaging server. This interface is not supposed to be thread-safe. 18 // Messaging server. This interface is not supposed to be thread-safe.
23 class GCM_EXPORT GCMClient { 19 class GCM_EXPORT GCMClient {
24 public: 20 public:
25 enum Result { 21 enum Result {
26 // Successful operation. 22 // Successful operation.
27 SUCCESS, 23 SUCCESS,
28 // Invalid parameter. 24 // Invalid parameter.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 Result result) = 0; 118 Result result) = 0;
123 119
124 // Returns the checkin info associated with this user. The delegate class 120 // Returns the checkin info associated with this user. The delegate class
125 // is expected to persist the checkin info that is provided by 121 // is expected to persist the checkin info that is provided by
126 // OnCheckInFinished. 122 // OnCheckInFinished.
127 virtual CheckinInfo GetCheckinInfo() const = 0; 123 virtual CheckinInfo GetCheckinInfo() const = 0;
128 124
129 // Called when the loading from the persistent store is done. The loading 125 // Called when the loading from the persistent store is done. The loading
130 // is triggered asynchronously when GCMClient is created. 126 // is triggered asynchronously when GCMClient is created.
131 virtual void OnLoadingCompleted() = 0; 127 virtual void OnLoadingCompleted() = 0;
132
133 // Returns a task runner for file operations that may block. This is used
134 // in writing to or reading from the persistent store.
135 virtual base::TaskRunner* GetFileTaskRunner() = 0;
136 }; 128 };
137 129
138 // Returns the single instance. Multiple profiles share the same client 130 virtual ~GCMClient() {}
Nicolas Zea 2014/01/16 23:47:36 explicit constructor?
jianli 2014/01/17 00:43:54 Done.
139 // that makes use of the same MCS connection.
140 static GCMClient* Get();
141
142 // Passes a mocked instance for testing purpose.
143 typedef GCMClient* (*TestingFactoryFunction)();
144 static void SetTestingFactory(TestingFactoryFunction factory);
145 131
146 // Sets the delegate to interact with related to a specific user. 132 // Sets the delegate to interact with related to a specific user.
147 // |username|: the username (email address) used to check in with the server. 133 // |username|: the username (email address) used to check in with the server.
148 // |delegate|: the delegate whose methods will be called asynchronously in 134 // |delegate|: the delegate whose methods will be called asynchronously in
149 // response to events and messages. 135 // response to events and messages.
150 virtual void SetUserDelegate(const std::string& username, 136 virtual void SetUserDelegate(const std::string& username,
151 Delegate* delegate) = 0; 137 Delegate* delegate) = 0;
152 138
153 // Checks in the user to use GCM. If the device has not been checked in, it 139 // Checks in the user to use GCM. If the device has not been checked in, it
154 // will be done first. 140 // will be done first.
(...skipping 27 matching lines...) Expand all
182 // |app_id|: application ID. 168 // |app_id|: application ID.
183 // |receiver_id|: registration ID of the receiver party. 169 // |receiver_id|: registration ID of the receiver party.
184 // |message|: message to be sent. 170 // |message|: message to be sent.
185 virtual void Send(const std::string& username, 171 virtual void Send(const std::string& username,
186 const std::string& app_id, 172 const std::string& app_id,
187 const std::string& receiver_id, 173 const std::string& receiver_id,
188 const OutgoingMessage& message) = 0; 174 const OutgoingMessage& message) = 0;
189 175
190 // Returns true if the loading from the persistent store is still in progress. 176 // Returns true if the loading from the persistent store is still in progress.
191 virtual bool IsLoading() const = 0; 177 virtual bool IsLoading() const = 0;
192
193 protected:
194 virtual ~GCMClient() {}
195 }; 178 };
196 179
197 } // namespace gcm 180 } // namespace gcm
198 181
199 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_ 182 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698