| 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 "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/invalidation/invalidation_service_util.h" | 10 #include "chrome/browser/invalidation/invalidation_service_util.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/signin/about_signin_internals.h" | 12 #include "chrome/browser/signin/about_signin_internals.h" |
| 13 #include "chrome/browser/signin/about_signin_internals_factory.h" | 13 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 14 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 16 #include "chrome/browser/signin/signin_manager.h" | 16 #include "chrome/browser/signin/signin_manager.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "google_apis/gaia/gaia_constants.h" | 18 #include "google_apis/gaia/gaia_constants.h" |
| 19 #include "sync/notifier/gcm_network_channel_delegate.h" |
| 19 #include "sync/notifier/invalidator.h" | 20 #include "sync/notifier/invalidator.h" |
| 20 #include "sync/notifier/invalidator_state.h" | 21 #include "sync/notifier/invalidator_state.h" |
| 21 #include "sync/notifier/non_blocking_invalidator.h" | 22 #include "sync/notifier/non_blocking_invalidator.h" |
| 22 | 23 |
| 23 static const char* kOAuth2Scopes[] = { | 24 static const char* kOAuth2Scopes[] = { |
| 24 GaiaConstants::kGoogleTalkOAuth2Scope | 25 GaiaConstants::kGoogleTalkOAuth2Scope |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 static const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { | 28 static const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { |
| 28 // Number of initial errors (in sequence) to ignore before applying | 29 // Number of initial errors (in sequence) to ignore before applying |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 notifier::NotifierOptions options = | 336 notifier::NotifierOptions options = |
| 336 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); | 337 ParseNotifierOptions(*CommandLine::ForCurrentProcess()); |
| 337 options.request_context_getter = profile_->GetRequestContext(); | 338 options.request_context_getter = profile_->GetRequestContext(); |
| 338 options.auth_mechanism = "X-OAUTH2"; | 339 options.auth_mechanism = "X-OAUTH2"; |
| 339 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); | 340 DCHECK_EQ(notifier::NOTIFICATION_SERVER, options.notification_method); |
| 340 network_channel_creator = | 341 network_channel_creator = |
| 341 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); | 342 syncer::NonBlockingInvalidator::MakePushClientChannelCreator(options); |
| 342 break; | 343 break; |
| 343 } | 344 } |
| 344 case GCM_NETWORK_CHANNEL: { | 345 case GCM_NETWORK_CHANNEL: { |
| 346 // TODO(pavely): Pass NULL pointer for now. When GCMNetworkChannelDelegate |
| 347 // is implemented it will be instantiated and passed here. |
| 348 scoped_ptr<syncer::GCMNetworkChannelDelegate> delegate; |
| 345 network_channel_creator = | 349 network_channel_creator = |
| 346 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator(); | 350 syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator( |
| 351 profile_->GetRequestContext(), |
| 352 delegate.Pass()); |
| 347 break; | 353 break; |
| 348 } | 354 } |
| 349 default: { | 355 default: { |
| 350 NOTREACHED(); | 356 NOTREACHED(); |
| 351 return; | 357 return; |
| 352 } | 358 } |
| 353 } | 359 } |
| 354 invalidator_.reset(new syncer::NonBlockingInvalidator( | 360 invalidator_.reset(new syncer::NonBlockingInvalidator( |
| 355 network_channel_creator, | 361 network_channel_creator, |
| 356 invalidator_storage_->GetInvalidatorClientId(), | 362 invalidator_storage_->GetInvalidatorClientId(), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 399 } |
| 394 | 400 |
| 395 // This service always expects to have a valid invalidator storage. | 401 // This service always expects to have a valid invalidator storage. |
| 396 // So we must not only clear the old one, but also start a new one. | 402 // So we must not only clear the old one, but also start a new one. |
| 397 invalidator_storage_->Clear(); | 403 invalidator_storage_->Clear(); |
| 398 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); | 404 invalidator_storage_.reset(new InvalidatorStorage(profile_->GetPrefs())); |
| 399 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); | 405 invalidator_storage_->SetInvalidatorClientId(GenerateInvalidatorClientId()); |
| 400 } | 406 } |
| 401 | 407 |
| 402 } // namespace invalidation | 408 } // namespace invalidation |
| OLD | NEW |