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"
16 struct DefaultSingletonTraits
;
19 class UpgradeDetectorChromeos
: public UpgradeDetector
,
20 public chromeos::UpdateEngineClient::Observer
{
22 ~UpgradeDetectorChromeos() override
;
24 static UpgradeDetectorChromeos
* GetInstance();
26 // Initializes the object. Starts observing changes from the update
30 // Shuts down the object. Stops observing observe changes from the
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_
;
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_