OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ipc/ipc_channel_posix.h" | 5 #include "ipc/ipc_channel_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 base::ProcessId ChannelPosix::GetPeerPID() const { | 1049 base::ProcessId ChannelPosix::GetPeerPID() const { |
1050 return peer_pid_; | 1050 return peer_pid_; |
1051 } | 1051 } |
1052 | 1052 |
1053 //------------------------------------------------------------------------------ | 1053 //------------------------------------------------------------------------------ |
1054 // Channel's methods | 1054 // Channel's methods |
1055 | 1055 |
1056 // static | 1056 // static |
1057 scoped_ptr<Channel> Channel::Create( | 1057 scoped_ptr<Channel> Channel::Create( |
1058 const IPC::ChannelHandle &channel_handle, Mode mode, Listener* listener) { | 1058 const IPC::ChannelHandle &channel_handle, Mode mode, Listener* listener) { |
1059 return scoped_ptr<Channel>( | 1059 return make_scoped_ptr(new ChannelPosix( |
1060 new ChannelPosix(channel_handle, mode, listener)); | 1060 channel_handle, mode, listener)).PassAs<Channel>(); |
1061 } | 1061 } |
1062 | 1062 |
1063 // static | 1063 // static |
1064 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) { | 1064 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) { |
1065 // A random name is sufficient validation on posix systems, so we don't need | 1065 // A random name is sufficient validation on posix systems, so we don't need |
1066 // an additional shared secret. | 1066 // an additional shared secret. |
1067 | 1067 |
1068 std::string id = prefix; | 1068 std::string id = prefix; |
1069 if (!id.empty()) | 1069 if (!id.empty()) |
1070 id.append("."); | 1070 id.append("."); |
1071 | 1071 |
1072 return id.append(GenerateUniqueRandomChannelID()); | 1072 return id.append(GenerateUniqueRandomChannelID()); |
1073 } | 1073 } |
1074 | 1074 |
1075 | 1075 |
1076 bool Channel::IsNamedServerInitialized( | 1076 bool Channel::IsNamedServerInitialized( |
1077 const std::string& channel_id) { | 1077 const std::string& channel_id) { |
1078 return ChannelPosix::IsNamedServerInitialized(channel_id); | 1078 return ChannelPosix::IsNamedServerInitialized(channel_id); |
1079 } | 1079 } |
1080 | 1080 |
1081 #if defined(OS_LINUX) | 1081 #if defined(OS_LINUX) |
1082 // static | 1082 // static |
1083 void Channel::SetGlobalPid(int pid) { | 1083 void Channel::SetGlobalPid(int pid) { |
1084 ChannelPosix::SetGlobalPid(pid); | 1084 ChannelPosix::SetGlobalPid(pid); |
1085 } | 1085 } |
1086 #endif // OS_LINUX | 1086 #endif // OS_LINUX |
1087 | 1087 |
1088 } // namespace IPC | 1088 } // namespace IPC |
OLD | NEW |