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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 bool ChannelWin::WillDispatchInputMessage(Message* msg) { | 154 bool ChannelWin::WillDispatchInputMessage(Message* msg) { |
155 // Make sure we get a hello when client validation is required. | 155 // Make sure we get a hello when client validation is required. |
156 if (validate_client_) | 156 if (validate_client_) |
157 return IsHelloMessage(*msg); | 157 return IsHelloMessage(*msg); |
158 return true; | 158 return true; |
159 } | 159 } |
160 | 160 |
161 void ChannelWin::HandleInternalMessage(const Message& msg) { | 161 void ChannelWin::HandleInternalMessage(const Message& msg) { |
162 DCHECK_EQ(msg.type(), static_cast<unsigned>(Channel::HELLO_MESSAGE_TYPE)); | 162 DCHECK_EQ(msg.type(), static_cast<unsigned>(Channel::HELLO_MESSAGE_TYPE)); |
163 // The hello message contains one parameter containing the PID. | 163 // The hello message contains one parameter containing the PID. |
164 PickleIterator it(msg); | 164 base::PickleIterator it(msg); |
165 int32 claimed_pid; | 165 int32 claimed_pid; |
166 bool failed = !it.ReadInt(&claimed_pid); | 166 bool failed = !it.ReadInt(&claimed_pid); |
167 | 167 |
168 if (!failed && validate_client_) { | 168 if (!failed && validate_client_) { |
169 int32 secret; | 169 int32 secret; |
170 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true; | 170 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true; |
171 } | 171 } |
172 | 172 |
173 if (failed) { | 173 if (failed) { |
174 NOTREACHED(); | 174 NOTREACHED(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 int secret; | 501 int secret; |
502 do { // Guarantee we get a non-zero value. | 502 do { // Guarantee we get a non-zero value. |
503 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 503 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
504 } while (secret == 0); | 504 } while (secret == 0); |
505 | 505 |
506 id.append(GenerateUniqueRandomChannelID()); | 506 id.append(GenerateUniqueRandomChannelID()); |
507 return id.append(base::StringPrintf("\\%d", secret)); | 507 return id.append(base::StringPrintf("\\%d", secret)); |
508 } | 508 } |
509 | 509 |
510 } // namespace IPC | 510 } // namespace IPC |
OLD | NEW |