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

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

Issue 19737005: Revert 212948 "Made MessagePump a non-thread safe class." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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();
39 38
40 // Like MessagePump::Run, but events are routed through dispatcher. 39 // Like MessagePump::Run, but events are routed through dispatcher.
41 virtual void RunWithDispatcher(Delegate* delegate, 40 virtual void RunWithDispatcher(Delegate* delegate,
42 MessagePumpDispatcher* dispatcher); 41 MessagePumpDispatcher* dispatcher);
43 42
44 // Internal methods used for processing the pump callbacks. They are 43 // Internal methods used for processing the pump callbacks. They are
45 // public for simplicity but should not be used directly. HandlePrepare 44 // public for simplicity but should not be used directly. HandlePrepare
46 // is called during the prepare step of glib, and returns a timeout that 45 // is called during the prepare step of glib, and returns a timeout that
47 // will be passed to the poll. HandleCheck is called after the poll 46 // will be passed to the poll. HandleCheck is called after the poll
48 // has completed, and returns whether or not HandleDispatch should be called. 47 // has completed, and returns whether or not HandleDispatch should be called.
49 // HandleDispatch is called if HandleCheck returned true. 48 // HandleDispatch is called if HandleCheck returned true.
50 int HandlePrepare(); 49 int HandlePrepare();
51 bool HandleCheck(); 50 bool HandleCheck();
52 void HandleDispatch(); 51 void HandleDispatch();
53 52
54 // Adds an Observer, which will start receiving notifications immediately. 53 // Adds an Observer, which will start receiving notifications immediately.
55 void AddObserver(MessagePumpObserver* observer); 54 void AddObserver(MessagePumpObserver* observer);
56 55
57 // Removes an Observer. It is safe to call this method while an Observer is 56 // Removes an Observer. It is safe to call this method while an Observer is
58 // receiving a notification callback. 57 // receiving a notification callback.
59 void RemoveObserver(MessagePumpObserver* observer); 58 void RemoveObserver(MessagePumpObserver* observer);
60 59
61 // Overridden from MessagePump: 60 // Overridden from MessagePump:
62 virtual void Run(Delegate* delegate) OVERRIDE; 61 virtual void Run(Delegate* delegate) OVERRIDE;
63 virtual void Quit() OVERRIDE; 62 virtual void Quit() OVERRIDE;
64 virtual void ScheduleWork() OVERRIDE; 63 virtual void ScheduleWork() OVERRIDE;
65 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE; 64 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
66 65
67 protected: 66 protected:
67 virtual ~MessagePumpGlib();
68
68 // Returns the dispatcher for the current run state (|state_->dispatcher|). 69 // Returns the dispatcher for the current run state (|state_->dispatcher|).
69 MessagePumpDispatcher* GetDispatcher(); 70 MessagePumpDispatcher* GetDispatcher();
70 71
71 ObserverList<MessagePumpObserver>& observers() { return observers_; } 72 ObserverList<MessagePumpObserver>& observers() { return observers_; }
72 73
73 private: 74 private:
74 // We may make recursive calls to Run, so we save state that needs to be 75 // We may make recursive calls to Run, so we save state that needs to be
75 // separate between them in this structure type. 76 // separate between them in this structure type.
76 struct RunState; 77 struct RunState;
77 78
(...skipping 22 matching lines...) Expand all
100 101
101 // List of observers. 102 // List of observers.
102 ObserverList<MessagePumpObserver> observers_; 103 ObserverList<MessagePumpObserver> observers_;
103 104
104 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib); 105 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib);
105 }; 106 };
106 107
107 } // namespace base 108 } // namespace base
108 109
109 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ 110 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_
OLDNEW
« no previous file with comments | « trunk/src/base/message_loop/message_pump_default.cc ('k') | trunk/src/base/message_loop/message_pump_glib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698