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/message_pump_mojo.h" | 5 #include "mojo/message_pump/message_pump_mojo.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "mojo/message_pump/message_pump_mojo_handler.h" | 15 #include "mojo/message_pump/message_pump_mojo_handler.h" |
15 #include "mojo/message_pump/time_helper.h" | 16 #include "mojo/message_pump/time_helper.h" |
16 #include "mojo/public/cpp/system/message_pipe.h" | 17 #include "mojo/public/cpp/system/message_pipe.h" |
17 #include "mojo/public/cpp/system/wait.h" | 18 #include "mojo/public/cpp/system/wait.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 CreateMessagePipe(nullptr, &read_handle, &write_handle); | 51 CreateMessagePipe(nullptr, &read_handle, &write_handle); |
51 } | 52 } |
52 | 53 |
53 base::TimeTicks delayed_work_time; | 54 base::TimeTicks delayed_work_time; |
54 | 55 |
55 // Used to wake up WaitForWork(). | 56 // Used to wake up WaitForWork(). |
56 ScopedMessagePipeHandle read_handle; | 57 ScopedMessagePipeHandle read_handle; |
57 ScopedMessagePipeHandle write_handle; | 58 ScopedMessagePipeHandle write_handle; |
58 | 59 |
59 // Cached structures to avoid the heap allocation cost of std::vector<>. | 60 // Cached structures to avoid the heap allocation cost of std::vector<>. |
60 scoped_ptr<WaitState> wait_state; | 61 std::unique_ptr<WaitState> wait_state; |
61 scoped_ptr<HandleToHandlerList> cloned_handlers; | 62 std::unique_ptr<HandleToHandlerList> cloned_handlers; |
62 | 63 |
63 bool should_quit; | 64 bool should_quit; |
64 }; | 65 }; |
65 | 66 |
66 MessagePumpMojo::MessagePumpMojo() : run_state_(nullptr), next_handler_id_(0) { | 67 MessagePumpMojo::MessagePumpMojo() : run_state_(nullptr), next_handler_id_(0) { |
67 DCHECK(!current()) | 68 DCHECK(!current()) |
68 << "There is already a MessagePumpMojo instance on this thread."; | 69 << "There is already a MessagePumpMojo instance on this thread."; |
69 CurrentPump()->Set(this); | 70 CurrentPump()->Set(this); |
70 } | 71 } |
71 | 72 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 void MessagePumpMojo::WillSignalHandler() { | 330 void MessagePumpMojo::WillSignalHandler() { |
330 FOR_EACH_OBSERVER(Observer, observers_, WillSignalHandler()); | 331 FOR_EACH_OBSERVER(Observer, observers_, WillSignalHandler()); |
331 } | 332 } |
332 | 333 |
333 void MessagePumpMojo::DidSignalHandler() { | 334 void MessagePumpMojo::DidSignalHandler() { |
334 FOR_EACH_OBSERVER(Observer, observers_, DidSignalHandler()); | 335 FOR_EACH_OBSERVER(Observer, observers_, DidSignalHandler()); |
335 } | 336 } |
336 | 337 |
337 } // namespace common | 338 } // namespace common |
338 } // namespace mojo | 339 } // namespace mojo |
OLD | NEW |