| 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 #include "google_apis/gcm/gcm_client_impl.h" | 5 #include "google_apis/gcm/gcm_client_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Indicates a message type of the received message. | 62 // Indicates a message type of the received message. |
| 63 enum MessageType { | 63 enum MessageType { |
| 64 UNKNOWN, // Undetermined type. | 64 UNKNOWN, // Undetermined type. |
| 65 DATA_MESSAGE, // Regular data message. | 65 DATA_MESSAGE, // Regular data message. |
| 66 DELETED_MESSAGES, // Messages were deleted on the server. | 66 DELETED_MESSAGES, // Messages were deleted on the server. |
| 67 SEND_ERROR, // Error sending a message. | 67 SEND_ERROR, // Error sending a message. |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 const char kMCSEndpoint[] = "https://mtalk.google.com:5228"; | 70 // MCS endpoints. SSL Key pinning is done automatically due to the *.google.com |
| 71 // pinning rule. |
| 72 // Note: modifying the endpoints will affect the ability to compare the |
| 73 // GCM.CurrentEnpoint histogram across versions. |
| 74 const char kMCSEndpointMain[] = "https://mtalk.google.com:5228"; |
| 75 const char kMCSEndpointFallback[] = "https://mtalk.google.com:443"; |
| 76 |
| 71 const int kMaxRegistrationRetries = 5; | 77 const int kMaxRegistrationRetries = 5; |
| 72 const char kMessageTypeDataMessage[] = "gcm"; | 78 const char kMessageTypeDataMessage[] = "gcm"; |
| 73 const char kMessageTypeDeletedMessagesKey[] = "deleted_messages"; | 79 const char kMessageTypeDeletedMessagesKey[] = "deleted_messages"; |
| 74 const char kMessageTypeKey[] = "message_type"; | 80 const char kMessageTypeKey[] = "message_type"; |
| 75 const char kMessageTypeSendErrorKey[] = "send_error"; | 81 const char kMessageTypeSendErrorKey[] = "send_error"; |
| 76 const char kSendErrorMessageIdKey[] = "google.message_id"; | 82 const char kSendErrorMessageIdKey[] = "google.message_id"; |
| 77 const char kSendMessageFromValue[] = "gcm@chrome.com"; | 83 const char kSendMessageFromValue[] = "gcm@chrome.com"; |
| 78 const int64 kDefaultUserSerialNumber = 0LL; | 84 const int64 kDefaultUserSerialNumber = 0LL; |
| 79 | 85 |
| 80 GCMClient::Result ToGCMClientResult(MCSClient::MessageSendStatus status) { | 86 GCMClient::Result ToGCMClientResult(MCSClient::MessageSendStatus status) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void GCMClientImpl::InitializeMCSClient( | 188 void GCMClientImpl::InitializeMCSClient( |
| 183 scoped_ptr<GCMStore::LoadResult> result) { | 189 scoped_ptr<GCMStore::LoadResult> result) { |
| 184 // |mcs_client_| might already be set for testing at this point. No need to | 190 // |mcs_client_| might already be set for testing at this point. No need to |
| 185 // create a |connection_factory_|. | 191 // create a |connection_factory_|. |
| 186 if (!mcs_client_.get()) { | 192 if (!mcs_client_.get()) { |
| 187 const net::HttpNetworkSession::Params* network_session_params = | 193 const net::HttpNetworkSession::Params* network_session_params = |
| 188 url_request_context_getter_->GetURLRequestContext()-> | 194 url_request_context_getter_->GetURLRequestContext()-> |
| 189 GetNetworkSessionParams(); | 195 GetNetworkSessionParams(); |
| 190 DCHECK(network_session_params); | 196 DCHECK(network_session_params); |
| 191 network_session_ = new net::HttpNetworkSession(*network_session_params); | 197 network_session_ = new net::HttpNetworkSession(*network_session_params); |
| 198 std::vector<GURL> endpoints; |
| 199 endpoints.push_back(GURL(kMCSEndpointMain)); |
| 200 endpoints.push_back(GURL(kMCSEndpointFallback)); |
| 192 connection_factory_.reset(new ConnectionFactoryImpl( | 201 connection_factory_.reset(new ConnectionFactoryImpl( |
| 193 GURL(kMCSEndpoint), | 202 endpoints, |
| 194 kDefaultBackoffPolicy, | 203 kDefaultBackoffPolicy, |
| 195 network_session_, | 204 network_session_, |
| 196 net_log_.net_log())); | 205 net_log_.net_log())); |
| 197 mcs_client_.reset(new MCSClient(chrome_build_proto_.chrome_version(), | 206 mcs_client_.reset(new MCSClient(chrome_build_proto_.chrome_version(), |
| 198 clock_.get(), | 207 clock_.get(), |
| 199 connection_factory_.get(), | 208 connection_factory_.get(), |
| 200 gcm_store_.get())); | 209 gcm_store_.get())); |
| 201 } | 210 } |
| 202 | 211 |
| 203 mcs_client_->Initialize( | 212 mcs_client_->Initialize( |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 631 |
| 623 delegate_->OnMessageSendError(data_message_stanza.category(), | 632 delegate_->OnMessageSendError(data_message_stanza.category(), |
| 624 send_error_details); | 633 send_error_details); |
| 625 } | 634 } |
| 626 | 635 |
| 627 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { | 636 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { |
| 628 mcs_client_ = mcs_client.Pass(); | 637 mcs_client_ = mcs_client.Pass(); |
| 629 } | 638 } |
| 630 | 639 |
| 631 } // namespace gcm | 640 } // namespace gcm |
| OLD | NEW |