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

Side by Side Diff: shell/child_process_host.h

Issue 1219683015: Convert //shell/... to use set_connection_error_handler() instead of set_error_handler(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 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.cc ('k') | shell/child_process_host.cc » ('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 #ifndef SHELL_CHILD_PROCESS_HOST_H_ 5 #ifndef SHELL_CHILD_PROCESS_HOST_H_
6 #define SHELL_CHILD_PROCESS_HOST_H_ 6 #define SHELL_CHILD_PROCESS_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/process/process.h" 14 #include "base/process/process.h"
15 #include "mojo/edk/embedder/channel_info_forward.h" 15 #include "mojo/edk/embedder/channel_info_forward.h"
16 #include "mojo/edk/embedder/scoped_platform_handle.h" 16 #include "mojo/edk/embedder/scoped_platform_handle.h"
17 #include "mojo/public/cpp/bindings/error_handler.h" 17 #include "mojo/public/cpp/bindings/error_handler.h"
18 #include "shell/child_controller.mojom.h" 18 #include "shell/child_controller.mojom.h"
19 19
20 namespace shell { 20 namespace shell {
21 21
22 class Context; 22 class Context;
23 23
24 // Child process host: parent-process representation of a child process, which 24 // Child process host: parent-process representation of a child process, which
25 // hosts/runs a native Mojo application loaded from the file system. This class 25 // hosts/runs a native Mojo application loaded from the file system. This class
26 // handles launching and communicating with the child process. 26 // handles launching and communicating with the child process.
27 // 27 //
28 // This class is not thread-safe. It should be created/used/destroyed on a 28 // This class is not thread-safe. It should be created/used/destroyed on a
29 // single thread. 29 // single thread.
30 class ChildProcessHost : public mojo::ErrorHandler { 30 class ChildProcessHost {
31 public: 31 public:
32 explicit ChildProcessHost(Context* context); 32 explicit ChildProcessHost(Context* context);
33 ~ChildProcessHost() override; 33 // TODO(vtl): Virtual because |DidStart()| is, even though it shouldn't be
34 // (see |DidStart()|).
35 virtual ~ChildProcessHost();
34 36
35 // |Start()|s the child process; calls |DidStart()| (on the thread on which 37 // |Start()|s the child process; calls |DidStart()| (on the thread on which
36 // |Start()| was called) when the child has been started (or failed to start). 38 // |Start()| was called) when the child has been started (or failed to start).
37 // After calling |Start()|, this object must not be destroyed until 39 // After calling |Start()|, this object must not be destroyed until
38 // |DidStart()| has been called. 40 // |DidStart()| has been called.
39 // TODO(vtl): Consider using weak pointers and removing this requirement. 41 // TODO(vtl): Consider using weak pointers and removing this requirement.
40 // TODO(vtl): This should probably take a callback instead. 42 // TODO(vtl): This should probably take a callback instead.
41 // TODO(vtl): Consider merging this with |StartApp()|. 43 // TODO(vtl): Consider merging this with |StartApp()|.
42 void Start(); 44 void Start();
43 45
(...skipping 22 matching lines...) Expand all
66 struct LaunchData; 68 struct LaunchData;
67 69
68 // Callback for |mojo::embedder::ConnectToSlave()|. 70 // Callback for |mojo::embedder::ConnectToSlave()|.
69 void DidConnectToSlave(); 71 void DidConnectToSlave();
70 72
71 // Note: This is probably executed on a different thread (namely, using the 73 // Note: This is probably executed on a different thread (namely, using the
72 // blocking pool). 74 // blocking pool).
73 base::Process DoLaunch(scoped_ptr<LaunchData> launch_data); 75 base::Process DoLaunch(scoped_ptr<LaunchData> launch_data);
74 76
75 void AppCompleted(int32_t result); 77 void AppCompleted(int32_t result);
76 78 void OnConnectionError();
77 // |mojo::ErrorHandler| methods:
78 void OnConnectionError() override;
79 79
80 Context* const context_; 80 Context* const context_;
81 81
82 ChildControllerPtr controller_; 82 ChildControllerPtr controller_;
83 mojo::embedder::ChannelInfo* channel_info_; 83 mojo::embedder::ChannelInfo* channel_info_;
84 ChildController::StartAppCallback on_app_complete_; 84 ChildController::StartAppCallback on_app_complete_;
85 85
86 base::Process child_process_; 86 base::Process child_process_;
87 87
88 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); 88 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
89 }; 89 };
90 90
91 } // namespace shell 91 } // namespace shell
92 92
93 #endif // SHELL_CHILD_PROCESS_HOST_H_ 93 #endif // SHELL_CHILD_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « shell/child_main.cc ('k') | shell/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698