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