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" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/time/default_clock.h" | 16 #include "base/time/default_clock.h" |
17 #include "google_apis/gcm/base/encryptor.h" | |
18 #include "google_apis/gcm/base/mcs_message.h" | 17 #include "google_apis/gcm/base/mcs_message.h" |
19 #include "google_apis/gcm/base/mcs_util.h" | 18 #include "google_apis/gcm/base/mcs_util.h" |
20 #include "google_apis/gcm/engine/checkin_request.h" | 19 #include "google_apis/gcm/engine/checkin_request.h" |
21 #include "google_apis/gcm/engine/connection_factory_impl.h" | 20 #include "google_apis/gcm/engine/connection_factory_impl.h" |
22 #include "google_apis/gcm/engine/gcm_store_impl.h" | 21 #include "google_apis/gcm/engine/gcm_store_impl.h" |
23 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 22 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
24 #include "google_apis/gcm/protocol/mcs.pb.h" | 23 #include "google_apis/gcm/protocol/mcs.pb.h" |
25 #include "net/http/http_network_session.h" | 24 #include "net/http/http_network_session.h" |
26 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
27 #include "url/gurl.h" | 26 #include "url/gurl.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 GCMClientImpl::~GCMClientImpl() { | 199 GCMClientImpl::~GCMClientImpl() { |
201 } | 200 } |
202 | 201 |
203 void GCMClientImpl::Initialize( | 202 void GCMClientImpl::Initialize( |
204 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 203 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
205 const base::FilePath& path, | 204 const base::FilePath& path, |
206 const std::vector<std::string>& account_ids, | 205 const std::vector<std::string>& account_ids, |
207 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 206 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
208 const scoped_refptr<net::URLRequestContextGetter>& | 207 const scoped_refptr<net::URLRequestContextGetter>& |
209 url_request_context_getter, | 208 url_request_context_getter, |
210 scoped_ptr<Encryptor> encryptor, | |
211 GCMClient::Delegate* delegate) { | 209 GCMClient::Delegate* delegate) { |
212 DCHECK_EQ(UNINITIALIZED, state_); | 210 DCHECK_EQ(UNINITIALIZED, state_); |
213 DCHECK(url_request_context_getter); | 211 DCHECK(url_request_context_getter); |
214 DCHECK(delegate); | 212 DCHECK(delegate); |
215 | 213 |
216 url_request_context_getter_ = url_request_context_getter; | 214 url_request_context_getter_ = url_request_context_getter; |
217 const net::HttpNetworkSession::Params* network_session_params = | 215 const net::HttpNetworkSession::Params* network_session_params = |
218 url_request_context_getter_->GetURLRequestContext()-> | 216 url_request_context_getter_->GetURLRequestContext()-> |
219 GetNetworkSessionParams(); | 217 GetNetworkSessionParams(); |
220 DCHECK(network_session_params); | 218 DCHECK(network_session_params); |
221 network_session_ = new net::HttpNetworkSession(*network_session_params); | 219 network_session_ = new net::HttpNetworkSession(*network_session_params); |
222 | 220 |
223 chrome_build_proto_.CopyFrom(chrome_build_proto); | 221 chrome_build_proto_.CopyFrom(chrome_build_proto); |
224 account_ids_ = account_ids; | 222 account_ids_ = account_ids; |
225 | 223 |
226 gcm_store_.reset( | 224 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); |
227 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass())); | |
228 | 225 |
229 delegate_ = delegate; | 226 delegate_ = delegate; |
230 | 227 |
231 recorder_.SetDelegate(this); | 228 recorder_.SetDelegate(this); |
232 | 229 |
233 state_ = INITIALIZED; | 230 state_ = INITIALIZED; |
234 } | 231 } |
235 | 232 |
236 void GCMClientImpl::Start() { | 233 void GCMClientImpl::Start() { |
237 DCHECK_EQ(INITIALIZED, state_); | 234 DCHECK_EQ(INITIALIZED, state_); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 | 802 |
806 recorder_.RecordIncomingSendError( | 803 recorder_.RecordIncomingSendError( |
807 data_message_stanza.category(), | 804 data_message_stanza.category(), |
808 data_message_stanza.to(), | 805 data_message_stanza.to(), |
809 data_message_stanza.id()); | 806 data_message_stanza.id()); |
810 delegate_->OnMessageSendError(data_message_stanza.category(), | 807 delegate_->OnMessageSendError(data_message_stanza.category(), |
811 send_error_details); | 808 send_error_details); |
812 } | 809 } |
813 | 810 |
814 } // namespace gcm | 811 } // namespace gcm |
OLD | NEW |