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

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

Issue 2695593009: Use the location where FileDescriptorWatcher is created to track the libevent handlers (Closed)
Patch Set: fix mac. Created 3 years, 10 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_unittest.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/location.h"
9 #include "base/mac/scoped_cffiledescriptorref.h" 10 #include "base/mac/scoped_cffiledescriptorref.h"
10 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_pump_mac.h" 15 #include "base/message_loop/message_pump_mac.h"
15 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
16 17
17 namespace base { 18 namespace base {
18 19
(...skipping 10 matching lines...) Expand all
29 virtual void OnFileCanReadWithoutBlocking(int fd) = 0; 30 virtual void OnFileCanReadWithoutBlocking(int fd) = 0;
30 virtual void OnFileCanWriteWithoutBlocking(int fd) = 0; 31 virtual void OnFileCanWriteWithoutBlocking(int fd) = 0;
31 32
32 protected: 33 protected:
33 virtual ~Watcher() {} 34 virtual ~Watcher() {}
34 }; 35 };
35 36
36 // Object returned by WatchFileDescriptor to manage further watching. 37 // Object returned by WatchFileDescriptor to manage further watching.
37 class FileDescriptorWatcher { 38 class FileDescriptorWatcher {
38 public: 39 public:
39 FileDescriptorWatcher(); 40 explicit FileDescriptorWatcher(const tracked_objects::Location& from_here);
40 ~FileDescriptorWatcher(); // Implicitly calls StopWatchingFileDescriptor. 41 ~FileDescriptorWatcher(); // Implicitly calls StopWatchingFileDescriptor.
41 42
42 // NOTE: These methods aren't called StartWatching()/StopWatching() to 43 // NOTE: These methods aren't called StartWatching()/StopWatching() to
43 // avoid confusion with the win32 ObjectWatcher class. 44 // avoid confusion with the win32 ObjectWatcher class.
44 45
45 // Stop watching the FD, always safe to call. No-op if there's nothing 46 // Stop watching the FD, always safe to call. No-op if there's nothing
46 // to do. 47 // to do.
47 bool StopWatchingFileDescriptor(); 48 bool StopWatchingFileDescriptor();
48 49
50 const tracked_objects::Location& created_from_location() {
51 return created_from_location_;
52 }
53
49 private: 54 private:
50 friend class MessagePumpIOSForIO; 55 friend class MessagePumpIOSForIO;
51 friend class MessagePumpIOSForIOTest; 56 friend class MessagePumpIOSForIOTest;
52 57
53 // Called by MessagePumpIOSForIO, ownership of |fdref| and |fd_source| 58 // Called by MessagePumpIOSForIO, ownership of |fdref| and |fd_source|
54 // is transferred to this object. 59 // is transferred to this object.
55 void Init(CFFileDescriptorRef fdref, 60 void Init(CFFileDescriptorRef fdref,
56 CFOptionFlags callback_types, 61 CFOptionFlags callback_types,
57 CFRunLoopSourceRef fd_source, 62 CFRunLoopSourceRef fd_source,
58 bool is_persistent); 63 bool is_persistent);
59 64
60 void set_pump(base::WeakPtr<MessagePumpIOSForIO> pump) { pump_ = pump; } 65 void set_pump(base::WeakPtr<MessagePumpIOSForIO> pump) { pump_ = pump; }
61 const base::WeakPtr<MessagePumpIOSForIO>& pump() const { return pump_; } 66 const base::WeakPtr<MessagePumpIOSForIO>& pump() const { return pump_; }
62 67
63 void set_watcher(Watcher* watcher) { watcher_ = watcher; } 68 void set_watcher(Watcher* watcher) { watcher_ = watcher; }
64 69
65 void OnFileCanReadWithoutBlocking(int fd, MessagePumpIOSForIO* pump); 70 void OnFileCanReadWithoutBlocking(int fd, MessagePumpIOSForIO* pump);
66 void OnFileCanWriteWithoutBlocking(int fd, MessagePumpIOSForIO* pump); 71 void OnFileCanWriteWithoutBlocking(int fd, MessagePumpIOSForIO* pump);
67 72
68 bool is_persistent_; // false if this event is one-shot. 73 bool is_persistent_; // false if this event is one-shot.
69 base::mac::ScopedCFFileDescriptorRef fdref_; 74 base::mac::ScopedCFFileDescriptorRef fdref_;
70 CFOptionFlags callback_types_; 75 CFOptionFlags callback_types_;
71 base::ScopedCFTypeRef<CFRunLoopSourceRef> fd_source_; 76 base::ScopedCFTypeRef<CFRunLoopSourceRef> fd_source_;
72 base::WeakPtr<MessagePumpIOSForIO> pump_; 77 base::WeakPtr<MessagePumpIOSForIO> pump_;
73 Watcher* watcher_; 78 Watcher* watcher_;
74 79
80 tracked_objects::Location created_from_location_;
81
75 DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher); 82 DISALLOW_COPY_AND_ASSIGN(FileDescriptorWatcher);
76 }; 83 };
77 84
78 enum Mode { 85 enum Mode {
79 WATCH_READ = 1 << 0, 86 WATCH_READ = 1 << 0,
80 WATCH_WRITE = 1 << 1, 87 WATCH_WRITE = 1 << 1,
81 WATCH_READ_WRITE = WATCH_READ | WATCH_WRITE 88 WATCH_READ_WRITE = WATCH_READ | WATCH_WRITE
82 }; 89 };
83 90
84 MessagePumpIOSForIO(); 91 MessagePumpIOSForIO();
(...skipping 28 matching lines...) Expand all
113 ThreadChecker watch_file_descriptor_caller_checker_; 120 ThreadChecker watch_file_descriptor_caller_checker_;
114 121
115 base::WeakPtrFactory<MessagePumpIOSForIO> weak_factory_; 122 base::WeakPtrFactory<MessagePumpIOSForIO> weak_factory_;
116 123
117 DISALLOW_COPY_AND_ASSIGN(MessagePumpIOSForIO); 124 DISALLOW_COPY_AND_ASSIGN(MessagePumpIOSForIO);
118 }; 125 };
119 126
120 } // namespace base 127 } // namespace base
121 128
122 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_ 129 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_IO_IOS_H_
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_unittest.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