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

Unified Diff: mojo/edk/embedder/platform_channel_pair.cc

Issue 1651183003: Make PlatformChannelPair "dumb". (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/embedder/platform_channel_pair.h ('k') | mojo/edk/embedder/platform_channel_pair_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/embedder/platform_channel_pair.cc
diff --git a/mojo/edk/embedder/platform_channel_pair.cc b/mojo/edk/embedder/platform_channel_pair.cc
index 2a143b623d60d434fbeeb133c90e723ef5ca1fb9..43b6e281c4e57c88e8f049091d236a0b2e0e0b0a 100644
--- a/mojo/edk/embedder/platform_channel_pair.cc
+++ b/mojo/edk/embedder/platform_channel_pair.cc
@@ -10,36 +10,14 @@
#include <unistd.h>
#include "base/logging.h"
-#include "base/posix/global_descriptors.h"
#include "build/build_config.h"
#include "mojo/edk/platform/platform_handle.h"
-#include "mojo/edk/util/string_number_conversions.h"
using mojo::platform::PlatformHandle;
-using mojo::platform::ScopedPlatformHandle;
-using mojo::util::NumberToString;
-using mojo::util::StringToNumberWithError;
namespace mojo {
namespace embedder {
-namespace {
-
-bool IsTargetDescriptorUsed(
- const base::FileHandleMappingVector& file_handle_mapping,
- int target_fd) {
- for (size_t i = 0; i < file_handle_mapping.size(); i++) {
- if (file_handle_mapping[i].second == target_fd)
- return true;
- }
- return false;
-}
-
-} // namespace
-
-const char PlatformChannelPair::kMojoPlatformChannelHandleSwitch[] =
- "mojo-platform-channel-handle";
-
PlatformChannelPair::PlatformChannelPair() {
// Create the Unix domain socket and set the ends to nonblocking.
int fds[2];
@@ -59,62 +37,13 @@ PlatformChannelPair::PlatformChannelPair() {
sizeof(no_sigpipe)) == 0);
#endif // defined(OS_MACOSX)
- server_handle_.reset(PlatformHandle(fds[0]));
- DCHECK(server_handle_.is_valid());
- client_handle_.reset(PlatformHandle(fds[1]));
- DCHECK(client_handle_.is_valid());
-}
-
-PlatformChannelPair::~PlatformChannelPair() {
-}
-
-ScopedPlatformHandle PlatformChannelPair::PassServerHandle() {
- return server_handle_.Pass();
-}
-
-ScopedPlatformHandle PlatformChannelPair::PassClientHandle() {
- return client_handle_.Pass();
-}
-
-// static
-ScopedPlatformHandle PlatformChannelPair::PassClientHandleFromParentProcess(
- const std::string& string_from_parent) {
- int client_fd = -1;
- if (!StringToNumberWithError<int>(string_from_parent, &client_fd)) {
- LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch;
- return ScopedPlatformHandle();
- }
-
- return ScopedPlatformHandle(PlatformHandle(client_fd));
-}
-
-void PlatformChannelPair::PrepareToPassClientHandleToChildProcess(
- std::string* string_for_child,
- HandlePassingInformation* handle_passing_info) const {
- DCHECK(string_for_child);
- DCHECK(handle_passing_info);
- // This is an arbitrary sanity check. (Note that this guarantees that the loop
- // below will terminate sanely.)
- CHECK_LT(handle_passing_info->size(), 1000u);
-
- DCHECK(client_handle_.is_valid());
-
- // Find a suitable FD to map our client handle to in the child process.
- // This has quadratic time complexity in the size of |*handle_passing_info|,
- // but |*handle_passing_info| should be very small (usually/often empty).
- int target_fd = base::GlobalDescriptors::kBaseDescriptor;
- while (IsTargetDescriptorUsed(*handle_passing_info, target_fd))
- target_fd++;
-
- handle_passing_info->push_back(
- std::pair<int, int>(client_handle_.get().fd, target_fd));
- *string_for_child = NumberToString<int>(target_fd);
+ handle0.reset(PlatformHandle(fds[0]));
+ DCHECK(handle0.is_valid());
+ handle1.reset(PlatformHandle(fds[1]));
+ DCHECK(handle1.is_valid());
}
-void PlatformChannelPair::ChildProcessLaunched() {
- DCHECK(client_handle_.is_valid());
- client_handle_.reset();
-}
+PlatformChannelPair::~PlatformChannelPair() {}
} // namespace embedder
} // namespace mojo
« no previous file with comments | « mojo/edk/embedder/platform_channel_pair.h ('k') | mojo/edk/embedder/platform_channel_pair_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698