OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/shell/background/background_shell.h" | 5 #include "services/shell/background/background_shell.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_pump_default.h" | 12 #include "base/message_loop/message_pump_default.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/run_loop.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
16 #include "base/threading/simple_thread.h" | 17 #include "base/threading/simple_thread.h" |
17 #include "services/catalog/store.h" | 18 #include "services/catalog/store.h" |
18 #include "services/shell/connect_params.h" | 19 #include "services/shell/connect_params.h" |
19 #include "services/shell/public/cpp/service.h" | 20 #include "services/shell/public/cpp/service.h" |
20 #include "services/shell/public/cpp/service_context.h" | 21 #include "services/shell/public/cpp/service_context.h" |
21 #include "services/shell/service_manager.h" | 22 #include "services/shell/service_manager.h" |
22 #include "services/shell/standalone/context.h" | 23 #include "services/shell/standalone/context.h" |
23 | 24 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 104 } |
104 if (context_init_params->init_edk) | 105 if (context_init_params->init_edk) |
105 Context::EnsureEmbedderIsInitialized(); | 106 Context::EnsureEmbedderIsInitialized(); |
106 | 107 |
107 message_loop_->BindToCurrentThread(); | 108 message_loop_->BindToCurrentThread(); |
108 | 109 |
109 std::unique_ptr<Context> context(new Context); | 110 std::unique_ptr<Context> context(new Context); |
110 context_ = context.get(); | 111 context_ = context.get(); |
111 context_->Init(std::move(context_init_params)); | 112 context_->Init(std::move(context_init_params)); |
112 | 113 |
113 message_loop_->Run(); | 114 base::RunLoop().Run(); |
114 | 115 |
115 // Has to happen after run, but while messageloop still valid. | 116 // Has to happen after run, but while messageloop still valid. |
116 context_->Shutdown(); | 117 context_->Shutdown(); |
117 | 118 |
118 // Context has to be destroyed after the MessageLoop has been destroyed. | 119 // Context has to be destroyed after the MessageLoop has been destroyed. |
119 message_loop.reset(); | 120 message_loop.reset(); |
120 context_ = nullptr; | 121 context_ = nullptr; |
121 } | 122 } |
122 | 123 |
123 private: | 124 private: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 169 } |
169 | 170 |
170 void BackgroundShell::ExecuteOnServiceManagerThread( | 171 void BackgroundShell::ExecuteOnServiceManagerThread( |
171 const ServiceManagerThreadCallback& callback) { | 172 const ServiceManagerThreadCallback& callback) { |
172 thread_->message_loop()->task_runner()->PostTask( | 173 thread_->message_loop()->task_runner()->PostTask( |
173 FROM_HERE, base::Bind(&MojoThread::RunServiceManagerCallback, | 174 FROM_HERE, base::Bind(&MojoThread::RunServiceManagerCallback, |
174 base::Unretained(thread_.get()), callback)); | 175 base::Unretained(thread_.get()), callback)); |
175 } | 176 } |
176 | 177 |
177 } // namespace shell | 178 } // namespace shell |
OLD | NEW |