| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 | 138 |
| 139 base::ProcessId ChannelWin::GetPeerPID() const { | 139 base::ProcessId ChannelWin::GetPeerPID() const { |
| 140 return peer_pid_; | 140 return peer_pid_; |
| 141 } | 141 } |
| 142 | 142 |
| 143 base::ProcessId ChannelWin::GetSelfPID() const { | 143 base::ProcessId ChannelWin::GetSelfPID() const { |
| 144 return GetCurrentProcessId(); | 144 return GetCurrentProcessId(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 ChannelHandle ChannelWin::TakePipeHandle() { | |
| 148 ChannelHandle handle = ChannelHandle(pipe_); | |
| 149 pipe_ = INVALID_HANDLE_VALUE; | |
| 150 return handle; | |
| 151 } | |
| 152 | |
| 153 // static | 147 // static |
| 154 bool ChannelWin::IsNamedServerInitialized( | 148 bool ChannelWin::IsNamedServerInitialized( |
| 155 const std::string& channel_id) { | 149 const std::string& channel_id) { |
| 156 if (WaitNamedPipe(PipeName(channel_id, NULL).c_str(), 1)) | 150 if (WaitNamedPipe(PipeName(channel_id, NULL).c_str(), 1)) |
| 157 return true; | 151 return true; |
| 158 // If ERROR_SEM_TIMEOUT occurred, the pipe exists but is handling another | 152 // If ERROR_SEM_TIMEOUT occurred, the pipe exists but is handling another |
| 159 // connection. | 153 // connection. |
| 160 return GetLastError() == ERROR_SEM_TIMEOUT; | 154 return GetLastError() == ERROR_SEM_TIMEOUT; |
| 161 } | 155 } |
| 162 | 156 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 int secret; | 558 int secret; |
| 565 do { // Guarantee we get a non-zero value. | 559 do { // Guarantee we get a non-zero value. |
| 566 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 560 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
| 567 } while (secret == 0); | 561 } while (secret == 0); |
| 568 | 562 |
| 569 id.append(GenerateUniqueRandomChannelID()); | 563 id.append(GenerateUniqueRandomChannelID()); |
| 570 return id.append(base::StringPrintf("\\%d", secret)); | 564 return id.append(base::StringPrintf("\\%d", secret)); |
| 571 } | 565 } |
| 572 | 566 |
| 573 } // namespace IPC | 567 } // namespace IPC |
| OLD | NEW |