| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
| 6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 // This method is a variant of Quit, that does not wait for pending messages | 246 // This method is a variant of Quit, that does not wait for pending messages |
| 247 // to be processed before returning from Run. | 247 // to be processed before returning from Run. |
| 248 void QuitNow(); | 248 void QuitNow(); |
| 249 | 249 |
| 250 // Invokes Quit on the current MessageLoop when run. Useful to schedule an | 250 // Invokes Quit on the current MessageLoop when run. Useful to schedule an |
| 251 // arbitrary MessageLoop to Quit. | 251 // arbitrary MessageLoop to Quit. |
| 252 // TODO(jhawkins): Remove once task.h is removed. | 252 // TODO(jhawkins): Remove once task.h is removed. |
| 253 class QuitTask : public Task { | 253 class QuitTask : public Task { |
| 254 public: | 254 public: |
| 255 virtual void Run() { | 255 virtual void Run() OVERRIDE { |
| 256 MessageLoop::current()->Quit(); | 256 MessageLoop::current()->Quit(); |
| 257 } | 257 } |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 // Invokes Quit on the current MessageLoop when run. Useful to schedule an | 260 // Invokes Quit on the current MessageLoop when run. Useful to schedule an |
| 261 // arbitrary MessageLoop to Quit. | 261 // arbitrary MessageLoop to Quit. |
| 262 static base::Closure QuitClosure(); | 262 static base::Closure QuitClosure(); |
| 263 | 263 |
| 264 // Returns the type passed to the constructor. | 264 // Returns the type passed to the constructor. |
| 265 Type type() const { return type_; } | 265 Type type() const { return type_; } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // Start recording histogram info about events and action IF it was enabled | 502 // Start recording histogram info about events and action IF it was enabled |
| 503 // and IF the statistics recorder can accept a registration of our histogram. | 503 // and IF the statistics recorder can accept a registration of our histogram. |
| 504 void StartHistogrammer(); | 504 void StartHistogrammer(); |
| 505 | 505 |
| 506 // Add occurence of event to our histogram, so that we can see what is being | 506 // Add occurence of event to our histogram, so that we can see what is being |
| 507 // done in a specific MessageLoop instance (i.e., specific thread). | 507 // done in a specific MessageLoop instance (i.e., specific thread). |
| 508 // If message_histogram_ is NULL, this is a no-op. | 508 // If message_histogram_ is NULL, this is a no-op. |
| 509 void HistogramEvent(int event); | 509 void HistogramEvent(int event); |
| 510 | 510 |
| 511 // base::MessagePump::Delegate methods: | 511 // base::MessagePump::Delegate methods: |
| 512 virtual bool DoWork(); | 512 virtual bool DoWork() OVERRIDE; |
| 513 virtual bool DoDelayedWork(base::TimeTicks* next_delayed_work_time); | 513 virtual bool DoDelayedWork(base::TimeTicks* next_delayed_work_time) OVERRIDE; |
| 514 virtual bool DoIdleWork(); | 514 virtual bool DoIdleWork() OVERRIDE; |
| 515 | 515 |
| 516 Type type_; | 516 Type type_; |
| 517 | 517 |
| 518 // A list of tasks that need to be processed by this instance. Note that | 518 // A list of tasks that need to be processed by this instance. Note that |
| 519 // this queue is only accessed (push/pop) by our current thread. | 519 // this queue is only accessed (push/pop) by our current thread. |
| 520 TaskQueue work_queue_; | 520 TaskQueue work_queue_; |
| 521 | 521 |
| 522 // Contains delayed tasks, sorted by their 'delayed_run_time' property. | 522 // Contains delayed tasks, sorted by their 'delayed_run_time' property. |
| 523 DelayedTaskQueue delayed_work_queue_; | 523 DelayedTaskQueue delayed_work_queue_; |
| 524 | 524 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 #endif // defined(OS_POSIX) | 698 #endif // defined(OS_POSIX) |
| 699 }; | 699 }; |
| 700 | 700 |
| 701 // Do not add any member variables to MessageLoopForIO! This is important b/c | 701 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 702 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 702 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 703 // data that you need should be stored on the MessageLoop's pump_ instance. | 703 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 704 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 704 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 705 MessageLoopForIO_should_not_have_extra_member_variables); | 705 MessageLoopForIO_should_not_have_extra_member_variables); |
| 706 | 706 |
| 707 #endif // BASE_MESSAGE_LOOP_H_ | 707 #endif // BASE_MESSAGE_LOOP_H_ |
| OLD | NEW |