| OLD | NEW | 
|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_EDK_EMBEDDER_PENDING_PROCESS_CONNECTION_H_ | 5 #ifndef MOJO_EDK_EMBEDDER_PENDING_PROCESS_CONNECTION_H_ | 
| 6 #define MOJO_EDK_EMBEDDER_PENDING_PROCESS_CONNECTION_H_ | 6 #define MOJO_EDK_EMBEDDER_PENDING_PROCESS_CONNECTION_H_ | 
| 7 | 7 | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/callback.h" | 10 #include "base/callback.h" | 
| 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 "mojo/edk/embedder/connection_param.h" | 
| 13 #include "mojo/edk/embedder/scoped_platform_handle.h" | 14 #include "mojo/edk/embedder/scoped_platform_handle.h" | 
| 14 #include "mojo/edk/system/system_impl_export.h" | 15 #include "mojo/edk/system/system_impl_export.h" | 
| 15 #include "mojo/public/cpp/system/message_pipe.h" | 16 #include "mojo/public/cpp/system/message_pipe.h" | 
| 16 | 17 | 
| 17 namespace mojo { | 18 namespace mojo { | 
| 18 namespace edk { | 19 namespace edk { | 
| 19 | 20 | 
| 20 using ProcessErrorCallback = base::Callback<void(const std::string& error)>; | 21 using ProcessErrorCallback = base::Callback<void(const std::string& error)>; | 
| 21 | 22 | 
| 22 // Represents a potential connection to an external process. Use this object | 23 // Represents a potential connection to an external process. Use this object | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 81   // | 82   // | 
| 82   // NOTES: This may be called any number of times to create multiple message | 83   // NOTES: This may be called any number of times to create multiple message | 
| 83   // pipes to the same remote process. This call ALWAYS succeeds, returning | 84   // pipes to the same remote process. This call ALWAYS succeeds, returning | 
| 84   // a valid message pipe handle and populating |*token| with a new unique | 85   // a valid message pipe handle and populating |*token| with a new unique | 
| 85   // string value. | 86   // string value. | 
| 86   ScopedMessagePipeHandle CreateMessagePipe(std::string* token); | 87   ScopedMessagePipeHandle CreateMessagePipe(std::string* token); | 
| 87 | 88 | 
| 88   // Connects to the process. This must be called at most once, with the process | 89   // Connects to the process. This must be called at most once, with the process | 
| 89   // handle in |process|. | 90   // handle in |process|. | 
| 90   // | 91   // | 
| 91   // |channel| is the platform handle of an OS pipe which can be used to | 92   // |connection_param| is the platform handle of an OS pipe which can be used | 
| 92   // communicate with the connected process. The other end of that pipe must | 93   // to communicate with the connected process. The other end of that pipe must | 
| 93   // ultimately be passed to mojo::edk::SetParentPipeHandle in the remote | 94   // ultimately be passed to mojo::edk::SetParentPipeHandle in the remote | 
| 94   // process, and getting that end of the pipe into the other process is the | 95   // process, and getting that end of the pipe into the other process is the | 
| 95   // embedder's responsibility. | 96   // embedder's responsibility. | 
| 96   // | 97   // | 
| 97   // If this method is not called by the time the PendingProcessConnection is | 98   // If this method is not called by the time the PendingProcessConnection is | 
| 98   // destroyed, it's assumed that the process is unavailable (e.g. process | 99   // destroyed, it's assumed that the process is unavailable (e.g. process | 
| 99   // launch failed or the process has otherwise been terminated early), and | 100   // launch failed or the process has otherwise been terminated early), and | 
| 100   // any associated resources, such as remote endpoints of messages pipes | 101   // any associated resources, such as remote endpoints of messages pipes | 
| 101   // created by CreateMessagePipe above) will be cleaned up at that time. | 102   // created by CreateMessagePipe above) will be cleaned up at that time. | 
| 102   void Connect( | 103   void Connect( | 
| 103       base::ProcessHandle process, | 104       base::ProcessHandle process, | 
| 104       ScopedPlatformHandle channel, | 105       ConnectionParam connection_param, | 
| 105       const ProcessErrorCallback& error_callback = ProcessErrorCallback()); | 106       const ProcessErrorCallback& error_callback = ProcessErrorCallback()); | 
| 106 | 107 | 
| 107  private: | 108  private: | 
| 108   // A GUID representing a potential new process to be connected to this one. | 109   // A GUID representing a potential new process to be connected to this one. | 
| 109   const std::string process_token_; | 110   const std::string process_token_; | 
| 110 | 111 | 
| 111   // Indicates whether this object has been used to create new message pipes. | 112   // Indicates whether this object has been used to create new message pipes. | 
| 112   bool has_message_pipes_ = false; | 113   bool has_message_pipes_ = false; | 
| 113 | 114 | 
| 114   // Indicates whether Connect() has been called yet. | 115   // Indicates whether Connect() has been called yet. | 
| 115   bool connected_ = false; | 116   bool connected_ = false; | 
| 116 | 117 | 
| 117   DISALLOW_COPY_AND_ASSIGN(PendingProcessConnection); | 118   DISALLOW_COPY_AND_ASSIGN(PendingProcessConnection); | 
| 118 }; | 119 }; | 
| 119 | 120 | 
| 120 }  // namespace edk | 121 }  // namespace edk | 
| 121 }  // namespace mojo | 122 }  // namespace mojo | 
| 122 | 123 | 
| 123 #endif  // MOJO_EDK_EMBEDDER_PENDING_PROCESS_CONNECTION_H_ | 124 #endif  // MOJO_EDK_EMBEDDER_PENDING_PROCESS_CONNECTION_H_ | 
| OLD | NEW | 
|---|