| 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/chromeos/upgrade_detector_chromeos.h" | 5 #include "chrome/browser/chromeos/upgrade_detector_chromeos.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 // How long to wait (each cycle) before checking which severity level we should | 12 // How long to wait (each cycle) before checking which severity level we should |
| 13 // be at. Once we reach the highest severity, the timer will stop. | 13 // be at. Once we reach the highest severity, the timer will stop. |
| 14 const int kNotifyCycleTimeMs = 20 * 60 * 1000; // 20 minutes. | 14 const int kNotifyCycleTimeMs = 20 * 60 * 1000; // 20 minutes. |
| 15 | 15 |
| 16 } // namespace | 16 } // namespace |
| 17 | 17 |
| 18 UpgradeDetectorChromeos::UpgradeDetectorChromeos() { | 18 UpgradeDetectorChromeos::UpgradeDetectorChromeos() : initialized_(false) { |
| 19 if (chromeos::CrosLibrary::Get()) | |
| 20 chromeos::CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); | |
| 21 } | 19 } |
| 22 | 20 |
| 23 UpgradeDetectorChromeos::~UpgradeDetectorChromeos() { | 21 UpgradeDetectorChromeos::~UpgradeDetectorChromeos() { |
| 22 } |
| 23 |
| 24 void UpgradeDetectorChromeos::Init() { |
| 25 if (chromeos::CrosLibrary::Get()) |
| 26 chromeos::CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); |
| 27 initialized_ = true; |
| 28 } |
| 29 |
| 30 void UpgradeDetectorChromeos::Shutdown() { |
| 31 // Init() may not be called from tests (ex. BrowserMainTest). |
| 32 if (!initialized_) |
| 33 return; |
| 24 if (chromeos::CrosLibrary::Get()) | 34 if (chromeos::CrosLibrary::Get()) |
| 25 chromeos::CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); | 35 chromeos::CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); |
| 26 } | 36 } |
| 27 | 37 |
| 28 void UpgradeDetectorChromeos::UpdateStatusChanged( | 38 void UpgradeDetectorChromeos::UpdateStatusChanged( |
| 29 const chromeos::UpdateLibrary::Status& status) { | 39 const chromeos::UpdateLibrary::Status& status) { |
| 30 if (status.status != chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) | 40 if (status.status != chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) |
| 31 return; | 41 return; |
| 32 | 42 |
| 33 NotifyUpgradeDetected(); | 43 NotifyUpgradeDetected(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 81 |
| 72 // static | 82 // static |
| 73 UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() { | 83 UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() { |
| 74 return Singleton<UpgradeDetectorChromeos>::get(); | 84 return Singleton<UpgradeDetectorChromeos>::get(); |
| 75 } | 85 } |
| 76 | 86 |
| 77 // static | 87 // static |
| 78 UpgradeDetector* UpgradeDetector::GetInstance() { | 88 UpgradeDetector* UpgradeDetector::GetInstance() { |
| 79 return UpgradeDetectorChromeos::GetInstance(); | 89 return UpgradeDetectorChromeos::GetInstance(); |
| 80 } | 90 } |
| OLD | NEW |