| OLD | NEW |
| 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_INVALIDATION_GCM_NETWORK_CHANNEL_H_ | 5 #ifndef COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ |
| 6 #define COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ | 6 #define COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 private: | 86 private: |
| 87 friend class GCMNetworkChannelTest; | 87 friend class GCMNetworkChannelTest; |
| 88 void Register(); | 88 void Register(); |
| 89 void OnRegisterComplete(const std::string& registration_id, | 89 void OnRegisterComplete(const std::string& registration_id, |
| 90 gcm::GCMClient::Result result); | 90 gcm::GCMClient::Result result); |
| 91 void RequestAccessToken(); | 91 void RequestAccessToken(); |
| 92 void OnGetTokenComplete(const GoogleServiceAuthError& error, | 92 void OnGetTokenComplete(const GoogleServiceAuthError& error, |
| 93 const std::string& token); | 93 const std::string& token); |
| 94 void OnIncomingMessage(const std::string& message, | 94 void OnIncomingMessage(const std::string& message, |
| 95 const std::string& echo_token); | 95 const std::string& echo_token); |
| 96 void OnConnectionStateChanged( | 96 void OnConnectionStateChanged(bool online); |
| 97 GCMNetworkChannelDelegate::ConnectionState connection_state); | 97 void UpdateGcmChannelState(bool online); |
| 98 | 98 void UpdateHttpChannelState(bool online); |
| 99 // Base64 encoding/decoding with URL safe alphabet. | 99 // Base64 encoding/decoding with URL safe alphabet. |
| 100 // http://tools.ietf.org/html/rfc4648#page-7 | 100 // http://tools.ietf.org/html/rfc4648#page-7 |
| 101 static void Base64EncodeURLSafe(const std::string& input, | 101 static void Base64EncodeURLSafe(const std::string& input, |
| 102 std::string* output); | 102 std::string* output); |
| 103 static bool Base64DecodeURLSafe(const std::string& input, | 103 static bool Base64DecodeURLSafe(const std::string& input, |
| 104 std::string* output); | 104 std::string* output); |
| 105 | 105 |
| 106 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 106 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 107 scoped_ptr<GCMNetworkChannelDelegate> delegate_; | 107 scoped_ptr<GCMNetworkChannelDelegate> delegate_; |
| 108 | 108 |
| 109 // Message is saved until all conditions are met: there is valid | 109 // Message is saved until all conditions are met: there is valid |
| 110 // registration_id and access_token. | 110 // registration_id and access_token. |
| 111 std::string cached_message_; | 111 std::string cached_message_; |
| 112 | 112 |
| 113 // Access token is saved because in case of auth failure from server we need | 113 // Access token is saved because in case of auth failure from server we need |
| 114 // to invalidate it. | 114 // to invalidate it. |
| 115 std::string access_token_; | 115 std::string access_token_; |
| 116 | 116 |
| 117 // GCM registration_id is requested one at startup and never refreshed until | 117 // GCM registration_id is requested one at startup and never refreshed until |
| 118 // next restart. | 118 // next restart. |
| 119 std::string registration_id_; | 119 std::string registration_id_; |
| 120 scoped_ptr<net::BackoffEntry> register_backoff_entry_; | 120 scoped_ptr<net::BackoffEntry> register_backoff_entry_; |
| 121 | 121 |
| 122 scoped_ptr<net::URLFetcher> fetcher_; | 122 scoped_ptr<net::URLFetcher> fetcher_; |
| 123 | 123 |
| 124 // cacheinvalidation client receives echo_token with incoming message from | 124 // cacheinvalidation client receives echo_token with incoming message from |
| 125 // GCM and shuld include it in headers with outgoing message over http. | 125 // GCM and shuld include it in headers with outgoing message over http. |
| 126 std::string echo_token_; | 126 std::string echo_token_; |
| 127 | 127 |
| 128 // State of gcm and http channels. GCMNetworkChannel will only report |
| 129 // INVALIDATIONS_ENABLED if both channels are online. |
| 130 bool gcm_channel_online_; |
| 131 bool http_channel_online_; |
| 132 |
| 128 GCMNetworkChannelDiagnostic diagnostic_info_; | 133 GCMNetworkChannelDiagnostic diagnostic_info_; |
| 129 | 134 |
| 130 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; | 135 base::WeakPtrFactory<GCMNetworkChannel> weak_factory_; |
| 131 | 136 |
| 132 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); | 137 DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel); |
| 133 }; | 138 }; |
| 134 | 139 |
| 135 } // namespace syncer | 140 } // namespace syncer |
| 136 | 141 |
| 137 #endif // COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ | 142 #endif // COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_H_ |
| OLD | NEW |