diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 18:06:45 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-07 18:06:45 +0000 |
commit | a502bbe7a3ea0d4909e4e163ab00a1f3be483143 (patch) | |
tree | c53bf6b7492be39d1fb2eaa4cacbc74f8d0c8cb1 /base/message_loop.h | |
parent | 8ebb7703fb1fd95f993081e674d04167fe1413fc (diff) | |
download | chromium_src-a502bbe7a3ea0d4909e4e163ab00a1f3be483143.zip chromium_src-a502bbe7a3ea0d4909e4e163ab00a1f3be483143.tar.gz chromium_src-a502bbe7a3ea0d4909e4e163ab00a1f3be483143.tar.bz2 |
Start sorting methods in class declarations.
A lot of our headers are a mess and aren't organized. Impose the following
order on files in the base/ directory:
class Blah {
each public/protected/private section:
typedefs;
enums;
static constants;
ctors;
dtors;
methods;
overridden virtual methods;
data members;
};
BUG=68682
TEST=compiles
Review URL: http://codereview.chromium.org/6081007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.h')
-rw-r--r-- | base/message_loop.h | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/base/message_loop.h b/base/message_loop.h index a5a94bc..8058e24 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -66,24 +66,43 @@ class Histogram; // class MessageLoop : public base::MessagePump::Delegate { public: - // A TaskObserver is an object that receives task notifications from the - // MessageLoop. - // - // NOTE: A TaskObserver implementation should be extremely fast! - class TaskObserver { - public: - TaskObserver(); - - // This method is called before processing a task. - virtual void WillProcessTask(const Task* task) = 0; - - // This method is called after processing a task. - virtual void DidProcessTask(const Task* task) = 0; +#if defined(OS_WIN) + typedef base::MessagePumpWin::Dispatcher Dispatcher; + typedef base::MessagePumpForUI::Observer Observer; +#elif !defined(OS_MACOSX) +#if defined(TOUCH_UI) + typedef base::MessagePumpGlibXDispatcher Dispatcher; +#else + typedef base::MessagePumpForUI::Dispatcher Dispatcher; +#endif + typedef base::MessagePumpForUI::Observer Observer; +#endif - protected: - virtual ~TaskObserver(); + // A MessageLoop has a particular type, which indicates the set of + // asynchronous events it may process in addition to tasks and timers. + // + // TYPE_DEFAULT + // This type of ML only supports tasks and timers. + // + // TYPE_UI + // This type of ML also supports native UI events (e.g., Windows messages). + // See also MessageLoopForUI. + // + // TYPE_IO + // This type of ML also supports asynchronous IO. See also + // MessageLoopForIO. + // + enum Type { + TYPE_DEFAULT, + TYPE_UI, + TYPE_IO }; + // Normally, it is not necessary to instantiate a MessageLoop. Instead, it + // is typical to make use of the current thread's MessageLoop instance. + explicit MessageLoop(Type type = TYPE_DEFAULT); + ~MessageLoop(); + static void EnableHistogrammer(bool enable_histogrammer); // A DestructionObserver is notified when the current MessageLoop is being @@ -200,31 +219,6 @@ class MessageLoop : public base::MessagePump::Delegate { } }; - // A MessageLoop has a particular type, which indicates the set of - // asynchronous events it may process in addition to tasks and timers. - // - // TYPE_DEFAULT - // This type of ML only supports tasks and timers. - // - // TYPE_UI - // This type of ML also supports native UI events (e.g., Windows messages). - // See also MessageLoopForUI. - // - // TYPE_IO - // This type of ML also supports asynchronous IO. See also - // MessageLoopForIO. - // - enum Type { - TYPE_DEFAULT, - TYPE_UI, - TYPE_IO - }; - - // Normally, it is not necessary to instantiate a MessageLoop. Instead, it - // is typical to make use of the current thread's MessageLoop instance. - explicit MessageLoop(Type type = TYPE_DEFAULT); - ~MessageLoop(); - // Returns the type passed to the constructor. Type type() const { return type_; } @@ -284,23 +278,29 @@ class MessageLoop : public base::MessagePump::Delegate { // Returns true if we are currently running a nested message loop. bool IsNested(); + // A TaskObserver is an object that receives task notifications from the + // MessageLoop. + // + // NOTE: A TaskObserver implementation should be extremely fast! + class TaskObserver { + public: + TaskObserver(); + + // This method is called before processing a task. + virtual void WillProcessTask(const Task* task) = 0; + + // This method is called after processing a task. + virtual void DidProcessTask(const Task* task) = 0; + + protected: + virtual ~TaskObserver(); + }; + // These functions can only be called on the same thread that |this| is // running on. void AddTaskObserver(TaskObserver* task_observer); void RemoveTaskObserver(TaskObserver* task_observer); -#if defined(OS_WIN) - typedef base::MessagePumpWin::Dispatcher Dispatcher; - typedef base::MessagePumpForUI::Observer Observer; -#elif !defined(OS_MACOSX) -#if defined(TOUCH_UI) - typedef base::MessagePumpGlibXDispatcher Dispatcher; -#else - typedef base::MessagePumpForUI::Dispatcher Dispatcher; -#endif - typedef base::MessagePumpForUI::Observer Observer; -#endif - // Returns true if the message loop has high resolution timers enabled. // Provided for testing. bool high_resolution_timers_enabled() { @@ -341,17 +341,17 @@ class MessageLoop : public base::MessagePump::Delegate { // This structure is copied around by value. struct PendingTask { - Task* task; // The task to run. - base::TimeTicks delayed_run_time; // The time when the task should be run. - int sequence_num; // Secondary sort key for run time. - bool nestable; // OK to dispatch from a nested loop. - PendingTask(Task* task, bool nestable) : task(task), sequence_num(0), nestable(nestable) { } // Used to support sorting. bool operator<(const PendingTask& other) const; + + Task* task; // The task to run. + base::TimeTicks delayed_run_time; // The time when the task should be run. + int sequence_num; // Secondary sort key for run time. + bool nestable; // OK to dispatch from a nested loop. }; class TaskQueue : public std::queue<PendingTask> { @@ -427,11 +427,6 @@ class MessageLoop : public base::MessagePump::Delegate { void PostTask_Helper(const tracked_objects::Location& from_here, Task* task, int64 delay_ms, bool nestable); - // base::MessagePump::Delegate methods: - virtual bool DoWork(); - virtual bool DoDelayedWork(base::TimeTicks* next_delayed_work_time); - virtual bool DoIdleWork(); - // Start recording histogram info about events and action IF it was enabled // and IF the statistics recorder can accept a registration of our histogram. void StartHistogrammer(); @@ -441,6 +436,11 @@ class MessageLoop : public base::MessagePump::Delegate { // If message_histogram_ is NULL, this is a no-op. void HistogramEvent(int event); + // base::MessagePump::Delegate methods: + virtual bool DoWork(); + virtual bool DoDelayedWork(base::TimeTicks* next_delayed_work_time); + virtual bool DoIdleWork(); + Type type_; // A list of tasks that need to be processed by this instance. Note that |