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

Side by Side Diff: base/message_pump_libevent.h

Issue 11412101: Provide an iOS message pump for IO implementation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Response to review, bugfix Created 8 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) 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_PUMP_LIBEVENT_H_ 5 #ifndef BASE_MESSAGE_PUMP_LIBEVENT_H_
6 #define BASE_MESSAGE_PUMP_LIBEVENT_H_ 6 #define BASE_MESSAGE_PUMP_LIBEVENT_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 20 matching lines...) Expand all
31 // MessagePump. 31 // MessagePump.
32 // 32 //
33 // NOTE: An IOObserver implementation should be extremely fast! 33 // NOTE: An IOObserver implementation should be extremely fast!
34 virtual void WillProcessIOEvent() = 0; 34 virtual void WillProcessIOEvent() = 0;
35 virtual void DidProcessIOEvent() = 0; 35 virtual void DidProcessIOEvent() = 0;
36 36
37 protected: 37 protected:
38 virtual ~IOObserver() {} 38 virtual ~IOObserver() {}
39 }; 39 };
40 40
41 class FileDescriptorWatcher; 41 class FileDescriptorWatcher;
wtc 2012/11/29 00:53:21 Remove this forward declaration.
blundell 2012/11/29 15:01:04 Done.
42 42
43 // Used with WatchFileDescriptor to asynchronously monitor the I/O readiness 43 // Used with WatchFileDescriptor to asynchronously monitor the I/O readiness
44 // of a file descriptor. 44 // of a file descriptor.
45 class Watcher { 45 class Watcher {
46 public: 46 public:
47 // Called from MessageLoop::Run when an FD can be read from/written to 47 // Called from MessageLoop::Run when an FD can be read from/written to
48 // without blocking 48 // without blocking
49 virtual void OnFileCanReadWithoutBlocking(int fd) = 0; 49 virtual void OnFileCanReadWithoutBlocking(int fd) = 0;
50 virtual void OnFileCanWriteWithoutBlocking(int fd) = 0; 50 virtual void OnFileCanWriteWithoutBlocking(int fd) = 0;
51 51
(...skipping 19 matching lines...) Expand all
71 friend class MessagePumpLibeventTest; 71 friend class MessagePumpLibeventTest;
72 72
73 // Called by MessagePumpLibevent, ownership of |e| is transferred to this 73 // Called by MessagePumpLibevent, ownership of |e| is transferred to this
74 // object. 74 // object.
75 void Init(event* e); 75 void Init(event* e);
76 76
77 // Used by MessagePumpLibevent to take ownership of event_. 77 // Used by MessagePumpLibevent to take ownership of event_.
78 event* ReleaseEvent(); 78 event* ReleaseEvent();
79 79
80 void set_pump(MessagePumpLibevent* pump) { pump_ = pump; } 80 void set_pump(MessagePumpLibevent* pump) { pump_ = pump; }
81 MessagePumpLibevent* pump() { return pump_; } 81 MessagePumpLibevent* pump() { return pump_; }
wtc 2012/11/29 00:53:21 Add 'const' to this getter method.
blundell 2012/11/29 15:01:04 Done.
82 82
83 void set_watcher(Watcher* watcher) { watcher_ = watcher; } 83 void set_watcher(Watcher* watcher) { watcher_ = watcher; }
84 84
85 void OnFileCanReadWithoutBlocking(int fd, MessagePumpLibevent* pump); 85 void OnFileCanReadWithoutBlocking(int fd, MessagePumpLibevent* pump);
86 void OnFileCanWriteWithoutBlocking(int fd, MessagePumpLibevent* pump); 86 void OnFileCanWriteWithoutBlocking(int fd, MessagePumpLibevent* pump);
87 87
88 event* event_; 88 event* event_;
89 MessagePumpLibevent* pump_; 89 MessagePumpLibevent* pump_;
90 Watcher* watcher_; 90 Watcher* watcher_;
91 base::WeakPtrFactory<FileDescriptorWatcher> weak_factory_; 91 base::WeakPtrFactory<FileDescriptorWatcher> weak_factory_;
(...skipping 16 matching lines...) Expand all
108 // If a FileDescriptorWatcher is passed in which is already attached to 108 // If a FileDescriptorWatcher is passed in which is already attached to
109 // an event, then the effect is cumulative i.e. after the call |controller| 109 // an event, then the effect is cumulative i.e. after the call |controller|
110 // will watch both the previous event and the new one. 110 // will watch both the previous event and the new one.
111 // If an error occurs while calling this method in a cumulative fashion, the 111 // If an error occurs while calling this method in a cumulative fashion, the
112 // event previously attached to |controller| is aborted. 112 // event previously attached to |controller| is aborted.
113 // Returns true on success. 113 // Returns true on success.
114 // Must be called on the same thread the message_pump is running on. 114 // Must be called on the same thread the message_pump is running on.
115 // TODO(dkegel): switch to edge-triggered readiness notification 115 // TODO(dkegel): switch to edge-triggered readiness notification
116 bool WatchFileDescriptor(int fd, 116 bool WatchFileDescriptor(int fd,
117 bool persistent, 117 bool persistent,
118 Mode mode, 118 int mode,
119 FileDescriptorWatcher *controller, 119 FileDescriptorWatcher *controller,
120 Watcher *delegate); 120 Watcher *delegate);
121 121
122 void AddIOObserver(IOObserver* obs); 122 void AddIOObserver(IOObserver* obs);
123 void RemoveIOObserver(IOObserver* obs); 123 void RemoveIOObserver(IOObserver* obs);
124 124
125 // MessagePump methods: 125 // MessagePump methods:
126 virtual void Run(Delegate* delegate) OVERRIDE; 126 virtual void Run(Delegate* delegate) OVERRIDE;
127 virtual void Quit() OVERRIDE; 127 virtual void Quit() OVERRIDE;
128 virtual void ScheduleWork() OVERRIDE; 128 virtual void ScheduleWork() OVERRIDE;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 event* wakeup_event_; 172 event* wakeup_event_;
173 173
174 ObserverList<IOObserver> io_observers_; 174 ObserverList<IOObserver> io_observers_;
175 ThreadChecker watch_file_descriptor_caller_checker_; 175 ThreadChecker watch_file_descriptor_caller_checker_;
176 DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent); 176 DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent);
177 }; 177 };
178 178
179 } // namespace base 179 } // namespace base
180 180
181 #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_ 181 #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698