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

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

Issue 8746002: Use OAuth2 refresh token to download GAIA info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix observer 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::ShouldUseOAuthRefreshToken() {
92 return true;
93 }
94
91 void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader, 95 void GAIAInfoUpdateService::OnDownloadComplete(ProfileDownloader* downloader,
92 bool success) { 96 bool success) {
93 // Save the last updated time. 97 // Save the last updated time.
94 last_updated_ = base::Time::Now(); 98 last_updated_ = base::Time::Now();
95 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime, 99 profile_->GetPrefs()->SetInt64(prefs::kProfileGAIAInfoUpdateTime,
96 last_updated_.ToInternalValue()); 100 last_updated_.ToInternalValue());
97 ScheduleNextUpdate(); 101 ScheduleNextUpdate();
98 102
99 if (!success) { 103 if (!success) {
100 profile_image_downloader_.reset(); 104 profile_image_downloader_.reset();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; 170 const base::TimeDelta update_delta = base::Time::Now() - last_updated_;
167 171
168 base::TimeDelta delta; 172 base::TimeDelta delta;
169 if (update_delta < base::TimeDelta() || update_delta > desired_delta) 173 if (update_delta < base::TimeDelta() || update_delta > desired_delta)
170 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); 174 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds);
171 else 175 else
172 delta = desired_delta - update_delta; 176 delta = desired_delta - update_delta;
173 177
174 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); 178 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update);
175 } 179 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service.h ('k') | chrome/browser/profiles/profile_downloader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698