OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
Ken Rockot(use gerrit already)
2016/12/12 22:23:08
nit: I think it might be less confusing to just lu
Jay Civelli
2016/12/13 18:23:25
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "mojo/edk/embedder/platform_channel_pair.h" | |
6 | |
7 #include "base/posix/global_descriptors.h" | |
8 #include "base/strings/string_number_conversions.h" | |
9 | |
10 namespace mojo { | |
11 namespace edk { | |
12 | |
13 std::string | |
14 PlatformChannelPair::PrepareToPassClientHandleToChildProcessAsString( | |
15 HandlePassingInformation* handle_passing_info) const { | |
16 int fd = client_handle_.get().handle; | |
17 base::GlobalDescriptors::Key fd_id = | |
18 base::GlobalDescriptors::GetInstance()->Register(fd); | |
19 handle_passing_info->push_back(std::pair<int, int>(fd, fd_id)); | |
20 return base::UintToString(fd_id); | |
21 } | |
22 | |
23 // static | |
24 ScopedPlatformHandle | |
25 PlatformChannelPair::PassClientHandleFromParentProcessFromString( | |
26 const std::string& value) { | |
27 base::GlobalDescriptors::Key fd_id = -1; | |
28 if (value.empty() || !base::StringToUint(value, &fd_id)) { | |
29 LOG(ERROR) << "Missing or invalid --" << kMojoPlatformChannelHandleSwitch; | |
30 return ScopedPlatformHandle(); | |
31 } | |
32 int fd = base::GlobalDescriptors::GetInstance()->Get(fd_id); | |
33 return ScopedPlatformHandle(PlatformHandle(fd)); | |
34 } | |
35 | |
36 } // namespace edk | |
37 } // namespace mojo | |
OLD | NEW |