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