| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if (pipe_ == INVALID_HANDLE_VALUE) { | 262 if (pipe_ == INVALID_HANDLE_VALUE) { |
| 263 // If this process is being closed, the pipe may be gone already. | 263 // If this process is being closed, the pipe may be gone already. |
| 264 LOG(WARNING) << "Unable to create pipe \"" << pipe_name << | 264 LOG(WARNING) << "Unable to create pipe \"" << pipe_name << |
| 265 "\" in " << (mode & MODE_SERVER_FLAG ? "server" : "client") | 265 "\" in " << (mode & MODE_SERVER_FLAG ? "server" : "client") |
| 266 << " mode. Error :" << GetLastError(); | 266 << " mode. Error :" << GetLastError(); |
| 267 return false; | 267 return false; |
| 268 } | 268 } |
| 269 | 269 |
| 270 // Create the Hello message to be sent when Connect is called | 270 // Create the Hello message to be sent when Connect is called |
| 271 scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE, | 271 scoped_ptr<Message> m(new Message(MSG_ROUTING_NONE, |
| 272 HELLO_MESSAGE_TYPE, | 272 HELLO_MESSAGE_TYPE)); |
| 273 IPC::Message::PRIORITY_NORMAL)); | |
| 274 | 273 |
| 275 // Don't send the secret to the untrusted process, and don't send a secret | 274 // Don't send the secret to the untrusted process, and don't send a secret |
| 276 // if the value is zero (for IPC backwards compatability). | 275 // if the value is zero (for IPC backwards compatability). |
| 277 int32 secret = validate_client_ ? 0 : client_secret_; | 276 int32 secret = validate_client_ ? 0 : client_secret_; |
| 278 if (!m->WriteInt(GetCurrentProcessId()) || | 277 if (!m->WriteInt(GetCurrentProcessId()) || |
| 279 (secret && !m->WriteUInt32(secret))) { | 278 (secret && !m->WriteUInt32(secret))) { |
| 280 CloseHandle(pipe_); | 279 CloseHandle(pipe_); |
| 281 pipe_ = INVALID_HANDLE_VALUE; | 280 pipe_ = INVALID_HANDLE_VALUE; |
| 282 return false; | 281 return false; |
| 283 } | 282 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 int secret; | 508 int secret; |
| 510 do { // Guarantee we get a non-zero value. | 509 do { // Guarantee we get a non-zero value. |
| 511 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 510 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
| 512 } while (secret == 0); | 511 } while (secret == 0); |
| 513 | 512 |
| 514 id.append(GenerateUniqueRandomChannelID()); | 513 id.append(GenerateUniqueRandomChannelID()); |
| 515 return id.append(base::StringPrintf("\\%d", secret)); | 514 return id.append(base::StringPrintf("\\%d", secret)); |
| 516 } | 515 } |
| 517 | 516 |
| 518 } // namespace IPC | 517 } // namespace IPC |
| OLD | NEW |