| OLD | NEW |
| 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/upgrade_detector_impl.h" | 5 #include "chrome/browser/upgrade_detector_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) | 152 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) |
| 153 return; | 153 return; |
| 154 // Windows: only enable upgrade notifications for official builds. | 154 // Windows: only enable upgrade notifications for official builds. |
| 155 // Mac: only enable them if the updater (Keystone) is present. | 155 // Mac: only enable them if the updater (Keystone) is present. |
| 156 // Linux (and other POSIX): always enable regardless of branding. | 156 // Linux (and other POSIX): always enable regardless of branding. |
| 157 #if (defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)) || defined(OS_POSIX) | 157 #if (defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)) || defined(OS_POSIX) |
| 158 #if defined(OS_MACOSX) | 158 #if defined(OS_MACOSX) |
| 159 if (keystone_glue::KeystoneEnabled()) | 159 if (keystone_glue::KeystoneEnabled()) |
| 160 #endif | 160 #endif |
| 161 { | 161 { |
| 162 detect_upgrade_timer_.Start(FROM_HERE, | 162 detect_upgrade_timer_.Start( |
| 163 base::TimeDelta::FromMilliseconds(GetCheckForUpgradeEveryMs()), | 163 base::TimeDelta::FromMilliseconds(GetCheckForUpgradeEveryMs()), |
| 164 this, &UpgradeDetectorImpl::CheckForUpgrade); | 164 this, &UpgradeDetectorImpl::CheckForUpgrade); |
| 165 } | 165 } |
| 166 #endif | 166 #endif |
| 167 } | 167 } |
| 168 | 168 |
| 169 UpgradeDetectorImpl::~UpgradeDetectorImpl() { | 169 UpgradeDetectorImpl::~UpgradeDetectorImpl() { |
| 170 } | 170 } |
| 171 | 171 |
| 172 void UpgradeDetectorImpl::CheckForUpgrade() { | 172 void UpgradeDetectorImpl::CheckForUpgrade() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 188 // Stop the recurring timer (that is checking for changes). | 188 // Stop the recurring timer (that is checking for changes). |
| 189 detect_upgrade_timer_.Stop(); | 189 detect_upgrade_timer_.Stop(); |
| 190 | 190 |
| 191 NotifyUpgradeDetected(); | 191 NotifyUpgradeDetected(); |
| 192 | 192 |
| 193 // Start the repeating timer for notifying the user after a certain period. | 193 // Start the repeating timer for notifying the user after a certain period. |
| 194 // The called function will eventually figure out that enough time has passed | 194 // The called function will eventually figure out that enough time has passed |
| 195 // and stop the timer. | 195 // and stop the timer. |
| 196 int cycle_time = CmdLineInterval().empty() ? kNotifyCycleTimeMs : | 196 int cycle_time = CmdLineInterval().empty() ? kNotifyCycleTimeMs : |
| 197 kNotifyCycleTimeForTestingMs; | 197 kNotifyCycleTimeForTestingMs; |
| 198 upgrade_notification_timer_.Start(FROM_HERE, | 198 upgrade_notification_timer_.Start( |
| 199 base::TimeDelta::FromMilliseconds(cycle_time), | 199 base::TimeDelta::FromMilliseconds(cycle_time), |
| 200 this, &UpgradeDetectorImpl::NotifyOnUpgrade); | 200 this, &UpgradeDetectorImpl::NotifyOnUpgrade); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void UpgradeDetectorImpl::NotifyOnUpgrade() { | 203 void UpgradeDetectorImpl::NotifyOnUpgrade() { |
| 204 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time(); | 204 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time(); |
| 205 std::string interval = CmdLineInterval(); | 205 std::string interval = CmdLineInterval(); |
| 206 | 206 |
| 207 // A command line interval implies testing, which we'll make more convenient | 207 // A command line interval implies testing, which we'll make more convenient |
| 208 // by switching to seconds of waiting instead of days between flipping | 208 // by switching to seconds of waiting instead of days between flipping |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 // static | 255 // static |
| 256 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 256 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
| 257 return Singleton<UpgradeDetectorImpl>::get(); | 257 return Singleton<UpgradeDetectorImpl>::get(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 // static | 260 // static |
| 261 UpgradeDetector* UpgradeDetector::GetInstance() { | 261 UpgradeDetector* UpgradeDetector::GetInstance() { |
| 262 return UpgradeDetectorImpl::GetInstance(); | 262 return UpgradeDetectorImpl::GetInstance(); |
| 263 } | 263 } |
| OLD | NEW |