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 "mojo/message_pump/handle_watcher.h" | 5 #include "mojo/message_pump/handle_watcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 delete watcher; | 47 delete watcher; |
48 next_callback.Run(result); | 48 next_callback.Run(result); |
49 } | 49 } |
50 | 50 |
51 scoped_ptr<base::MessageLoop> CreateMessageLoop(MessageLoopConfig config) { | 51 scoped_ptr<base::MessageLoop> CreateMessageLoop(MessageLoopConfig config) { |
52 scoped_ptr<base::MessageLoop> loop; | 52 scoped_ptr<base::MessageLoop> loop; |
53 if (config == MESSAGE_LOOP_CONFIG_DEFAULT) | 53 if (config == MESSAGE_LOOP_CONFIG_DEFAULT) |
54 loop.reset(new base::MessageLoop()); | 54 loop.reset(new base::MessageLoop()); |
55 else | 55 else |
56 loop.reset(new base::MessageLoop(MessagePumpMojo::Create())); | 56 loop.reset(new base::MessageLoop(MessagePumpMojo::Create())); |
57 return loop.Pass(); | 57 return loop; |
58 } | 58 } |
59 | 59 |
60 // Helper class to manage the callback and running the message loop waiting for | 60 // Helper class to manage the callback and running the message loop waiting for |
61 // message to be received. Typical usage is something like: | 61 // message to be received. Typical usage is something like: |
62 // Schedule callback returned from GetCallback(). | 62 // Schedule callback returned from GetCallback(). |
63 // RunUntilGotCallback(); | 63 // RunUntilGotCallback(); |
64 // EXPECT_TRUE(got_callback()); | 64 // EXPECT_TRUE(got_callback()); |
65 // clear_callback(); | 65 // clear_callback(); |
66 class CallbackHelper { | 66 class CallbackHelper { |
67 public: | 67 public: |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 message_loop.task_runner(), | 474 message_loop.task_runner(), |
475 &run_loop, &threads_active_counter)); | 475 &run_loop, &threads_active_counter)); |
476 } | 476 } |
477 run_loop.Run(); | 477 run_loop.Run(); |
478 ASSERT_EQ(0, threads_active_counter); | 478 ASSERT_EQ(0, threads_active_counter); |
479 } | 479 } |
480 | 480 |
481 } // namespace test | 481 } // namespace test |
482 } // namespace common | 482 } // namespace common |
483 } // namespace mojo | 483 } // namespace mojo |
OLD | NEW |