Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: base/message_loop.h

Issue 199105: Continue with the FreeBSD port - this version builds and links, though... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/logging.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
11 #include "base/histogram.h" 11 #include "base/histogram.h"
12 #include "base/message_pump.h" 12 #include "base/message_pump.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/ref_counted.h" 14 #include "base/ref_counted.h"
15 #include "base/scoped_ptr.h" 15 #include "base/scoped_ptr.h"
16 #include "base/task.h" 16 #include "base/task.h"
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 // We need this to declare base::MessagePumpWin::Dispatcher, which we should 19 // We need this to declare base::MessagePumpWin::Dispatcher, which we should
20 // really just eliminate. 20 // really just eliminate.
21 #include "base/message_pump_win.h" 21 #include "base/message_pump_win.h"
22 #elif defined(OS_POSIX) 22 #elif defined(OS_POSIX)
23 #include "base/message_pump_libevent.h" 23 #include "base/message_pump_libevent.h"
24 #endif 24 #endif
25 #if defined(OS_LINUX) 25 #if defined(USE_X11)
26 #include "base/message_pump_glib.h" 26 #include "base/message_pump_glib.h"
27 #endif 27 #endif
28 28
29 // A MessageLoop is used to process events for a particular thread. There is 29 // A MessageLoop is used to process events for a particular thread. There is
30 // at most one MessageLoop instance per thread. 30 // at most one MessageLoop instance per thread.
31 // 31 //
32 // Events include at a minimum Task instances submitted to PostTask or those 32 // Events include at a minimum Task instances submitted to PostTask or those
33 // managed by TimerManager. Depending on the type of message pump used by the 33 // managed by TimerManager. Depending on the type of message pump used by the
34 // MessageLoop other events such as UI messages may be processed. On Windows 34 // MessageLoop other events such as UI messages may be processed. On Windows
35 // APC calls (as time permits) and signals sent to a registered set of HANDLEs 35 // APC calls (as time permits) and signals sent to a registered set of HANDLEs
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void set_exception_restoration(bool restore) { 230 void set_exception_restoration(bool restore) {
231 exception_restoration_ = restore; 231 exception_restoration_ = restore;
232 } 232 }
233 233
234 // Returns true if we are currently running a nested message loop. 234 // Returns true if we are currently running a nested message loop.
235 bool IsNested(); 235 bool IsNested();
236 236
237 #if defined(OS_WIN) 237 #if defined(OS_WIN)
238 typedef base::MessagePumpWin::Dispatcher Dispatcher; 238 typedef base::MessagePumpWin::Dispatcher Dispatcher;
239 typedef base::MessagePumpWin::Observer Observer; 239 typedef base::MessagePumpWin::Observer Observer;
240 #elif defined(OS_LINUX) 240 #elif defined(USE_X11)
241 typedef base::MessagePumpForUI::Dispatcher Dispatcher; 241 typedef base::MessagePumpForUI::Dispatcher Dispatcher;
242 typedef base::MessagePumpForUI::Observer Observer; 242 typedef base::MessagePumpForUI::Observer Observer;
243 #endif 243 #endif
244 244
245 //---------------------------------------------------------------------------- 245 //----------------------------------------------------------------------------
246 protected: 246 protected:
247 struct RunState { 247 struct RunState {
248 // Used to count how many Run() invocations are on the stack. 248 // Used to count how many Run() invocations are on the stack.
249 int run_depth; 249 int run_depth;
250 250
251 // Used to record that Quit() was called, or that we should quit the pump 251 // Used to record that Quit() was called, or that we should quit the pump
252 // once it becomes idle. 252 // once it becomes idle.
253 bool quit_received; 253 bool quit_received;
254 254
255 #if defined(OS_WIN) || defined(OS_LINUX) 255 #if defined(OS_WIN) || defined(USE_X11)
256 Dispatcher* dispatcher; 256 Dispatcher* dispatcher;
257 #endif 257 #endif
258 }; 258 };
259 259
260 class AutoRunState : RunState { 260 class AutoRunState : RunState {
261 public: 261 public:
262 explicit AutoRunState(MessageLoop* loop); 262 explicit AutoRunState(MessageLoop* loop);
263 ~AutoRunState(); 263 ~AutoRunState();
264 private: 264 private:
265 MessageLoop* loop_; 265 MessageLoop* loop_;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); 429 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
430 return static_cast<MessageLoopForUI*>(loop); 430 return static_cast<MessageLoopForUI*>(loop);
431 } 431 }
432 432
433 #if defined(OS_WIN) 433 #if defined(OS_WIN)
434 void WillProcessMessage(const MSG& message); 434 void WillProcessMessage(const MSG& message);
435 void DidProcessMessage(const MSG& message); 435 void DidProcessMessage(const MSG& message);
436 void PumpOutPendingPaintMessages(); 436 void PumpOutPendingPaintMessages();
437 #endif 437 #endif
438 438
439 #if defined(OS_WIN) || defined(OS_LINUX) 439 #if defined(OS_WIN) || defined(USE_X11)
440 // Please see message_pump_win/message_pump_glib for definitions of these 440 // Please see message_pump_win/message_pump_glib for definitions of these
441 // methods. 441 // methods.
442 void AddObserver(Observer* observer); 442 void AddObserver(Observer* observer);
443 void RemoveObserver(Observer* observer); 443 void RemoveObserver(Observer* observer);
444 void Run(Dispatcher* dispatcher); 444 void Run(Dispatcher* dispatcher);
445 445
446 protected: 446 protected:
447 // TODO(rvargas): Make this platform independent. 447 // TODO(rvargas): Make this platform independent.
448 base::MessagePumpForUI* pump_ui() { 448 base::MessagePumpForUI* pump_ui() {
449 return static_cast<base::MessagePumpForUI*>(pump_.get()); 449 return static_cast<base::MessagePumpForUI*>(pump_.get());
450 } 450 }
451 #endif // defined(OS_WIN) || defined(OS_LINUX) 451 #endif // defined(OS_WIN) || defined(USE_X11)
452 }; 452 };
453 453
454 // Do not add any member variables to MessageLoopForUI! This is important b/c 454 // Do not add any member variables to MessageLoopForUI! This is important b/c
455 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra 455 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra
456 // data that you need should be stored on the MessageLoop's pump_ instance. 456 // data that you need should be stored on the MessageLoop's pump_ instance.
457 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), 457 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI),
458 MessageLoopForUI_should_not_have_extra_member_variables); 458 MessageLoopForUI_should_not_have_extra_member_variables);
459 459
460 //----------------------------------------------------------------------------- 460 //-----------------------------------------------------------------------------
461 // MessageLoopForIO extends MessageLoop with methods that are particular to a 461 // MessageLoopForIO extends MessageLoop with methods that are particular to a
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 #endif // defined(OS_POSIX) 510 #endif // defined(OS_POSIX)
511 }; 511 };
512 512
513 // Do not add any member variables to MessageLoopForIO! This is important b/c 513 // Do not add any member variables to MessageLoopForIO! This is important b/c
514 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 514 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
515 // data that you need should be stored on the MessageLoop's pump_ instance. 515 // data that you need should be stored on the MessageLoop's pump_ instance.
516 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 516 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
517 MessageLoopForIO_should_not_have_extra_member_variables); 517 MessageLoopForIO_should_not_have_extra_member_variables);
518 518
519 #endif // BASE_MESSAGE_LOOP_H_ 519 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « base/logging.cc ('k') | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698