Commit 22fe1e27 authored by Siddhartha's avatar Siddhartha Committed by Commit Bot

Add service name to trace event to GetService trace event

This data is useful to understand startup regressions from users.
Storing of service name in base factory is not a lot of overhead
considering that the strings are already part of binary.

BUG=900688
TBR=blundell@chromium.org

Change-Id: I240900515431fc56f005c7198ce0aea0645b3a62
Reviewed-on: https://chromium-review.googlesource.com/c/1311613Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avataroysteine <oysteine@chromium.org>
Reviewed-by: default avatarCait Phillips <caitkp@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606005}
parent faa86b61
......@@ -23,6 +23,7 @@ const char* const kInputLatencyAllowedArgs[] = {"data", nullptr};
const char* const kMemoryDumpAllowedArgs[] = {"dumps", nullptr};
const WhitelistEntry kEventArgsWhitelist[] = {
{"browser", "KeyedServiceFactory::GetServiceForContext", nullptr},
{"__metadata", "thread_name", nullptr},
{"__metadata", "process_name", nullptr},
{"__metadata", "process_uptime_seconds", nullptr},
......
......@@ -45,10 +45,7 @@ void KeyedServiceBaseFactory::RegisterUserPrefsOnContextForTest(
KeyedServiceBaseFactory::KeyedServiceBaseFactory(const char* service_name,
DependencyManager* manager)
: dependency_manager_(manager) {
#ifndef NDEBUG
service_name_ = service_name;
#endif
: dependency_manager_(manager), service_name_(service_name) {
dependency_manager_->AddComponent(this);
}
......
......@@ -30,10 +30,8 @@ class PrefRegistrySyncable;
// direct subclasses react to lifecycle events and implement memory management.
class KEYED_SERVICE_EXPORT KeyedServiceBaseFactory : public DependencyNode {
public:
#ifndef NDEBUG
// Returns our name. We don't keep track of this in release mode.
// Returns our name.
const char* name() const { return service_name_; }
#endif
protected:
KeyedServiceBaseFactory(const char* service_name, DependencyManager* manager);
......@@ -135,12 +133,9 @@ class KEYED_SERVICE_EXPORT KeyedServiceBaseFactory : public DependencyNode {
// Contexts that have this service's preferences registered on them.
std::set<base::SupportsUserData*> registered_preferences_;
#if !defined(NDEBUG)
// A static string passed in to the constructor. Should be unique across all
// services. This is used only for debugging in debug mode. (Used to print
// pretty graphs with GraphViz.)
// services.
const char* service_name_;
#endif
};
#endif // COMPONENTS_KEYED_SERVICE_CORE_KEYED_SERVICE_BASE_FACTORY_H_
......@@ -58,7 +58,8 @@ KeyedService* KeyedServiceFactory::SetTestingFactoryAndUse(
KeyedService* KeyedServiceFactory::GetServiceForContext(
base::SupportsUserData* context,
bool create) {
TRACE_EVENT0("browser,startup", "KeyedServiceFactory::GetServiceForContext");
TRACE_EVENT1("browser,startup", "KeyedServiceFactory::GetServiceForContext",
"service_name", name());
context = GetContextToUse(context);
if (!context)
return nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment