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

Unified Diff: trunk/src/mojo/system/raw_channel_win.cc

Issue 449063003: Revert 286239 "Reland r285211: "Debugging RawChannelWin: replace..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/mojo/system/raw_channel.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/mojo/system/raw_channel_win.cc
===================================================================
--- trunk/src/mojo/system/raw_channel_win.cc (revision 288091)
+++ trunk/src/mojo/system/raw_channel_win.cc (working copy)
@@ -9,7 +9,6 @@
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/compiler_specific.h"
-#include "base/debug/alias.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
@@ -89,30 +88,6 @@
// - there is no pending write.
class RawChannelIOHandler : public base::MessageLoopForIO::IOHandler {
public:
- // TODO(yzshen): This is for debugging http://crbug.com/385795.
- // This code should be removed once the issue is fixed or nothing is
- // revealed by it. (No later than Aug 1, 2014.)
- struct WriteStats {
- WriteStats()
- : write_no_lock_call(0),
- schedule_write_no_lock_call(0),
- os_write_call(0),
- os_write_pending(0),
- os_write_failure(0),
- task_posted_by_schedule_write(0),
- write_completion(0),
- write_completion_failure(0) {}
-
- uint32_t write_no_lock_call;
- uint32_t schedule_write_no_lock_call;
- uint32_t os_write_call;
- uint32_t os_write_pending;
- uint32_t os_write_failure;
- uint32_t task_posted_by_schedule_write;
- uint32_t write_completion;
- uint32_t write_completion_failure;
- };
-
RawChannelIOHandler(RawChannelWin* owner,
embedder::ScopedPlatformHandle handle);
@@ -130,7 +105,6 @@
base::MessageLoopForIO::IOContext* write_context_no_lock();
// Instructs the object to wait for an |OnIOCompleted()| notification.
void OnPendingWriteStartedNoLock();
- WriteStats* write_stats_no_lock();
// |base::MessageLoopForIO::IOHandler| implementation:
// Must be called on the I/O thread. It could be called before or after
@@ -182,8 +156,6 @@
bool pending_write_;
base::MessageLoopForIO::IOContext write_context_;
- WriteStats write_stats_;
-
DISALLOW_COPY_AND_ASSIGN(RawChannelIOHandler);
};
@@ -227,74 +199,55 @@
}
RawChannelWin::RawChannelIOHandler::~RawChannelIOHandler() {
- CHECK(ShouldSelfDestruct());
-
- VLOG(4) << "write_no_lock_call: " << write_stats_.write_no_lock_call << "\n"
- << "schedule_write_no_lock_call: "
- << write_stats_.schedule_write_no_lock_call << "\n"
- << "os_write_call: " << write_stats_.os_write_call << "\n"
- << "os_write_pending: " << write_stats_.os_write_pending << "\n"
- << "os_write_failure: " << write_stats_.os_write_failure << "\n"
- << "task_posted_by_schedule_write: "
- << write_stats_.task_posted_by_schedule_write << "\n"
- << "write_completion: " << write_stats_.write_completion << "\n"
- << "write_completion_failure: "
- << write_stats_.write_completion_failure << "\n";
+ DCHECK(ShouldSelfDestruct());
}
bool RawChannelWin::RawChannelIOHandler::pending_read() const {
- CHECK(owner_);
- CHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
+ DCHECK(owner_);
+ DCHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
return pending_read_;
}
base::MessageLoopForIO::IOContext*
RawChannelWin::RawChannelIOHandler::read_context() {
- CHECK(owner_);
- CHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
+ DCHECK(owner_);
+ DCHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
return &read_context_;
}
void RawChannelWin::RawChannelIOHandler::OnPendingReadStarted() {
- CHECK(owner_);
- CHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
- CHECK(!pending_read_);
+ DCHECK(owner_);
+ DCHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
+ DCHECK(!pending_read_);
pending_read_ = true;
}
bool RawChannelWin::RawChannelIOHandler::pending_write_no_lock() const {
- CHECK(owner_);
+ DCHECK(owner_);
owner_->write_lock().AssertAcquired();
return pending_write_;
}
base::MessageLoopForIO::IOContext*
RawChannelWin::RawChannelIOHandler::write_context_no_lock() {
- CHECK(owner_);
+ DCHECK(owner_);
owner_->write_lock().AssertAcquired();
return &write_context_;
}
void RawChannelWin::RawChannelIOHandler::OnPendingWriteStartedNoLock() {
- CHECK(owner_);
+ DCHECK(owner_);
owner_->write_lock().AssertAcquired();
- CHECK(!pending_write_);
+ DCHECK(!pending_write_);
pending_write_ = true;
}
-RawChannelWin::RawChannelIOHandler::WriteStats*
-RawChannelWin::RawChannelIOHandler::write_stats_no_lock() {
- CHECK(owner_);
- owner_->write_lock().AssertAcquired();
- return &write_stats_;
-}
-
void RawChannelWin::RawChannelIOHandler::OnIOCompleted(
base::MessageLoopForIO::IOContext* context,
DWORD bytes_transferred,
DWORD error) {
- CHECK(!owner_ ||
- base::MessageLoop::current() == owner_->message_loop_for_io());
+ DCHECK(!owner_ ||
+ base::MessageLoop::current() == owner_->message_loop_for_io());
{
// Suppress self-destruction inside |OnReadCompleted()|, etc. (in case they
@@ -316,8 +269,8 @@
void RawChannelWin::RawChannelIOHandler::DetachFromOwnerNoLock(
scoped_ptr<ReadBuffer> read_buffer,
scoped_ptr<WriteBuffer> write_buffer) {
- CHECK(owner_);
- CHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
+ DCHECK(owner_);
+ DCHECK_EQ(base::MessageLoop::current(), owner_->message_loop_for_io());
owner_->write_lock().AssertAcquired();
// If read/write is pending, we have to retain the corresponding buffer.
@@ -341,9 +294,9 @@
void RawChannelWin::RawChannelIOHandler::OnReadCompleted(DWORD bytes_read,
DWORD error) {
- CHECK(!owner_ ||
- base::MessageLoop::current() == owner_->message_loop_for_io());
- CHECK(suppress_self_destruct_);
+ DCHECK(!owner_ ||
+ base::MessageLoop::current() == owner_->message_loop_for_io());
+ DCHECK(suppress_self_destruct_);
CHECK(pending_read_);
pending_read_ = false;
@@ -351,33 +304,24 @@
return;
if (error != ERROR_SUCCESS) {
- CHECK_EQ(bytes_read, 0u);
+ DCHECK_EQ(bytes_read, 0u);
LOG_IF(ERROR, error != ERROR_BROKEN_PIPE)
<< "ReadFile: " << logging::SystemErrorCodeToString(error);
owner_->OnReadCompleted(false, 0);
} else {
- CHECK_GT(bytes_read, 0u);
+ DCHECK_GT(bytes_read, 0u);
owner_->OnReadCompleted(true, bytes_read);
}
}
void RawChannelWin::RawChannelIOHandler::OnWriteCompleted(DWORD bytes_written,
DWORD error) {
- CHECK(!owner_ ||
- base::MessageLoop::current() == owner_->message_loop_for_io());
- CHECK(suppress_self_destruct_);
+ DCHECK(!owner_ ||
+ base::MessageLoop::current() == owner_->message_loop_for_io());
+ DCHECK(suppress_self_destruct_);
- WriteStats stack_copy;
- base::debug::Alias(&stack_copy);
-
if (!owner_) {
// No lock needed.
-
- write_stats_.write_completion++;
- if (error != ERROR_SUCCESS)
- write_stats_.write_completion_failure++;
- stack_copy = write_stats_;
-
CHECK(pending_write_);
pending_write_ = false;
return;
@@ -385,12 +329,6 @@
{
base::AutoLock locker(owner_->write_lock());
-
- write_stats_.write_completion++;
- if (error != ERROR_SUCCESS)
- write_stats_.write_completion_failure++;
- stack_copy = write_stats_;
-
CHECK(pending_write_);
pending_write_ = false;
}
@@ -408,11 +346,11 @@
io_handler_(NULL),
skip_completion_port_on_success_(
g_vista_or_higher_functions.Get().is_vista_or_higher()) {
- CHECK(handle_.is_valid());
+ DCHECK(handle_.is_valid());
}
RawChannelWin::~RawChannelWin() {
- CHECK(!io_handler_);
+ DCHECK(!io_handler_);
}
size_t RawChannelWin::GetSerializedPlatformHandleSize() const {
@@ -421,9 +359,9 @@
}
RawChannel::IOResult RawChannelWin::Read(size_t* bytes_read) {
- CHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
- CHECK(io_handler_);
- CHECK(!io_handler_->pending_read());
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
+ DCHECK(io_handler_);
+ DCHECK(!io_handler_->pending_read());
char* buffer = NULL;
size_t bytes_to_read = 0;
@@ -436,7 +374,7 @@
&bytes_read_dword,
&io_handler_->read_context()->overlapped);
if (!result) {
- CHECK_EQ(bytes_read_dword, 0u);
+ DCHECK_EQ(bytes_read_dword, 0u);
DWORD error = GetLastError();
if (error != ERROR_IO_PENDING) {
LOG_IF(ERROR, error != ERROR_BROKEN_PIPE)
@@ -464,14 +402,14 @@
}
RawChannel::IOResult RawChannelWin::ScheduleRead() {
- CHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
- CHECK(io_handler_);
- CHECK(!io_handler_->pending_read());
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
+ DCHECK(io_handler_);
+ DCHECK(!io_handler_->pending_read());
size_t bytes_read = 0;
IOResult io_result = Read(&bytes_read);
if (io_result == IO_SUCCEEDED) {
- CHECK(skip_completion_port_on_success_);
+ DCHECK(skip_completion_port_on_success_);
// We have finished reading successfully. Queue a notification manually.
io_handler_->OnPendingReadStarted();
@@ -503,16 +441,9 @@
size_t* bytes_written) {
write_lock().AssertAcquired();
- RawChannelIOHandler::WriteStats stack_copy(
- *io_handler_->write_stats_no_lock());
- base::debug::Alias(&stack_copy);
+ DCHECK(io_handler_);
+ DCHECK(!io_handler_->pending_write_no_lock());
- io_handler_->write_stats_no_lock()->write_no_lock_call++;
- stack_copy.write_no_lock_call++;
-
- CHECK(io_handler_);
- CHECK(!io_handler_->pending_write_no_lock());
-
if (write_buffer_no_lock()->HavePlatformHandlesToSend()) {
// TODO(vtl): Implement.
NOTIMPLEMENTED();
@@ -520,11 +451,8 @@
std::vector<WriteBuffer::Buffer> buffers;
write_buffer_no_lock()->GetBuffers(&buffers);
- CHECK(!buffers.empty());
+ DCHECK(!buffers.empty());
- io_handler_->write_stats_no_lock()->os_write_call++;
- stack_copy.os_write_call++;
-
// TODO(yzshen): Handle multi-segment writes more efficiently.
DWORD bytes_written_dword = 0;
BOOL result = WriteFile(io_handler_->handle(),
@@ -532,18 +460,9 @@
static_cast<DWORD>(buffers[0].size),
&bytes_written_dword,
&io_handler_->write_context_no_lock()->overlapped);
-
- if (!result) {
- if (GetLastError() == ERROR_IO_PENDING) {
- io_handler_->write_stats_no_lock()->os_write_pending++;
- stack_copy.os_write_pending++;
- } else {
- io_handler_->write_stats_no_lock()->os_write_failure++;
- stack_copy.os_write_failure++;
-
- PLOG(ERROR) << "WriteFile";
- return IO_FAILED;
- }
+ if (!result && GetLastError() != ERROR_IO_PENDING) {
+ PLOG(ERROR) << "WriteFile";
+ return IO_FAILED;
}
if (result && skip_completion_port_on_success_) {
@@ -568,29 +487,18 @@
RawChannel::IOResult RawChannelWin::ScheduleWriteNoLock() {
write_lock().AssertAcquired();
- RawChannelIOHandler::WriteStats stack_copy(
- *io_handler_->write_stats_no_lock());
- base::debug::Alias(&stack_copy);
+ DCHECK(io_handler_);
+ DCHECK(!io_handler_->pending_write_no_lock());
- io_handler_->write_stats_no_lock()->schedule_write_no_lock_call++;
- stack_copy.schedule_write_no_lock_call++;
-
- CHECK(io_handler_);
- CHECK(!io_handler_->pending_write_no_lock());
-
// TODO(vtl): Do something with |platform_handles_written|.
size_t platform_handles_written = 0;
size_t bytes_written = 0;
IOResult io_result = WriteNoLock(&platform_handles_written, &bytes_written);
if (io_result == IO_SUCCEEDED) {
- CHECK(skip_completion_port_on_success_);
+ DCHECK(skip_completion_port_on_success_);
// We have finished writing successfully. Queue a notification manually.
io_handler_->OnPendingWriteStartedNoLock();
-
- io_handler_->write_stats_no_lock()->task_posted_by_schedule_write++;
- stack_copy.task_posted_by_schedule_write++;
-
// |io_handler_| won't go away before that task is run, so it is safe to use
// |base::Unretained()|.
message_loop_for_io()->PostTask(
@@ -607,16 +515,16 @@
}
bool RawChannelWin::OnInit() {
- CHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
- CHECK(handle_.is_valid());
+ DCHECK(handle_.is_valid());
if (skip_completion_port_on_success_ &&
!g_vista_or_higher_functions.Get().SetFileCompletionNotificationModes(
handle_.get().handle, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
return false;
}
- CHECK(!io_handler_);
+ DCHECK(!io_handler_);
io_handler_ = new RawChannelIOHandler(this, handle_.Pass());
return true;
@@ -624,8 +532,8 @@
void RawChannelWin::OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
scoped_ptr<WriteBuffer> write_buffer) {
- CHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
- CHECK(io_handler_);
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
+ DCHECK(io_handler_);
write_lock().AssertAcquired();
« no previous file with comments | « trunk/src/mojo/system/raw_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698