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

Side by Side Diff: chrome/browser/profiles/gaia_info_update_service.cc

Issue 8742008: ChromeOS: Use OAuth2 refresh token to download GAIA info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/profiles/gaia_info_update_service.h" 5 #include "chrome/browser/profiles/gaia_info_update_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 int GAIAInfoUpdateService::GetDesiredImageSideLength() { 83 int GAIAInfoUpdateService::GetDesiredImageSideLength() {
84 return 256; 84 return 256;
85 } 85 }
86 86
87 Profile* GAIAInfoUpdateService::GetBrowserProfile() { 87 Profile* GAIAInfoUpdateService::GetBrowserProfile() {
88 return profile_; 88 return profile_;
89 } 89 }
90 90
91 bool GAIAInfoUpdateService::GetShouldUseOAuthRefreshToken() {
92 return true;
93 }
94
95 void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader, 91 void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
96 bool success) { 92 bool success) {
97 // Save the last updated time. 93 // Save the last updated time.
98 last_updated_ = base::Time::Now(); 94 last_updated_ = base::Time::Now();
99 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, 95 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime,
100 last_updated_.ToInternalValue()); 96 last_updated_.ToInternalValue());
101 ScheduleNextUpdate(); 97 ScheduleNextUpdate();
102 98
103 if (!success) { 99 if (!success) {
104 profile_image_downloader_.reset(); 100 profile_image_downloader_.reset();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; 166 const base::TimeDelta update_delta = base::Time::Now() - last_updated_;
171 167
172 base::TimeDelta delta; 168 base::TimeDelta delta;
173 if (update_delta < base::TimeDelta() || update_delta > desired_delta) 169 if (update_delta < base::TimeDelta() || update_delta > desired_delta)
174 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); 170 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds);
175 else 171 else
176 delta = desired_delta - update_delta; 172 delta = desired_delta - update_delta;
177 173
178 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); 174 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update);
179 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698