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

Unified Diff: base/message_loop/message_pump_mac.mm

Issue 20792003: DO NOT SUBMIT. Hacky trace event data for MessagePumpMac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_loop/message_pump_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_mac.mm
diff --git a/base/message_loop/message_pump_mac.mm b/base/message_loop/message_pump_mac.mm
index f885fbf5f6bbb9d53fc1d24363c0f427699ace6c..3793ab85decf591bf13925aa1d06514f2f959a93 100644
--- a/base/message_loop/message_pump_mac.mm
+++ b/base/message_loop/message_pump_mac.mm
@@ -8,6 +8,7 @@
#include <limits>
+#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/run_loop.h"
#include "base/time/time.h"
@@ -101,7 +102,8 @@ MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase()
CFRunLoopObserverContext observer_context = CFRunLoopObserverContext();
observer_context.info = this;
pre_wait_observer_ = CFRunLoopObserverCreate(NULL, // allocator
- kCFRunLoopBeforeWaiting,
+ kCFRunLoopBeforeWaiting |
+ kCFRunLoopAfterWaiting,
true, // repeat
0, // priority
PreWaitObserver,
@@ -226,6 +228,7 @@ void MessagePumpCFRunLoopBase::RunDelayedWorkTimer(CFRunLoopTimerRef timer,
// Called from the run loop.
// static
void MessagePumpCFRunLoopBase::RunWorkSource(void* info) {
+ TRACE_EVENT0("CFRunLoop", "RunWorkSource");
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
self->RunWork();
}
@@ -285,6 +288,7 @@ bool MessagePumpCFRunLoopBase::RunWork() {
// Called from the run loop.
// static
void MessagePumpCFRunLoopBase::RunIdleWorkSource(void* info) {
+ TRACE_EVENT0("CFRunLoop", "RunWorkIdleSource");
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
self->RunIdleWork();
}
@@ -319,6 +323,7 @@ bool MessagePumpCFRunLoopBase::RunIdleWork() {
// Called from the run loop.
// static
void MessagePumpCFRunLoopBase::RunNestingDeferredWorkSource(void* info) {
+ TRACE_EVENT0("CFRunLoop", "RunNestingDeferredWorkSource");
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
self->RunNestingDeferredWork();
}
@@ -368,6 +373,18 @@ void MessagePumpCFRunLoopBase::PreWaitObserver(CFRunLoopObserverRef observer,
void* info) {
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
+ static uint32 last_id = 0;
+ if (activity == kCFRunLoopBeforeWaiting)
+ self->nesting_stack_.push(++last_id);
+ uint64_t trace_id = ((uintptr_t)observer << sizeof(uint32)) | self->nesting_stack_.top();
+ if (activity == kCFRunLoopAfterWaiting) {
+ TRACE_EVENT_ASYNC_END0("CFRunLoop", "Waiting", trace_id);
+ self->nesting_stack_.pop();
+ return;
+ } else {
+ TRACE_EVENT_ASYNC_BEGIN0("CFRunLoop", "Waiting", trace_id);
+ }
+
// Attempt to do some idle work before going to sleep.
self->RunIdleWork();
@@ -399,9 +416,16 @@ void MessagePumpCFRunLoopBase::EnterExitObserver(CFRunLoopObserverRef observer,
CFRunLoopActivity activity,
void* info) {
MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
+ static uint32 last_id = 0;
+
+ if (activity == kCFRunLoopEntry)
+ self->nesting_stack_.push(++last_id);
+
+ uint64_t trace_id = ((uintptr_t)observer << sizeof(uint32)) | self->nesting_stack_.top();
switch (activity) {
case kCFRunLoopEntry:
+ TRACE_EVENT_ASYNC_BEGIN0("CFRunLoop", "LoopCycle", trace_id);
++self->nesting_level_;
if (self->nesting_level_ > self->deepest_nesting_level_) {
self->deepest_nesting_level_ = self->nesting_level_;
@@ -427,6 +451,8 @@ void MessagePumpCFRunLoopBase::EnterExitObserver(CFRunLoopObserverRef observer,
// loop.
self->MaybeScheduleNestingDeferredWork();
--self->nesting_level_;
+ TRACE_EVENT_ASYNC_END0("CFRunLoop", "LoopCycle", trace_id);
+ self->nesting_stack_.pop();
break;
default:
@@ -461,6 +487,7 @@ void MessagePumpCFRunLoop::DoRun(Delegate* delegate) {
// pool management is introduced.
int result;
do {
+ TRACE_EVENT0("CFRunLoop", "DoRun");
MessagePumpScopedAutoreleasePool autorelease_pool(this);
result = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
kCFTimeIntervalMax,
@@ -515,6 +542,7 @@ MessagePumpNSRunLoop::~MessagePumpNSRunLoop() {
void MessagePumpNSRunLoop::DoRun(Delegate* delegate) {
while (keep_running_) {
+ TRACE_EVENT0("NSRunLoop", "DoRun");
// NSRunLoop manages autorelease pools itself.
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
@@ -578,6 +606,7 @@ void MessagePumpNSApplication::DoRun(Delegate* delegate) {
running_own_loop_ = true;
NSDate* distant_future = [NSDate distantFuture];
while (keep_running_) {
+ TRACE_EVENT0("NSApplication", "DoRun");
MessagePumpScopedAutoreleasePool autorelease_pool(this);
NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:distant_future
« no previous file with comments | « base/message_loop/message_pump_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698