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

Unified Diff: base/message_loop/message_pump_io_ios.cc

Issue 19661004: Made MessagePump a non-thread safe class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding a missing header. Created 7 years, 5 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 | « base/message_loop/message_pump_io_ios.h ('k') | base/message_loop/message_pump_io_ios_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_io_ios.cc
diff --git a/base/message_loop/message_pump_io_ios.cc b/base/message_loop/message_pump_io_ios.cc
index 0dd6930fe705d1c67b4992528eed2c96ddd3d383..cd5ffed4b9969da61223338d74a6820b40b9a3b8 100644
--- a/base/message_loop/message_pump_io_ios.cc
+++ b/base/message_loop/message_pump_io_ios.cc
@@ -11,7 +11,6 @@ MessagePumpIOSForIO::FileDescriptorWatcher::FileDescriptorWatcher()
fdref_(NULL),
callback_types_(0),
fd_source_(NULL),
- pump_(NULL),
watcher_(NULL) {
}
@@ -24,11 +23,12 @@ bool MessagePumpIOSForIO::FileDescriptorWatcher::StopWatchingFileDescriptor() {
return true;
CFFileDescriptorDisableCallBacks(fdref_, callback_types_);
- pump_->RemoveRunLoopSource(fd_source_);
+ if (pump_)
+ pump_->RemoveRunLoopSource(fd_source_);
fd_source_.reset();
fdref_.reset();
callback_types_ = 0;
- pump_ = NULL;
+ pump_.reset();
watcher_ = NULL;
return true;
}
@@ -65,7 +65,7 @@ void MessagePumpIOSForIO::FileDescriptorWatcher::OnFileCanWriteWithoutBlocking(
pump->DidProcessIOEvent();
}
-MessagePumpIOSForIO::MessagePumpIOSForIO() {
+MessagePumpIOSForIO::MessagePumpIOSForIO() : weak_factory_(this) {
}
MessagePumpIOSForIO::~MessagePumpIOSForIO() {
@@ -143,7 +143,7 @@ bool MessagePumpIOSForIO::WatchFileDescriptor(
}
controller->set_watcher(delegate);
- controller->set_pump(this);
+ controller->set_pump(weak_factory_.GetWeakPtr());
return true;
}
@@ -183,7 +183,8 @@ void MessagePumpIOSForIO::HandleFdIOEvent(CFFileDescriptorRef fdref,
fdref, base::scoped_policy::RETAIN);
int fd = CFFileDescriptorGetNativeDescriptor(fdref);
- MessagePumpIOSForIO* pump = controller->pump();
+ MessagePumpIOSForIO* pump = controller->pump().get();
+ DCHECK(pump);
if (callback_types & kCFFileDescriptorWriteCallBack)
controller->OnFileCanWriteWithoutBlocking(fd, pump);
« no previous file with comments | « base/message_loop/message_pump_io_ios.h ('k') | base/message_loop/message_pump_io_ios_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698