| 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 #ifndef CHROME_BROWSER_CHROMEOS_UPGRADE_DETECTOR_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_UPGRADE_DETECTOR_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_UPGRADE_DETECTOR_CHROMEOS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_UPGRADE_DETECTOR_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 9 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| 10 #include "chrome/browser/upgrade_detector.h" | 11 #include "chrome/browser/upgrade_detector.h" |
| 11 #include "chromeos/dbus/update_engine_client.h" | 12 #include "chromeos/dbus/update_engine_client.h" |
| 12 | 13 |
| 13 template <typename T> struct DefaultSingletonTraits; | 14 template <typename T> struct DefaultSingletonTraits; |
| 14 | 15 |
| 15 class UpgradeDetectorChromeos : public UpgradeDetector, | 16 class UpgradeDetectorChromeos : public UpgradeDetector, |
| 16 public chromeos::UpdateEngineClient::Observer { | 17 public chromeos::UpdateEngineClient::Observer { |
| 17 public: | 18 public: |
| 18 virtual ~UpgradeDetectorChromeos(); | 19 virtual ~UpgradeDetectorChromeos(); |
| 19 | 20 |
| 20 static UpgradeDetectorChromeos* GetInstance(); | 21 static UpgradeDetectorChromeos* GetInstance(); |
| 21 | 22 |
| 22 // Initializes the object. Starts observing changes from the update | 23 // Initializes the object. Starts observing changes from the update |
| 23 // engine. | 24 // engine. |
| 24 void Init(); | 25 void Init(); |
| 25 | 26 |
| 26 // Shuts down the object. Stops observing observe changes from the | 27 // Shuts down the object. Stops observing observe changes from the |
| 27 // update engine. | 28 // update engine. |
| 28 void Shutdown(); | 29 void Shutdown(); |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 friend struct DefaultSingletonTraits<UpgradeDetectorChromeos>; | 32 friend struct DefaultSingletonTraits<UpgradeDetectorChromeos>; |
| 33 class ChannelsRequester; |
| 32 | 34 |
| 33 UpgradeDetectorChromeos(); | 35 UpgradeDetectorChromeos(); |
| 34 | 36 |
| 35 // chromeos::UpdateEngineClient::Observer implementation. | 37 // chromeos::UpdateEngineClient::Observer implementation. |
| 36 virtual void UpdateStatusChanged( | 38 virtual void UpdateStatusChanged( |
| 37 const chromeos::UpdateEngineClient::Status& status) override; | 39 const chromeos::UpdateEngineClient::Status& status) override; |
| 38 | 40 |
| 39 // The function that sends out a notification (after a certain time has | 41 // The function that sends out a notification (after a certain time has |
| 40 // elapsed) that lets the rest of the UI know we should start notifying the | 42 // elapsed) that lets the rest of the UI know we should start notifying the |
| 41 // user that a new version is available. | 43 // user that a new version is available. |
| 42 void NotifyOnUpgrade(); | 44 void NotifyOnUpgrade(); |
| 43 | 45 |
| 46 void OnChannelsReceived(const std::string& current_channel, |
| 47 const std::string& target_channel); |
| 48 |
| 44 // After we detect an upgrade we start a recurring timer to see if enough time | 49 // After we detect an upgrade we start a recurring timer to see if enough time |
| 45 // has passed and we should start notifying the user. | 50 // has passed and we should start notifying the user. |
| 46 base::RepeatingTimer<UpgradeDetectorChromeos> upgrade_notification_timer_; | 51 base::RepeatingTimer<UpgradeDetectorChromeos> upgrade_notification_timer_; |
| 47 bool initialized_; | 52 bool initialized_; |
| 48 base::Time upgrade_detected_time_; | 53 base::Time upgrade_detected_time_; |
| 49 | 54 |
| 55 scoped_ptr<ChannelsRequester> channels_requester_; |
| 56 |
| 57 base::WeakPtrFactory<UpgradeDetectorChromeos> weak_factory_; |
| 58 |
| 50 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorChromeos); | 59 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorChromeos); |
| 51 }; | 60 }; |
| 52 | 61 |
| 53 #endif // CHROME_BROWSER_CHROMEOS_UPGRADE_DETECTOR_CHROMEOS_H_ | 62 #endif // CHROME_BROWSER_CHROMEOS_UPGRADE_DETECTOR_CHROMEOS_H_ |
| OLD | NEW |