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://bla.google.com:5228"; | |
fgorski
2014/03/20 16:45:42
bla.google.com?
Nicolas Zea
2014/03/20 20:10:02
Whoops, good catch, that was from some manual test
| |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 void GCMClientImpl::InitializeMCSClient( | 185 void GCMClientImpl::InitializeMCSClient( |
180 scoped_ptr<GCMStore::LoadResult> result) { | 186 scoped_ptr<GCMStore::LoadResult> result) { |
181 // |mcs_client_| might already be set for testing at this point. No need to | 187 // |mcs_client_| might already be set for testing at this point. No need to |
182 // create a |connection_factory_|. | 188 // create a |connection_factory_|. |
183 if (!mcs_client_.get()) { | 189 if (!mcs_client_.get()) { |
184 const net::HttpNetworkSession::Params* network_session_params = | 190 const net::HttpNetworkSession::Params* network_session_params = |
185 url_request_context_getter_->GetURLRequestContext()-> | 191 url_request_context_getter_->GetURLRequestContext()-> |
186 GetNetworkSessionParams(); | 192 GetNetworkSessionParams(); |
187 DCHECK(network_session_params); | 193 DCHECK(network_session_params); |
188 network_session_ = new net::HttpNetworkSession(*network_session_params); | 194 network_session_ = new net::HttpNetworkSession(*network_session_params); |
195 std::vector<GURL> endpoints; | |
196 endpoints.push_back(GURL(kMCSEndpointMain)); | |
197 endpoints.push_back(GURL(kMCSEndpointFallback)); | |
189 connection_factory_.reset(new ConnectionFactoryImpl( | 198 connection_factory_.reset(new ConnectionFactoryImpl( |
190 GURL(kMCSEndpoint), | 199 endpoints, |
191 kDefaultBackoffPolicy, | 200 kDefaultBackoffPolicy, |
192 network_session_, | 201 network_session_, |
193 net_log_.net_log())); | 202 net_log_.net_log())); |
194 mcs_client_.reset(new MCSClient(chrome_build_proto_.chrome_version(), | 203 mcs_client_.reset(new MCSClient(chrome_build_proto_.chrome_version(), |
195 clock_.get(), | 204 clock_.get(), |
196 connection_factory_.get(), | 205 connection_factory_.get(), |
197 gcm_store_.get())); | 206 gcm_store_.get())); |
198 } | 207 } |
199 | 208 |
200 mcs_client_->Initialize( | 209 mcs_client_->Initialize( |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 | 573 |
565 delegate_->OnMessageSendError(data_message_stanza.category(), | 574 delegate_->OnMessageSendError(data_message_stanza.category(), |
566 send_error_details); | 575 send_error_details); |
567 } | 576 } |
568 | 577 |
569 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { | 578 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { |
570 mcs_client_ = mcs_client.Pass(); | 579 mcs_client_ = mcs_client.Pass(); |
571 } | 580 } |
572 | 581 |
573 } // namespace gcm | 582 } // namespace gcm |
OLD | NEW |