| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 return READ_PENDING; | 145 return READ_PENDING; |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool Channel::ChannelImpl::WillDispatchInputMessage(Message* msg) { | 148 bool Channel::ChannelImpl::WillDispatchInputMessage(Message* msg) { |
| 149 // Make sure we get a hello when client validation is required. | 149 // Make sure we get a hello when client validation is required. |
| 150 if (validate_client_) | 150 if (validate_client_) |
| 151 return IsHelloMessage(*msg); | 151 return IsHelloMessage(*msg); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void Channel::ChannelImpl::HandleHelloMessage(const Message& msg) { | 155 void Channel::ChannelImpl::HandleInternalMessage(const Message& msg) { |
| 156 DCHECK_EQ(msg.type(), static_cast<unsigned>(Channel::HELLO_MESSAGE_TYPE)); |
| 156 // The hello message contains one parameter containing the PID. | 157 // The hello message contains one parameter containing the PID. |
| 157 PickleIterator it(msg); | 158 PickleIterator it(msg); |
| 158 int32 claimed_pid; | 159 int32 claimed_pid; |
| 159 bool failed = !it.ReadInt(&claimed_pid); | 160 bool failed = !it.ReadInt(&claimed_pid); |
| 160 | 161 |
| 161 if (!failed && validate_client_) { | 162 if (!failed && validate_client_) { |
| 162 int32 secret; | 163 int32 secret; |
| 163 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true; | 164 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true; |
| 164 } | 165 } |
| 165 | 166 |
| (...skipping 342 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 |