| 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 bool clean_app_path, |
| 187 ScopedMessagePipeHandle service) override { | 188 ScopedMessagePipeHandle service) override { |
| 188 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; | 189 DVLOG(2) << "AppChildControllerImpl::StartApp(" << app_path << ", ...)"; |
| 189 DCHECK(thread_checker_.CalledOnValidThread()); | 190 DCHECK(thread_checker_.CalledOnValidThread()); |
| 190 | 191 |
| 191 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, | 192 unblocker_.Unblock(base::Bind(&AppChildControllerImpl::StartAppOnMainThread, |
| 192 base::FilePath::FromUTF8Unsafe(app_path), | 193 base::FilePath::FromUTF8Unsafe(app_path), |
| 193 base::Passed(&service))); | 194 clean_app_path, base::Passed(&service))); |
| 194 } | 195 } |
| 195 | 196 |
| 196 private: | 197 private: |
| 197 AppChildControllerImpl(AppContext* app_context, | 198 AppChildControllerImpl(AppContext* app_context, |
| 198 const Blocker::Unblocker& unblocker) | 199 const Blocker::Unblocker& unblocker) |
| 199 : app_context_(app_context), unblocker_(unblocker), channel_info_(NULL) {} | 200 : app_context_(app_context), unblocker_(unblocker), channel_info_(NULL) {} |
| 200 | 201 |
| 201 // Callback for |embedder::CreateChannel()|. | 202 // Callback for |embedder::CreateChannel()|. |
| 202 void DidCreateChannel(embedder::ChannelInfo* channel_info) { | 203 void DidCreateChannel(embedder::ChannelInfo* channel_info) { |
| 203 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; | 204 DVLOG(2) << "AppChildControllerImpl::DidCreateChannel()"; |
| 204 DCHECK(thread_checker_.CalledOnValidThread()); | 205 DCHECK(thread_checker_.CalledOnValidThread()); |
| 205 channel_info_ = channel_info; | 206 channel_info_ = channel_info; |
| 206 } | 207 } |
| 207 | 208 |
| 208 static void StartAppOnMainThread(const base::FilePath& app_path, | 209 static void StartAppOnMainThread(const base::FilePath& app_path, |
| 210 bool clean_app_path, |
| 209 ScopedMessagePipeHandle service) { | 211 ScopedMessagePipeHandle service) { |
| 210 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc. | 212 // TODO(vtl): This is copied from in_process_dynamic_service_runner.cc. |
| 211 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() | 213 DVLOG(2) << "Loading/running Mojo app from " << app_path.value() |
| 212 << " out of process"; | 214 << " out of process"; |
| 213 | 215 |
| 214 // We intentionally don't unload the native library as its lifetime is the | 216 // We intentionally don't unload the native library as its lifetime is the |
| 215 // same as that of the process. | 217 // same as that of the process. |
| 216 DynamicServiceRunner::LoadAndRunService(app_path, service.Pass()); | 218 DynamicServiceRunner::LoadAndRunService(app_path, clean_app_path, |
| 219 service.Pass()); |
| 217 } | 220 } |
| 218 | 221 |
| 219 base::ThreadChecker thread_checker_; | 222 base::ThreadChecker thread_checker_; |
| 220 AppContext* const app_context_; | 223 AppContext* const app_context_; |
| 221 Blocker::Unblocker unblocker_; | 224 Blocker::Unblocker unblocker_; |
| 222 | 225 |
| 223 embedder::ChannelInfo* channel_info_; | 226 embedder::ChannelInfo* channel_info_; |
| 224 | 227 |
| 225 DISALLOW_COPY_AND_ASSIGN(AppChildControllerImpl); | 228 DISALLOW_COPY_AND_ASSIGN(AppChildControllerImpl); |
| 226 }; | 229 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 247 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), | 250 base::Bind(&AppChildControllerImpl::Init, base::Unretained(&app_context), |
| 248 base::Passed(platform_channel()), blocker.GetUnblocker())); | 251 base::Passed(platform_channel()), blocker.GetUnblocker())); |
| 249 // This will block, then run whatever the controller wants. | 252 // This will block, then run whatever the controller wants. |
| 250 blocker.Block(); | 253 blocker.Block(); |
| 251 | 254 |
| 252 app_context.Shutdown(); | 255 app_context.Shutdown(); |
| 253 } | 256 } |
| 254 | 257 |
| 255 } // namespace shell | 258 } // namespace shell |
| 256 } // namespace mojo | 259 } // namespace mojo |
| OLD | NEW |