Chromium Code Reviews| Index: mojo/edk/embedder/platform_channel_pair_posix.cc |
| diff --git a/mojo/edk/embedder/platform_channel_pair_posix.cc b/mojo/edk/embedder/platform_channel_pair_posix.cc |
| index 55f3ae24ab1b297910bbbfb5536f6b0b8089a961..c6a0ff75322ca924b69aa3f4083020e114ead823 100644 |
| --- a/mojo/edk/embedder/platform_channel_pair_posix.cc |
| +++ b/mojo/edk/embedder/platform_channel_pair_posix.cc |
| @@ -35,6 +35,7 @@ namespace edk { |
| namespace { |
| +#if !defined(OS_ANDROID) |
| bool IsTargetDescriptorUsed( |
| const base::FileHandleMappingVector& file_handle_mapping, |
| int target_fd) { |
| @@ -44,6 +45,7 @@ bool IsTargetDescriptorUsed( |
| } |
| return false; |
| } |
| +#endif |
| } // namespace |
| @@ -92,13 +94,21 @@ ScopedPlatformHandle |
| PlatformChannelPair::PassClientHandleFromParentProcessFromString( |
| const std::string& value) { |
| int client_fd = -1; |
| +#if defined(OS_ANDROID) |
| + base::GlobalDescriptors::Key fd_id = -1; |
| + if (value.empty() || !base::StringToUint(value, &fd_id)) { |
| + LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch; |
| + return ScopedPlatformHandle(); |
| + } |
| + client_fd = base::GlobalDescriptors::GetInstance()->Get(fd_id); |
| +#else |
| if (value.empty() || |
| !base::StringToInt(value, &client_fd) || |
| client_fd < base::GlobalDescriptors::kBaseDescriptor) { |
| LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch; |
| return ScopedPlatformHandle(); |
| } |
| - |
| +#endif |
| return ScopedPlatformHandle(PlatformHandle(client_fd)); |
| } |
| @@ -121,9 +131,17 @@ void PlatformChannelPair::PrepareToPassClientHandleToChildProcess( |
| PrepareToPassClientHandleToChildProcessAsString(handle_passing_info)); |
| } |
| + |
|
Robert Sesek
2016/12/20 20:44:34
nit: extra blank line
Jay Civelli
2016/12/20 23:07:27
Done.
|
| std::string |
| PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString( |
| HandlePassingInformation* handle_passing_info) const { |
| +#if defined(OS_ANDROID) |
| + int fd = client_handle_.get().handle; |
| + base::GlobalDescriptors::Key fd_id = |
| + base::GlobalDescriptors::GetInstance()->Register(fd); |
| + handle_passing_info->push_back(std::pair<int, int>(fd, fd_id)); |
| + return base::UintToString(fd_id); |
| +#else |
| DCHECK(handle_passing_info); |
| // This is an arbitrary sanity check. (Note that this guarantees that the loop |
| // below will terminate sanely.) |
| @@ -141,6 +159,7 @@ PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString( |
| handle_passing_info->push_back( |
| std::pair<int, int>(client_handle_.get().handle, target_fd)); |
| return base::IntToString(target_fd); |
| +#endif |
| } |
| } // namespace edk |