OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 EXPECT_EQ(order.Get(14), TaskItem(RECURSIVE, 1, true)); | 449 EXPECT_EQ(order.Get(14), TaskItem(RECURSIVE, 1, true)); |
450 EXPECT_EQ(order.Get(15), TaskItem(RECURSIVE, 1, false)); | 450 EXPECT_EQ(order.Get(15), TaskItem(RECURSIVE, 1, false)); |
451 EXPECT_EQ(order.Get(16), TaskItem(RECURSIVE, 3, true)); | 451 EXPECT_EQ(order.Get(16), TaskItem(RECURSIVE, 3, true)); |
452 EXPECT_EQ(order.Get(17), TaskItem(RECURSIVE, 3, false)); | 452 EXPECT_EQ(order.Get(17), TaskItem(RECURSIVE, 3, false)); |
453 } | 453 } |
454 | 454 |
455 #endif // defined(OS_WIN) | 455 #endif // defined(OS_WIN) |
456 | 456 |
457 void PostNTasksThenQuit(int posts_remaining) { | 457 void PostNTasksThenQuit(int posts_remaining) { |
458 if (posts_remaining > 1) { | 458 if (posts_remaining > 1) { |
459 MessageLoop::current()->task_runner()->PostTask( | 459 ThreadTaskRunnerHandle::Get()->PostTask( |
460 FROM_HERE, Bind(&PostNTasksThenQuit, posts_remaining - 1)); | 460 FROM_HERE, Bind(&PostNTasksThenQuit, posts_remaining - 1)); |
461 } else { | 461 } else { |
462 MessageLoop::current()->QuitWhenIdle(); | 462 MessageLoop::current()->QuitWhenIdle(); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 #if defined(OS_WIN) | 466 #if defined(OS_WIN) |
467 | 467 |
468 class TestIOHandler : public MessageLoopForIO::IOHandler { | 468 class TestIOHandler : public MessageLoopForIO::IOHandler { |
469 public: | 469 public: |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 // posts tasks on that message loop. | 865 // posts tasks on that message loop. |
866 TEST(MessageLoopTest, ThreadMainTaskRunner) { | 866 TEST(MessageLoopTest, ThreadMainTaskRunner) { |
867 MessageLoop loop; | 867 MessageLoop loop; |
868 | 868 |
869 scoped_refptr<Foo> foo(new Foo()); | 869 scoped_refptr<Foo> foo(new Foo()); |
870 std::string a("a"); | 870 std::string a("a"); |
871 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind( | 871 ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, Bind( |
872 &Foo::Test1ConstRef, foo, a)); | 872 &Foo::Test1ConstRef, foo, a)); |
873 | 873 |
874 // Post quit task; | 874 // Post quit task; |
875 MessageLoop::current()->task_runner()->PostTask( | 875 ThreadTaskRunnerHandle::Get()->PostTask( |
876 FROM_HERE, | 876 FROM_HERE, |
877 Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current()))); | 877 Bind(&MessageLoop::QuitWhenIdle, Unretained(MessageLoop::current()))); |
878 | 878 |
879 // Now kick things off | 879 // Now kick things off |
880 RunLoop().Run(); | 880 RunLoop().Run(); |
881 | 881 |
882 EXPECT_EQ(foo->test_count(), 1); | 882 EXPECT_EQ(foo->test_count(), 1); |
883 EXPECT_EQ(foo->result(), "a"); | 883 EXPECT_EQ(foo->result(), "a"); |
884 } | 884 } |
885 | 885 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 | 1024 |
1025 { | 1025 { |
1026 std::string kThreadName("bar"); | 1026 std::string kThreadName("bar"); |
1027 base::Thread thread(kThreadName); | 1027 base::Thread thread(kThreadName); |
1028 ASSERT_TRUE(thread.StartAndWaitForTesting()); | 1028 ASSERT_TRUE(thread.StartAndWaitForTesting()); |
1029 EXPECT_EQ(kThreadName, thread.message_loop()->GetThreadName()); | 1029 EXPECT_EQ(kThreadName, thread.message_loop()->GetThreadName()); |
1030 } | 1030 } |
1031 } | 1031 } |
1032 | 1032 |
1033 } // namespace base | 1033 } // namespace base |
OLD | NEW |