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

Side by Side Diff: chrome/browser/services/gcm/gcm_profile_service.cc

Issue 631343002: [GCM] Fetching OAuth2 tokens periodically in account tracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mapper-in-driver
Patch Set: Created 6 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 (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/services/gcm/gcm_profile_service.h" 5 #include "chrome/browser/services/gcm/gcm_profile_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // When sign-in enforcement is not dropped, OnSignedOut will also clear all 104 // When sign-in enforcement is not dropped, OnSignedOut will also clear all
105 // the GCM data and a new GCM ID will be retrieved after the user signs in 105 // the GCM data and a new GCM ID will be retrieved after the user signs in
106 // again. Otherwise, the user sign-out will not affect the existing GCM 106 // again. Otherwise, the user sign-out will not affect the existing GCM
107 // data. 107 // data.
108 driver_->OnSignedOut(); 108 driver_->OnSignedOut();
109 } 109 }
110 110
111 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { 111 std::string GCMProfileService::IdentityObserver::SignedInUserName() const {
112 return driver_->IsStarted() ? account_id_ : std::string(); 112 return driver_->IsStarted() ? account_id_ : std::string();
113 } 113 }
114
115 void GCMProfileService::IdentityObserver::StartAccountTracker() { 114 void GCMProfileService::IdentityObserver::StartAccountTracker() {
116 if (gcm_account_tracker_) 115 if (gcm_account_tracker_)
117 return; 116 return;
118 117
119 scoped_ptr<gaia::AccountTracker> gaia_account_tracker( 118 scoped_ptr<gaia::AccountTracker> gaia_account_tracker(
120 new gaia::AccountTracker(identity_provider_.get(), 119 new gaia::AccountTracker(identity_provider_.get(),
121 profile_->GetRequestContext())); 120 profile_->GetRequestContext()));
122 121
123 gcm_account_tracker_.reset( 122 gcm_account_tracker_.reset(new GCMAccountTracker(
124 new GCMAccountTracker(gaia_account_tracker.Pass(), driver_)); 123 gaia_account_tracker.Pass(), driver_, profile_->GetPrefs()));
125 124
126 gcm_account_tracker_->Start(); 125 gcm_account_tracker_->Start();
127 } 126 }
128 127
129 #endif // !defined(OS_ANDROID) 128 #endif // !defined(OS_ANDROID)
130 129
131 // static 130 // static
132 bool GCMProfileService::IsGCMEnabled(Profile* profile) { 131 bool GCMProfileService::IsGCMEnabled(Profile* profile) {
133 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); 132 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled);
134 } 133 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 #endif // defined(OS_ANDROID) 222 #endif // defined(OS_ANDROID)
224 } 223 }
225 224
226 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { 225 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
227 driver_.reset(driver); 226 driver_.reset(driver);
228 if (identity_observer_) 227 if (identity_observer_)
229 identity_observer_.reset(new IdentityObserver(profile_, driver)); 228 identity_observer_.reset(new IdentityObserver(profile_, driver));
230 } 229 }
231 230
232 } // namespace gcm 231 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698