| 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 23 matching lines...) Expand all Loading... |
| 34 #include "base/win/scoped_handle.h" | 34 #include "base/win/scoped_handle.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 namespace base { | 37 namespace base { |
| 38 | 38 |
| 39 // TODO(darin): Platform-specific MessageLoop tests should be grouped together | 39 // TODO(darin): Platform-specific MessageLoop tests should be grouped together |
| 40 // to avoid chopping this file up with so many #ifdefs. | 40 // to avoid chopping this file up with so many #ifdefs. |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 scoped_ptr<MessagePump> TypeDefaultMessagePumpFactory() { | 44 std::unique_ptr<MessagePump> TypeDefaultMessagePumpFactory() { |
| 45 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_DEFAULT); | 45 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_DEFAULT); |
| 46 } | 46 } |
| 47 | 47 |
| 48 scoped_ptr<MessagePump> TypeIOMessagePumpFactory() { | 48 std::unique_ptr<MessagePump> TypeIOMessagePumpFactory() { |
| 49 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_IO); | 49 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_IO); |
| 50 } | 50 } |
| 51 | 51 |
| 52 scoped_ptr<MessagePump> TypeUIMessagePumpFactory() { | 52 std::unique_ptr<MessagePump> TypeUIMessagePumpFactory() { |
| 53 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_UI); | 53 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_UI); |
| 54 } | 54 } |
| 55 | 55 |
| 56 class Foo : public RefCounted<Foo> { | 56 class Foo : public RefCounted<Foo> { |
| 57 public: | 57 public: |
| 58 Foo() : test_count_(0) { | 58 Foo() : test_count_(0) { |
| 59 } | 59 } |
| 60 | 60 |
| 61 void Test1ConstRef(const std::string& a) { | 61 void Test1ConstRef(const std::string& a) { |
| 62 ++test_count_; | 62 ++test_count_; |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 original_runner->PostTask(FROM_HERE, | 964 original_runner->PostTask(FROM_HERE, |
| 965 Bind(&Foo::Test1ConstRef, foo.get(), "a")); | 965 Bind(&Foo::Test1ConstRef, foo.get(), "a")); |
| 966 loop.RunUntilIdle(); | 966 loop.RunUntilIdle(); |
| 967 EXPECT_EQ(1, foo->test_count()); | 967 EXPECT_EQ(1, foo->test_count()); |
| 968 } | 968 } |
| 969 | 969 |
| 970 TEST(MessageLoopTest, DeleteUnboundLoop) { | 970 TEST(MessageLoopTest, DeleteUnboundLoop) { |
| 971 // It should be possible to delete an unbound message loop on a thread which | 971 // It should be possible to delete an unbound message loop on a thread which |
| 972 // already has another active loop. This happens when thread creation fails. | 972 // already has another active loop. This happens when thread creation fails. |
| 973 MessageLoop loop; | 973 MessageLoop loop; |
| 974 scoped_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( | 974 std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( |
| 975 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); | 975 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); |
| 976 unbound_loop.reset(); | 976 unbound_loop.reset(); |
| 977 EXPECT_EQ(&loop, MessageLoop::current()); | 977 EXPECT_EQ(&loop, MessageLoop::current()); |
| 978 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); | 978 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); |
| 979 } | 979 } |
| 980 | 980 |
| 981 } // namespace base | 981 } // namespace base |
| OLD | NEW |