OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "shell/app_child_process.h" | 5 #include "shell/app_child_process.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 app_context->set_controller(impl.Pass()); | 178 app_context->set_controller(impl.Pass()); |
179 } | 179 } |
180 | 180 |
181 void OnConnectionError() override { | 181 void OnConnectionError() override { |
182 // TODO(darin): How should we handle a connection error here? | 182 // TODO(darin): How should we handle a connection error here? |
183 } | 183 } |
184 | 184 |
185 // |AppChildController| methods: | 185 // |AppChildController| methods: |
186 void StartApp(const String& app_path, | 186 void StartApp(const String& app_path, |
187 ScopedMessagePipeHandle service) override { | 187 InterfaceRequest<Application> application_request) override { |
188 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; | 188 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; |
189 DCHECK(thread_checker_.CalledOnValidThread()); | 189 DCHECK(thread_checker_.CalledOnValidThread()); |
190 | 190 |
191 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, | 191 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, |
192 base::FilePath::FromUTF8Unsafe(app_path), | 192 base::FilePath::FromUTF8Unsafe(app_path), |
193 base::Passed(&service))); | 193 base::Passed(&application_request))); |
194 } | 194 } |
195 | 195 |
196 private: | 196 private: |
197 AppChildControllerImpl(AppContext* app_context, | 197 AppChildControllerImpl(AppContext* app_context, |
198 const Blocker::Unblocker& unblocker) | 198 const Blocker::Unblocker& unblocker) |
199 : app_context_(app_context), unblocker_(unblocker), channel_info_(NULL) {} | 199 : app_context_(app_context), unblocker_(unblocker), channel_info_(NULL) {} |
200 | 200 |
201 // Callback for |embedder::CreateChannel()|. | 201 // Callback for |embedder::CreateChannel()|. |
202 void DidCreateChannel(embedder::ChannelInfo* channel_info) { | 202 void DidCreateChannel(embedder::ChannelInfo* channel_info) { |
203 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; | 203 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; |
204 DCHECK(thread_checker_.CalledOnValidThread()); | 204 DCHECK(thread_checker_.CalledOnValidThread()); |
205 channel_info_ = channel_info; | 205 channel_info_ = channel_info; |
206 } | 206 } |
207 | 207 |
208 static void StartAppOnMainThread(const base::FilePath& app_path, | 208 static void StartAppOnMainThread( |
209 ScopedMessagePipeHandle service) { | 209 const base::FilePath& app_path, |
| 210 InterfaceRequest<Application> application_request) { |
210 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc. | 211 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc. |
211 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() | 212 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() |
212 << " out of process"; | 213 << " out of process"; |
213 | 214 |
214 // We intentionally don't unload the native library as its lifetime is the | 215 // We intentionally don't unload the native library as its lifetime is the |
215 // same as that of the process. | 216 // same as that of the process. |
216 DynamicServiceRunner::LoadAndRunService(app_path, service.Pass()); | 217 DynamicServiceRunner::LoadAndRunService(app_path, |
| 218 application_request.Pass()); |
217 } | 219 } |
218 | 220 |
219 base::ThreadChecker thread_checker_; | 221 base::ThreadChecker thread_checker_; |
220 AppContext* const app_context_; | 222 AppContext* const app_context_; |
221 Blocker::Unblocker unblocker_; | 223 Blocker::Unblocker unblocker_; |
222 | 224 |
223 embedder::ChannelInfo* channel_info_; | 225 embedder::ChannelInfo* channel_info_; |
224 | 226 |
225 DISALLOW_COPY_AND_ASSIGN(AppChildControllerImpl); | 227 DISALLOW_COPY_AND_ASSIGN(AppChildControllerImpl); |
226 }; | 228 }; |
(...skipping 20 matching lines...) Expand all Loading... |
247 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), | 249 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), |
248 base::Passed(platform_channel()), blocker.GetUnblocker())); | 250 base::Passed(platform_channel()), blocker.GetUnblocker())); |
249 // This will block, then run whatever the controller wants. | 251 // This will block, then run whatever the controller wants. |
250 blocker.Block(); | 252 blocker.Block(); |
251 | 253 |
252 app_context.Shutdown(); | 254 app_context.Shutdown(); |
253 } | 255 } |
254 | 256 |
255 } // namespace shell | 257 } // namespace shell |
256 } // namespace mojo | 258 } // namespace mojo |
OLD | NEW |