| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 last_updated_ = base::Time::FromInternalValue( | 45 last_updated_ = base::Time::FromInternalValue( |
| 46 prefs->GetInt64(prefs::kProfileGAIAInfoUpdateTime)); | 46 prefs->GetInt64(prefs::kProfileGAIAInfoUpdateTime)); |
| 47 ScheduleNextUpdate(); | 47 ScheduleNextUpdate(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 GAIAInfoUpdateService::~GAIAInfoUpdateService() { | 50 GAIAInfoUpdateService::~GAIAInfoUpdateService() { |
| 51 DCHECK(!profile_) << "Shutdown not called before dtor"; | 51 DCHECK(!profile_) << "Shutdown not called before dtor"; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void GAIAInfoUpdateService::Update() { | 54 void GAIAInfoUpdateService::Update() { |
| 55 // UMA Profile Metrics should be logged regularly. |
| 56 ProfileMetrics::LogNumberOfProfiles(g_browser_process->profile_manager()); |
| 57 |
| 55 // The user must be logged in. | 58 // The user must be logged in. |
| 56 SigninManagerBase* signin_manager = | 59 SigninManagerBase* signin_manager = |
| 57 SigninManagerFactory::GetForProfile(profile_); | 60 SigninManagerFactory::GetForProfile(profile_); |
| 58 if (!signin_manager->IsAuthenticated()) | 61 if (!signin_manager->IsAuthenticated()) |
| 59 return; | 62 return; |
| 60 | 63 |
| 61 if (profile_image_downloader_) | 64 if (profile_image_downloader_) |
| 62 return; | 65 return; |
| 63 profile_image_downloader_.reset(new ProfileDownloader(this)); | 66 profile_image_downloader_.reset(new ProfileDownloader(this)); |
| 64 profile_image_downloader_->Start(); | 67 profile_image_downloader_->Start(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 const base::TimeDelta desired_delta = | 207 const base::TimeDelta desired_delta = |
| 205 base::TimeDelta::FromHours(kUpdateIntervalHours); | 208 base::TimeDelta::FromHours(kUpdateIntervalHours); |
| 206 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; | 209 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; |
| 207 | 210 |
| 208 base::TimeDelta delta; | 211 base::TimeDelta delta; |
| 209 if (update_delta < base::TimeDelta() || update_delta > desired_delta) | 212 if (update_delta < base::TimeDelta() || update_delta > desired_delta) |
| 210 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); | 213 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); |
| 211 else | 214 else |
| 212 delta = desired_delta - update_delta; | 215 delta = desired_delta - update_delta; |
| 213 | 216 |
| 214 // UMA Profile Metrics should be logged regularly. Logging is not performed | |
| 215 // in Update() because it is a public method and may be called at any time. | |
| 216 // These metrics should logged only on this schedule. | |
| 217 // | |
| 218 // In mac perf tests, the browser process pointer may be null. | |
| 219 if (g_browser_process) | |
| 220 ProfileMetrics::LogNumberOfProfiles(g_browser_process->profile_manager()); | |
| 221 | |
| 222 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); | 217 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); |
| 223 } | 218 } |
| 224 | 219 |
| 225 void GAIAInfoUpdateService::GoogleSigninSucceeded( | 220 void GAIAInfoUpdateService::GoogleSigninSucceeded( |
| 226 const std::string& account_id, | 221 const std::string& account_id, |
| 227 const std::string& username, | 222 const std::string& username, |
| 228 const std::string& password) { | 223 const std::string& password) { |
| 229 OnUsernameChanged(username); | 224 OnUsernameChanged(username); |
| 230 } | 225 } |
| 231 | 226 |
| 232 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& account_id, | 227 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& account_id, |
| 233 const std::string& username) { | 228 const std::string& username) { |
| 234 OnUsernameChanged(std::string()); | 229 OnUsernameChanged(std::string()); |
| 235 } | 230 } |
| OLD | NEW |