| 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 bool clean_app_path, |
| 33 ScopedMessagePipeHandle service_handle, | 34 ScopedMessagePipeHandle service_handle, |
| 34 const base::Closure& app_completed_callback) { | 35 const base::Closure& app_completed_callback) { |
| 35 app_path_ = app_path; | 36 app_path_ = app_path; |
| 36 | 37 |
| 37 DCHECK(app_completed_callback_.is_null()); | 38 DCHECK(app_completed_callback_.is_null()); |
| 38 app_completed_callback_ = app_completed_callback; | 39 app_completed_callback_ = app_completed_callback; |
| 39 | 40 |
| 40 app_child_process_host_.reset(new AppChildProcessHost(context_, this)); | 41 app_child_process_host_.reset(new AppChildProcessHost(context_, this)); |
| 41 app_child_process_host_->Start(); | 42 app_child_process_host_->Start(); |
| 42 | 43 |
| 43 // TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe. | 44 // TODO(vtl): |app_path.AsUTF8Unsafe()| is unsafe. |
| 44 app_child_process_host_->controller()->StartApp( | 45 app_child_process_host_->controller()->StartApp( |
| 45 app_path.AsUTF8Unsafe(), ScopedMessagePipeHandle(MessagePipeHandle( | 46 app_path.AsUTF8Unsafe(), clean_app_path, |
| 46 service_handle.release().value()))); | 47 ScopedMessagePipeHandle( |
| 48 MessagePipeHandle(service_handle.release().value()))); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void OutOfProcessDynamicServiceRunner::AppCompleted(int32_t result) { | 51 void OutOfProcessDynamicServiceRunner::AppCompleted(int32_t result) { |
| 50 DVLOG(2) << "OutOfProcessDynamicServiceRunner::AppCompleted(" << result | 52 DVLOG(2) << "OutOfProcessDynamicServiceRunner::AppCompleted(" << result |
| 51 << ")"; | 53 << ")"; |
| 52 | 54 |
| 53 app_child_process_host_.reset(); | 55 app_child_process_host_.reset(); |
| 54 // This object may be deleted by this callback. | 56 // This object may be deleted by this callback. |
| 55 base::Closure app_completed_callback = app_completed_callback_; | 57 base::Closure app_completed_callback = app_completed_callback_; |
| 56 app_completed_callback_.Reset(); | 58 app_completed_callback_.Reset(); |
| 57 app_completed_callback.Run(); | 59 app_completed_callback.Run(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 } // namespace shell | 62 } // namespace shell |
| 61 } // namespace mojo | 63 } // namespace mojo |
| OLD | NEW |