Skip to content

Commit

Permalink
Adding tracking to verify the theory that jankiness of ExtensionMessa…
Browse files Browse the repository at this point in the history
…geFilter::OnExtensionAddListener is because of the observer invocation.

BUG=401560, 417106

Review URL: https://codereview.chromium.org/600213002

Cr-Commit-Position: refs/heads/master@{#296804}
  • Loading branch information
vadimt authored and Commit bot committed Sep 25, 2014
1 parent ab5a96f commit a19e487
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 29 deletions.
25 changes: 5 additions & 20 deletions base/profiler/scoped_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,16 @@
#include "base/profiler/tracked_time.h"
#include "base/tracked_objects.h"

#if defined(GOOGLE_CHROME_BUILD)

// We don't ship these profiled regions. This is for developer builds only.
// It allows developers to do some profiling of their code, and see results on
// their about:profiler page.
#define TRACK_RUN_IN_THIS_SCOPED_REGION_FOR_DEVELOPER_BUILDS(scope_name) \
((void)0)

#else

#define TRACK_RUN_IN_THIS_SCOPED_REGION_FOR_DEVELOPER_BUILDS(scope_name) \
::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
FROM_HERE_WITH_EXPLICIT_FUNCTION(#scope_name))

#endif



#define PASTE_LINE_NUMBER_ON_NAME(name, line) name##line

#define LINE_BASED_VARIABLE_NAME_FOR_PROFILING \
PASTE_LINE_NUMBER_ON_NAME(some_profiler_variable_, __LINE__)

#define TRACK_RUN_IN_IPC_HANDLER(dispatch_function_name) \
::tracked_objects::ScopedProfile some_tracking_variable_name( \
// Defines the containing scope as a profiled region. This allows developers to
// profile their code and see results on their about:profiler page, as well as
// on the UMA dashboard.
#define TRACK_RUN_IN_THIS_SCOPED_REGION(dispatch_function_name) \
::tracked_objects::ScopedProfile LINE_BASED_VARIABLE_NAME_FOR_PROFILING( \
FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name))


Expand Down
8 changes: 7 additions & 1 deletion extensions/browser/event_router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/profiler/scoped_profile.h"
#include "base/stl_util.h"
#include "base/values.h"
#include "content/public/browser/child_process_security_policy.h"
Expand Down Expand Up @@ -237,8 +238,13 @@ void EventRouter::OnListenerAdded(const EventListener* listener) {
listener->GetBrowserContext());
std::string base_event_name = GetBaseEventName(listener->event_name());
ObserverMap::iterator observer = observers_.find(base_event_name);
if (observer != observers_.end())
if (observer != observers_.end()) {
// TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed.
tracked_objects::ScopedProfile tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"EventRouter_OnListenerAdded_ObserverCall"));
observer->second->OnListenerAdded(details);
}
}

void EventRouter::OnListenerRemoved(const EventListener* listener) {
Expand Down
8 changes: 4 additions & 4 deletions ipc/ipc_message_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@

#define IPC_MESSAGE_FORWARD(msg_class, obj, member_func) \
case msg_class::ID: { \
TRACK_RUN_IN_IPC_HANDLER(member_func); \
TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \
if (!msg_class::Dispatch(&ipc_message__, obj, this, param__, \
&member_func)) \
ipc_message__.set_dispatch_error(); \
Expand All @@ -926,7 +926,7 @@

#define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \
case msg_class::ID: { \
TRACK_RUN_IN_IPC_HANDLER(member_func); \
TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \
if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__, \
&member_func)) \
ipc_message__.set_dispatch_error(); \
Expand All @@ -940,14 +940,14 @@
// TODO(jar): fix chrome frame to always supply |code| argument.
#define IPC_MESSAGE_HANDLER_GENERIC(msg_class, code) \
case msg_class::ID: { \
/* TRACK_RUN_IN_IPC_HANDLER(code); TODO(jar) */ \
/* TRACK_RUN_IN_THIS_SCOPED_REGION(code); TODO(jar) */ \
code; \
} \
break;

#define IPC_REPLY_HANDLER(func) \
case IPC_REPLY_ID: { \
TRACK_RUN_IN_IPC_HANDLER(func); \
TRACK_RUN_IN_THIS_SCOPED_REGION(func); \
func(ipc_message__); \
} \
break;
Expand Down
6 changes: 3 additions & 3 deletions ppapi/host/dispatch_host_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef PPAPI_HOST_DISPATCH_HOST_MESSAGE_H_
#define PPAPI_HOST_DISPATCH_HOST_MESSAGE_H_

#include "base/profiler/scoped_profile.h" // For TRACK_RUN_IN_IPC_HANDLER.
#include "base/profiler/scoped_profile.h"
#include "ipc/ipc_message_macros.h"
#include "ppapi/c/pp_errors.h"

Expand Down Expand Up @@ -66,7 +66,7 @@ inline int32_t DispatchResourceCall(ObjT* obj, Method method,
// no params in the message).
#define PPAPI_DISPATCH_HOST_RESOURCE_CALL(msg_class, member_func) \
case msg_class::ID: { \
TRACK_RUN_IN_IPC_HANDLER(member_func); \
TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \
msg_class::Schema::Param p; \
if (msg_class::Read(&ipc_message__, &p)) { \
return ppapi::host::DispatchResourceCall( \
Expand All @@ -79,7 +79,7 @@ inline int32_t DispatchResourceCall(ObjT* obj, Method method,

#define PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(msg_class, member_func) \
case msg_class::ID: { \
TRACK_RUN_IN_IPC_HANDLER(member_func); \
TRACK_RUN_IN_THIS_SCOPED_REGION(member_func); \
return member_func(context); \
}

Expand Down
1 change: 0 additions & 1 deletion ppapi/proxy/dispatch_reply_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define PPAPI_PROXY_DISPATCH_REPLY_MESSAGE_H_

#include "base/callback.h"
#include "base/profiler/scoped_profile.h" // For TRACK_RUN_IN_IPC_HANDLER.
#include "ipc/ipc_message_macros.h"
#include "ppapi/c/pp_errors.h"

Expand Down

0 comments on commit a19e487

Please sign in to comment.