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/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 "chromeos/dbus/dbus_thread_manager.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 23 matching lines...) Expand all Loading... |
34 if (!initialized_) | 34 if (!initialized_) |
35 return; | 35 return; |
36 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); | 36 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
37 } | 37 } |
38 | 38 |
39 void UpgradeDetectorChromeos::UpdateStatusChanged( | 39 void UpgradeDetectorChromeos::UpdateStatusChanged( |
40 const UpdateEngineClient::Status& status) { | 40 const UpdateEngineClient::Status& status) { |
41 if (status.status != UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) | 41 if (status.status != UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) |
42 return; | 42 return; |
43 | 43 |
44 NotifyUpgradeDetected(); | 44 upgrade_detected_time_ = base::Time::Now(); |
45 | 45 |
46 // ChromeOS shows upgrade arrow once the upgrade becomes available. | 46 // ChromeOS shows upgrade arrow once the upgrade becomes available. |
47 NotifyOnUpgrade(); | 47 NotifyOnUpgrade(); |
48 | 48 |
49 // Setup timer to to move along the upgrade advisory system. | 49 // Setup timer to to move along the upgrade advisory system. |
50 upgrade_notification_timer_.Start( | 50 upgrade_notification_timer_.Start( |
51 FROM_HERE, base::TimeDelta::FromMilliseconds(kNotifyCycleTimeMs), | 51 FROM_HERE, base::TimeDelta::FromMilliseconds(kNotifyCycleTimeMs), |
52 this, &UpgradeDetectorChromeos::NotifyOnUpgrade); | 52 this, &UpgradeDetectorChromeos::NotifyOnUpgrade); |
53 } | 53 } |
54 | 54 |
55 void UpgradeDetectorChromeos::NotifyOnUpgrade() { | 55 void UpgradeDetectorChromeos::NotifyOnUpgrade() { |
56 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time(); | 56 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time_; |
57 int64 time_passed = delta.InDays(); | 57 int64 time_passed = delta.InDays(); |
58 | 58 |
59 const int kSevereThreshold = 7; | 59 const int kSevereThreshold = 7; |
60 const int kHighThreshold = 4; | 60 const int kHighThreshold = 4; |
61 const int kElevatedThreshold = 2; | 61 const int kElevatedThreshold = 2; |
62 const int kLowThreshold = 0; | 62 const int kLowThreshold = 0; |
63 | 63 |
64 // These if statements must be sorted (highest interval first). | 64 // These if statements must be sorted (highest interval first). |
65 if (time_passed >= kSevereThreshold) { | 65 if (time_passed >= kSevereThreshold) { |
66 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_SEVERE); | 66 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_SEVERE); |
(...skipping 15 matching lines...) Expand all Loading... |
82 | 82 |
83 // static | 83 // static |
84 UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() { | 84 UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() { |
85 return Singleton<UpgradeDetectorChromeos>::get(); | 85 return Singleton<UpgradeDetectorChromeos>::get(); |
86 } | 86 } |
87 | 87 |
88 // static | 88 // static |
89 UpgradeDetector* UpgradeDetector::GetInstance() { | 89 UpgradeDetector* UpgradeDetector::GetInstance() { |
90 return UpgradeDetectorChromeos::GetInstance(); | 90 return UpgradeDetectorChromeos::GetInstance(); |
91 } | 91 } |
OLD | NEW |