Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: google_apis/gcm/gcm_client_impl.cc

Issue 261853012: Componentize GCM Part 1: create GCM component and move some files over (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/monitoring/gcm_stats_recorder.h" 23 #include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
23 #include "google_apis/gcm/protocol/mcs.pb.h" 24 #include "google_apis/gcm/protocol/mcs.pb.h"
24 #include "net/http/http_network_session.h" 25 #include "net/http/http_network_session.h"
25 #include "net/url_request/url_request_context.h" 26 #include "net/url_request/url_request_context.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 net::NetLog* net_log, 148 net::NetLog* net_log,
148 GCMStatsRecorder* recorder) { 149 GCMStatsRecorder* recorder) {
149 return make_scoped_ptr<ConnectionFactory>( 150 return make_scoped_ptr<ConnectionFactory>(
150 new ConnectionFactoryImpl(endpoints, 151 new ConnectionFactoryImpl(endpoints,
151 backoff_policy, 152 backoff_policy,
152 network_session, 153 network_session,
153 net_log, 154 net_log,
154 recorder)); 155 recorder));
155 } 156 }
156 157
157 GCMClientImpl::GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder) 158 GCMClientImpl::GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder,
159 scoped_ptr<Encryptor> encryptor)
158 : internals_builder_(internals_builder.Pass()), 160 : internals_builder_(internals_builder.Pass()),
161 encryptor_(encryptor.Pass()),
159 state_(UNINITIALIZED), 162 state_(UNINITIALIZED),
160 clock_(internals_builder_->BuildClock()), 163 clock_(internals_builder_->BuildClock()),
161 url_request_context_getter_(NULL), 164 url_request_context_getter_(NULL),
162 pending_registration_requests_deleter_(&pending_registration_requests_), 165 pending_registration_requests_deleter_(&pending_registration_requests_),
163 pending_unregistration_requests_deleter_( 166 pending_unregistration_requests_deleter_(
164 &pending_unregistration_requests_), 167 &pending_unregistration_requests_),
165 periodic_checkin_ptr_factory_(this), 168 periodic_checkin_ptr_factory_(this),
166 weak_ptr_factory_(this) { 169 weak_ptr_factory_(this) {
167 } 170 }
168 171
(...skipping 15 matching lines...) Expand all
184 url_request_context_getter_ = url_request_context_getter; 187 url_request_context_getter_ = url_request_context_getter;
185 const net::HttpNetworkSession::Params* network_session_params = 188 const net::HttpNetworkSession::Params* network_session_params =
186 url_request_context_getter_->GetURLRequestContext()-> 189 url_request_context_getter_->GetURLRequestContext()->
187 GetNetworkSessionParams(); 190 GetNetworkSessionParams();
188 DCHECK(network_session_params); 191 DCHECK(network_session_params);
189 network_session_ = new net::HttpNetworkSession(*network_session_params); 192 network_session_ = new net::HttpNetworkSession(*network_session_params);
190 193
191 chrome_build_proto_.CopyFrom(chrome_build_proto); 194 chrome_build_proto_.CopyFrom(chrome_build_proto);
192 account_ids_ = account_ids; 195 account_ids_ = account_ids;
193 196
194 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); 197 gcm_store_.reset(
198 new GCMStoreImpl(path, blocking_task_runner, encryptor_.get()));
195 199
196 delegate_ = delegate; 200 delegate_ = delegate;
197 201
198 state_ = INITIALIZED; 202 state_ = INITIALIZED;
199 } 203 }
200 204
201 void GCMClientImpl::Load() { 205 void GCMClientImpl::Load() {
202 DCHECK_EQ(INITIALIZED, state_); 206 DCHECK_EQ(INITIALIZED, state_);
203 207
204 // Once the loading is completed, the check-in will be initiated. 208 // Once the loading is completed, the check-in will be initiated.
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 768
765 recorder_.RecordIncomingSendError( 769 recorder_.RecordIncomingSendError(
766 data_message_stanza.category(), 770 data_message_stanza.category(),
767 data_message_stanza.to(), 771 data_message_stanza.to(),
768 data_message_stanza.id()); 772 data_message_stanza.id());
769 delegate_->OnMessageSendError(data_message_stanza.category(), 773 delegate_->OnMessageSendError(data_message_stanza.category(),
770 send_error_details); 774 send_error_details);
771 } 775 }
772 776
773 } // namespace gcm 777 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698