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

Side by Side Diff: chrome/browser/invalidation/ticl_invalidation_service.cc

Issue 225403021: Extract Profile-independent GCMService from GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 6 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/invalidation/ticl_invalidation_service.h" 5 #include "chrome/browser/invalidation/ticl_invalidation_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" 10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
11 #include "chrome/browser/invalidation/invalidation_service_util.h" 11 #include "chrome/browser/invalidation/invalidation_service_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/services/gcm/gcm_profile_service.h" 13 #include "chrome/browser/services/gcm/gcm_profile_service.h"
14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 14 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
15 #include "chrome/browser/services/gcm/gcm_service.h"
15 #include "chrome/common/chrome_content_client.h" 16 #include "chrome/common/chrome_content_client.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "components/signin/core/browser/profile_oauth2_token_service.h" 19 #include "components/signin/core/browser/profile_oauth2_token_service.h"
19 #include "google_apis/gaia/gaia_constants.h" 20 #include "google_apis/gaia/gaia_constants.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 #include "sync/notifier/gcm_network_channel_delegate.h" 22 #include "sync/notifier/gcm_network_channel_delegate.h"
22 #include "sync/notifier/invalidation_util.h" 23 #include "sync/notifier/invalidation_util.h"
23 #include "sync/notifier/invalidator.h" 24 #include "sync/notifier/invalidator.h"
24 #include "sync/notifier/invalidator_state.h" 25 #include "sync/notifier/invalidator_state.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 network_channel_options_.SetString("Options.HostPort", 388 network_channel_options_.SetString("Options.HostPort",
388 options.xmpp_host_port.ToString()); 389 options.xmpp_host_port.ToString());
389 network_channel_options_.SetString("Options.AuthMechanism", 390 network_channel_options_.SetString("Options.AuthMechanism",
390 options.auth_mechanism); 391 options.auth_mechanism);
391 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); 392 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method);
392 network_channel_creator = 393 network_channel_creator =
393 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); 394 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options);
394 break; 395 break;
395 } 396 }
396 case GCM_NETWORK_CHANNEL: { 397 case GCM_NETWORK_CHANNEL: {
397 gcm::GCMProfileService* gcm_profile_service = 398 gcm::GCMService* gcm_service =
398 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 399 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
399 gcm_invalidation_bridge_.reset(new GCMInvalidationBridge( 400 gcm_invalidation_bridge_.reset(new GCMInvalidationBridge(
400 gcm_profile_service, identity_provider_.get())); 401 gcm_service, identity_provider_.get()));
401 network_channel_creator = 402 network_channel_creator =
402 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( 403 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator(
403 request_context_, 404 request_context_,
404 gcm_invalidation_bridge_->CreateDelegate().Pass()); 405 gcm_invalidation_bridge_->CreateDelegate().Pass());
405 break; 406 break;
406 } 407 }
407 default: { 408 default: {
408 NOTREACHED(); 409 NOTREACHED();
409 return; 410 return;
410 } 411 }
(...skipping 10 matching lines...) Expand all
421 UpdateInvalidatorCredentials(); 422 UpdateInvalidatorCredentials();
422 423
423 invalidator_->RegisterHandler(this); 424 invalidator_->RegisterHandler(this);
424 invalidator_->UpdateRegisteredIds( 425 invalidator_->UpdateRegisteredIds(
425 this, 426 this,
426 invalidator_registrar_->GetAllRegisteredIds()); 427 invalidator_registrar_->GetAllRegisteredIds());
427 } 428 }
428 429
429 void TiclInvalidationService::UpdateInvalidationNetworkChannel() { 430 void TiclInvalidationService::UpdateInvalidationNetworkChannel() {
430 InvalidationNetworkChannel network_channel_type = PUSH_CLIENT_CHANNEL; 431 InvalidationNetworkChannel network_channel_type = PUSH_CLIENT_CHANNEL;
431 if (gcm::GCMProfileService::GetGCMEnabledState(profile_) == 432 if (gcm::GCMProfileService::GetGCMEnabledState(profile_) ==
dcheng 2014/04/23 01:13:58 Do we need to update this as well to indirect thro
bartfab (slow) 2014/04/23 11:33:07 Yes, this will be done in a follow-up CL that remo
432 gcm::GCMProfileService::ALWAYS_ENABLED && 433 gcm::GCMProfileService::ALWAYS_ENABLED &&
433 (profile_->GetPrefs()->GetBoolean( 434 (profile_->GetPrefs()->GetBoolean(
434 prefs::kInvalidationServiceUseGCMChannel) || 435 prefs::kInvalidationServiceUseGCMChannel) ||
435 CommandLine::ForCurrentProcess()->HasSwitch( 436 CommandLine::ForCurrentProcess()->HasSwitch(
436 switches::kInvalidationUseGCMChannel))) { 437 switches::kInvalidationUseGCMChannel))) {
437 network_channel_type = GCM_NETWORK_CHANNEL; 438 network_channel_type = GCM_NETWORK_CHANNEL;
438 } 439 }
439 if (network_channel_type_ == network_channel_type) 440 if (network_channel_type_ == network_channel_type)
440 return; 441 return;
441 network_channel_type_ = network_channel_type; 442 network_channel_type_ = network_channel_type;
(...skipping 13 matching lines...) Expand all
455 } 456 }
456 457
457 void TiclInvalidationService::StopInvalidator() { 458 void TiclInvalidationService::StopInvalidator() {
458 DCHECK(invalidator_); 459 DCHECK(invalidator_);
459 gcm_invalidation_bridge_.reset(); 460 gcm_invalidation_bridge_.reset();
460 invalidator_->UnregisterHandler(this); 461 invalidator_->UnregisterHandler(this);
461 invalidator_.reset(); 462 invalidator_.reset();
462 } 463 }
463 464
464 } // namespace invalidation 465 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698