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" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 thread_.reset(new MojoThread(std::move(init_params))); | 144 thread_.reset(new MojoThread(std::move(init_params))); |
145 thread_->Start(); | 145 thread_->Start(); |
146 } | 146 } |
147 | 147 |
148 mojom::ShellClientRequest BackgroundShell::CreateShellClientRequest( | 148 mojom::ShellClientRequest BackgroundShell::CreateShellClientRequest( |
149 const std::string& name) { | 149 const std::string& name) { |
150 std::unique_ptr<ConnectParams> params(new ConnectParams); | 150 std::unique_ptr<ConnectParams> params(new ConnectParams); |
151 params->set_source(CreateShellIdentity()); | 151 params->set_source(CreateShellIdentity()); |
152 params->set_target(Identity(name, mojom::kRootUserID)); | 152 params->set_target(Identity(name, mojom::kRootUserID)); |
153 mojom::ShellClientRequest request; | 153 mojom::ShellClientRequest request; |
154 base::WaitableEvent signal(true, false); | 154 base::WaitableEvent signal(base::WaitableEvent::ResetPolicy::MANUAL, |
| 155 base::WaitableEvent::InitialState::NOT_SIGNALED); |
155 thread_->message_loop()->task_runner()->PostTask( | 156 thread_->message_loop()->task_runner()->PostTask( |
156 FROM_HERE, base::Bind(&MojoThread::CreateShellClientRequest, | 157 FROM_HERE, base::Bind(&MojoThread::CreateShellClientRequest, |
157 base::Unretained(thread_.get()), &signal, name, | 158 base::Unretained(thread_.get()), &signal, name, |
158 &request)); | 159 &request)); |
159 signal.Wait(); | 160 signal.Wait(); |
160 thread_->message_loop()->task_runner()->PostTask( | 161 thread_->message_loop()->task_runner()->PostTask( |
161 FROM_HERE, base::Bind(&MojoThread::Connect, | 162 FROM_HERE, base::Bind(&MojoThread::Connect, |
162 base::Unretained(thread_.get()), | 163 base::Unretained(thread_.get()), |
163 base::Passed(¶ms))); | 164 base::Passed(¶ms))); |
164 return request; | 165 return request; |
165 } | 166 } |
166 | 167 |
167 void BackgroundShell::ExecuteOnShellThread( | 168 void BackgroundShell::ExecuteOnShellThread( |
168 const ShellThreadCallback& callback) { | 169 const ShellThreadCallback& callback) { |
169 thread_->message_loop()->task_runner()->PostTask( | 170 thread_->message_loop()->task_runner()->PostTask( |
170 FROM_HERE, base::Bind(&MojoThread::RunShellCallback, | 171 FROM_HERE, base::Bind(&MojoThread::RunShellCallback, |
171 base::Unretained(thread_.get()), callback)); | 172 base::Unretained(thread_.get()), callback)); |
172 } | 173 } |
173 | 174 |
174 } // namespace shell | 175 } // namespace shell |
OLD | NEW |