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