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)); |
273 | 274 |
274 // Don't send the secret to the untrusted process, and don't send a secret | 275 // Don't send the secret to the untrusted process, and don't send a secret |
275 // if the value is zero (for IPC backwards compatability). | 276 // if the value is zero (for IPC backwards compatability). |
276 int32 secret = validate_client_ ? 0 : client_secret_; | 277 int32 secret = validate_client_ ? 0 : client_secret_; |
277 if (!m->WriteInt(GetCurrentProcessId()) || | 278 if (!m->WriteInt(GetCurrentProcessId()) || |
278 (secret && !m->WriteUInt32(secret))) { | 279 (secret && !m->WriteUInt32(secret))) { |
279 CloseHandle(pipe_); | 280 CloseHandle(pipe_); |
280 pipe_ = INVALID_HANDLE_VALUE; | 281 pipe_ = INVALID_HANDLE_VALUE; |
281 return false; | 282 return false; |
282 } | 283 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 int secret; | 509 int secret; |
509 do { // Guarantee we get a non-zero value. | 510 do { // Guarantee we get a non-zero value. |
510 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 511 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
511 } while (secret == 0); | 512 } while (secret == 0); |
512 | 513 |
513 id.append(GenerateUniqueRandomChannelID()); | 514 id.append(GenerateUniqueRandomChannelID()); |
514 return id.append(base::StringPrintf("\\%d", secret)); | 515 return id.append(base::StringPrintf("\\%d", secret)); |
515 } | 516 } |
516 | 517 |
517 } // namespace IPC | 518 } // namespace IPC |
OLD | NEW |