Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: mojo/shell/runner/host/child_process.cc

Issue 1679573002: Move shell interfaces into the shell.mojom namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "mojo/shell/runner/host/child_process.h" 5 #include "mojo/shell/runner/host/child_process.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 scoped_ptr<ChildControllerImpl> controller_; 187 scoped_ptr<ChildControllerImpl> controller_;
188 188
189 // Used to unblock the main thread on shutdown. 189 // Used to unblock the main thread on shutdown.
190 Blocker::Unblocker shutdown_unblocker_; 190 Blocker::Unblocker shutdown_unblocker_;
191 191
192 DISALLOW_COPY_AND_ASSIGN(AppContext); 192 DISALLOW_COPY_AND_ASSIGN(AppContext);
193 }; 193 };
194 194
195 // ChildControllerImpl ------------------------------------------------------ 195 // ChildControllerImpl ------------------------------------------------------
196 196
197 class ChildControllerImpl : public ChildController { 197 class ChildControllerImpl : public mojom::ChildController {
198 public: 198 public:
199 ~ChildControllerImpl() override { 199 ~ChildControllerImpl() override {
200 DCHECK(thread_checker_.CalledOnValidThread()); 200 DCHECK(thread_checker_.CalledOnValidThread());
201 201
202 // TODO(vtl): Pass in the result from |MainMain()|. 202 // TODO(vtl): Pass in the result from |MainMain()|.
203 on_app_complete_.Run(MOJO_RESULT_UNIMPLEMENTED); 203 on_app_complete_.Run(MOJO_RESULT_UNIMPLEMENTED);
204 } 204 }
205 205
206 // To be executed on the controller thread. Creates the |ChildController|, 206 // To be executed on the controller thread. Creates the |ChildController|,
207 // etc. 207 // etc.
(...skipping 20 matching lines...) Expand all
228 } 228 }
229 229
230 void OnConnectionError() { 230 void OnConnectionError() {
231 // A connection error means the connection to the shell is lost. This is not 231 // A connection error means the connection to the shell is lost. This is not
232 // recoverable. 232 // recoverable.
233 LOG(ERROR) << "Connection error to the shell."; 233 LOG(ERROR) << "Connection error to the shell.";
234 _exit(1); 234 _exit(1);
235 } 235 }
236 236
237 // |ChildController| methods: 237 // |ChildController| methods:
238 void StartApp(InterfaceRequest<Application> application_request, 238 void StartApp(InterfaceRequest<mojom::Application> application_request,
239 const StartAppCallback& on_app_complete) override { 239 const StartAppCallback& on_app_complete) override {
240 DCHECK(thread_checker_.CalledOnValidThread()); 240 DCHECK(thread_checker_.CalledOnValidThread());
241 241
242 on_app_complete_ = on_app_complete; 242 on_app_complete_ = on_app_complete;
243 unblocker_.Unblock(base::Bind(&ChildControllerImpl::StartAppOnMainThread, 243 unblocker_.Unblock(base::Bind(&ChildControllerImpl::StartAppOnMainThread,
244 base::Unretained(app_library_), 244 base::Unretained(app_library_),
245 base::Passed(&application_request))); 245 base::Passed(&application_request)));
246 } 246 }
247 247
248 void ExitNow(int32_t exit_code) override { 248 void ExitNow(int32_t exit_code) override {
249 DVLOG(2) << "ChildControllerImpl::ExitNow(" << exit_code << ")"; 249 DVLOG(2) << "ChildControllerImpl::ExitNow(" << exit_code << ")";
250 _exit(exit_code); 250 _exit(exit_code);
251 } 251 }
252 252
253 private: 253 private:
254 ChildControllerImpl(AppContext* app_context, 254 ChildControllerImpl(AppContext* app_context,
255 base::NativeLibrary app_library, 255 base::NativeLibrary app_library,
256 const Blocker::Unblocker& unblocker) 256 const Blocker::Unblocker& unblocker)
257 : app_library_(app_library), unblocker_(unblocker), binding_(this) {} 257 : app_library_(app_library), unblocker_(unblocker), binding_(this) {}
258 258
259 static void StartAppOnMainThread( 259 static void StartAppOnMainThread(
260 base::NativeLibrary app_library, 260 base::NativeLibrary app_library,
261 InterfaceRequest<Application> application_request) { 261 InterfaceRequest<mojom::Application> application_request) {
262 if (!RunNativeApplication(app_library, std::move(application_request))) { 262 if (!RunNativeApplication(app_library, std::move(application_request))) {
263 LOG(ERROR) << "Failure to RunNativeApplication()"; 263 LOG(ERROR) << "Failure to RunNativeApplication()";
264 } 264 }
265 } 265 }
266 266
267 base::ThreadChecker thread_checker_; 267 base::ThreadChecker thread_checker_;
268 base::NativeLibrary app_library_; 268 base::NativeLibrary app_library_;
269 Blocker::Unblocker unblocker_; 269 Blocker::Unblocker unblocker_;
270 StartAppCallback on_app_complete_; 270 StartAppCallback on_app_complete_;
271 271
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // This will block, then run whatever the controller wants. 383 // This will block, then run whatever the controller wants.
384 blocker.Block(); 384 blocker.Block();
385 385
386 app_context.Shutdown(); 386 app_context.Shutdown();
387 387
388 return 0; 388 return 0;
389 } 389 }
390 390
391 } // namespace shell 391 } // namespace shell
392 } // namespace mojo 392 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/runner/child/test_native_main.cc ('k') | mojo/shell/runner/host/child_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698