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

Side by Side Diff: base/message_loop/message_pump_libevent.cc

Issue 1097283004: Add toplevel trace event to MessagePumpLibevent::OnLibeventNotification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/message_loop/message_pump_libevent.h" 5 #include "base/message_loop/message_pump_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/posix/eintr_wrapper.h" 16 #include "base/posix/eintr_wrapper.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/trace_event/trace_event.h"
18 #include "third_party/libevent/event.h" 19 #include "third_party/libevent/event.h"
19 20
20 #if defined(OS_MACOSX) 21 #if defined(OS_MACOSX)
21 #include "base/mac/scoped_nsautorelease_pool.h" 22 #include "base/mac/scoped_nsautorelease_pool.h"
22 #endif 23 #endif
23 24
24 // Lifecycle of struct event 25 // Lifecycle of struct event
25 // Libevent uses two main data structures: 26 // Libevent uses two main data structures:
26 // struct event_base (of which there is one per message pump), and 27 // struct event_base (of which there is one per message pump), and
27 // struct event (of which there is roughly one per socket). 28 // struct event (of which there is roughly one per socket).
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return false; 338 return false;
338 return true; 339 return true;
339 } 340 }
340 341
341 // static 342 // static
342 void MessagePumpLibevent::OnLibeventNotification(int fd, short flags, 343 void MessagePumpLibevent::OnLibeventNotification(int fd, short flags,
343 void* context) { 344 void* context) {
344 WeakPtr<FileDescriptorWatcher> controller = 345 WeakPtr<FileDescriptorWatcher> controller =
345 static_cast<FileDescriptorWatcher*>(context)->weak_factory_.GetWeakPtr(); 346 static_cast<FileDescriptorWatcher*>(context)->weak_factory_.GetWeakPtr();
346 DCHECK(controller.get()); 347 DCHECK(controller.get());
348 TRACE_EVENT1("toplevel", "MessagePumpLibevent::OnLibeventNotification",
349 "fd", fd);
347 350
348 MessagePumpLibevent* pump = controller->pump(); 351 MessagePumpLibevent* pump = controller->pump();
349 pump->processed_io_events_ = true; 352 pump->processed_io_events_ = true;
350 353
351 if (flags & EV_WRITE) { 354 if (flags & EV_WRITE) {
352 controller->OnFileCanWriteWithoutBlocking(fd, pump); 355 controller->OnFileCanWriteWithoutBlocking(fd, pump);
353 } 356 }
354 // Check |controller| in case it's been deleted in 357 // Check |controller| in case it's been deleted in
355 // controller->OnFileCanWriteWithoutBlocking(). 358 // controller->OnFileCanWriteWithoutBlocking().
356 if (controller.get() && flags & EV_READ) { 359 if (controller.get() && flags & EV_READ) {
(...skipping 10 matching lines...) Expand all
367 // Remove and discard the wakeup byte. 370 // Remove and discard the wakeup byte.
368 char buf; 371 char buf;
369 int nread = HANDLE_EINTR(read(socket, &buf, 1)); 372 int nread = HANDLE_EINTR(read(socket, &buf, 1));
370 DCHECK_EQ(nread, 1); 373 DCHECK_EQ(nread, 1);
371 that->processed_io_events_ = true; 374 that->processed_io_events_ = true;
372 // Tell libevent to break out of inner loop. 375 // Tell libevent to break out of inner loop.
373 event_base_loopbreak(that->event_base_); 376 event_base_loopbreak(that->event_base_);
374 } 377 }
375 378
376 } // namespace base 379 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698