diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 04:50:43 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 04:50:43 +0000 |
commit | 2d0faf1987d552da78ac84f195c35812b387924b (patch) | |
tree | 7a8e271f83ed01b4f19790c538ea3b325b48282d /ipc/ipc_channel_win.cc | |
parent | c62fc9819f6682a98d3e1893c821d795fea3bb1a (diff) | |
download | chromium_src-2d0faf1987d552da78ac84f195c35812b387924b.zip chromium_src-2d0faf1987d552da78ac84f195c35812b387924b.tar.gz chromium_src-2d0faf1987d552da78ac84f195c35812b387924b.tar.bz2 |
IPC ChannelWin: Add temporary debug info.
Add some state tracking info to the channel object while working on a crash.
BUG=387876
Review URL: https://codereview.chromium.org/355943002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_win.cc')
-rw-r--r-- | ipc/ipc_channel_win.cc | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/ipc/ipc_channel_win.cc b/ipc/ipc_channel_win.cc index 2f6bc9b..9741dda 100644 --- a/ipc/ipc_channel_win.cc +++ b/ipc/ipc_channel_win.cc @@ -21,6 +21,27 @@ #include "ipc/ipc_logging.h" #include "ipc/ipc_message_utils.h" +namespace { + +enum DebugFlags { + INIT_DONE = 1 << 0, + CALLED_CONNECT = 1 << 1, + PENDING_CONNECT = 1 << 2, + CONNECT_COMPLETED = 1 << 3, + PIPE_CONNECTED = 1 << 4, + WRITE_MSG = 1 << 5, + READ_MSG = 1 << 6, + WRITE_COMPLETED = 1 << 7, + READ_COMPLETED = 1 << 8, + CLOSED = 1 << 9, + WAIT_FOR_READ = 1 << 10, + WAIT_FOR_WRITE = 1 << 11, + WAIT_FOR_READ_COMPLETE = 1 << 12, + WAIT_FOR_WRITE_COMPLETE = 1 << 13 +}; + +} // namespace + namespace IPC { ChannelWin::State::State(ChannelWin* channel) : is_pending(false) { @@ -34,7 +55,7 @@ ChannelWin::State::~State() { } ChannelWin::ChannelWin(const IPC::ChannelHandle &channel_handle, - Mode mode, Listener* listener) + Mode mode, Listener* listener) : ChannelReader(listener), input_state_(this), output_state_(this), @@ -43,8 +64,9 @@ ChannelWin::ChannelWin(const IPC::ChannelHandle &channel_handle, waiting_connect_(mode & MODE_SERVER_FLAG), processing_incoming_(false), weak_factory_(this), - client_secret_(0), - validate_client_(false) { + validate_client_(false), + debug_flags_(0), + client_secret_(0) { CreatePipe(channel_handle, mode); } @@ -56,6 +78,7 @@ void ChannelWin::Close() { if (thread_check_.get()) { DCHECK(thread_check_->CalledOnValidThread()); } + debug_flags_ |= CLOSED; if (input_state_.is_pending || output_state_.is_pending) CancelIo(pipe_); @@ -67,6 +90,12 @@ void ChannelWin::Close() { pipe_ = INVALID_HANDLE_VALUE; } + if (input_state_.is_pending) + debug_flags_ |= WAIT_FOR_READ; + + if (output_state_.is_pending) + debug_flags_ |= WAIT_FOR_WRITE; + // Make sure all IO has completed. base::Time start = base::Time::Now(); while (input_state_.is_pending || output_state_.is_pending) { @@ -124,6 +153,7 @@ ChannelWin::ReadState ChannelWin::ReadData( if (INVALID_HANDLE_VALUE == pipe_) return READ_FAILED; + debug_flags_ |= READ_MSG; DWORD bytes_read = 0; BOOL ok = ReadFile(pipe_, buffer, buffer_len, &bytes_read, &input_state_.context.overlapped); @@ -285,6 +315,8 @@ bool ChannelWin::CreatePipe(const IPC::ChannelHandle &channel_handle, return false; } + debug_flags_ |= INIT_DONE; + output_queue_.push(m.release()); return true; } @@ -332,6 +364,7 @@ bool ChannelWin::ProcessConnection() { return false; BOOL ok = ConnectNamedPipe(pipe_, &input_state_.context.overlapped); + debug_flags_ |= CALLED_CONNECT; DWORD err = GetLastError(); if (ok) { @@ -344,8 +377,10 @@ bool ChannelWin::ProcessConnection() { switch (err) { case ERROR_IO_PENDING: input_state_.is_pending = true; + debug_flags_ |= PENDING_CONNECT; break; case ERROR_PIPE_CONNECTED: + debug_flags_ |= PIPE_CONNECTED; waiting_connect_ = false; break; case ERROR_NO_DATA: @@ -390,6 +425,7 @@ bool ChannelWin::ProcessOutgoingMessages( // Write to pipe... Message* m = output_queue_.front(); DCHECK(m->size() <= INT_MAX); + debug_flags_ |= WRITE_MSG; BOOL ok = WriteFile(pipe_, m->data(), static_cast<int>(m->size()), @@ -424,6 +460,7 @@ void ChannelWin::OnIOCompleted( DCHECK(thread_check_->CalledOnValidThread()); if (context == &input_state_.context) { if (waiting_connect_) { + debug_flags_ |= CONNECT_COMPLETED; if (!ProcessConnection()) return; // We may have some messages queued up to send... @@ -442,6 +479,11 @@ void ChannelWin::OnIOCompleted( // Process the new data. if (input_state_.is_pending) { // This is the normal case for everything except the initialization step. + debug_flags_ |= READ_COMPLETED; + if (debug_flags_ & WAIT_FOR_READ) { + CHECK(!(debug_flags_ & WAIT_FOR_READ_COMPLETE)); + debug_flags_ |= WAIT_FOR_READ_COMPLETE; + } input_state_.is_pending = false; if (!bytes_transfered) ok = false; @@ -456,6 +498,11 @@ void ChannelWin::OnIOCompleted( ok = ProcessIncomingMessages(); } else { DCHECK(context == &output_state_.context); + debug_flags_ |= WRITE_COMPLETED; + if (debug_flags_ & WAIT_FOR_WRITE) { + CHECK(!(debug_flags_ & WAIT_FOR_WRITE_COMPLETE)); + debug_flags_ |= WAIT_FOR_WRITE_COMPLETE; + } ok = ProcessOutgoingMessages(context, bytes_transfered); } if (!ok && INVALID_HANDLE_VALUE != pipe_) { |