| OLD | NEW |
| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/message_loop/message_loop_proxy.h" | |
| 21 #include "base/prefs/pref_service.h" | 20 #include "base/prefs/pref_service.h" |
| 22 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 23 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 24 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/test/scoped_path_override.h" | 24 #include "base/test/scoped_path_override.h" |
| 25 #include "base/thread_task_runner_handle.h" |
| 26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
| 27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 28 #include "chrome/browser/apps/app_browsertest_util.h" | 28 #include "chrome/browser/apps/app_browsertest_util.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/browser_process_platform_part.h" | 30 #include "chrome/browser/browser_process_platform_part.h" |
| 31 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" | 31 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" |
| 32 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h" | 32 #include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // Wait for the |automatic_reboot_manager_| to finish initializing. | 97 // Wait for the |automatic_reboot_manager_| to finish initializing. |
| 98 base::RunLoop run_loop; | 98 base::RunLoop run_loop; |
| 99 base::SequencedWorkerPool* worker_pool = | 99 base::SequencedWorkerPool* worker_pool = |
| 100 content::BrowserThread::GetBlockingPool(); | 100 content::BrowserThread::GetBlockingPool(); |
| 101 // Ensure that the initialization task the |automatic_reboot_manager_| posts | 101 // Ensure that the initialization task the |automatic_reboot_manager_| posts |
| 102 // to the blocking pool has finished by posting another task with the same | 102 // to the blocking pool has finished by posting another task with the same |
| 103 // |SequenceToken| and waiting for it to finish. | 103 // |SequenceToken| and waiting for it to finish. |
| 104 worker_pool->PostSequencedWorkerTask( | 104 worker_pool->PostSequencedWorkerTask( |
| 105 worker_pool->GetNamedSequenceToken("automatic-reboot-manager"), | 105 worker_pool->GetNamedSequenceToken("automatic-reboot-manager"), |
| 106 FROM_HERE, | 106 FROM_HERE, base::Bind(&RunCallback, base::ThreadTaskRunnerHandle::Get(), |
| 107 base::Bind(&RunCallback, | 107 run_loop.QuitClosure())); |
| 108 base::MessageLoopProxy::current(), | |
| 109 run_loop.QuitClosure())); | |
| 110 run_loop.Run(); | 108 run_loop.Run(); |
| 111 // Ensure that the |automatic_reboot_manager_| has had a chance to fully | 109 // Ensure that the |automatic_reboot_manager_| has had a chance to fully |
| 112 // process the result of the task posted to the blocking pool. | 110 // process the result of the task posted to the blocking pool. |
| 113 base::RunLoop().RunUntilIdle(); | 111 base::RunLoop().RunUntilIdle(); |
| 114 | 112 |
| 115 automatic_reboot_manager_->AddObserver(this); | 113 automatic_reboot_manager_->AddObserver(this); |
| 116 } | 114 } |
| 117 | 115 |
| 118 // system::AutomaticRebootManagerObserver: | 116 // system::AutomaticRebootManagerObserver: |
| 119 void OnRebootRequested( | 117 void OnRebootRequested( |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // was requested before Chrome was started. | 208 // was requested before Chrome was started. |
| 211 IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, StartAfterPeriodic) { | 209 IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, StartAfterPeriodic) { |
| 212 RequestPeriodicReboot(); | 210 RequestPeriodicReboot(); |
| 213 | 211 |
| 214 ExtensionTestMessageListener listener("periodic", false); | 212 ExtensionTestMessageListener listener("periodic", false); |
| 215 CreateKioskAppUpdateService(); | 213 CreateKioskAppUpdateService(); |
| 216 listener.WaitUntilSatisfied(); | 214 listener.WaitUntilSatisfied(); |
| 217 } | 215 } |
| 218 | 216 |
| 219 } // namespace chromeos | 217 } // namespace chromeos |
| OLD | NEW |