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

Side by Side Diff: content/browser/mojo/mojo_child_connection.h

Issue 2019973002: [mojo-edk] Bind a child token to child launches and port reservations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ 5 #ifndef CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_
6 #define CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ 6 #define CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/process/process_handle.h" 12 #include "base/process/process_handle.h"
13 #include "services/shell/public/interfaces/connector.mojom.h" 13 #include "services/shell/public/interfaces/connector.mojom.h"
14 14
15 namespace shell { 15 namespace shell {
16 class Connection; 16 class Connection;
17 } 17 }
18 18
19 namespace content { 19 namespace content {
20 20
21 // Helper class to establish a connection between the shell and a single child 21 // Helper class to establish a connection between the shell and a single child
22 // process. Process hosts can use this when launching new processes which 22 // process. Process hosts can use this when launching new processes which
23 // should be registered with the shell. 23 // should be registered with the shell.
24 class MojoChildConnection { 24 class MojoChildConnection {
25 public: 25 public:
26 // Prepares a new child connection for a child process which will be 26 // Prepares a new child connection for a child process which will be
27 // identified to the shell as |application_name|. |instance_id| must be 27 // identified to the shell as |application_name|. |instance_id| must be
28 // unique among all child connections using the same |application_name|. 28 // unique among all child connections using the same |application_name|.
29 MojoChildConnection(const std::string& application_name, 29 MojoChildConnection(const std::string& application_name,
30 const std::string& instance_id); 30 const std::string& instance_id,
31 const std::string& child_token);
31 ~MojoChildConnection(); 32 ~MojoChildConnection();
32 33
33 shell::Connection* connection() const { 34 shell::Connection* connection() const {
34 return connection_.get(); 35 return connection_.get();
35 } 36 }
36 37
37 // A token which must be passed to the child process via 38 // A token which must be passed to the child process via
38 // |switches::kPrimordialPipeToken| in order for the child to initialize its 39 // |switches::kPrimordialPipeToken| in order for the child to initialize its
39 // end of the shell connection pipe. 40 // end of the shell connection pipe.
40 std::string shell_client_token() const { return shell_client_token_; } 41 std::string shell_client_token() const { return shell_client_token_; }
41 42
42 // Sets the child connection's process handle. This should be called as soon 43 // Sets the child connection's process handle. This should be called as soon
43 // as the process has been launched, and the connection will not be fully 44 // as the process has been launched, and the connection will not be fully
44 // functional until this is called. 45 // functional until this is called.
45 void SetProcessHandle(base::ProcessHandle handle); 46 void SetProcessHandle(base::ProcessHandle handle);
46 47
47 private: 48 private:
48 const std::string shell_client_token_; 49 const std::string shell_client_token_;
49 std::unique_ptr<shell::Connection> connection_; 50 std::unique_ptr<shell::Connection> connection_;
50 shell::mojom::PIDReceiverPtr pid_receiver_; 51 shell::mojom::PIDReceiverPtr pid_receiver_;
51 52
52 DISALLOW_COPY_AND_ASSIGN(MojoChildConnection); 53 DISALLOW_COPY_AND_ASSIGN(MojoChildConnection);
53 }; 54 };
54 55
55 } // namespace content 56 } // namespace content
56 57
57 #endif // CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_ 58 #endif // CONTENT_BROWSER_MOJO_MOJO_CHILD_CONNECTION_H_
OLDNEW
« no previous file with comments | « content/browser/mojo/mojo_application_host.cc ('k') | content/browser/mojo/mojo_child_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698