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/out_of_process_dynamic_service_runner.h" | 5 #include "shell/out_of_process_dynamic_service_runner.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_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // TODO(vtl): Race condition: If |AppChildProcessHost::DidStart()| hasn't | 23 // TODO(vtl): Race condition: If |AppChildProcessHost::DidStart()| hasn't |
24 // been called yet, we shouldn't call |Join()| here. (Until |DidStart()|, we | 24 // been called yet, we shouldn't call |Join()| here. (Until |DidStart()|, we |
25 // may not have a child process to wait on.) Probably we should fix | 25 // may not have a child process to wait on.) Probably we should fix |
26 // |Join()|. | 26 // |Join()|. |
27 app_child_process_host_->Join(); | 27 app_child_process_host_->Join(); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 void OutOfProcessDynamicServiceRunner::Start( | 31 void OutOfProcessDynamicServiceRunner::Start( |
32 const base::FilePath& app_path, | 32 const base::FilePath& app_path, |
33 ScopedMessagePipeHandle service_handle, | 33 InterfaceRequest<Application> application_request, |
34 const base::Closure& app_completed_callback) { | 34 const base::Closure& app_completed_callback) { |
35 app_path_ = app_path; | 35 app_path_ = app_path; |
36 | 36 |
37 DCHECK(app_completed_callback_.is_null()); | 37 DCHECK(app_completed_callback_.is_null()); |
38 app_completed_callback_ = app_completed_callback; | 38 app_completed_callback_ = app_completed_callback; |
39 | 39 |
40 app_child_process_host_.reset(new AppChildProcessHost(context_, this)); | 40 app_child_process_host_.reset(new AppChildProcessHost(context_, this)); |
41 app_child_process_host_->Start(); | 41 app_child_process_host_->Start(); |
42 | 42 |
43 // TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe. | 43 // TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe. |
44 app_child_process_host_->controller()->StartApp( | 44 app_child_process_host_->controller()->StartApp(app_path.AsUTF8Unsafe(), |
45 app_path.AsUTF8Unsafe(), ScopedMessagePipeHandle(MessagePipeHandle( | 45 application_request.Pass()); |
46 service_handle.release().value()))); | |
47 } | 46 } |
48 | 47 |
49 void OutOfProcessDynamicServiceRunner::AppCompleted(int32_t result) { | 48 void OutOfProcessDynamicServiceRunner::AppCompleted(int32_t result) { |
50 DVLOG(2) << "OutOfProcessDynamicServiceRunner::AppCompleted(" << result | 49 DVLOG(2) << "OutOfProcessDynamicServiceRunner::AppCompleted(" << result |
51 << ")"; | 50 << ")"; |
52 | 51 |
53 app_child_process_host_.reset(); | 52 app_child_process_host_.reset(); |
54 // This object may be deleted by this callback. | 53 // This object may be deleted by this callback. |
55 base::Closure app_completed_callback = app_completed_callback_; | 54 base::Closure app_completed_callback = app_completed_callback_; |
56 app_completed_callback_.Reset(); | 55 app_completed_callback_.Reset(); |
57 app_completed_callback.Run(); | 56 app_completed_callback.Run(); |
58 } | 57 } |
59 | 58 |
60 } // namespace shell | 59 } // namespace shell |
61 } // namespace mojo | 60 } // namespace mojo |
OLD | NEW |