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

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

Issue 727363002: Fire notifications when reboot is requested, not scheduled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@managed_cros
Patch Set: Created 6 years, 1 month 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
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 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/app_mode/app_mode_utils.h" 8 #include "chrome/browser/app_mode/app_mode_utils.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/browser_process_platform_part_chromeos.h" 10 #include "chrome/browser/browser_process_platform_part_chromeos.h"
(...skipping 26 matching lines...) Expand all
37 ExtensionService* service = 37 ExtensionService* service =
38 extensions::ExtensionSystem::Get(profile_)->extension_service(); 38 extensions::ExtensionSystem::Get(profile_)->extension_service();
39 if (service) 39 if (service)
40 service->AddUpdateObserver(this); 40 service->AddUpdateObserver(this);
41 41
42 if (automatic_reboot_manager_) 42 if (automatic_reboot_manager_)
43 automatic_reboot_manager_->AddObserver(this); 43 automatic_reboot_manager_->AddObserver(this);
44 44
45 if (KioskAppManager::Get()) 45 if (KioskAppManager::Get())
46 KioskAppManager::Get()->AddObserver(this); 46 KioskAppManager::Get()->AddObserver(this);
47
48 if (automatic_reboot_manager_->reboot_requested())
49 OnRebootRequested(automatic_reboot_manager_->reboot_reason());
xiyuan 2014/11/17 18:42:52 Think we should make KioskAppUpdateService::set_ap
bartfab (slow) 2014/11/17 19:58:24 Done.
47 } 50 }
48 51
49 KioskAppUpdateService::~KioskAppUpdateService() { 52 KioskAppUpdateService::~KioskAppUpdateService() {
50 } 53 }
51 54
52 void KioskAppUpdateService::StartAppUpdateRestartTimer() { 55 void KioskAppUpdateService::StartAppUpdateRestartTimer() {
53 if (restart_timer_.IsRunning()) 56 if (restart_timer_.IsRunning())
54 return; 57 return;
55 58
56 // Setup timer to force restart once the wait period expires. 59 // Setup timer to force restart once the wait period expires.
(...skipping 29 matching lines...) Expand all
86 app_id_, profile_, extension); 89 app_id_, profile_, extension);
87 90
88 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( 91 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent(
89 profile_, 92 profile_,
90 app_id_, 93 app_id_,
91 extensions::core_api::runtime::OnRestartRequired::REASON_APP_UPDATE); 94 extensions::core_api::runtime::OnRestartRequired::REASON_APP_UPDATE);
92 95
93 StartAppUpdateRestartTimer(); 96 StartAppUpdateRestartTimer();
94 } 97 }
95 98
96 void KioskAppUpdateService::OnRebootScheduled(Reason reason) { 99 void KioskAppUpdateService::OnRebootRequested(Reason reason) {
97 extensions::core_api::runtime::OnRestartRequired::Reason restart_reason = 100 extensions::core_api::runtime::OnRestartRequired::Reason restart_reason =
98 extensions::core_api::runtime::OnRestartRequired::REASON_NONE; 101 extensions::core_api::runtime::OnRestartRequired::REASON_NONE;
99 switch (reason) { 102 switch (reason) {
100 case REBOOT_REASON_OS_UPDATE: 103 case REBOOT_REASON_OS_UPDATE:
101 restart_reason = 104 restart_reason =
102 extensions::core_api::runtime::OnRestartRequired::REASON_OS_UPDATE; 105 extensions::core_api::runtime::OnRestartRequired::REASON_OS_UPDATE;
103 break; 106 break;
104 case REBOOT_REASON_PERIODIC: 107 case REBOOT_REASON_PERIODIC:
105 restart_reason = 108 restart_reason =
106 extensions::core_api::runtime::OnRestartRequired::REASON_PERIODIC; 109 extensions::core_api::runtime::OnRestartRequired::REASON_PERIODIC;
107 break; 110 break;
108 default: 111 default:
109 NOTREACHED() << "Unknown reboot reason=" << reason; 112 NOTREACHED() << "Unknown reboot reason=" << reason;
110 return; 113 return;
111 } 114 }
112 115
113 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( 116 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent(
114 profile_, app_id_, restart_reason); 117 profile_, app_id_, restart_reason);
115 } 118 }
116 119
117 void KioskAppUpdateService::WillDestroyAutomaticRebootManager() { 120 void KioskAppUpdateService::WillDestroyAutomaticRebootManager() {
118 automatic_reboot_manager_->RemoveObserver(this);
xiyuan 2014/11/17 18:42:52 Why do we need to remove this?
bartfab (slow) 2014/11/17 19:58:24 We want to make sure that all observers are notifi
xiyuan 2014/11/17 20:08:03 Thanks for the clarification. I am slightly prefer
bartfab (slow) 2014/11/18 11:04:46 I changed back to the empty check. I slightly pref
119 automatic_reboot_manager_ = NULL; 121 automatic_reboot_manager_ = NULL;
120 } 122 }
121 123
122 void KioskAppUpdateService::OnKioskAppCacheUpdated(const std::string& app_id) { 124 void KioskAppUpdateService::OnKioskAppCacheUpdated(const std::string& app_id) {
123 if (app_id != app_id_) 125 if (app_id != app_id_)
124 return; 126 return;
125 127
126 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent( 128 extensions::RuntimeEventRouter::DispatchOnRestartRequiredEvent(
127 profile_, 129 profile_,
128 app_id_, 130 app_id_,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 162 }
161 163
162 KeyedService* KioskAppUpdateServiceFactory::BuildServiceInstanceFor( 164 KeyedService* KioskAppUpdateServiceFactory::BuildServiceInstanceFor(
163 content::BrowserContext* context) const { 165 content::BrowserContext* context) const {
164 return new KioskAppUpdateService( 166 return new KioskAppUpdateService(
165 Profile::FromBrowserContext(context), 167 Profile::FromBrowserContext(context),
166 g_browser_process->platform_part()->automatic_reboot_manager()); 168 g_browser_process->platform_part()->automatic_reboot_manager());
167 } 169 }
168 170
169 } // namespace chromeos 171 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698