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

Unified Diff: base/message_loop/message_loop.cc

Issue 185413019: Used scoped_ptr in InitMessagePumpForUIFactory and CreateMessagePumpForType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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_loop.h ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop.cc
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 8f6c9d8cb6f0d0901d1a6d7fdb1d04b871adc6a9..ac9b44617db9cc007ceaacf3b540d5771981ec8b 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -87,7 +87,6 @@ const LinearHistogram::DescriptionPair event_descriptions_[] = {
bool enable_histogrammer_ = false;
MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL;
-
darin (slow to review) 2014/03/05 00:37:05 nit: I think it was better to have a new line here
// Returns true if MessagePump::ScheduleWork() must be called one
// time for every task that is added to the MessageLoop incoming queue.
bool AlwaysNotifyPump(MessageLoop::Type type) {
@@ -123,7 +122,7 @@ MessageLoop::MessageLoop(Type type)
run_loop_(NULL) {
Init();
- pump_.reset(CreateMessagePumpForType(type));
+ pump_.reset(CreateMessagePumpForType(type).release());
darin (slow to review) 2014/03/05 00:37:05 nit: you could also write: pump_ = CreateMessag
}
MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump)
@@ -190,36 +189,37 @@ void MessageLoop::EnableHistogrammer(bool enable) {
}
// static
-bool MessageLoop::InitMessagePumpForUIFactory(MessagePumpFactory* factory) {
+bool MessageLoop::InitMessagePumpForUIFactory(scoped_ptr<MessagePumpFactory>
+ factory) {
if (message_pump_for_ui_factory_)
return false;
- message_pump_for_ui_factory_ = factory;
+ message_pump_for_ui_factory_ = factory.release();
return true;
}
// static
-MessagePump* MessageLoop::CreateMessagePumpForType(Type type) {
+scoped_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
// TODO(rvargas): Get rid of the OS guards.
#if defined(OS_WIN)
-#define MESSAGE_PUMP_UI new MessagePumpForUI()
-#define MESSAGE_PUMP_IO new MessagePumpForIO()
+#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI())
+#define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpForIO())
#elif defined(OS_IOS)
-#define MESSAGE_PUMP_UI MessagePumpMac::Create()
-#define MESSAGE_PUMP_IO new MessagePumpIOSForIO()
+#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create())
+#define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpIOSForIO())
#elif defined(OS_MACOSX)
-#define MESSAGE_PUMP_UI MessagePumpMac::Create()
-#define MESSAGE_PUMP_IO new MessagePumpLibevent()
+#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(MessagePumpMac::Create())
+#define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent())
#elif defined(OS_NACL)
// Currently NaCl doesn't have a UI MessageLoop.
// TODO(abarth): Figure out if we need this.
-#define MESSAGE_PUMP_UI NULL
+#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>()
// ipc_channel_nacl.cc uses a worker thread to do socket reads currently, and
// doesn't require extra support for watching file descriptors.
-#define MESSAGE_PUMP_IO new MessagePumpDefault()
+#define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpDefault())
#elif defined(OS_POSIX) // POSIX but not MACOSX.
-#define MESSAGE_PUMP_UI new MessagePumpForUI()
-#define MESSAGE_PUMP_IO new MessagePumpLibevent()
+#define MESSAGE_PUMP_UI scoped_ptr<MessagePump>(new MessagePumpForUI())
+#define MESSAGE_PUMP_IO scoped_ptr<MessagePump>(new MessagePumpLibevent())
#else
#error Not implemented
#endif
@@ -240,7 +240,7 @@ MessagePump* MessageLoop::CreateMessagePumpForType(Type type) {
return MESSAGE_PUMP_UI;
#endif
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
- return new MessagePumpDefault();
+ return scoped_ptr<MessagePump>(new MessagePumpDefault());
}
void MessageLoop::AddDestructionObserver(
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698