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

Side by Side Diff: components/gcm_driver/gcm_client_impl.cc

Issue 1298253002: Remove reference counting from HttpNetworkSession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test Created 5 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/gcm_driver/gcm_client_impl.h" 5 #include "components/gcm_driver/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/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 ConnectionFactory* connection_factory, 248 ConnectionFactory* connection_factory,
249 GCMStore* gcm_store, 249 GCMStore* gcm_store,
250 GCMStatsRecorder* recorder) { 250 GCMStatsRecorder* recorder) {
251 return scoped_ptr<MCSClient>(new MCSClient( 251 return scoped_ptr<MCSClient>(new MCSClient(
252 version, clock, connection_factory, gcm_store, recorder)); 252 version, clock, connection_factory, gcm_store, recorder));
253 } 253 }
254 254
255 scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory( 255 scoped_ptr<ConnectionFactory> GCMInternalsBuilder::BuildConnectionFactory(
256 const std::vector<GURL>& endpoints, 256 const std::vector<GURL>& endpoints,
257 const net::BackoffEntry::Policy& backoff_policy, 257 const net::BackoffEntry::Policy& backoff_policy,
258 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, 258 net::HttpNetworkSession* gcm_network_session,
259 const scoped_refptr<net::HttpNetworkSession>& http_network_session, 259 net::HttpNetworkSession* http_network_session,
260 net::NetLog* net_log,
261 GCMStatsRecorder* recorder) { 260 GCMStatsRecorder* recorder) {
262 return make_scoped_ptr<ConnectionFactory>( 261 return make_scoped_ptr<ConnectionFactory>(
263 new ConnectionFactoryImpl(endpoints, 262 new ConnectionFactoryImpl(endpoints,
264 backoff_policy, 263 backoff_policy,
265 gcm_network_session, 264 gcm_network_session,
266 http_network_session, 265 http_network_session,
267 net_log, 266 nullptr,
268 recorder)); 267 recorder));
269 } 268 }
270 269
271 GCMClientImpl::CheckinInfo::CheckinInfo() 270 GCMClientImpl::CheckinInfo::CheckinInfo()
272 : android_id(0), secret(0), accounts_set(false) { 271 : android_id(0), secret(0), accounts_set(false) {
273 } 272 }
274 273
275 GCMClientImpl::CheckinInfo::~CheckinInfo() { 274 GCMClientImpl::CheckinInfo::~CheckinInfo() {
276 } 275 }
277 276
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 GCMClient::Delegate* delegate) { 318 GCMClient::Delegate* delegate) {
320 DCHECK_EQ(UNINITIALIZED, state_); 319 DCHECK_EQ(UNINITIALIZED, state_);
321 DCHECK(url_request_context_getter.get()); 320 DCHECK(url_request_context_getter.get());
322 DCHECK(delegate); 321 DCHECK(delegate);
323 322
324 url_request_context_getter_ = url_request_context_getter; 323 url_request_context_getter_ = url_request_context_getter;
325 const net::HttpNetworkSession::Params* network_session_params = 324 const net::HttpNetworkSession::Params* network_session_params =
326 url_request_context_getter_->GetURLRequestContext()-> 325 url_request_context_getter_->GetURLRequestContext()->
327 GetNetworkSessionParams(); 326 GetNetworkSessionParams();
328 DCHECK(network_session_params); 327 DCHECK(network_session_params);
329 network_session_ = new net::HttpNetworkSession(*network_session_params); 328 network_session_.reset(new net::HttpNetworkSession(*network_session_params));
330 329
331 chrome_build_info_ = chrome_build_info; 330 chrome_build_info_ = chrome_build_info;
332 331
333 gcm_store_.reset( 332 gcm_store_.reset(
334 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass())); 333 new GCMStoreImpl(path, blocking_task_runner, encryptor.Pass()));
335 334
336 delegate_ = delegate; 335 delegate_ = delegate;
337 336
338 recorder_.SetDelegate(this); 337 recorder_.SetDelegate(this);
339 338
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 StartCheckin(); 475 StartCheckin();
477 } 476 }
478 477
479 void GCMClientImpl::InitializeMCSClient() { 478 void GCMClientImpl::InitializeMCSClient() {
480 std::vector<GURL> endpoints; 479 std::vector<GURL> endpoints;
481 endpoints.push_back(gservices_settings_.GetMCSMainEndpoint()); 480 endpoints.push_back(gservices_settings_.GetMCSMainEndpoint());
482 endpoints.push_back(gservices_settings_.GetMCSFallbackEndpoint()); 481 endpoints.push_back(gservices_settings_.GetMCSFallbackEndpoint());
483 connection_factory_ = internals_builder_->BuildConnectionFactory( 482 connection_factory_ = internals_builder_->BuildConnectionFactory(
484 endpoints, 483 endpoints,
485 GetGCMBackoffPolicy(), 484 GetGCMBackoffPolicy(),
486 network_session_, 485 network_session_.get(),
487 url_request_context_getter_->GetURLRequestContext() 486 url_request_context_getter_->GetURLRequestContext()
488 ->http_transaction_factory() 487 ->http_transaction_factory()
489 ->GetSession(), 488 ->GetSession(),
490 net_log_.net_log(),
491 &recorder_); 489 &recorder_);
492 connection_factory_->SetConnectionListener(this); 490 connection_factory_->SetConnectionListener(this);
493 mcs_client_ = internals_builder_->BuildMCSClient( 491 mcs_client_ = internals_builder_->BuildMCSClient(
494 chrome_build_info_.version, 492 chrome_build_info_.version,
495 clock_.get(), 493 clock_.get(),
496 connection_factory_.get(), 494 connection_factory_.get(),
497 gcm_store_.get(), 495 gcm_store_.get(),
498 &recorder_).Pass(); 496 &recorder_).Pass();
499 497
500 mcs_client_->Initialize( 498 mcs_client_->Initialize(
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 bool GCMClientImpl::HasStandaloneRegisteredApp() const { 1371 bool GCMClientImpl::HasStandaloneRegisteredApp() const {
1374 if (registrations_.empty()) 1372 if (registrations_.empty())
1375 return false; 1373 return false;
1376 // Note that account mapper is not counted as a standalone app since it is 1374 // Note that account mapper is not counted as a standalone app since it is
1377 // automatically started when other app uses GCM. 1375 // automatically started when other app uses GCM.
1378 return registrations_.size() > 1 || 1376 return registrations_.size() > 1 ||
1379 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId); 1377 !ExistsGCMRegistrationInMap(registrations_, kGCMAccountMapperAppId);
1380 } 1378 }
1381 1379
1382 } // namespace gcm 1380 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_client_impl.h ('k') | components/gcm_driver/gcm_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698