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/in_process_dynamic_service_runner.h" | 5 #include "shell/in_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/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // thread-local data and destructors to run on thread termination. | 23 // thread-local data and destructors to run on thread termination. |
24 if (thread_) { | 24 if (thread_) { |
25 DCHECK(thread_->HasBeenStarted()); | 25 DCHECK(thread_->HasBeenStarted()); |
26 DCHECK(!thread_->HasBeenJoined()); | 26 DCHECK(!thread_->HasBeenJoined()); |
27 thread_->Join(); | 27 thread_->Join(); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 void InProcessDynamicServiceRunner::Start( | 31 void InProcessDynamicServiceRunner::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(!service_handle_.is_valid()); | 37 DCHECK(!application_request_.is_pending()); |
38 service_handle_ = service_handle.Pass(); | 38 application_request_ = application_request.Pass(); |
39 | 39 |
40 DCHECK(app_completed_callback_runner_.is_null()); | 40 DCHECK(app_completed_callback_runner_.is_null()); |
41 app_completed_callback_runner_ = | 41 app_completed_callback_runner_ = |
42 base::Bind(&base::TaskRunner::PostTask, base::MessageLoopProxy::current(), | 42 base::Bind(&base::TaskRunner::PostTask, base::MessageLoopProxy::current(), |
43 FROM_HERE, app_completed_callback); | 43 FROM_HERE, app_completed_callback); |
44 | 44 |
45 DCHECK(!thread_); | 45 DCHECK(!thread_); |
46 thread_.reset(new base::DelegateSimpleThread(this, "app_thread")); | 46 thread_.reset(new base::DelegateSimpleThread(this, "app_thread")); |
47 thread_->Start(); | 47 thread_->Start(); |
48 } | 48 } |
49 | 49 |
50 void InProcessDynamicServiceRunner::Run() { | 50 void InProcessDynamicServiceRunner::Run() { |
51 DVLOG(2) << "Loading/running Mojo app in process from library: " | 51 DVLOG(2) << "Loading/running Mojo app in process from library: " |
52 << app_path_.value() | 52 << app_path_.value() |
53 << " thread id=" << base::PlatformThread::CurrentId(); | 53 << " thread id=" << base::PlatformThread::CurrentId(); |
54 | 54 |
55 app_library_.Reset(LoadAndRunService(app_path_, service_handle_.Pass())); | 55 app_library_.Reset(LoadAndRunService(app_path_, application_request_.Pass())); |
56 app_completed_callback_runner_.Run(); | 56 app_completed_callback_runner_.Run(); |
57 app_completed_callback_runner_.Reset(); | 57 app_completed_callback_runner_.Reset(); |
58 } | 58 } |
59 | 59 |
60 } // namespace shell | 60 } // namespace shell |
61 } // namespace mojo | 61 } // namespace mojo |
OLD | NEW |