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

Side by Side Diff: mojo/shell/runner/host/child_process_host.h

Issue 1678333003: Revert of [mojo-edk] Simplify multiprocess pipe bootstrap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « mojo/shell/runner/host/child_process.cc ('k') | mojo/shell/runner/host/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 MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ 5 #ifndef MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_
6 #define MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ 6 #define MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Waits for the child process to terminate, and returns its exit code. 64 // Waits for the child process to terminate, and returns its exit code.
65 int Join(); 65 int Join();
66 66
67 // See |mojom::ChildController|: 67 // See |mojom::ChildController|:
68 void StartApp( 68 void StartApp(
69 InterfaceRequest<mojom::ShellClient> request, 69 InterfaceRequest<mojom::ShellClient> request,
70 const mojom::ChildController::StartAppCallback& on_app_complete); 70 const mojom::ChildController::StartAppCallback& on_app_complete);
71 void ExitNow(int32_t exit_code); 71 void ExitNow(int32_t exit_code);
72 72
73 protected: 73 protected:
74 void DidStart(const ProcessReadyCallback& callback); 74 void DidStart();
75 75
76 private: 76 private:
77 // A thread-safe holder for the bootstrap message pipe to this child process.
78 // The pipe is established on an arbitrary thread and may not be connected
79 // until the host's message loop has stopped running.
80 class PipeHolder : public base::RefCountedThreadSafe<PipeHolder> {
81 public:
82 PipeHolder();
83
84 void Reject();
85 void SetPipe(ScopedMessagePipeHandle pipe);
86 ScopedMessagePipeHandle PassPipe();
87
88 private:
89 friend class base::RefCountedThreadSafe<PipeHolder>;
90
91 ~PipeHolder();
92
93 base::Lock lock_;
94 bool reject_pipe_ = false;
95 ScopedMessagePipeHandle pipe_;
96
97 DISALLOW_COPY_AND_ASSIGN(PipeHolder);
98 };
99
77 void DoLaunch(); 100 void DoLaunch();
78 101
79 void AppCompleted(int32_t result); 102 void AppCompleted(int32_t result);
80 103
104 // Callback for |embedder::CreateChannel()|.
105 void DidCreateChannel(embedder::ChannelInfo* channel_info);
106
107 // Called once |pipe_holder_| is bound to a pipe.
108 void OnMessagePipeCreated();
109
110 // Called when the child process is launched and when the bootstrap
111 // message pipe is created. Once both things have happened (which may happen
112 // in either order), |process_ready_callback_| is invoked.
113 void MaybeNotifyProcessReady();
114
115 // Callback used to receive the child message pipe from the ports EDK.
116 // This may be called on any thread. It will always stash the pipe in
117 // |holder|, and it will then attempt to call |callback| on
118 // |callback_task_runner| (which may or may not still be running tasks.)
119 static void OnParentMessagePipeCreated(
120 scoped_refptr<PipeHolder> holder,
121 scoped_refptr<base::TaskRunner> callback_task_runner,
122 const base::Closure& callback,
123 ScopedMessagePipeHandle pipe);
124
81 scoped_refptr<base::TaskRunner> launch_process_runner_; 125 scoped_refptr<base::TaskRunner> launch_process_runner_;
82 bool start_sandboxed_; 126 bool start_sandboxed_;
83 const base::FilePath app_path_; 127 const base::FilePath app_path_;
84 base::Process child_process_; 128 base::Process child_process_;
85 // Used for the ChildController binding. 129 // Used for the ChildController binding.
86 edk::PlatformChannelPair platform_channel_pair_; 130 embedder::PlatformChannelPair platform_channel_pair_;
87 mojom::ChildControllerPtr controller_; 131 mojom::ChildControllerPtr controller_;
132 embedder::ChannelInfo* channel_info_;
88 mojom::ChildController::StartAppCallback on_app_complete_; 133 mojom::ChildController::StartAppCallback on_app_complete_;
89 edk::HandlePassingInformation handle_passing_info_; 134 embedder::HandlePassingInformation handle_passing_info_;
90 135
91 // Used to back the NodeChannel between the parent and child node. 136 // Used only when --use-new-edk is specified. Used to back the NodeChannel
137 // between the parent and child node.
92 scoped_ptr<edk::PlatformChannelPair> node_channel_; 138 scoped_ptr<edk::PlatformChannelPair> node_channel_;
93 139
94 // Since Start() calls a method on another thread, we use an event to block 140 // Since Start() calls a method on another thread, we use an event to block
95 // the main thread if it tries to destruct |this| while launching the process. 141 // the main thread if it tries to destruct |this| while launching the process.
96 base::WaitableEvent start_child_process_event_; 142 base::WaitableEvent start_child_process_event_;
97 143
98 // A token the child can use to connect a primordial pipe to the host. 144 // A token the child can use to connect a primordial pipe to the host.
99 std::string primordial_pipe_token_; 145 std::string primordial_pipe_token_;
100 146
147 // Holds the message pipe to the child process until it is either closed or
148 // bound to the controller interface.
149 scoped_refptr<PipeHolder> pipe_holder_;
150
151 // Invoked exactly once, as soon as the child process's ID is known and
152 // a pipe to the child has been established.
153 ProcessReadyCallback process_ready_callback_;
154
101 base::WeakPtrFactory<ChildProcessHost> weak_factory_; 155 base::WeakPtrFactory<ChildProcessHost> weak_factory_;
102 156
103 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); 157 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
104 }; 158 };
105 159
106 } // namespace shell 160 } // namespace shell
107 } // namespace mojo 161 } // namespace mojo
108 162
109 #endif // MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_ 163 #endif // MOJO_SHELL_RUNNER_HOST_CHILD_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « mojo/shell/runner/host/child_process.cc ('k') | mojo/shell/runner/host/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698