Chromium Code Reviews

Side by Side Diff: base/message_loop.h

Issue 6189001: Make the order of methods in the cc files match the headers in base/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « base/file_path.cc ('k') | base/message_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 85 matching lines...)
96 TYPE_DEFAULT, 96 TYPE_DEFAULT,
97 TYPE_UI, 97 TYPE_UI,
98 TYPE_IO 98 TYPE_IO
99 }; 99 };
100 100
101 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it 101 // Normally, it is not necessary to instantiate a MessageLoop. Instead, it
102 // is typical to make use of the current thread's MessageLoop instance. 102 // is typical to make use of the current thread's MessageLoop instance.
103 explicit MessageLoop(Type type = TYPE_DEFAULT); 103 explicit MessageLoop(Type type = TYPE_DEFAULT);
104 ~MessageLoop(); 104 ~MessageLoop();
105 105
106 // Returns the MessageLoop object for the current thread, or null if none.
107 static MessageLoop* current();
108
106 static void EnableHistogrammer(bool enable_histogrammer); 109 static void EnableHistogrammer(bool enable_histogrammer);
107 110
108 // A DestructionObserver is notified when the current MessageLoop is being 111 // A DestructionObserver is notified when the current MessageLoop is being
109 // destroyed. These obsevers are notified prior to MessageLoop::current() 112 // destroyed. These obsevers are notified prior to MessageLoop::current()
110 // being changed to return NULL. This gives interested parties the chance to 113 // being changed to return NULL. This gives interested parties the chance to
111 // do final cleanup that depends on the MessageLoop. 114 // do final cleanup that depends on the MessageLoop.
112 // 115 //
113 // NOTE: Any tasks posted to the MessageLoop during this notification will 116 // NOTE: Any tasks posted to the MessageLoop during this notification will
114 // not be run. Instead, they will be deleted. 117 // not be run. Instead, they will be deleted.
115 // 118 //
(...skipping 106 matching lines...)
222 // Returns the type passed to the constructor. 225 // Returns the type passed to the constructor.
223 Type type() const { return type_; } 226 Type type() const { return type_; }
224 227
225 // Optional call to connect the thread name with this loop. 228 // Optional call to connect the thread name with this loop.
226 void set_thread_name(const std::string& thread_name) { 229 void set_thread_name(const std::string& thread_name) {
227 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; 230 DCHECK(thread_name_.empty()) << "Should not rename this thread!";
228 thread_name_ = thread_name; 231 thread_name_ = thread_name;
229 } 232 }
230 const std::string& thread_name() const { return thread_name_; } 233 const std::string& thread_name() const { return thread_name_; }
231 234
232 // Returns the MessageLoop object for the current thread, or null if none.
233 static MessageLoop* current();
234
235 // Enables or disables the recursive task processing. This happens in the case 235 // Enables or disables the recursive task processing. This happens in the case
236 // of recursive message loops. Some unwanted message loop may occurs when 236 // of recursive message loops. Some unwanted message loop may occurs when
237 // using common controls or printer functions. By default, recursive task 237 // using common controls or printer functions. By default, recursive task
238 // processing is disabled. 238 // processing is disabled.
239 // 239 //
240 // The specific case where tasks get queued is: 240 // The specific case where tasks get queued is:
241 // - The thread is running a message loop. 241 // - The thread is running a message loop.
242 // - It receives a task #1 and execute it. 242 // - It receives a task #1 and execute it.
243 // - The task #1 implicitly start a message loop, like a MessageBox in the 243 // - The task #1 implicitly start a message loop, like a MessageBox in the
244 // unit test. This can also be StartDoc or GetSaveFileName. 244 // unit test. This can also be StartDoc or GetSaveFileName.
(...skipping 139 matching lines...)
384 #endif 384 #endif
385 385
386 // A surrounding stack frame around the running of the message loop that 386 // A surrounding stack frame around the running of the message loop that
387 // supports all saving and restoring of state, as is needed for any/all (ugly) 387 // supports all saving and restoring of state, as is needed for any/all (ugly)
388 // recursive calls. 388 // recursive calls.
389 void RunInternal(); 389 void RunInternal();
390 390
391 // Called to process any delayed non-nestable tasks. 391 // Called to process any delayed non-nestable tasks.
392 bool ProcessNextDelayedNonNestableTask(); 392 bool ProcessNextDelayedNonNestableTask();
393 393
394 //----------------------------------------------------------------------------
395 // Run a work_queue_ task or new_task, and delete it (if it was processed by
396 // PostTask). If there are queued tasks, the oldest one is executed and
397 // new_task is queued. new_task is optional and can be NULL. In this NULL
398 // case, the method will run one pending task (if any exist). Returns true if
399 // it executes a task. Queued tasks accumulate only when there is a
400 // non-nestable task currently processing, in which case the new_task is
401 // appended to the list work_queue_. Such re-entrancy generally happens when
402 // an unrequested message pump (typical of a native dialog) is executing in
403 // the context of a task.
404 bool QueueOrRunTask(Task* new_task);
405
406 // Runs the specified task and deletes it. 394 // Runs the specified task and deletes it.
407 void RunTask(Task* task); 395 void RunTask(Task* task);
408 396
409 // Calls RunTask or queues the pending_task on the deferred task list if it 397 // Calls RunTask or queues the pending_task on the deferred task list if it
410 // cannot be run right now. Returns true if the task was run. 398 // cannot be run right now. Returns true if the task was run.
411 bool DeferOrRunPendingTask(const PendingTask& pending_task); 399 bool DeferOrRunPendingTask(const PendingTask& pending_task);
412 400
413 // Adds the pending task to delayed_work_queue_. 401 // Adds the pending task to delayed_work_queue_.
414 void AddToDelayedWorkQueue(const PendingTask& pending_task); 402 void AddToDelayedWorkQueue(const PendingTask& pending_task);
415 403
(...skipping 193 matching lines...)
609 #endif // defined(OS_POSIX) 597 #endif // defined(OS_POSIX)
610 }; 598 };
611 599
612 // Do not add any member variables to MessageLoopForIO! This is important b/c 600 // Do not add any member variables to MessageLoopForIO! This is important b/c
613 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 601 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
614 // data that you need should be stored on the MessageLoop's pump_ instance. 602 // data that you need should be stored on the MessageLoop's pump_ instance.
615 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 603 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
616 MessageLoopForIO_should_not_have_extra_member_variables); 604 MessageLoopForIO_should_not_have_extra_member_variables);
617 605
618 #endif // BASE_MESSAGE_LOOP_H_ 606 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « base/file_path.cc ('k') | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine