diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-25 11:39:07 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-01-25 15:20:42 +0000 |
commit | 6c91641271e536ffaa88a1dff5127e42ee99a91e (patch) | |
tree | 703d9dd49602377ddc90cbf886aad37913f2496b /chromium/base/message_loop | |
parent | b145b7fafd36f0c260d6a768c81fc14e32578099 (diff) |
BASELINE: Update Chromium to 49.0.2623.23
Also adds missing printing sources.
Change-Id: I3726b8f0c7d6751c9fc846096c571fadca7108cd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/base/message_loop')
24 files changed, 119 insertions, 78 deletions
diff --git a/chromium/base/message_loop/incoming_task_queue.cc b/chromium/base/message_loop/incoming_task_queue.cc index eab14e9b707..d02bbc72952 100644 --- a/chromium/base/message_loop/incoming_task_queue.cc +++ b/chromium/base/message_loop/incoming_task_queue.cc @@ -11,6 +11,7 @@ #include "base/metrics/histogram.h" #include "base/synchronization/waitable_event.h" #include "base/time/time.h" +#include "build/build_config.h" namespace base { namespace internal { diff --git a/chromium/base/message_loop/incoming_task_queue.h b/chromium/base/message_loop/incoming_task_queue.h index 7dd1e823129..e450aa164fa 100644 --- a/chromium/base/message_loop/incoming_task_queue.h +++ b/chromium/base/message_loop/incoming_task_queue.h @@ -6,6 +6,7 @@ #define BASE_MESSAGE_LOOP_INCOMING_TASK_QUEUE_H_ #include "base/base_export.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/pending_task.h" #include "base/synchronization/lock.h" diff --git a/chromium/base/message_loop/message_loop.cc b/chromium/base/message_loop/message_loop.cc index a44f46863e4..e84765a0f7a 100644 --- a/chromium/base/message_loop/message_loop.cc +++ b/chromium/base/message_loop/message_loop.cc @@ -5,6 +5,7 @@ #include "base/message_loop/message_loop.h" #include <algorithm> +#include <utility> #include "base/bind.h" #include "base/compiler_specific.h" @@ -21,6 +22,7 @@ #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "base/tracked_objects.h" +#include "build/build_config.h" #if defined(OS_MACOSX) #include "base/message_loop/message_pump_mac.h" @@ -131,9 +133,11 @@ MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump) } MessageLoop::~MessageLoop() { - // current() could be NULL if this message loop is destructed before it is - // bound to a thread. - DCHECK(current() == this || !current()); + // If |pump_| is non-null, this message loop has been bound and should be the + // current one on this thread. Otherwise, this loop is being destructed before + // it was bound to a thread, so a different message loop (or no loop at all) + // may be current. + DCHECK((pump_ && current() == this) || (!pump_ && current() != this)); // iOS just attaches to the loop, it doesn't Run it. // TODO(stuartmorgan): Consider wiring up a Detach(). @@ -175,7 +179,8 @@ MessageLoop::~MessageLoop() { task_runner_ = NULL; // OK, now make it so that no one can find us. - lazy_tls_ptr.Pointer()->Set(NULL); + if (current() == this) + lazy_tls_ptr.Pointer()->Set(nullptr); } // static @@ -417,7 +422,7 @@ void MessageLoop::SetTaskRunner( DCHECK_EQ(this, current()); DCHECK(task_runner->BelongsToCurrentThread()); DCHECK(!unbound_task_runner_); - task_runner_ = task_runner.Pass(); + task_runner_ = std::move(task_runner); SetThreadTaskRunnerHandle(); } diff --git a/chromium/base/message_loop/message_loop.h b/chromium/base/message_loop/message_loop.h index 63a29f15e95..8ef8d6a21ff 100644 --- a/chromium/base/message_loop/message_loop.h +++ b/chromium/base/message_loop/message_loop.h @@ -9,10 +9,11 @@ #include <string> #include "base/base_export.h" -#include "base/basictypes.h" #include "base/callback_forward.h" #include "base/debug/task_annotator.h" +#include "base/gtest_prod_util.h" #include "base/location.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/incoming_task_queue.h" @@ -25,6 +26,7 @@ #include "base/synchronization/lock.h" #include "base/time/time.h" #include "base/tracking_info.h" +#include "build/build_config.h" // TODO(sky): these includes should not be necessary. Nuke them. #if defined(OS_WIN) @@ -242,9 +244,6 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { // Return as soon as all items that can be run are taken care of. void RunUntilIdle(); - // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdle(). - void Quit() { QuitWhenIdle(); } - // Deprecated: use RunLoop instead. // // Signals the Run method to return when it becomes idle. It will continue to @@ -268,9 +267,6 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { // to be processed before returning from Run. void QuitNow(); - // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure(). - static Closure QuitClosure() { return QuitWhenIdleClosure(); } - // Deprecated: use RunLoop instead. // Construct a Closure that will call QuitWhenIdle(). Useful to schedule an // arbitrary MessageLoop to QuitWhenIdle. @@ -408,6 +404,7 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate { friend class internal::IncomingTaskQueue; friend class ScheduleWorkTest; friend class Thread; + FRIEND_TEST_ALL_PREFIXES(MessageLoopTest, DeleteUnboundLoop); using MessagePumpFactoryCallback = Callback<scoped_ptr<MessagePump>()>; @@ -607,8 +604,8 @@ class BASE_EXPORT MessageLoopForUI : public MessageLoop { // Do not add any member variables to MessageLoopForUI! This is important b/c // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra // data that you need should be stored on the MessageLoop's pump_ instance. -COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), - MessageLoopForUI_should_not_have_extra_member_variables); +static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForUI), + "MessageLoopForUI should not have extra member variables"); #endif // !defined(OS_NACL) @@ -688,8 +685,8 @@ class BASE_EXPORT MessageLoopForIO : public MessageLoop { // Do not add any member variables to MessageLoopForIO! This is important b/c // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra // data that you need should be stored on the MessageLoop's pump_ instance. -COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), - MessageLoopForIO_should_not_have_extra_member_variables); +static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), + "MessageLoopForIO should not have extra member variables"); } // namespace base diff --git a/chromium/base/message_loop/message_loop_task_runner.h b/chromium/base/message_loop/message_loop_task_runner.h index dc2947df26c..5e70b128b20 100644 --- a/chromium/base/message_loop/message_loop_task_runner.h +++ b/chromium/base/message_loop/message_loop_task_runner.h @@ -6,6 +6,7 @@ #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_TASK_RUNNER_H_ #include "base/base_export.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/pending_task.h" #include "base/single_thread_task_runner.h" diff --git a/chromium/base/message_loop/message_loop_test.cc b/chromium/base/message_loop/message_loop_test.cc index eca6c8f2452..ac50d648481 100644 --- a/chromium/base/message_loop/message_loop_test.cc +++ b/chromium/base/message_loop/message_loop_test.cc @@ -4,7 +4,12 @@ #include "base/message_loop/message_loop_test.h" +#include <stddef.h> + +#include <utility> + #include "base/bind.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/run_loop.h" #include "base/synchronization/waitable_event.h" @@ -87,7 +92,7 @@ void RecordRunTimeFunc(Time* run_time, int* quit_counter) { void RunTest_PostTask(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Add tests to message loop scoped_refptr<Foo> foo(new Foo()); std::string a("a"), b("b"), c("c"), d("d"); @@ -104,8 +109,9 @@ void RunTest_PostTask(MessagePumpFactory factory) { MessageLoop::current()->PostTask(FROM_HERE, Bind( &Foo::Test2Mixed, foo.get(), a, &d)); // After all tests, post a message that will shut down the message loop - MessageLoop::current()->PostTask(FROM_HERE, Bind( - &MessageLoop::Quit, Unretained(MessageLoop::current()))); + MessageLoop::current()->PostTask( + FROM_HERE, + Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current()))); // Now kick things off MessageLoop::current()->Run(); @@ -116,7 +122,7 @@ void RunTest_PostTask(MessagePumpFactory factory) { void RunTest_PostDelayedTask_Basic(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Test that PostDelayedTask results in a delayed task. @@ -139,7 +145,7 @@ void RunTest_PostDelayedTask_Basic(MessagePumpFactory factory) { void RunTest_PostDelayedTask_InDelayOrder(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Test that two tasks with different delays run in the right order. int num_tasks = 2; @@ -164,7 +170,7 @@ void RunTest_PostDelayedTask_InDelayOrder(MessagePumpFactory factory) { void RunTest_PostDelayedTask_InPostOrder(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Test that two tasks with the same delay run in the order in which they // were posted. @@ -194,7 +200,7 @@ void RunTest_PostDelayedTask_InPostOrder(MessagePumpFactory factory) { void RunTest_PostDelayedTask_InPostOrder_2(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Test that a delayed task still runs after a normal tasks even if the // normal tasks take a long time to run. @@ -221,7 +227,7 @@ void RunTest_PostDelayedTask_InPostOrder_2(MessagePumpFactory factory) { void RunTest_PostDelayedTask_InPostOrder_3(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Test that a delayed task still runs after a pile of normal tasks. The key // difference between this test and the previous one is that here we return @@ -249,7 +255,7 @@ void RunTest_PostDelayedTask_InPostOrder_3(MessagePumpFactory factory) { void RunTest_PostDelayedTask_SharedTimer(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // Test that the interval of the timer, used to run the next delayed task, is // set to a value corresponding to when the next delayed task should run. @@ -316,7 +322,7 @@ void RunTest_EnsureDeletion(MessagePumpFactory factory) { bool b_was_deleted = false; { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); loop.PostTask( FROM_HERE, Bind(&RecordDeletionProbe::Run, new RecordDeletionProbe(NULL, &a_was_deleted))); @@ -336,7 +342,7 @@ void RunTest_EnsureDeletion_Chain(MessagePumpFactory factory) { bool c_was_deleted = false; { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); // The scoped_refptr for each of the below is held either by the chained // RecordDeletionProbe, or the bound RecordDeletionProbe::Run() callback. RecordDeletionProbe* a = new RecordDeletionProbe(NULL, &a_was_deleted); @@ -363,7 +369,7 @@ void NestingFunc(int* depth) { void RunTest_Nesting(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); int depth = 100; MessageLoop::current()->PostTask(FROM_HERE, @@ -471,7 +477,7 @@ void QuitFunc(TaskList* order, int cookie) { } void RunTest_RecursiveDenial1(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed()); TaskList order; @@ -518,7 +524,7 @@ void OrderedFunc(TaskList* order, int cookie) { void RunTest_RecursiveDenial3(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed()); TaskList order; @@ -559,7 +565,7 @@ void RunTest_RecursiveDenial3(MessagePumpFactory factory) { void RunTest_RecursiveSupport1(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; MessageLoop::current()->PostTask( @@ -592,7 +598,7 @@ void RunTest_RecursiveSupport1(MessagePumpFactory factory) { // Tests that non nestable tasks run in FIFO if there are no nested loops. void RunTest_NonNestableWithNoNesting(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -634,7 +640,7 @@ void SleepFunc(TaskList* order, int cookie, TimeDelta delay) { void RunTest_NonNestableInNestedLoop(MessagePumpFactory factory, bool use_delayed) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -702,7 +708,7 @@ void FuncThatQuitsNow() { // Tests RunLoopQuit only quits the corresponding MessageLoop::Run. void RunTest_QuitNow(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -737,7 +743,7 @@ void RunTest_QuitNow(MessagePumpFactory factory) { // Tests RunLoopQuit only quits the corresponding MessageLoop::Run. void RunTest_RunLoopQuitTop(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -767,7 +773,7 @@ void RunTest_RunLoopQuitTop(MessagePumpFactory factory) { // Tests RunLoopQuit only quits the corresponding MessageLoop::Run. void RunTest_RunLoopQuitNested(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -797,7 +803,7 @@ void RunTest_RunLoopQuitNested(MessagePumpFactory factory) { // Tests RunLoopQuit only quits the corresponding MessageLoop::Run. void RunTest_RunLoopQuitBogus(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -830,7 +836,7 @@ void RunTest_RunLoopQuitBogus(MessagePumpFactory factory) { // Tests RunLoopQuit only quits the corresponding MessageLoop::Run. void RunTest_RunLoopQuitDeep(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -899,7 +905,7 @@ void RunTest_RunLoopQuitDeep(MessagePumpFactory factory) { // Tests RunLoopQuit works before RunWithID. void RunTest_RunLoopQuitOrderBefore(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -920,7 +926,7 @@ void RunTest_RunLoopQuitOrderBefore(MessagePumpFactory factory) { // Tests RunLoopQuit works during RunWithID. void RunTest_RunLoopQuitOrderDuring(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -947,7 +953,7 @@ void RunTest_RunLoopQuitOrderDuring(MessagePumpFactory factory) { // Tests RunLoopQuit works after RunWithID. void RunTest_RunLoopQuitOrderAfter(MessagePumpFactory factory) { scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); TaskList order; @@ -1005,7 +1011,7 @@ void PostNTasksThenQuit(int posts_remaining) { void RunTest_RecursivePosts(MessagePumpFactory factory) { const int kNumTimes = 1 << 17; scoped_ptr<MessagePump> pump(factory()); - MessageLoop loop(pump.Pass()); + MessageLoop loop(std::move(pump)); loop.PostTask(FROM_HERE, Bind(&PostNTasksThenQuit, kNumTimes)); loop.Run(); } diff --git a/chromium/base/message_loop/message_loop_unittest.cc b/chromium/base/message_loop/message_loop_unittest.cc index 89f9a40a5ef..1a3a9257007 100644 --- a/chromium/base/message_loop/message_loop_unittest.cc +++ b/chromium/base/message_loop/message_loop_unittest.cc @@ -2,12 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include <vector> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/compiler_specific.h" #include "base/logging.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_test.h" @@ -19,6 +23,7 @@ #include "base/thread_task_runner_handle.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" +#include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(OS_WIN) @@ -336,7 +341,7 @@ void RunTest_RecursiveDenial2(MessageLoop::Type message_loop_type) { WaitForSingleObject(event.Get(), INFINITE); MessageLoop::current()->Run(); - ASSERT_EQ(order.Size(), 17); + ASSERT_EQ(17u, order.Size()); EXPECT_EQ(order.Get(0), TaskItem(RECURSIVE, 1, true)); EXPECT_EQ(order.Get(1), TaskItem(RECURSIVE, 1, false)); EXPECT_EQ(order.Get(2), TaskItem(MESSAGEBOX, 2, true)); @@ -380,7 +385,7 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) { WaitForSingleObject(event.Get(), INFINITE); MessageLoop::current()->Run(); - ASSERT_EQ(order.Size(), 18); + ASSERT_EQ(18u, order.Size()); EXPECT_EQ(order.Get(0), TaskItem(RECURSIVE, 1, true)); EXPECT_EQ(order.Get(1), TaskItem(RECURSIVE, 1, false)); EXPECT_EQ(order.Get(2), TaskItem(MESSAGEBOX, 2, true)); @@ -522,7 +527,7 @@ void TestIOHandler::Init() { DWORD read; EXPECT_FALSE(ReadFile(file_.Get(), buffer_, size(), &read, context())); - EXPECT_EQ(ERROR_IO_PENDING, GetLastError()); + EXPECT_EQ(static_cast<DWORD>(ERROR_IO_PENDING), GetLastError()); if (wait_) WaitForIO(); } @@ -615,8 +620,9 @@ void RunTest_WaitForIO() { DWORD written; EXPECT_TRUE(WriteFile(server1.Get(), buffer, sizeof(buffer), &written, NULL)); PlatformThread::Sleep(2 * delay); - EXPECT_EQ(WAIT_TIMEOUT, WaitForSingleObject(callback1_called.Get(), 0)) << - "handler1 has not been called"; + EXPECT_EQ(static_cast<DWORD>(WAIT_TIMEOUT), + WaitForSingleObject(callback1_called.Get(), 0)) + << "handler1 has not been called"; EXPECT_TRUE(WriteFile(server2.Get(), buffer, sizeof(buffer), &written, NULL)); @@ -907,8 +913,9 @@ TEST(MessageLoopTest, ThreadMainTaskRunner) { &Foo::Test1ConstRef, foo.get(), a)); // Post quit task; - MessageLoop::current()->PostTask(FROM_HERE, Bind( - &MessageLoop::Quit, Unretained(MessageLoop::current()))); + MessageLoop::current()->PostTask( + FROM_HERE, + Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current()))); // Now kick things off MessageLoop::current()->Run(); @@ -983,7 +990,7 @@ LRESULT CALLBACK TestWndProcThunk(HWND hwnd, UINT message, break; } EXPECT_TRUE(did_run); - MessageLoop::current()->Quit(); + MessageLoop::current()->QuitWhenIdle(); break; } return 0; @@ -1034,4 +1041,15 @@ TEST(MessageLoopTest, OriginalRunnerWorks) { EXPECT_EQ(1, foo->test_count()); } +TEST(MessageLoopTest, DeleteUnboundLoop) { + // It should be possible to delete an unbound message loop on a thread which + // already has another active loop. This happens when thread creation fails. + MessageLoop loop; + scoped_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( + MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); + unbound_loop.reset(); + EXPECT_EQ(&loop, MessageLoop::current()); + EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); +} + } // namespace base diff --git a/chromium/base/message_loop/message_pump.h b/chromium/base/message_loop/message_pump.h index a2edb458a96..c53be804109 100644 --- a/chromium/base/message_loop/message_pump.h +++ b/chromium/base/message_loop/message_pump.h @@ -6,7 +6,6 @@ #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_H_ #include "base/base_export.h" -#include "base/basictypes.h" #include "base/message_loop/timer_slack.h" #include "base/threading/non_thread_safe.h" diff --git a/chromium/base/message_loop/message_pump_android.h b/chromium/base/message_loop/message_pump_android.h index d48050d21d1..795bd5e79ee 100644 --- a/chromium/base/message_loop/message_pump_android.h +++ b/chromium/base/message_loop/message_pump_android.h @@ -10,6 +10,7 @@ #include "base/android/scoped_java_ref.h" #include "base/base_export.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/message_loop/message_pump.h" namespace base { diff --git a/chromium/base/message_loop/message_pump_default.cc b/chromium/base/message_loop/message_pump_default.cc index 27c19e0227b..ed15395d56f 100644 --- a/chromium/base/message_loop/message_pump_default.cc +++ b/chromium/base/message_loop/message_pump_default.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/threading/thread_restrictions.h" +#include "build/build_config.h" #if defined(OS_MACOSX) #include "base/mac/scoped_nsautorelease_pool.h" diff --git a/chromium/base/message_loop/message_pump_default.h b/chromium/base/message_loop/message_pump_default.h index 8aeaa62fcd2..4cd7cd17d56 100644 --- a/chromium/base/message_loop/message_pump_default.h +++ b/chromium/base/message_loop/message_pump_default.h @@ -6,6 +6,7 @@ #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_DEFAULT_H_ #include "base/base_export.h" +#include "base/macros.h" #include "base/message_loop/message_pump.h" #include "base/synchronization/waitable_event.h" #include "base/time/time.h" diff --git a/chromium/base/message_loop/message_pump_glib.h b/chromium/base/message_loop/message_pump_glib.h index 9f4457141d7..b94eeaf4304 100644 --- a/chromium/base/message_loop/message_pump_glib.h +++ b/chromium/base/message_loop/message_pump_glib.h @@ -6,6 +6,7 @@ #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ #include "base/base_export.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_pump.h" #include "base/observer_list.h" diff --git a/chromium/base/message_loop/message_pump_glib_unittest.cc b/chromium/base/message_loop/message_pump_glib_unittest.cc index 7ddd4f08a04..cd12eba9f59 100644 --- a/chromium/base/message_loop/message_pump_glib_unittest.cc +++ b/chromium/base/message_loop/message_pump_glib_unittest.cc @@ -13,6 +13,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" diff --git a/chromium/base/message_loop/message_pump_io_ios.cc b/chromium/base/message_loop/message_pump_io_ios.cc index cd5ffed4b99..9e6efeca193 100644 --- a/chromium/base/message_loop/message_pump_io_ios.cc +++ b/chromium/base/message_loop/message_pump_io_ios.cc @@ -22,7 +22,7 @@ bool MessagePumpIOSForIO::FileDescriptorWatcher::StopWatchingFileDescriptor() { if (fdref_ == NULL) return true; - CFFileDescriptorDisableCallBacks(fdref_, callback_types_); + CFFileDescriptorDisableCallBacks(fdref_.get(), callback_types_); if (pump_) pump_->RemoveRunLoopSource(fd_source_); fd_source_.reset(); @@ -39,7 +39,7 @@ void MessagePumpIOSForIO::FileDescriptorWatcher::Init( CFRunLoopSourceRef fd_source, bool is_persistent) { DCHECK(fdref); - DCHECK(!fdref_); + DCHECK(!fdref_.is_valid()); is_persistent_ = is_persistent; fdref_.reset(fdref); @@ -97,7 +97,7 @@ bool MessagePumpIOSForIO::WatchFileDescriptor( callback_types |= kCFFileDescriptorWriteCallBack; } - CFFileDescriptorRef fdref = controller->fdref_; + CFFileDescriptorRef fdref = controller->fdref_.get(); if (fdref == NULL) { base::ScopedCFTypeRef<CFFileDescriptorRef> scoped_fdref( CFFileDescriptorCreate( @@ -174,7 +174,7 @@ void MessagePumpIOSForIO::HandleFdIOEvent(CFFileDescriptorRef fdref, void* context) { FileDescriptorWatcher* controller = static_cast<FileDescriptorWatcher*>(context); - DCHECK_EQ(fdref, controller->fdref_); + DCHECK_EQ(fdref, controller->fdref_.get()); // Ensure that |fdref| will remain live for the duration of this function // call even if |controller| is deleted or |StopWatchingFileDescriptor()| is @@ -194,14 +194,14 @@ void MessagePumpIOSForIO::HandleFdIOEvent(CFFileDescriptorRef fdref, // guarantees that |controller| has not been deleted. if (callback_types & kCFFileDescriptorReadCallBack && CFFileDescriptorIsValid(fdref)) { - DCHECK_EQ(fdref, controller->fdref_); + DCHECK_EQ(fdref, controller->fdref_.get()); controller->OnFileCanReadWithoutBlocking(fd, pump); } // Re-enable callbacks after the read/write if the file descriptor is still // valid and the controller is persistent. if (CFFileDescriptorIsValid(fdref) && controller->is_persistent_) { - DCHECK_EQ(fdref, controller->fdref_); + DCHECK_EQ(fdref, controller->fdref_.get()); CFFileDescriptorEnableCallBacks(fdref, callback_types); } } diff --git a/chromium/base/message_loop/message_pump_io_ios.h b/chromium/base/message_loop/message_pump_io_ios.h index 317a59c5d9a..e1cbae6f92f 100644 --- a/chromium/base/message_loop/message_pump_io_ios.h +++ b/chromium/base/message_loop/message_pump_io_ios.h @@ -8,6 +8,7 @@ #include "base/base_export.h" #include "base/mac/scoped_cffiledescriptorref.h" #include "base/mac/scoped_cftyperef.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_pump_mac.h" diff --git a/chromium/base/message_loop/message_pump_io_ios_unittest.cc b/chromium/base/message_loop/message_pump_io_ios_unittest.cc index ba96f83bbf0..e51de70c0e0 100644 --- a/chromium/base/message_loop/message_pump_io_ios_unittest.cc +++ b/chromium/base/message_loop/message_pump_io_ios_unittest.cc @@ -6,6 +6,7 @@ #include <unistd.h> +#include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/posix/eintr_wrapper.h" #include "base/threading/thread.h" @@ -43,7 +44,7 @@ class MessagePumpIOSForIOTest : public testing::Test { } void HandleFdIOEvent(MessageLoopForIO::FileDescriptorWatcher* watcher) { - MessagePumpIOSForIO::HandleFdIOEvent(watcher->fdref_, + MessagePumpIOSForIO::HandleFdIOEvent(watcher->fdref_.get(), kCFFileDescriptorReadCallBack | kCFFileDescriptorWriteCallBack, watcher); } diff --git a/chromium/base/message_loop/message_pump_libevent.cc b/chromium/base/message_loop/message_pump_libevent.cc index 74602a7b320..c0a02b2b492 100644 --- a/chromium/base/message_loop/message_pump_libevent.cc +++ b/chromium/base/message_loop/message_pump_libevent.cc @@ -5,18 +5,19 @@ #include "base/message_loop/message_pump_libevent.h" #include <errno.h> -#include <fcntl.h> #include <unistd.h> #include "base/auto_reset.h" #include "base/compiler_specific.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/posix/eintr_wrapper.h" +#include "base/third_party/libevent/event.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" -#include "third_party/libevent/event.h" +#include "build/build_config.h" #if defined(OS_MACOSX) #include "base/mac/scoped_nsautorelease_pool.h" @@ -42,15 +43,6 @@ namespace base { -// Return 0 on success -// Too small a function to bother putting in a library? -static int SetNonBlocking(int fd) { - int flags = fcntl(fd, F_GETFL, 0); - if (flags == -1) - flags = 0; - return fcntl(fd, F_SETFL, flags | O_NONBLOCK); -} - MessagePumpLibevent::FileDescriptorWatcher::FileDescriptorWatcher() : event_(NULL), pump_(NULL), @@ -322,11 +314,11 @@ bool MessagePumpLibevent::Init() { DLOG(ERROR) << "pipe() failed, errno: " << errno; return false; } - if (SetNonBlocking(fds[0])) { + if (!SetNonBlocking(fds[0])) { DLOG(ERROR) << "SetNonBlocking for pipe fd[0] failed, errno: " << errno; return false; } - if (SetNonBlocking(fds[1])) { + if (!SetNonBlocking(fds[1])) { DLOG(ERROR) << "SetNonBlocking for pipe fd[1] failed, errno: " << errno; return false; } diff --git a/chromium/base/message_loop/message_pump_libevent.h b/chromium/base/message_loop/message_pump_libevent.h index 8b815aea588..4d2f4f70372 100644 --- a/chromium/base/message_loop/message_pump_libevent.h +++ b/chromium/base/message_loop/message_pump_libevent.h @@ -5,8 +5,8 @@ #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_LIBEVENT_H_ #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_LIBEVENT_H_ -#include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/message_loop/message_pump.h" #include "base/observer_list.h" #include "base/threading/thread_checker.h" diff --git a/chromium/base/message_loop/message_pump_libevent_unittest.cc b/chromium/base/message_loop/message_pump_libevent_unittest.cc index e911905abd7..eb30d535db6 100644 --- a/chromium/base/message_loop/message_pump_libevent_unittest.cc +++ b/chromium/base/message_loop/message_pump_libevent_unittest.cc @@ -15,9 +15,10 @@ #include "base/run_loop.h" #include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event_watcher.h" +#include "base/third_party/libevent/event.h" #include "base/threading/thread.h" +#include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/libevent/event.h" namespace base { diff --git a/chromium/base/message_loop/message_pump_mac.h b/chromium/base/message_loop/message_pump_mac.h index c46f2612666..14b8377b908 100644 --- a/chromium/base/message_loop/message_pump_mac.h +++ b/chromium/base/message_loop/message_pump_mac.h @@ -32,12 +32,13 @@ #include "base/message_loop/message_pump.h" -#include "base/basictypes.h" #include <CoreFoundation/CoreFoundation.h> +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/timer_slack.h" +#include "build/build_config.h" #if defined(__OBJC__) #if defined(OS_IOS) diff --git a/chromium/base/message_loop/message_pump_mac.mm b/chromium/base/message_loop/message_pump_mac.mm index 53e3363da57..b50ea687881 100644 --- a/chromium/base/message_loop/message_pump_mac.mm +++ b/chromium/base/message_loop/message_pump_mac.mm @@ -12,9 +12,11 @@ #include "base/logging.h" #include "base/mac/call_with_eh_frame.h" #include "base/mac/scoped_cftyperef.h" +#include "base/macros.h" #include "base/message_loop/timer_slack.h" #include "base/run_loop.h" #include "base/time/time.h" +#include "build/build_config.h" #if !defined(OS_IOS) #import <AppKit/AppKit.h> diff --git a/chromium/base/message_loop/message_pump_perftest.cc b/chromium/base/message_loop/message_pump_perftest.cc index 9f76064ce38..789fc1f391b 100644 --- a/chromium/base/message_loop/message_pump_perftest.cc +++ b/chromium/base/message_loop/message_pump_perftest.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "base/bind.h" #include "base/format_macros.h" #include "base/memory/scoped_vector.h" @@ -25,6 +28,11 @@ class ScheduleWorkTest : public testing::Test { public: ScheduleWorkTest() : counter_(0) {} + void SetUp() override { + if (base::ThreadTicks::IsSupported()) + base::ThreadTicks::WaitUntilInitialized(); + } + void Increment(uint64_t amount) { counter_ += amount; } void Schedule(int index) { @@ -79,14 +87,15 @@ class ScheduleWorkTest : public testing::Test { target_->WaitUntilThreadStarted(); } - ScopedVector<Thread> scheduling_threads; + std::vector<scoped_ptr<Thread>> scheduling_threads; scheduling_times_.reset(new base::TimeDelta[num_scheduling_threads]); scheduling_thread_times_.reset(new base::TimeDelta[num_scheduling_threads]); min_batch_times_.reset(new base::TimeDelta[num_scheduling_threads]); max_batch_times_.reset(new base::TimeDelta[num_scheduling_threads]); for (int i = 0; i < num_scheduling_threads; ++i) { - scheduling_threads.push_back(new Thread("posting thread")); + scheduling_threads.push_back( + make_scoped_ptr(new Thread("posting thread"))); scheduling_threads[i]->Start(); } diff --git a/chromium/base/message_loop/message_pump_win.cc b/chromium/base/message_loop/message_pump_win.cc index 14e432015e0..e7246fee16a 100644 --- a/chromium/base/message_loop/message_pump_win.cc +++ b/chromium/base/message_loop/message_pump_win.cc @@ -4,8 +4,10 @@ #include "base/message_loop/message_pump_win.h" -#include <limits> #include <math.h> +#include <stdint.h> + +#include <limits> #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" diff --git a/chromium/base/message_loop/message_pump_win.h b/chromium/base/message_loop/message_pump_win.h index 9f1838d6e4f..257ccc92b19 100644 --- a/chromium/base/message_loop/message_pump_win.h +++ b/chromium/base/message_loop/message_pump_win.h @@ -10,7 +10,6 @@ #include <list> #include "base/base_export.h" -#include "base/basictypes.h" #include "base/message_loop/message_pump.h" #include "base/message_loop/message_pump_dispatcher.h" #include "base/observer_list.h" |