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

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

Issue 1950633002: Remove IOObservers from MessageLoopForIO. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 7 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
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/message_loop/message_pump_io_ios.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_IO_IOS_H_ 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/mac/scoped_cffiledescriptorref.h" 9 #include "base/mac/scoped_cffiledescriptorref.h"
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_pump_mac.h" 14 #include "base/message_loop/message_pump_mac.h"
15 #include "base/observer_list.h"
16 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
17 16
18 namespace base { 17 namespace base {
19 18
20 // This file introduces a class to monitor sockets and issue callbacks when 19 // This file introduces a class to monitor sockets and issue callbacks when
21 // sockets are ready for I/O on iOS. 20 // sockets are ready for I/O on iOS.
22 class BASE_EXPORT MessagePumpIOSForIO : public MessagePumpNSRunLoop { 21 class BASE_EXPORT MessagePumpIOSForIO : public MessagePumpNSRunLoop {
23 public: 22 public:
24 class IOObserver {
25 public:
26 IOObserver() {}
27
28 // An IOObserver is an object that receives IO notifications from the
29 // MessagePump.
30 //
31 // NOTE: An IOObserver implementation should be extremely fast!
32 virtual void WillProcessIOEvent() = 0;
33 virtual void DidProcessIOEvent() = 0;
34
35 protected:
36 virtual ~IOObserver() {}
37 };
38
39 // Used with WatchFileDescriptor to asynchronously monitor the I/O readiness 23 // Used with WatchFileDescriptor to asynchronously monitor the I/O readiness
40 // of a file descriptor. 24 // of a file descriptor.
41 class Watcher { 25 class Watcher {
42 public: 26 public:
43 // Called from MessageLoop::Run when an FD can be read from/written to 27 // Called from MessageLoop::Run when an FD can be read from/written to
44 // without blocking 28 // without blocking
45 virtual void OnFileCanReadWithoutBlocking(int fd) = 0; 29 virtual void OnFileCanReadWithoutBlocking(int fd) = 0;
46 virtual void OnFileCanWriteWithoutBlocking(int fd) = 0; 30 virtual void OnFileCanWriteWithoutBlocking(int fd) = 0;
47 31
48 protected: 32 protected:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Returns true on success. 96 // Returns true on success.
113 // Must be called on the same thread the message_pump is running on. 97 // Must be called on the same thread the message_pump is running on.
114 bool WatchFileDescriptor(int fd, 98 bool WatchFileDescriptor(int fd,
115 bool persistent, 99 bool persistent,
116 int mode, 100 int mode,
117 FileDescriptorWatcher *controller, 101 FileDescriptorWatcher *controller,
118 Watcher *delegate); 102 Watcher *delegate);
119 103
120 void RemoveRunLoopSource(CFRunLoopSourceRef source); 104 void RemoveRunLoopSource(CFRunLoopSourceRef source);
121 105
122 void AddIOObserver(IOObserver* obs);
123 void RemoveIOObserver(IOObserver* obs);
124
125 private: 106 private:
126 friend class MessagePumpIOSForIOTest; 107 friend class MessagePumpIOSForIOTest;
127 108
128 void WillProcessIOEvent(); 109 void WillProcessIOEvent();
129 void DidProcessIOEvent(); 110 void DidProcessIOEvent();
130 111
131 static void HandleFdIOEvent(CFFileDescriptorRef fdref, 112 static void HandleFdIOEvent(CFFileDescriptorRef fdref,
132 CFOptionFlags callback_types, 113 CFOptionFlags callback_types,
133 void* context); 114 void* context);
134 115
135 ObserverList<IOObserver> io_observers_;
136 ThreadChecker watch_file_descriptor_caller_checker_; 116 ThreadChecker watch_file_descriptor_caller_checker_;
137 117
138 base::WeakPtrFactory<MessagePumpIOSForIO> weak_factory_; 118 base::WeakPtrFactory<MessagePumpIOSForIO> weak_factory_;
139 119
140 DISALLOW_COPY_AND_ASSIGN(MessagePumpIOSForIO); 120 DISALLOW_COPY_AND_ASSIGN(MessagePumpIOSForIO);
141 }; 121 };
142 122
143 } // namespace base 123 } // namespace base
144 124
145 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_ 125 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.cc ('k') | base/message_loop/message_pump_io_ios.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698