| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 public: | 164 public: |
| 165 virtual void OnBeginNestedMessageLoop() = 0; | 165 virtual void OnBeginNestedMessageLoop() = 0; |
| 166 | 166 |
| 167 protected: | 167 protected: |
| 168 virtual ~NestingObserver(); | 168 virtual ~NestingObserver(); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 void AddNestingObserver(NestingObserver* observer); | 171 void AddNestingObserver(NestingObserver* observer); |
| 172 void RemoveNestingObserver(NestingObserver* observer); | 172 void RemoveNestingObserver(NestingObserver* observer); |
| 173 | 173 |
| 174 class BASE_EXPORT RecentTimeObserver { |
| 175 public: |
| 176 virtual void OnUpdateRecentTime(base::TimeTicks recent_time) = 0; |
| 177 |
| 178 protected: |
| 179 virtual ~RecentTimeObserver(); |
| 180 }; |
| 181 |
| 182 void AddRecentTimeObserver(RecentTimeObserver* observer); |
| 183 void RemoveRecentTimeObserver(RecentTimeObserver* observer); |
| 184 |
| 174 // NOTE: Deprecated; prefer task_runner() and the TaskRunner interfaces. | 185 // NOTE: Deprecated; prefer task_runner() and the TaskRunner interfaces. |
| 175 // TODO(skyostil): Remove these functions (crbug.com/465354). | 186 // TODO(skyostil): Remove these functions (crbug.com/465354). |
| 176 // | 187 // |
| 177 // The "PostTask" family of methods call the task's Run method asynchronously | 188 // The "PostTask" family of methods call the task's Run method asynchronously |
| 178 // from within a message loop at some point in the future. | 189 // from within a message loop at some point in the future. |
| 179 // | 190 // |
| 180 // With the PostTask variant, tasks are invoked in FIFO order, inter-mixed | 191 // With the PostTask variant, tasks are invoked in FIFO order, inter-mixed |
| 181 // with normal UI or IO event processing. With the PostDelayedTask variant, | 192 // with normal UI or IO event processing. With the PostDelayedTask variant, |
| 182 // tasks are called after at least approximately 'delay_ms' have elapsed. | 193 // tasks are called after at least approximately 'delay_ms' have elapsed. |
| 183 // | 194 // |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 513 |
| 503 // A queue of non-nestable tasks that we had to defer because when it came | 514 // A queue of non-nestable tasks that we had to defer because when it came |
| 504 // time to execute them we were in a nested message loop. They will execute | 515 // time to execute them we were in a nested message loop. They will execute |
| 505 // once we're out of nested message loops. | 516 // once we're out of nested message loops. |
| 506 TaskQueue deferred_non_nestable_work_queue_; | 517 TaskQueue deferred_non_nestable_work_queue_; |
| 507 | 518 |
| 508 ObserverList<DestructionObserver> destruction_observers_; | 519 ObserverList<DestructionObserver> destruction_observers_; |
| 509 | 520 |
| 510 ObserverList<NestingObserver> nesting_observers_; | 521 ObserverList<NestingObserver> nesting_observers_; |
| 511 | 522 |
| 523 ObserverList<RecentTimeObserver> recent_time_observers_; |
| 524 |
| 512 // A recursion block that prevents accidentally running additional tasks when | 525 // A recursion block that prevents accidentally running additional tasks when |
| 513 // insider a (accidentally induced?) nested message pump. | 526 // insider a (accidentally induced?) nested message pump. |
| 514 bool nestable_tasks_allowed_; | 527 bool nestable_tasks_allowed_; |
| 515 | 528 |
| 516 // pump_factory_.Run() is called to create a message pump for this loop | 529 // pump_factory_.Run() is called to create a message pump for this loop |
| 517 // if type_ is TYPE_CUSTOM and pump_ is null. | 530 // if type_ is TYPE_CUSTOM and pump_ is null. |
| 518 MessagePumpFactoryCallback pump_factory_; | 531 MessagePumpFactoryCallback pump_factory_; |
| 519 | 532 |
| 520 std::string thread_name_; | 533 std::string thread_name_; |
| 521 // A profiling histogram showing the counts of various messages and events. | 534 // A profiling histogram showing the counts of various messages and events. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 694 |
| 682 // Do not add any member variables to MessageLoopForIO! This is important b/c | 695 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 683 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 696 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 684 // data that you need should be stored on the MessageLoop's pump_ instance. | 697 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 685 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 698 static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 686 "MessageLoopForIO should not have extra member variables"); | 699 "MessageLoopForIO should not have extra member variables"); |
| 687 | 700 |
| 688 } // namespace base | 701 } // namespace base |
| 689 | 702 |
| 690 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 703 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
| OLD | NEW |