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

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 Created 8 years, 1 month 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher); 93 DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher);
94 }; 94 };
95 95
96 enum Mode { 96 enum Mode {
97 WATCH_READ = 1 << 0, 97 WATCH_READ = 1 << 0,
98 WATCH_WRITE = 1 << 1, 98 WATCH_WRITE = 1 << 1
99 WATCH_READ_WRITE = WATCH_READ | WATCH_WRITE
100 }; 99 };
101 100
102 MessagePumpLibevent(); 101 MessagePumpLibevent();
103 102
104 // Have the current thread's message loop watch for a a situation in which 103 // Have the current thread's message loop watch for a a situation in which
105 // reading/writing to the FD can be performed without blocking. 104 // reading/writing to the FD can be performed without blocking.
106 // Callers must provide a preallocated FileDescriptorWatcher object which 105 // Callers must provide a preallocated FileDescriptorWatcher object which
107 // can later be used to manage the lifetime of this event. 106 // can later be used to manage the lifetime of this event.
108 // If a FileDescriptorWatcher is passed in which is already attached to 107 // 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| 108 // an event, then the effect is cumulative i.e. after the call |controller|
110 // will watch both the previous event and the new one. 109 // will watch both the previous event and the new one.
111 // If an error occurs while calling this method in a cumulative fashion, the 110 // If an error occurs while calling this method in a cumulative fashion, the
112 // event previously attached to |controller| is aborted. 111 // event previously attached to |controller| is aborted.
113 // Returns true on success. 112 // Returns true on success.
114 // Must be called on the same thread the message_pump is running on. 113 // Must be called on the same thread the message_pump is running on.
115 // TODO(dkegel): switch to edge-triggered readiness notification 114 // TODO(dkegel): switch to edge-triggered readiness notification
116 bool WatchFileDescriptor(int fd, 115 bool WatchFileDescriptor(int fd,
117 bool persistent, 116 bool persistent,
118 Mode mode, 117 int mode,
119 FileDescriptorWatcher *controller, 118 FileDescriptorWatcher *controller,
120 Watcher *delegate); 119 Watcher *delegate);
121 120
122 void AddIOObserver(IOObserver* obs); 121 void AddIOObserver(IOObserver* obs);
123 void RemoveIOObserver(IOObserver* obs); 122 void RemoveIOObserver(IOObserver* obs);
124 123
125 // MessagePump methods: 124 // MessagePump methods:
126 virtual void Run(Delegate* delegate) OVERRIDE; 125 virtual void Run(Delegate* delegate) OVERRIDE;
127 virtual void Quit() OVERRIDE; 126 virtual void Quit() OVERRIDE;
128 virtual void ScheduleWork() OVERRIDE; 127 virtual void ScheduleWork() OVERRIDE;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 event* wakeup_event_; 171 event* wakeup_event_;
173 172
174 ObserverList<IOObserver> io_observers_; 173 ObserverList<IOObserver> io_observers_;
175 ThreadChecker watch_file_descriptor_caller_checker_; 174 ThreadChecker watch_file_descriptor_caller_checker_;
176 DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent); 175 DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent);
177 }; 176 };
178 177
179 } // namespace base 178 } // namespace base
180 179
181 #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_ 180 #endif // BASE_MESSAGE_PUMP_LIBEVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698