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_win.h" | 5 #include "ipc/ipc_channel_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 base::ProcessId ChannelWin::GetPeerPID() const { | 135 base::ProcessId ChannelWin::GetPeerPID() const { |
136 return peer_pid_; | 136 return peer_pid_; |
137 } | 137 } |
138 | 138 |
| 139 base::ProcessId ChannelWin::GetSelfPID() const { |
| 140 return GetCurrentProcessId(); |
| 141 } |
| 142 |
| 143 ChannelHandle ChannelWin::TakePipeHandle() { |
| 144 ChannelHandle handle = ChannelHandle(pipe_); |
| 145 pipe_ = INVALID_HANDLE_VALUE; |
| 146 return handle; |
| 147 } |
| 148 |
139 // static | 149 // static |
140 bool ChannelWin::IsNamedServerInitialized( | 150 bool ChannelWin::IsNamedServerInitialized( |
141 const std::string& channel_id) { | 151 const std::string& channel_id) { |
142 if (WaitNamedPipe(PipeName(channel_id, NULL).c_str(), 1)) | 152 if (WaitNamedPipe(PipeName(channel_id, NULL).c_str(), 1)) |
143 return true; | 153 return true; |
144 // If ERROR_SEM_TIMEOUT occurred, the pipe exists but is handling another | 154 // If ERROR_SEM_TIMEOUT occurred, the pipe exists but is handling another |
145 // connection. | 155 // connection. |
146 return GetLastError() == ERROR_SEM_TIMEOUT; | 156 return GetLastError() == ERROR_SEM_TIMEOUT; |
147 } | 157 } |
148 | 158 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 int secret; | 551 int secret; |
542 do { // Guarantee we get a non-zero value. | 552 do { // Guarantee we get a non-zero value. |
543 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 553 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
544 } while (secret == 0); | 554 } while (secret == 0); |
545 | 555 |
546 id.append(GenerateUniqueRandomChannelID()); | 556 id.append(GenerateUniqueRandomChannelID()); |
547 return id.append(base::StringPrintf("\\%d", secret)); | 557 return id.append(base::StringPrintf("\\%d", secret)); |
548 } | 558 } |
549 | 559 |
550 } // namespace IPC | 560 } // namespace IPC |
OLD | NEW |