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

Side by Side Diff: shell/child_main.cc

Issue 1055463004: Replace ChildProcess/AppChildProcess with a simple ChildMain(). (Closed) Base URL: https://github.com/domokit/mojo.git@simplify_child_6-x-simplify_child_5
Patch Set: rebased Created 5 years, 8 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
« no previous file with comments | « shell/child_main.h ('k') | shell/child_process.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "shell/app_child_process.h" 5 #include "shell/child_main.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/command_line.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
20 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
21 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
22 #include "mojo/common/message_pump_mojo.h" 23 #include "mojo/common/message_pump_mojo.h"
23 #include "mojo/edk/embedder/embedder.h" 24 #include "mojo/edk/embedder/embedder.h"
25 #include "mojo/edk/embedder/platform_channel_pair.h"
24 #include "mojo/edk/embedder/process_delegate.h" 26 #include "mojo/edk/embedder/process_delegate.h"
27 #include "mojo/edk/embedder/scoped_platform_handle.h"
25 #include "mojo/edk/embedder/simple_platform_support.h" 28 #include "mojo/edk/embedder/simple_platform_support.h"
26 #include "mojo/public/cpp/system/core.h" 29 #include "mojo/public/cpp/system/core.h"
27 #include "shell/child_controller.mojom.h" 30 #include "shell/child_controller.mojom.h"
28 #include "shell/native_application_support.h" 31 #include "shell/native_application_support.h"
29 32
30 namespace mojo { 33 namespace mojo {
31 namespace shell { 34 namespace shell {
32 35
33 namespace { 36 namespace {
34 37
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 StartAppCallback on_app_complete_; 269 StartAppCallback on_app_complete_;
267 270
268 embedder::ChannelInfo* channel_info_; 271 embedder::ChannelInfo* channel_info_;
269 Binding<ChildController> binding_; 272 Binding<ChildController> binding_;
270 273
271 DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl); 274 DISALLOW_COPY_AND_ASSIGN(ChildControllerImpl);
272 }; 275 };
273 276
274 } // namespace 277 } // namespace
275 278
276 // AppChildProcess ------------------------------------------------------------- 279 // ChildMain -------------------------------------------------------------------
277 280
278 AppChildProcess::AppChildProcess() { 281 int ChildMain() {
279 } 282 DVLOG(2) << "ChildMain()";
280
281 AppChildProcess::~AppChildProcess() {
282 }
283
284 void AppChildProcess::Main() {
285 DVLOG(2) << "AppChildProcess::Main()";
286 283
287 DCHECK(!base::MessageLoop::current()); 284 DCHECK(!base::MessageLoop::current());
288 285
286 embedder::ScopedPlatformHandle platform_channel =
287 embedder::PlatformChannelPair::PassClientHandleFromParentProcess(
288 *base::CommandLine::ForCurrentProcess());
289 CHECK(platform_channel.is_valid());
290
289 AppContext app_context; 291 AppContext app_context;
290 app_context.Init(); 292 app_context.Init();
291 293
292 Blocker blocker; 294 Blocker blocker;
293 app_context.controller_runner()->PostTask( 295 app_context.controller_runner()->PostTask(
294 FROM_HERE, 296 FROM_HERE,
295 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context), 297 base::Bind(&ChildControllerImpl::Init, base::Unretained(&app_context),
296 base::Passed(platform_channel()), blocker.GetUnblocker())); 298 base::Passed(&platform_channel), blocker.GetUnblocker()));
297 // This will block, then run whatever the controller wants. 299 // This will block, then run whatever the controller wants.
298 blocker.Block(); 300 blocker.Block();
299 301
300 app_context.Shutdown(); 302 app_context.Shutdown();
303
304 return 0;
301 } 305 }
302 306
303 } // namespace shell 307 } // namespace shell
304 } // namespace mojo 308 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/child_main.h ('k') | shell/child_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698