OLD | NEW |
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" | |
15 #include "chrome/browser/services/gcm/gcm_service.h" | 14 #include "chrome/browser/services/gcm/gcm_service.h" |
16 #include "chrome/common/chrome_content_client.h" | 15 #include "chrome/common/chrome_content_client.h" |
17 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
19 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 18 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
20 #include "google_apis/gaia/gaia_constants.h" | 19 #include "google_apis/gaia/gaia_constants.h" |
21 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
22 #include "sync/notifier/gcm_network_channel_delegate.h" | 21 #include "sync/notifier/gcm_network_channel_delegate.h" |
23 #include "sync/notifier/invalidation_util.h" | 22 #include "sync/notifier/invalidation_util.h" |
24 #include "sync/notifier/invalidator.h" | 23 #include "sync/notifier/invalidator.h" |
(...skipping 30 matching lines...) Expand all Loading... |
55 -1, | 54 -1, |
56 | 55 |
57 // Don't use initial delay unless the last request was an error. | 56 // Don't use initial delay unless the last request was an error. |
58 false, | 57 false, |
59 }; | 58 }; |
60 | 59 |
61 namespace invalidation { | 60 namespace invalidation { |
62 | 61 |
63 TiclInvalidationService::TiclInvalidationService( | 62 TiclInvalidationService::TiclInvalidationService( |
64 scoped_ptr<IdentityProvider> identity_provider, | 63 scoped_ptr<IdentityProvider> identity_provider, |
| 64 gcm::GCMService* gcm_service, |
65 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 65 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
66 Profile* profile) | 66 Profile* profile) |
67 : OAuth2TokenService::Consumer("ticl_invalidation"), | 67 : OAuth2TokenService::Consumer("ticl_invalidation"), |
68 profile_(profile), | 68 profile_(profile), |
69 identity_provider_(identity_provider.Pass()), | 69 identity_provider_(identity_provider.Pass()), |
70 invalidator_registrar_(new syncer::InvalidatorRegistrar()), | 70 invalidator_registrar_(new syncer::InvalidatorRegistrar()), |
71 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), | 71 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), |
72 network_channel_type_(PUSH_CLIENT_CHANNEL), | 72 network_channel_type_(PUSH_CLIENT_CHANNEL), |
| 73 gcm_service_(gcm_service), |
73 request_context_(request_context), | 74 request_context_(request_context), |
74 logger_() {} | 75 logger_() {} |
75 | 76 |
76 TiclInvalidationService::~TiclInvalidationService() { | 77 TiclInvalidationService::~TiclInvalidationService() { |
77 DCHECK(CalledOnValidThread()); | 78 DCHECK(CalledOnValidThread()); |
78 } | 79 } |
79 | 80 |
80 void TiclInvalidationService::Init( | 81 void TiclInvalidationService::Init( |
81 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker) { | 82 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker) { |
82 DCHECK(CalledOnValidThread()); | 83 DCHECK(CalledOnValidThread()); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 network_channel_options_.SetString("Options.HostPort", | 389 network_channel_options_.SetString("Options.HostPort", |
389 options.xmpp_host_port.ToString()); | 390 options.xmpp_host_port.ToString()); |
390 network_channel_options_.SetString("Options.AuthMechanism", | 391 network_channel_options_.SetString("Options.AuthMechanism", |
391 options.auth_mechanism); | 392 options.auth_mechanism); |
392 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); | 393 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); |
393 network_channel_creator = | 394 network_channel_creator = |
394 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); | 395 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); |
395 break; | 396 break; |
396 } | 397 } |
397 case GCM_NETWORK_CHANNEL: { | 398 case GCM_NETWORK_CHANNEL: { |
398 gcm::GCMService* gcm_service = | |
399 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | |
400 gcm_invalidation_bridge_.reset(new GCMInvalidationBridge( | 399 gcm_invalidation_bridge_.reset(new GCMInvalidationBridge( |
401 gcm_service, identity_provider_.get())); | 400 gcm_service_, identity_provider_.get())); |
402 network_channel_creator = | 401 network_channel_creator = |
403 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( | 402 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( |
404 request_context_, | 403 request_context_, |
405 gcm_invalidation_bridge_->CreateDelegate().Pass()); | 404 gcm_invalidation_bridge_->CreateDelegate().Pass()); |
406 break; | 405 break; |
407 } | 406 } |
408 default: { | 407 default: { |
409 NOTREACHED(); | 408 NOTREACHED(); |
410 return; | 409 return; |
411 } | 410 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 455 } |
457 | 456 |
458 void TiclInvalidationService::StopInvalidator() { | 457 void TiclInvalidationService::StopInvalidator() { |
459 DCHECK(invalidator_); | 458 DCHECK(invalidator_); |
460 gcm_invalidation_bridge_.reset(); | 459 gcm_invalidation_bridge_.reset(); |
461 invalidator_->UnregisterHandler(this); | 460 invalidator_->UnregisterHandler(this); |
462 invalidator_.reset(); | 461 invalidator_.reset(); |
463 } | 462 } |
464 | 463 |
465 } // namespace invalidation | 464 } // namespace invalidation |
OLD | NEW |