#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/invalidation/gcm_network_channel_delegate_impl.h"
+#include "chrome/browser/invalidation/invalidation_logger.h"
#include "chrome/browser/invalidation/invalidation_service_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/about_signin_internals.h"
#include "content/public/browser/notification_service.h"
#include "google_apis/gaia/gaia_constants.h"
#include "sync/notifier/gcm_network_channel_delegate.h"
+#include "sync/notifier/invalidation_util.h"
#include "sync/notifier/invalidator.h"
#include "sync/notifier/invalidator_state.h"
#include "sync/notifier/non_blocking_invalidator.h"
+#include "sync/notifier/object_id_invalidation_map.h"
static const char* kOAuth2Scopes[] = {
GaiaConstants::kGoogleTalkOAuth2Scope
signin_manager_(signin),
oauth2_token_service_(oauth2_token_service),
invalidator_registrar_(new syncer::InvalidatorRegistrar()),
- request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy) {
-}
+ request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
+ logger_() {}
TiclInvalidationService::~TiclInvalidationService() {
DCHECK(CalledOnValidThread());
return invalidator_storage_->GetInvalidatorClientId();
}
+InvalidationLogger* TiclInvalidationService::GetInvalidationLogger() {
+ return &logger_;
+}
+
void TiclInvalidationService::Observe(
int type,
const content::NotificationSource& source,
oauth2_scopes.insert(kOAuth2Scopes[i]);
// Invalidate previous token, otherwise token service will return the same
// token again.
- const std::string& account_id = oauth2_token_service_->GetPrimaryAccountId();
+ const std::string& account_id = signin_manager_->GetAuthenticatedAccountId();
oauth2_token_service_->InvalidateToken(account_id,
oauth2_scopes,
access_token_);
void TiclInvalidationService::OnRefreshTokenAvailable(
const std::string& account_id) {
- if (oauth2_token_service_->GetPrimaryAccountId() == account_id) {
+ if (signin_manager_->GetAuthenticatedAccountId() == account_id) {
if (!IsStarted() && IsReadyToStart()) {
StartInvalidator(PUSH_CLIENT_CHANNEL);
}
void TiclInvalidationService::OnRefreshTokenRevoked(
const std::string& account_id) {
- if (oauth2_token_service_->GetPrimaryAccountId() == account_id) {
+ if (signin_manager_->GetAuthenticatedAccountId() == account_id) {
access_token_.clear();
if (IsStarted()) {
UpdateInvalidatorCredentials();
} else {
invalidator_registrar_->UpdateInvalidatorState(state);
}
+ logger_.OnStateChange(state);
}
void TiclInvalidationService::OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) {
invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map);
+
+ logger_.OnInvalidation(invalidation_map);
}
void TiclInvalidationService::Shutdown() {
}
if (!oauth2_token_service_->RefreshTokenIsAvailable(
- oauth2_token_service_->GetPrimaryAccountId())) {
+ signin_manager_->GetAuthenticatedAccountId())) {
DVLOG(2)
<< "Not starting TiclInvalidationServce: Waiting for refresh token.";
return false;
break;
}
case GCM_NETWORK_CHANNEL: {
- // TODO(pavely): Pass NULL pointer for now. When GCMNetworkChannelDelegate
- // is implemented it will be instantiated and passed here.
scoped_ptr<syncer::GCMNetworkChannelDelegate> delegate;
+ delegate.reset(new GCMNetworkChannelDelegateImpl(profile_));
network_channel_creator =
syncer::NonBlockingInvalidator::MakeGCMNetworkChannelCreator(
profile_->GetRequestContext(),