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

Side by Side Diff: ipc/ipc_channel_posix.cc

Issue 320433002: IPC::Channel: Reduce POSIX specific API surface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 PipeMap::GetInstance()->map_.clear(); 170 PipeMap::GetInstance()->map_.clear();
171 } 171 }
172 #endif 172 #endif
173 173
174 //------------------------------------------------------------------------------ 174 //------------------------------------------------------------------------------
175 175
176 #if defined(OS_LINUX) 176 #if defined(OS_LINUX)
177 int ChannelPosix::global_pid_ = 0; 177 int ChannelPosix::global_pid_ = 0;
178 #endif // OS_LINUX 178 #endif // OS_LINUX
179 179
180 // static
181 scoped_ptr<ChannelPosix> ChannelPosix::Create(
182 const IPC::ChannelHandle& channel_handle, Mode mode,
183 Listener* listener) {
184 return make_scoped_ptr(new ChannelPosix(channel_handle,
185 mode,
186 listener));
187 }
188
180 ChannelPosix::ChannelPosix(const IPC::ChannelHandle& channel_handle, 189 ChannelPosix::ChannelPosix(const IPC::ChannelHandle& channel_handle,
181 Mode mode, Listener* listener) 190 Mode mode, Listener* listener)
182 : ChannelReader(listener), 191 : ChannelReader(listener),
183 mode_(mode), 192 mode_(mode),
184 peer_pid_(base::kNullProcessId), 193 peer_pid_(base::kNullProcessId),
185 is_blocked_on_write_(false), 194 is_blocked_on_write_(false),
186 waiting_connect_(true), 195 waiting_connect_(true),
187 message_send_bytes_written_(0), 196 message_send_bytes_written_(0),
188 server_listen_pipe_(-1), 197 server_listen_pipe_(-1),
189 pipe_(-1), 198 pipe_(-1),
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 base::ProcessId ChannelPosix::GetPeerPID() const { 1058 base::ProcessId ChannelPosix::GetPeerPID() const {
1050 return peer_pid_; 1059 return peer_pid_;
1051 } 1060 }
1052 1061
1053 //------------------------------------------------------------------------------ 1062 //------------------------------------------------------------------------------
1054 // Channel's methods 1063 // Channel's methods
1055 1064
1056 // static 1065 // static
1057 scoped_ptr<Channel> Channel::Create( 1066 scoped_ptr<Channel> Channel::Create(
1058 const IPC::ChannelHandle &channel_handle, Mode mode, Listener* listener) { 1067 const IPC::ChannelHandle &channel_handle, Mode mode, Listener* listener) {
1059 return scoped_ptr<Channel>( 1068 return ChannelPosix::Create(channel_handle, mode, listener).PassAs<Channel>();
1060 new ChannelPosix(channel_handle, mode, listener));
1061 } 1069 }
1062 1070
1063 // static 1071 // static
1064 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) { 1072 std::string Channel::GenerateVerifiedChannelID(const std::string& prefix) {
1065 // A random name is sufficient validation on posix systems, so we don't need 1073 // A random name is sufficient validation on posix systems, so we don't need
1066 // an additional shared secret. 1074 // an additional shared secret.
1067 1075
1068 std::string id = prefix; 1076 std::string id = prefix;
1069 if (!id.empty()) 1077 if (!id.empty())
1070 id.append("."); 1078 id.append(".");
1071 1079
1072 return id.append(GenerateUniqueRandomChannelID()); 1080 return id.append(GenerateUniqueRandomChannelID());
1073 } 1081 }
1074 1082
1075 1083
1076 bool Channel::IsNamedServerInitialized( 1084 bool Channel::IsNamedServerInitialized(
1077 const std::string& channel_id) { 1085 const std::string& channel_id) {
1078 return ChannelPosix::IsNamedServerInitialized(channel_id); 1086 return ChannelPosix::IsNamedServerInitialized(channel_id);
1079 } 1087 }
1080 1088
1081 #if defined(OS_LINUX) 1089 #if defined(OS_LINUX)
1082 // static 1090 // static
1083 void Channel::SetGlobalPid(int pid) { 1091 void Channel::SetGlobalPid(int pid) {
1084 ChannelPosix::SetGlobalPid(pid); 1092 ChannelPosix::SetGlobalPid(pid);
1085 } 1093 }
1086 #endif // OS_LINUX 1094 #endif // OS_LINUX
1087 1095
1088 } // namespace IPC 1096 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698