OLD | NEW |
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_IMPL_H_ | 5 #ifndef GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 virtual ~GCMClientImpl(); | 47 virtual ~GCMClientImpl(); |
48 | 48 |
49 // Overridden from GCMClient: | 49 // Overridden from GCMClient: |
50 virtual void Initialize( | 50 virtual void Initialize( |
51 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 51 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
52 const base::FilePath& store_path, | 52 const base::FilePath& store_path, |
53 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 53 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
54 const scoped_refptr<net::URLRequestContextGetter>& | 54 const scoped_refptr<net::URLRequestContextGetter>& |
55 url_request_context_getter, | 55 url_request_context_getter, |
56 Delegate* delegate) OVERRIDE; | 56 Delegate* delegate) OVERRIDE; |
| 57 virtual void Load() OVERRIDE; |
57 virtual void CheckOut() OVERRIDE; | 58 virtual void CheckOut() OVERRIDE; |
58 virtual void Register(const std::string& app_id, | 59 virtual void Register(const std::string& app_id, |
59 const std::string& cert, | 60 const std::string& cert, |
60 const std::vector<std::string>& sender_ids) OVERRIDE; | 61 const std::vector<std::string>& sender_ids) OVERRIDE; |
61 virtual void Unregister(const std::string& app_id) OVERRIDE; | 62 virtual void Unregister(const std::string& app_id) OVERRIDE; |
62 virtual void Send(const std::string& app_id, | 63 virtual void Send(const std::string& app_id, |
63 const std::string& receiver_id, | 64 const std::string& receiver_id, |
64 const OutgoingMessage& message) OVERRIDE; | 65 const OutgoingMessage& message) OVERRIDE; |
65 virtual bool IsReady() const OVERRIDE; | |
66 | 66 |
67 private: | 67 private: |
68 // State representation of the GCMClient. | 68 // State representation of the GCMClient. |
69 enum State { | 69 enum State { |
70 // Uninitialized. | 70 // Uninitialized. |
71 UNINITIALIZED, | 71 UNINITIALIZED, |
| 72 // Initialized, |
| 73 INITIALIZED, |
72 // GCM store loading is in progress. | 74 // GCM store loading is in progress. |
73 LOADING, | 75 LOADING, |
74 // Initial device checkin is in progress. | 76 // Initial device checkin is in progress. |
75 INITIAL_DEVICE_CHECKIN, | 77 INITIAL_DEVICE_CHECKIN, |
76 // Ready to accept requests. | 78 // Ready to accept requests. |
77 READY, | 79 READY, |
78 }; | 80 }; |
79 | 81 |
80 // The check-in info for the user. Returned by the server. | 82 // The check-in info for the user. Returned by the server. |
81 struct GCM_EXPORT CheckinInfo { | 83 struct GCM_EXPORT CheckinInfo { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 void SetDeviceCredentialsCallback(bool success); | 144 void SetDeviceCredentialsCallback(bool success); |
143 | 145 |
144 // Completes the registration request. | 146 // Completes the registration request. |
145 void OnRegisterCompleted(const std::string& app_id, | 147 void OnRegisterCompleted(const std::string& app_id, |
146 RegistrationRequest::Status status, | 148 RegistrationRequest::Status status, |
147 const std::string& registration_id); | 149 const std::string& registration_id); |
148 | 150 |
149 // Completes the unregistration request. | 151 // Completes the unregistration request. |
150 void OnUnregisterCompleted(const std::string& app_id, bool status); | 152 void OnUnregisterCompleted(const std::string& app_id, bool status); |
151 | 153 |
| 154 // Completes the GCM store destroy request. |
| 155 void OnGCMStoreDestroyed(bool success); |
| 156 |
152 // Handles incoming data message and dispatches it the a relevant user | 157 // Handles incoming data message and dispatches it the a relevant user |
153 // delegate. | 158 // delegate. |
154 void HandleIncomingMessage(const gcm::MCSMessage& message); | 159 void HandleIncomingMessage(const gcm::MCSMessage& message); |
155 | 160 |
156 // Fires OnMessageSendError event on |delegate|, with specified |app_id| and | 161 // Fires OnMessageSendError event on |delegate|, with specified |app_id| and |
157 // message ID obtained from |incoming_message| if one is available. | 162 // message ID obtained from |incoming_message| if one is available. |
158 void NotifyDelegateOnMessageSendError( | 163 void NotifyDelegateOnMessageSendError( |
159 GCMClient::Delegate* delegate, | 164 GCMClient::Delegate* delegate, |
160 const std::string& app_id, | 165 const std::string& app_id, |
161 const IncomingMessage& incoming_message); | 166 const IncomingMessage& incoming_message); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 213 |
209 // Factory for creating references in callbacks. | 214 // Factory for creating references in callbacks. |
210 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 215 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
211 | 216 |
212 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 217 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
213 }; | 218 }; |
214 | 219 |
215 } // namespace gcm | 220 } // namespace gcm |
216 | 221 |
217 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 222 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
OLD | NEW |