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

Side by Side Diff: base/files/file_descriptor_watcher_posix.cc

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 | « no previous file | base/message_loop/message_loop_unittest.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "base/files/file_descriptor_watcher_posix.h" 5 #include "base/files/file_descriptor_watcher_posix.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // MessageLoopForIO thread. 85 // MessageLoopForIO thread.
86 bool registered_as_destruction_observer_ = false; 86 bool registered_as_destruction_observer_ = false;
87 87
88 DISALLOW_COPY_AND_ASSIGN(Watcher); 88 DISALLOW_COPY_AND_ASSIGN(Watcher);
89 }; 89 };
90 90
91 FileDescriptorWatcher::Controller::Watcher::Watcher( 91 FileDescriptorWatcher::Controller::Watcher::Watcher(
92 WeakPtr<Controller> controller, 92 WeakPtr<Controller> controller,
93 MessageLoopForIO::Mode mode, 93 MessageLoopForIO::Mode mode,
94 int fd) 94 int fd)
95 : controller_(controller), mode_(mode), fd_(fd) { 95 : file_descriptor_watcher_(FROM_HERE),
96 controller_(controller),
97 mode_(mode),
98 fd_(fd) {
96 DCHECK(callback_task_runner_); 99 DCHECK(callback_task_runner_);
97 thread_checker_.DetachFromThread(); 100 thread_checker_.DetachFromThread();
98 } 101 }
99 102
100 FileDescriptorWatcher::Controller::Watcher::~Watcher() { 103 FileDescriptorWatcher::Controller::Watcher::~Watcher() {
101 DCHECK(thread_checker_.CalledOnValidThread()); 104 DCHECK(thread_checker_.CalledOnValidThread());
102 MessageLoopForIO::current()->RemoveDestructionObserver(this); 105 MessageLoopForIO::current()->RemoveDestructionObserver(this);
103 } 106 }
104 107
105 void FileDescriptorWatcher::Controller::Watcher::StartWatching() { 108 void FileDescriptorWatcher::Controller::Watcher::StartWatching() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return WrapUnique(new Controller(MessageLoopForIO::WATCH_READ, fd, callback)); 201 return WrapUnique(new Controller(MessageLoopForIO::WATCH_READ, fd, callback));
199 } 202 }
200 203
201 std::unique_ptr<FileDescriptorWatcher::Controller> 204 std::unique_ptr<FileDescriptorWatcher::Controller>
202 FileDescriptorWatcher::WatchWritable(int fd, const Closure& callback) { 205 FileDescriptorWatcher::WatchWritable(int fd, const Closure& callback) {
203 return WrapUnique( 206 return WrapUnique(
204 new Controller(MessageLoopForIO::WATCH_WRITE, fd, callback)); 207 new Controller(MessageLoopForIO::WATCH_WRITE, fd, callback));
205 } 208 }
206 209
207 } // namespace base 210 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/message_loop/message_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698