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

Side by Side Diff: mojo/edk/system/channel_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 | « dbus/bus.cc ('k') | net/base/address_tracker_linux.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 "mojo/edk/system/channel.h" 5 #include "mojo/edk/system/channel.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 ~ChannelPosix() override { 203 ~ChannelPosix() override {
204 DCHECK(!read_watcher_); 204 DCHECK(!read_watcher_);
205 DCHECK(!write_watcher_); 205 DCHECK(!write_watcher_);
206 for (auto handle : incoming_platform_handles_) 206 for (auto handle : incoming_platform_handles_)
207 handle.CloseIfNecessary(); 207 handle.CloseIfNecessary();
208 } 208 }
209 209
210 void StartOnIOThread() { 210 void StartOnIOThread() {
211 DCHECK(!read_watcher_); 211 DCHECK(!read_watcher_);
212 DCHECK(!write_watcher_); 212 DCHECK(!write_watcher_);
213 read_watcher_.reset(new base::MessageLoopForIO::FileDescriptorWatcher); 213 read_watcher_.reset(
214 new base::MessageLoopForIO::FileDescriptorWatcher(FROM_HERE));
214 base::MessageLoop::current()->AddDestructionObserver(this); 215 base::MessageLoop::current()->AddDestructionObserver(this);
215 if (handle_.get().needs_connection) { 216 if (handle_.get().needs_connection) {
216 base::MessageLoopForIO::current()->WatchFileDescriptor( 217 base::MessageLoopForIO::current()->WatchFileDescriptor(
217 handle_.get().handle, false /* persistent */, 218 handle_.get().handle, false /* persistent */,
218 base::MessageLoopForIO::WATCH_READ, read_watcher_.get(), this); 219 base::MessageLoopForIO::WATCH_READ, read_watcher_.get(), this);
219 } else { 220 } else {
220 write_watcher_.reset(new base::MessageLoopForIO::FileDescriptorWatcher); 221 write_watcher_.reset(
222 new base::MessageLoopForIO::FileDescriptorWatcher(FROM_HERE));
221 base::MessageLoopForIO::current()->WatchFileDescriptor( 223 base::MessageLoopForIO::current()->WatchFileDescriptor(
222 handle_.get().handle, true /* persistent */, 224 handle_.get().handle, true /* persistent */,
223 base::MessageLoopForIO::WATCH_READ, read_watcher_.get(), this); 225 base::MessageLoopForIO::WATCH_READ, read_watcher_.get(), this);
224 base::AutoLock lock(write_lock_); 226 base::AutoLock lock(write_lock_);
225 FlushOutgoingMessagesNoLock(); 227 FlushOutgoingMessagesNoLock();
226 } 228 }
227 } 229 }
228 230
229 void WaitForWriteOnIOThread() { 231 void WaitForWriteOnIOThread() {
230 base::AutoLock lock(write_lock_); 232 base::AutoLock lock(write_lock_);
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // static 561 // static
560 scoped_refptr<Channel> Channel::Create( 562 scoped_refptr<Channel> Channel::Create(
561 Delegate* delegate, 563 Delegate* delegate,
562 ScopedPlatformHandle platform_handle, 564 ScopedPlatformHandle platform_handle,
563 scoped_refptr<base::TaskRunner> io_task_runner) { 565 scoped_refptr<base::TaskRunner> io_task_runner) {
564 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner); 566 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner);
565 } 567 }
566 568
567 } // namespace edk 569 } // namespace edk
568 } // namespace mojo 570 } // namespace mojo
OLDNEW
« no previous file with comments | « dbus/bus.cc ('k') | net/base/address_tracker_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698