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

Side by Side Diff: base/message_loop/message_pump_glib.h

Issue 17567007: Made MessagePump a non-thread safe class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_MESSAGE_PUMP_GLIB_H_ 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_pump.h" 10 #include "base/message_loop/message_pump.h"
(...skipping 17 matching lines...) Expand all
28 // passed to Dispatcher's Dispatch method for dispatch. It is up to the 28 // passed to Dispatcher's Dispatch method for dispatch. It is up to the
29 // Dispatcher to dispatch, or not, the event. The platform specific 29 // Dispatcher to dispatch, or not, the event. The platform specific
30 // implementation of the class is in message_pump_gtk/message_pump_x. 30 // implementation of the class is in message_pump_gtk/message_pump_x.
31 class MessagePumpDispatcher; 31 class MessagePumpDispatcher;
32 32
33 // This class implements a base MessagePump needed for TYPE_UI MessageLoops on 33 // This class implements a base MessagePump needed for TYPE_UI MessageLoops on
34 // platforms using GLib. 34 // platforms using GLib.
35 class BASE_EXPORT MessagePumpGlib : public MessagePump { 35 class BASE_EXPORT MessagePumpGlib : public MessagePump {
36 public: 36 public:
37 MessagePumpGlib(); 37 MessagePumpGlib();
38 virtual ~MessagePumpGlib();
38 39
39 // Like MessagePump::Run, but events are routed through dispatcher. 40 // Like MessagePump::Run, but events are routed through dispatcher.
40 virtual void RunWithDispatcher(Delegate* delegate, 41 virtual void RunWithDispatcher(Delegate* delegate,
41 MessagePumpDispatcher* dispatcher); 42 MessagePumpDispatcher* dispatcher);
42 43
43 // Internal methods used for processing the pump callbacks. They are 44 // Internal methods used for processing the pump callbacks. They are
44 // public for simplicity but should not be used directly. HandlePrepare 45 // public for simplicity but should not be used directly. HandlePrepare
45 // is called during the prepare step of glib, and returns a timeout that 46 // is called during the prepare step of glib, and returns a timeout that
46 // will be passed to the poll. HandleCheck is called after the poll 47 // will be passed to the poll. HandleCheck is called after the poll
47 // has completed, and returns whether or not HandleDispatch should be called. 48 // has completed, and returns whether or not HandleDispatch should be called.
48 // HandleDispatch is called if HandleCheck returned true. 49 // HandleDispatch is called if HandleCheck returned true.
49 int HandlePrepare(); 50 int HandlePrepare();
50 bool HandleCheck(); 51 bool HandleCheck();
51 void HandleDispatch(); 52 void HandleDispatch();
52 53
53 // Adds an Observer, which will start receiving notifications immediately. 54 // Adds an Observer, which will start receiving notifications immediately.
54 void AddObserver(MessagePumpObserver* observer); 55 void AddObserver(MessagePumpObserver* observer);
55 56
56 // Removes an Observer. It is safe to call this method while an Observer is 57 // Removes an Observer. It is safe to call this method while an Observer is
57 // receiving a notification callback. 58 // receiving a notification callback.
58 void RemoveObserver(MessagePumpObserver* observer); 59 void RemoveObserver(MessagePumpObserver* observer);
59 60
60 // Overridden from MessagePump: 61 // Overridden from MessagePump:
61 virtual void Run(Delegate* delegate) OVERRIDE; 62 virtual void Run(Delegate* delegate) OVERRIDE;
62 virtual void Quit() OVERRIDE; 63 virtual void Quit() OVERRIDE;
63 virtual void ScheduleWork() OVERRIDE; 64 virtual void ScheduleWork() OVERRIDE;
64 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE; 65 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
65 66
66 protected: 67 protected:
67 virtual ~MessagePumpGlib();
68
69 // Returns the dispatcher for the current run state (|state_->dispatcher|). 68 // Returns the dispatcher for the current run state (|state_->dispatcher|).
70 MessagePumpDispatcher* GetDispatcher(); 69 MessagePumpDispatcher* GetDispatcher();
71 70
72 ObserverList<MessagePumpObserver>& observers() { return observers_; } 71 ObserverList<MessagePumpObserver>& observers() { return observers_; }
73 72
74 private: 73 private:
75 // We may make recursive calls to Run, so we save state that needs to be 74 // We may make recursive calls to Run, so we save state that needs to be
76 // separate between them in this structure type. 75 // separate between them in this structure type.
77 struct RunState; 76 struct RunState;
78 77
(...skipping 22 matching lines...) Expand all
101 100
102 // List of observers. 101 // List of observers.
103 ObserverList<MessagePumpObserver> observers_; 102 ObserverList<MessagePumpObserver> observers_;
104 103
105 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib); 104 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib);
106 }; 105 };
107 106
108 } // namespace base 107 } // namespace base
109 108
110 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ 109 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698