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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp

Issue 1059193002: Add UMA to understand the typical total size of ServiceWorker script [1/2 blink] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: check Platform::current() Created 5 years, 9 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 | « Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
index 3af04a81b7690dda7fef14a5c822c0d19d849f5c..29c044cb90b7a494db91995aad9055a689adddef 100644
--- a/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp
@@ -55,6 +55,7 @@
#include "platform/network/ResourceRequest.h"
#include "platform/weborigin/DatabaseIdentifier.h"
#include "platform/weborigin/KURL.h"
+#include "public/platform/Platform.h"
#include "public/platform/WebServiceWorkerSkipWaitingCallbacks.h"
#include "public/platform/WebURL.h"
#include "wtf/CurrentTime.h"
@@ -94,6 +95,9 @@ ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String
, m_didEvaluateScript(false)
, m_hadErrorInTopLevelEventHandler(false)
, m_eventNestingLevel(0)
+ , m_scriptCount(0)
+ , m_scriptTotalSize(0)
+ , m_scriptCachedMetadataTotalSize(0)
{
workerInspectorController()->registerModuleAgent(InspectorServiceWorkerCacheAgent::create(this));
}
@@ -104,6 +108,12 @@ ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope()
void ServiceWorkerGlobalScope::didEvaluateWorkerScript()
{
+ if (Platform* platform = Platform::current()) {
+ platform->histogramCustomCounts("ServiceWorker.ScriptCount", m_scriptCount, 1, 1000, 50);
+ platform->histogramCustomCounts("ServiceWorker.ScriptTotalSize", m_scriptTotalSize, 1000, 5000000, 50);
+ if (m_scriptCachedMetadataTotalSize)
+ platform->histogramCustomCounts("ServiceWorker.ScriptCachedMetadataTotalSize", m_scriptCachedMetadataTotalSize, 1000, 50000000, 50);
+ }
m_didEvaluateScript = true;
}
@@ -235,4 +245,11 @@ void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage,
addMessageToWorkerConsole(consoleMessage.release());
}
+void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMetadataSize)
+{
+ ++m_scriptCount;
+ m_scriptTotalSize += scriptSize;
+ m_scriptCachedMetadataTotalSize += cachedMetadataSize;
+}
+
} // namespace blink
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698