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" |
17 #include "google_apis/gcm/base/mcs_message.h" | 18 #include "google_apis/gcm/base/mcs_message.h" |
18 #include "google_apis/gcm/base/mcs_util.h" | 19 #include "google_apis/gcm/base/mcs_util.h" |
19 #include "google_apis/gcm/engine/checkin_request.h" | 20 #include "google_apis/gcm/engine/checkin_request.h" |
20 #include "google_apis/gcm/engine/connection_factory_impl.h" | 21 #include "google_apis/gcm/engine/connection_factory_impl.h" |
21 #include "google_apis/gcm/engine/gcm_store_impl.h" | 22 #include "google_apis/gcm/engine/gcm_store_impl.h" |
22 #include "google_apis/gcm/engine/gservices_settings.h" | 23 #include "google_apis/gcm/engine/gservices_settings.h" |
23 #include "google_apis/gcm/engine/mcs_client.h" | 24 #include "google_apis/gcm/engine/mcs_client.h" |
24 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" | 25 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h" |
25 #include "google_apis/gcm/protocol/mcs.pb.h" | 26 #include "google_apis/gcm/protocol/mcs.pb.h" |
26 #include "net/http/http_network_session.h" | 27 #include "net/http/http_network_session.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 net::NetLog* net_log, | 150 net::NetLog* net_log, |
150 GCMStatsRecorder* recorder) { | 151 GCMStatsRecorder* recorder) { |
151 return make_scoped_ptr<ConnectionFactory>( | 152 return make_scoped_ptr<ConnectionFactory>( |
152 new ConnectionFactoryImpl(endpoints, | 153 new ConnectionFactoryImpl(endpoints, |
153 backoff_policy, | 154 backoff_policy, |
154 network_session, | 155 network_session, |
155 net_log, | 156 net_log, |
156 recorder)); | 157 recorder)); |
157 } | 158 } |
158 | 159 |
159 GCMClientImpl::GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder) | 160 GCMClientImpl::GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder, |
| 161 scoped_ptr<Encryptor> encryptor) |
160 : internals_builder_(internals_builder.Pass()), | 162 : internals_builder_(internals_builder.Pass()), |
| 163 encryptor_(encryptor.Pass()), |
161 state_(UNINITIALIZED), | 164 state_(UNINITIALIZED), |
162 clock_(internals_builder_->BuildClock()), | 165 clock_(internals_builder_->BuildClock()), |
163 url_request_context_getter_(NULL), | 166 url_request_context_getter_(NULL), |
164 pending_registration_requests_deleter_(&pending_registration_requests_), | 167 pending_registration_requests_deleter_(&pending_registration_requests_), |
165 pending_unregistration_requests_deleter_( | 168 pending_unregistration_requests_deleter_( |
166 &pending_unregistration_requests_), | 169 &pending_unregistration_requests_), |
167 periodic_checkin_ptr_factory_(this), | 170 periodic_checkin_ptr_factory_(this), |
168 weak_ptr_factory_(this) { | 171 weak_ptr_factory_(this) { |
169 } | 172 } |
170 | 173 |
(...skipping 15 matching lines...) Expand all Loading... |
186 url_request_context_getter_ = url_request_context_getter; | 189 url_request_context_getter_ = url_request_context_getter; |
187 const net::HttpNetworkSession::Params* network_session_params = | 190 const net::HttpNetworkSession::Params* network_session_params = |
188 url_request_context_getter_->GetURLRequestContext()-> | 191 url_request_context_getter_->GetURLRequestContext()-> |
189 GetNetworkSessionParams(); | 192 GetNetworkSessionParams(); |
190 DCHECK(network_session_params); | 193 DCHECK(network_session_params); |
191 network_session_ = new net::HttpNetworkSession(*network_session_params); | 194 network_session_ = new net::HttpNetworkSession(*network_session_params); |
192 | 195 |
193 chrome_build_proto_.CopyFrom(chrome_build_proto); | 196 chrome_build_proto_.CopyFrom(chrome_build_proto); |
194 account_ids_ = account_ids; | 197 account_ids_ = account_ids; |
195 | 198 |
196 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); | 199 gcm_store_.reset( |
| 200 new GCMStoreImpl(path, blocking_task_runner, encryptor_.get())); |
197 gservices_settings_.reset(new GServicesSettings(gcm_store_.get())); | 201 gservices_settings_.reset(new GServicesSettings(gcm_store_.get())); |
198 | 202 |
199 delegate_ = delegate; | 203 delegate_ = delegate; |
200 | 204 |
201 state_ = INITIALIZED; | 205 state_ = INITIALIZED; |
202 } | 206 } |
203 | 207 |
204 void GCMClientImpl::Load() { | 208 void GCMClientImpl::Load() { |
205 DCHECK_EQ(INITIALIZED, state_); | 209 DCHECK_EQ(INITIALIZED, state_); |
206 | 210 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 | 760 |
757 recorder_.RecordIncomingSendError( | 761 recorder_.RecordIncomingSendError( |
758 data_message_stanza.category(), | 762 data_message_stanza.category(), |
759 data_message_stanza.to(), | 763 data_message_stanza.to(), |
760 data_message_stanza.id()); | 764 data_message_stanza.id()); |
761 delegate_->OnMessageSendError(data_message_stanza.category(), | 765 delegate_->OnMessageSendError(data_message_stanza.category(), |
762 send_error_details); | 766 send_error_details); |
763 } | 767 } |
764 | 768 |
765 } // namespace gcm | 769 } // namespace gcm |
OLD | NEW |