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

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: Fix trybot 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 GCMClientImpl::~GCMClientImpl() { 170 GCMClientImpl::~GCMClientImpl() {
170 } 171 }
171 172
172 void GCMClientImpl::Initialize( 173 void GCMClientImpl::Initialize(
173 const checkin_proto::ChromeBuildProto& chrome_build_proto, 174 const checkin_proto::ChromeBuildProto& chrome_build_proto,
174 const base::FilePath& path, 175 const base::FilePath& path,
175 const std::vector<std::string>& account_ids, 176 const std::vector<std::string>& account_ids,
176 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, 177 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
177 const scoped_refptr<net::URLRequestContextGetter>& 178 const scoped_refptr<net::URLRequestContextGetter>&
178 url_request_context_getter, 179 url_request_context_getter,
180 scoped_ptr<Encryptor> encryptor,
179 Delegate* delegate) { 181 Delegate* delegate) {
180 DCHECK_EQ(UNINITIALIZED, state_); 182 DCHECK_EQ(UNINITIALIZED, state_);
181 DCHECK(url_request_context_getter); 183 DCHECK(url_request_context_getter);
182 DCHECK(delegate); 184 DCHECK(delegate);
183 185
184 url_request_context_getter_ = url_request_context_getter; 186 url_request_context_getter_ = url_request_context_getter;
185 const net::HttpNetworkSession::Params* network_session_params = 187 const net::HttpNetworkSession::Params* network_session_params =
186 url_request_context_getter_->GetURLRequestContext()-> 188 url_request_context_getter_->GetURLRequestContext()->
187 GetNetworkSessionParams(); 189 GetNetworkSessionParams();
188 DCHECK(network_session_params); 190 DCHECK(network_session_params);
189 network_session_ = new net::HttpNetworkSession(*network_session_params); 191 network_session_ = new net::HttpNetworkSession(*network_session_params);
190 192
191 chrome_build_proto_.CopyFrom(chrome_build_proto); 193 chrome_build_proto_.CopyFrom(chrome_build_proto);
192 account_ids_ = account_ids; 194 account_ids_ = account_ids;
193 195
194 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); 196 gcm_store_.reset(
197 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass()));
195 198
196 delegate_ = delegate; 199 delegate_ = delegate;
197 200
198 state_ = INITIALIZED; 201 state_ = INITIALIZED;
199 } 202 }
200 203
201 void GCMClientImpl::Load() { 204 void GCMClientImpl::Load() {
202 DCHECK_EQ(INITIALIZED, state_); 205 DCHECK_EQ(INITIALIZED, state_);
203 206
204 // Once the loading is completed, the check-in will be initiated. 207 // Once the loading is completed, the check-in will be initiated.
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 767
765 recorder_.RecordIncomingSendError( 768 recorder_.RecordIncomingSendError(
766 data_message_stanza.category(), 769 data_message_stanza.category(),
767 data_message_stanza.to(), 770 data_message_stanza.to(),
768 data_message_stanza.id()); 771 data_message_stanza.id());
769 delegate_->OnMessageSendError(data_message_stanza.category(), 772 delegate_->OnMessageSendError(data_message_stanza.category(),
770 send_error_details); 773 send_error_details);
771 } 774 }
772 775
773 } // namespace gcm 776 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698