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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // will be signalled even in the "synchronously completed" state. | 165 // will be signalled even in the "synchronously completed" state. |
166 // | 166 // |
167 // This allows us to potentially process some outgoing messages and | 167 // This allows us to potentially process some outgoing messages and |
168 // interleave other work on this thread when we're getting hammered with | 168 // interleave other work on this thread when we're getting hammered with |
169 // input messages. Potentially, this could be tuned to be more efficient | 169 // input messages. Potentially, this could be tuned to be more efficient |
170 // with some testing. | 170 // with some testing. |
171 input_state_.is_pending = true; | 171 input_state_.is_pending = true; |
172 return READ_PENDING; | 172 return READ_PENDING; |
173 } | 173 } |
174 | 174 |
175 bool ChannelWin::WillDispatchInputMessage(Message* msg) { | 175 bool ChannelWin::ShouldDispatchInputMessage(Message* msg) { |
176 // Make sure we get a hello when client validation is required. | 176 // Make sure we get a hello when client validation is required. |
177 if (validate_client_) | 177 if (validate_client_) |
178 return IsHelloMessage(*msg); | 178 return IsHelloMessage(*msg); |
179 return true; | 179 return true; |
180 } | 180 } |
181 | 181 |
| 182 bool ChannelWin::GetNonBrokeredAttachments(Message* msg) { |
| 183 return true; |
| 184 } |
| 185 |
182 void ChannelWin::HandleInternalMessage(const Message& msg) { | 186 void ChannelWin::HandleInternalMessage(const Message& msg) { |
183 DCHECK_EQ(msg.type(), static_cast<unsigned>(Channel::HELLO_MESSAGE_TYPE)); | 187 DCHECK_EQ(msg.type(), static_cast<unsigned>(Channel::HELLO_MESSAGE_TYPE)); |
184 // The hello message contains one parameter containing the PID. | 188 // The hello message contains one parameter containing the PID. |
185 base::PickleIterator it(msg); | 189 base::PickleIterator it(msg); |
186 int32 claimed_pid; | 190 int32 claimed_pid; |
187 bool failed = !it.ReadInt(&claimed_pid); | 191 bool failed = !it.ReadInt(&claimed_pid); |
188 | 192 |
189 if (!failed && validate_client_) { | 193 if (!failed && validate_client_) { |
190 int32 secret; | 194 int32 secret; |
191 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true; | 195 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 467 |
464 // We don't support recursion through OnMessageReceived yet! | 468 // We don't support recursion through OnMessageReceived yet! |
465 DCHECK(!processing_incoming_); | 469 DCHECK(!processing_incoming_); |
466 base::AutoReset<bool> auto_reset_processing_incoming( | 470 base::AutoReset<bool> auto_reset_processing_incoming( |
467 &processing_incoming_, true); | 471 &processing_incoming_, true); |
468 | 472 |
469 // Process the new data. | 473 // Process the new data. |
470 if (input_state_.is_pending) { | 474 if (input_state_.is_pending) { |
471 // This is the normal case for everything except the initialization step. | 475 // This is the normal case for everything except the initialization step. |
472 input_state_.is_pending = false; | 476 input_state_.is_pending = false; |
473 if (!bytes_transfered) | 477 if (!bytes_transfered) { |
474 ok = false; | 478 ok = false; |
475 else if (pipe_.IsValid()) | 479 } else if (pipe_.IsValid()) { |
476 ok = AsyncReadComplete(bytes_transfered); | 480 ok = (AsyncReadComplete(bytes_transfered) != DISPATCH_ERROR); |
| 481 } |
477 } else { | 482 } else { |
478 DCHECK(!bytes_transfered); | 483 DCHECK(!bytes_transfered); |
479 } | 484 } |
480 | 485 |
481 // Request more data. | 486 // Request more data. |
482 if (ok) | 487 if (ok) |
483 ok = ProcessIncomingMessages(); | 488 ok = (ProcessIncomingMessages() != DISPATCH_ERROR); |
484 } else { | 489 } else { |
485 DCHECK(context == &output_state_.context); | 490 DCHECK(context == &output_state_.context); |
486 CHECK(output_state_.is_pending); | 491 CHECK(output_state_.is_pending); |
487 ok = ProcessOutgoingMessages(context, bytes_transfered); | 492 ok = ProcessOutgoingMessages(context, bytes_transfered); |
488 } | 493 } |
489 if (!ok && pipe_.IsValid()) { | 494 if (!ok && pipe_.IsValid()) { |
490 // We don't want to re-enter Close(). | 495 // We don't want to re-enter Close(). |
491 Close(); | 496 Close(); |
492 listener()->OnChannelError(); | 497 listener()->OnChannelError(); |
493 } | 498 } |
(...skipping 30 matching lines...) Expand all Loading... |
524 int secret; | 529 int secret; |
525 do { // Guarantee we get a non-zero value. | 530 do { // Guarantee we get a non-zero value. |
526 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 531 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
527 } while (secret == 0); | 532 } while (secret == 0); |
528 | 533 |
529 id.append(GenerateUniqueRandomChannelID()); | 534 id.append(GenerateUniqueRandomChannelID()); |
530 return id.append(base::StringPrintf("\\%d", secret)); | 535 return id.append(base::StringPrintf("\\%d", secret)); |
531 } | 536 } |
532 | 537 |
533 } // namespace IPC | 538 } // namespace IPC |
OLD | NEW |