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

Side by Side Diff: base/message_loop.h

Issue 495002: Changes to base/ from a combination of FreeBSD and OpenBSD patches. (Closed)
Patch Set: minor tweaks Created 11 years 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
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 #if !defined(OS_MACOSX)
agl 2009/12/14 19:31:26 It might be against our style, but I would still i
25 #include "base/message_pump_glib.h"
24 #endif 26 #endif
25 #if defined(OS_LINUX)
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
36 // may also be processed. 36 // may also be processed.
(...skipping 193 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(OS_MACOSX)
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_MACOSX)
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type()); 433 DCHECK_EQ(MessageLoop::TYPE_UI, loop->type());
434 return static_cast<MessageLoopForUI*>(loop); 434 return static_cast<MessageLoopForUI*>(loop);
435 } 435 }
436 436
437 #if defined(OS_WIN) 437 #if defined(OS_WIN)
438 void WillProcessMessage(const MSG& message); 438 void WillProcessMessage(const MSG& message);
439 void DidProcessMessage(const MSG& message); 439 void DidProcessMessage(const MSG& message);
440 void PumpOutPendingPaintMessages(); 440 void PumpOutPendingPaintMessages();
441 #endif 441 #endif
442 442
443 #if defined(OS_WIN) || defined(OS_LINUX) 443 #if !defined(OS_MACOSX)
444 // Please see message_pump_win/message_pump_glib for definitions of these 444 // Please see message_pump_win/message_pump_glib for definitions of these
445 // methods. 445 // methods.
446 void AddObserver(Observer* observer); 446 void AddObserver(Observer* observer);
447 void RemoveObserver(Observer* observer); 447 void RemoveObserver(Observer* observer);
448 void Run(Dispatcher* dispatcher); 448 void Run(Dispatcher* dispatcher);
449 449
450 protected: 450 protected:
451 // TODO(rvargas): Make this platform independent. 451 // TODO(rvargas): Make this platform independent.
452 base::MessagePumpForUI* pump_ui() { 452 base::MessagePumpForUI* pump_ui() {
453 return static_cast<base::MessagePumpForUI*>(pump_.get()); 453 return static_cast<base::MessagePumpForUI*>(pump_.get());
454 } 454 }
455 #endif // defined(OS_WIN) || defined(OS_LINUX) 455 #endif // defined(OS_MACOSX)
456 }; 456 };
457 457
458 // Do not add any member variables to MessageLoopForUI! This is important b/c 458 // Do not add any member variables to MessageLoopForUI! This is important b/c
459 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra 459 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra
460 // data that you need should be stored on the MessageLoop's pump_ instance. 460 // data that you need should be stored on the MessageLoop's pump_ instance.
461 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), 461 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI),
462 MessageLoopForUI_should_not_have_extra_member_variables); 462 MessageLoopForUI_should_not_have_extra_member_variables);
463 463
464 //----------------------------------------------------------------------------- 464 //-----------------------------------------------------------------------------
465 // MessageLoopForIO extends MessageLoop with methods that are particular to a 465 // MessageLoopForIO extends MessageLoop with methods that are particular to a
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 #endif // defined(OS_POSIX) 514 #endif // defined(OS_POSIX)
515 }; 515 };
516 516
517 // Do not add any member variables to MessageLoopForIO! This is important b/c 517 // Do not add any member variables to MessageLoopForIO! This is important b/c
518 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 518 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
519 // data that you need should be stored on the MessageLoop's pump_ instance. 519 // data that you need should be stored on the MessageLoop's pump_ instance.
520 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 520 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
521 MessageLoopForIO_should_not_have_extra_member_variables); 521 MessageLoopForIO_should_not_have_extra_member_variables);
522 522
523 #endif // BASE_MESSAGE_LOOP_H_ 523 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« base/file_util_posix.cc ('K') | « base/logging.cc ('k') | base/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698