| 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 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 void DisallowNesting() { allow_nesting_ = false; } | 327 void DisallowNesting() { allow_nesting_ = false; } |
| 328 | 328 |
| 329 // Disallow task observers. After this is called, calling | 329 // Disallow task observers. After this is called, calling |
| 330 // Add/RemoveTaskObserver() on this MessageLoop will crash. | 330 // Add/RemoveTaskObserver() on this MessageLoop will crash. |
| 331 void DisallowTaskObservers() { allow_task_observers_ = false; } | 331 void DisallowTaskObservers() { allow_task_observers_ = false; } |
| 332 | 332 |
| 333 //---------------------------------------------------------------------------- | 333 //---------------------------------------------------------------------------- |
| 334 protected: | 334 protected: |
| 335 std::unique_ptr<MessagePump> pump_; | 335 std::unique_ptr<MessagePump> pump_; |
| 336 | 336 |
| 337 using MessagePumpFactoryCallback = Callback<std::unique_ptr<MessagePump>()>; | 337 using MessagePumpFactoryCallback = |
| 338 OnceCallback<std::unique_ptr<MessagePump>()>; |
| 338 | 339 |
| 339 // Common protected constructor. Other constructors delegate the | 340 // Common protected constructor. Other constructors delegate the |
| 340 // initialization to this constructor. | 341 // initialization to this constructor. |
| 341 // A subclass can invoke this constructor to create a message_loop of a | 342 // A subclass can invoke this constructor to create a message_loop of a |
| 342 // specific type with a custom loop. The implementation does not call | 343 // specific type with a custom loop. The implementation does not call |
| 343 // BindToCurrentThread. If this constructor is invoked directly by a subclass, | 344 // BindToCurrentThread. If this constructor is invoked directly by a subclass, |
| 344 // then the subclass must subsequently bind the message loop. | 345 // then the subclass must subsequently bind the message loop. |
| 345 MessageLoop(Type type, MessagePumpFactoryCallback pump_factory); | 346 MessageLoop(Type type, MessagePumpFactoryCallback pump_factory); |
| 346 | 347 |
| 347 // Configure various members and bind this message loop to the current thread. | 348 // Configure various members and bind this message loop to the current thread. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 621 |
| 621 // Do not add any member variables to MessageLoopForIO! This is important b/c | 622 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 622 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 623 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 623 // data that you need should be stored on the MessageLoop's pump_ instance. | 624 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 624 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 625 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 625 "MessageLoopForIO should not have extra member variables"); | 626 "MessageLoopForIO should not have extra member variables"); |
| 626 | 627 |
| 627 } // namespace base | 628 } // namespace base |
| 628 | 629 |
| 629 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 630 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| OLD | NEW |