Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: ipc/ipc_channel_win.cc

Issue 427693004: IPC: Add more debug logic (crash tracking) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 ChannelWin::ChannelWin(const IPC::ChannelHandle &channel_handle, 57 ChannelWin::ChannelWin(const IPC::ChannelHandle &channel_handle,
58 Mode mode, Listener* listener) 58 Mode mode, Listener* listener)
59 : ChannelReader(listener), 59 : ChannelReader(listener),
60 input_state_(this), 60 input_state_(this),
61 output_state_(this), 61 output_state_(this),
62 pipe_(INVALID_HANDLE_VALUE), 62 pipe_(INVALID_HANDLE_VALUE),
63 peer_pid_(base::kNullProcessId), 63 peer_pid_(base::kNullProcessId),
64 waiting_connect_(mode & MODE_SERVER_FLAG), 64 waiting_connect_(mode & MODE_SERVER_FLAG),
65 processing_incoming_(false), 65 processing_incoming_(false),
66 weak_factory_(this),
67 validate_client_(false), 66 validate_client_(false),
67 writing_(false),
68 debug_flags_(0), 68 debug_flags_(0),
69 client_secret_(0) { 69 client_secret_(0),
70 weak_factory_(this) {
70 CreatePipe(channel_handle, mode); 71 CreatePipe(channel_handle, mode);
71 } 72 }
72 73
73 ChannelWin::~ChannelWin() { 74 ChannelWin::~ChannelWin() {
74 Close(); 75 Close();
75 } 76 }
76 77
77 void ChannelWin::Close() { 78 void ChannelWin::Close() {
78 if (thread_check_.get()) { 79 if (thread_check_.get()) {
79 DCHECK(thread_check_->CalledOnValidThread()); 80 DCHECK(thread_check_->CalledOnValidThread());
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (output_queue_.empty()) 420 if (output_queue_.empty())
420 return true; 421 return true;
421 422
422 if (INVALID_HANDLE_VALUE == pipe_) 423 if (INVALID_HANDLE_VALUE == pipe_)
423 return false; 424 return false;
424 425
425 // Write to pipe... 426 // Write to pipe...
426 Message* m = output_queue_.front(); 427 Message* m = output_queue_.front();
427 DCHECK(m->size() <= INT_MAX); 428 DCHECK(m->size() <= INT_MAX);
428 debug_flags_ |= WRITE_MSG; 429 debug_flags_ |= WRITE_MSG;
430 CHECK(!writing_);
431 writing_ = true;
429 BOOL ok = WriteFile(pipe_, 432 BOOL ok = WriteFile(pipe_,
430 m->data(), 433 m->data(),
431 static_cast<int>(m->size()), 434 static_cast<int>(m->size()),
432 &bytes_written, 435 &bytes_written,
433 &output_state_.context.overlapped); 436 &output_state_.context.overlapped);
434 if (!ok) { 437 if (!ok) {
435 DWORD err = GetLastError(); 438 DWORD err = GetLastError();
436 if (err == ERROR_IO_PENDING) { 439 if (err == ERROR_IO_PENDING) {
437 output_state_.is_pending = true; 440 output_state_.is_pending = true;
438 441
439 DVLOG(2) << "sent pending message @" << m << " on channel @" << this 442 DVLOG(2) << "sent pending message @" << m << " on channel @" << this
440 << " with type " << m->type(); 443 << " with type " << m->type();
441 444
cpu_(ooo_6.6-7.5) 2014/07/29 19:47:20 ERROR_IO_PENDING is the normal case, right? so wr
rvargas (doing something else) 2014/07/29 20:36:21 Because we are reusing the same overlapped structu
442 return true; 445 return true;
443 } 446 }
447 writing_ = false;
444 LOG(ERROR) << "pipe error: " << err; 448 LOG(ERROR) << "pipe error: " << err;
445 return false; 449 return false;
446 } 450 }
447 451
448 DVLOG(2) << "sent message @" << m << " on channel @" << this 452 DVLOG(2) << "sent message @" << m << " on channel @" << this
449 << " with type " << m->type(); 453 << " with type " << m->type();
450 454
451 output_state_.is_pending = true; 455 output_state_.is_pending = true;
452 return true; 456 return true;
453 } 457 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 ok = AsyncReadComplete(bytes_transfered); 495 ok = AsyncReadComplete(bytes_transfered);
492 } else { 496 } else {
493 DCHECK(!bytes_transfered); 497 DCHECK(!bytes_transfered);
494 } 498 }
495 499
496 // Request more data. 500 // Request more data.
497 if (ok) 501 if (ok)
498 ok = ProcessIncomingMessages(); 502 ok = ProcessIncomingMessages();
499 } else { 503 } else {
500 DCHECK(context == &output_state_.context); 504 DCHECK(context == &output_state_.context);
505 CHECK(writing_);
506 CHECK(output_state_.is_pending);
507 writing_ = false;
501 debug_flags_ |= WRITE_COMPLETED; 508 debug_flags_ |= WRITE_COMPLETED;
502 if (debug_flags_ & WAIT_FOR_WRITE) { 509 if (debug_flags_ & WAIT_FOR_WRITE) {
503 CHECK(!(debug_flags_ & WAIT_FOR_WRITE_COMPLETE)); 510 CHECK(!(debug_flags_ & WAIT_FOR_WRITE_COMPLETE));
504 debug_flags_ |= WAIT_FOR_WRITE_COMPLETE; 511 debug_flags_ |= WAIT_FOR_WRITE_COMPLETE;
505 } 512 }
506 ok = ProcessOutgoingMessages(context, bytes_transfered); 513 ok = ProcessOutgoingMessages(context, bytes_transfered);
507 } 514 }
508 if (!ok && INVALID_HANDLE_VALUE != pipe_) { 515 if (!ok && INVALID_HANDLE_VALUE != pipe_) {
509 // We don't want to re-enter Close(). 516 // We don't want to re-enter Close().
510 Close(); 517 Close();
(...skipping 30 matching lines...) Expand all
541 int secret; 548 int secret;
542 do { // Guarantee we get a non-zero value. 549 do { // Guarantee we get a non-zero value.
543 secret = base::RandInt(0, std::numeric_limits<int>::max()); 550 secret = base::RandInt(0, std::numeric_limits<int>::max());
544 } while (secret == 0); 551 } while (secret == 0);
545 552
546 id.append(GenerateUniqueRandomChannelID()); 553 id.append(GenerateUniqueRandomChannelID());
547 return id.append(base::StringPrintf("\\%d", secret)); 554 return id.append(base::StringPrintf("\\%d", secret));
548 } 555 }
549 556
550 } // namespace IPC 557 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698