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

Side by Side Diff: ipc/ipc_channel_posix.cc

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 5 years, 3 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
« no previous file with comments | « ios/web/webui/web_ui_ios_controller_factory_registry.cc ('k') | ipc/ipc_logging.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 10 #include <stdint.h>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // connects. Once the client connects, the server will close the original 88 // connects. Once the client connects, the server will close the original
89 // copy of the client socket and remove the mapping. Thus, when the client 89 // copy of the client socket and remove the mapping. Thus, when the client
90 // object closes, it will close the only remaining copy of the client socket 90 // object closes, it will close the only remaining copy of the client socket
91 // in the fd table and the server will see EOF on its side. 91 // in the fd table and the server will see EOF on its side.
92 // 92 //
93 // TODO(port): a client process cannot connect to multiple IPC channels with 93 // TODO(port): a client process cannot connect to multiple IPC channels with
94 // this scheme. 94 // this scheme.
95 95
96 class PipeMap { 96 class PipeMap {
97 public: 97 public:
98 static PipeMap* GetInstance() { 98 static PipeMap* GetInstance() { return base::Singleton<PipeMap>::get(); }
99 return Singleton<PipeMap>::get();
100 }
101 99
102 ~PipeMap() { 100 ~PipeMap() {
103 // Shouldn't have left over pipes. 101 // Shouldn't have left over pipes.
104 DCHECK(map_.empty()); 102 DCHECK(map_.empty());
105 } 103 }
106 104
107 // Lookup a given channel id. Return -1 if not found. 105 // Lookup a given channel id. Return -1 if not found.
108 int Lookup(const std::string& channel_id) { 106 int Lookup(const std::string& channel_id) {
109 base::AutoLock locked(lock_); 107 base::AutoLock locked(lock_);
110 108
(...skipping 21 matching lines...) Expand all
132 << "for '" << channel_id << "' while first " 130 << "for '" << channel_id << "' while first "
133 << "(fd " << i->second << ") still exists"; 131 << "(fd " << i->second << ") still exists";
134 map_[channel_id] = fd; 132 map_[channel_id] = fd;
135 } 133 }
136 134
137 private: 135 private:
138 base::Lock lock_; 136 base::Lock lock_;
139 typedef std::map<std::string, int> ChannelToFDMap; 137 typedef std::map<std::string, int> ChannelToFDMap;
140 ChannelToFDMap map_; 138 ChannelToFDMap map_;
141 139
142 friend struct DefaultSingletonTraits<PipeMap>; 140 friend struct base::DefaultSingletonTraits<PipeMap>;
143 #if defined(OS_ANDROID) 141 #if defined(OS_ANDROID)
144 friend void ::IPC::Channel::NotifyProcessForkedForTesting(); 142 friend void ::IPC::Channel::NotifyProcessForkedForTesting();
145 #endif 143 #endif
146 }; 144 };
147 145
148 //------------------------------------------------------------------------------ 146 //------------------------------------------------------------------------------
149 147
150 bool SocketWriteErrorIsRecoverable() { 148 bool SocketWriteErrorIsRecoverable() {
151 #if defined(OS_MACOSX) 149 #if defined(OS_MACOSX)
152 // On OS X if sendmsg() is trying to send fds between processes and there 150 // On OS X if sendmsg() is trying to send fds between processes and there
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 } 1043 }
1046 1044
1047 #if defined(OS_LINUX) 1045 #if defined(OS_LINUX)
1048 // static 1046 // static
1049 void Channel::SetGlobalPid(int pid) { 1047 void Channel::SetGlobalPid(int pid) {
1050 ChannelPosix::SetGlobalPid(pid); 1048 ChannelPosix::SetGlobalPid(pid);
1051 } 1049 }
1052 #endif // OS_LINUX 1050 #endif // OS_LINUX
1053 1051
1054 } // namespace IPC 1052 } // namespace IPC
OLDNEW
« no previous file with comments | « ios/web/webui/web_ui_ios_controller_factory_registry.cc ('k') | ipc/ipc_logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698