Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/chromeos/app_mode/kiosk_app_update_service.h

Issue 16844020: app_mode: Add runtime.onRestartRequired event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h"
14 #include "chrome/browser/extensions/update_observer.h" 15 #include "chrome/browser/extensions/update_observer.h"
15 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 16 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
16 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" 17 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h"
17 18
18 class Profile; 19 class Profile;
19 20
20 namespace chromeos { 21 namespace chromeos {
21 22
23 namespace system {
24 class AutomaticRebootManager;
25 }
26
22 // This class enforces automatic restart on app and Chrome updates in app mode. 27 // This class enforces automatic restart on app and Chrome updates in app mode.
23 class KioskAppUpdateService : public BrowserContextKeyedService, 28 class KioskAppUpdateService : public BrowserContextKeyedService,
24 public extensions::UpdateObserver { 29 public extensions::UpdateObserver,
30 public system::AutomaticRebootManagerObserver {
25 public: 31 public:
26 explicit KioskAppUpdateService(Profile* profile); 32 KioskAppUpdateService(
33 Profile* profile,
34 system::AutomaticRebootManager* automatic_reboot_manager);
27 virtual ~KioskAppUpdateService(); 35 virtual ~KioskAppUpdateService();
28 36
29 void set_app_id(const std::string& app_id) { app_id_ = app_id; } 37 void set_app_id(const std::string& app_id) { app_id_ = app_id; }
30 std::string get_app_id() const { return app_id_; } 38 std::string get_app_id() const { return app_id_; }
31 39
32 private: 40 private:
33 void StartRestartTimer(); 41 friend class KioskAppUpdateServiceTest;
34 void ForceRestart(); 42
43 void StartAppUpdateRestartTimer();
44 void ForceAppUpdateRestart();
45
46 // BrowserContextKeyedService overrides:
47 virtual void Shutdown() OVERRIDE;
35 48
36 // extensions::UpdateObserver overrides: 49 // extensions::UpdateObserver overrides:
37 virtual void OnAppUpdateAvailable(const std::string& app_id) OVERRIDE; 50 virtual void OnAppUpdateAvailable(const std::string& app_id) OVERRIDE;
38 virtual void OnChromeUpdateAvailable() OVERRIDE {} 51 virtual void OnChromeUpdateAvailable() OVERRIDE {}
39 52
40 // BrowserContextKeyedService overrides: 53 // system::AutomaticRebootManagerObserver overrides:
41 virtual void Shutdown() OVERRIDE; 54 virtual void OnRebootScheduled(Reason reason) OVERRIDE;
55 virtual void WillDestroyAutomaticRebootManager() OVERRIDE;
42 56
43 private:
44 Profile* profile_; 57 Profile* profile_;
45 std::string app_id_; 58 std::string app_id_;
46 59
47 // After we detect an upgrade we start a one-short timer to force restart. 60 // After we detect an upgrade we start a one-short timer to force restart.
48 base::OneShotTimer<KioskAppUpdateService> restart_timer_; 61 base::OneShotTimer<KioskAppUpdateService> restart_timer_;
49 62
63 system::AutomaticRebootManager* automatic_reboot_manager_; // Not owned.
64
50 DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateService); 65 DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateService);
51 }; 66 };
52 67
53 // Singleton that owns all KioskAppUpdateServices and associates them with 68 // Singleton that owns all KioskAppUpdateServices and associates them with
54 // profiles. 69 // profiles.
55 class KioskAppUpdateServiceFactory : public BrowserContextKeyedServiceFactory { 70 class KioskAppUpdateServiceFactory : public BrowserContextKeyedServiceFactory {
56 public: 71 public:
57 // Returns the KioskAppUpdateService for |profile|, creating it if it is not 72 // Returns the KioskAppUpdateService for |profile|, creating it if it is not
58 // yet created. 73 // yet created.
59 static KioskAppUpdateService* GetForProfile(Profile* profile); 74 static KioskAppUpdateService* GetForProfile(Profile* profile);
60 75
61 // Returns the KioskAppUpdateServiceFactory instance. 76 // Returns the KioskAppUpdateServiceFactory instance.
62 static KioskAppUpdateServiceFactory* GetInstance(); 77 static KioskAppUpdateServiceFactory* GetInstance();
63 78
64 private: 79 private:
65 friend struct DefaultSingletonTraits<KioskAppUpdateServiceFactory>; 80 friend struct DefaultSingletonTraits<KioskAppUpdateServiceFactory>;
66 81
67 KioskAppUpdateServiceFactory(); 82 KioskAppUpdateServiceFactory();
68 virtual ~KioskAppUpdateServiceFactory(); 83 virtual ~KioskAppUpdateServiceFactory();
69 84
70 // BrowserContextKeyedServiceFactory overrides: 85 // BrowserContextKeyedServiceFactory overrides:
71 virtual BrowserContextKeyedService* BuildServiceInstanceFor( 86 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
72 content::BrowserContext* profile) const OVERRIDE; 87 content::BrowserContext* profile) const OVERRIDE;
73 }; 88 };
74 89
75 } // namespace chromeos 90 } // namespace chromeos
76 91
77 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_ 92 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_UPDATE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_platform_part_chromeos.cc ('k') | chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698