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

Side by Side 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, 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 | « Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('k') | 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "modules/serviceworkers/InspectorServiceWorkerCacheAgent.h" 48 #include "modules/serviceworkers/InspectorServiceWorkerCacheAgent.h"
49 #include "modules/serviceworkers/ServiceWorkerClients.h" 49 #include "modules/serviceworkers/ServiceWorkerClients.h"
50 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" 50 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
51 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 51 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
52 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h" 52 #include "modules/serviceworkers/ServiceWorkerScriptCachedMetadataHandler.h"
53 #include "modules/serviceworkers/ServiceWorkerThread.h" 53 #include "modules/serviceworkers/ServiceWorkerThread.h"
54 #include "modules/serviceworkers/WaitUntilObserver.h" 54 #include "modules/serviceworkers/WaitUntilObserver.h"
55 #include "platform/network/ResourceRequest.h" 55 #include "platform/network/ResourceRequest.h"
56 #include "platform/weborigin/DatabaseIdentifier.h" 56 #include "platform/weborigin/DatabaseIdentifier.h"
57 #include "platform/weborigin/KURL.h" 57 #include "platform/weborigin/KURL.h"
58 #include "public/platform/Platform.h"
58 #include "public/platform/WebServiceWorkerSkipWaitingCallbacks.h" 59 #include "public/platform/WebServiceWorkerSkipWaitingCallbacks.h"
59 #include "public/platform/WebURL.h" 60 #include "public/platform/WebURL.h"
60 #include "wtf/CurrentTime.h" 61 #include "wtf/CurrentTime.h"
61 62
62 namespace blink { 63 namespace blink {
63 64
64 class ServiceWorkerGlobalScope::SkipWaitingCallback final : public WebServiceWor kerSkipWaitingCallbacks { 65 class ServiceWorkerGlobalScope::SkipWaitingCallback final : public WebServiceWor kerSkipWaitingCallbacks {
65 WTF_MAKE_NONCOPYABLE(SkipWaitingCallback); 66 WTF_MAKE_NONCOPYABLE(SkipWaitingCallback);
66 public: 67 public:
67 explicit SkipWaitingCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> r esolver) 68 explicit SkipWaitingCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> r esolver)
(...skipping 19 matching lines...) Expand all
87 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType); 88 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType);
88 89
89 return context.release(); 90 return context.release();
90 } 91 }
91 92
92 ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String & userAgent, ServiceWorkerThread* thread, double timeOrigin, const SecurityOrigi n* starterOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> workerClients) 93 ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String & userAgent, ServiceWorkerThread* thread, double timeOrigin, const SecurityOrigi n* starterOrigin, PassOwnPtrWillBeRawPtr<WorkerClients> workerClients)
93 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOrigin, worke rClients) 94 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOrigin, worke rClients)
94 , m_didEvaluateScript(false) 95 , m_didEvaluateScript(false)
95 , m_hadErrorInTopLevelEventHandler(false) 96 , m_hadErrorInTopLevelEventHandler(false)
96 , m_eventNestingLevel(0) 97 , m_eventNestingLevel(0)
98 , m_scriptCount(0)
99 , m_scriptTotalSize(0)
100 , m_scriptCachedMetadataTotalSize(0)
97 { 101 {
98 workerInspectorController()->registerModuleAgent(InspectorServiceWorkerCache Agent::create(this)); 102 workerInspectorController()->registerModuleAgent(InspectorServiceWorkerCache Agent::create(this));
99 } 103 }
100 104
101 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() 105 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope()
102 { 106 {
103 } 107 }
104 108
105 void ServiceWorkerGlobalScope::didEvaluateWorkerScript() 109 void ServiceWorkerGlobalScope::didEvaluateWorkerScript()
106 { 110 {
111 if (Platform* platform = Platform::current()) {
112 platform->histogramCustomCounts("ServiceWorker.ScriptCount", m_scriptCou nt, 1, 1000, 50);
113 platform->histogramCustomCounts("ServiceWorker.ScriptTotalSize", m_scrip tTotalSize, 1000, 5000000, 50);
114 if (m_scriptCachedMetadataTotalSize)
115 platform->histogramCustomCounts("ServiceWorker.ScriptCachedMetadataT otalSize", m_scriptCachedMetadataTotalSize, 1000, 50000000, 50);
116 }
107 m_didEvaluateScript = true; 117 m_didEvaluateScript = true;
108 } 118 }
109 119
110 CacheStorage* ServiceWorkerGlobalScope::caches(ExecutionContext* context) 120 CacheStorage* ServiceWorkerGlobalScope::caches(ExecutionContext* context)
111 { 121 {
112 if (!m_caches) { 122 if (!m_caches) {
113 String identifier = createDatabaseIdentifierFromSecurityOrigin(context-> securityOrigin()); 123 String identifier = createDatabaseIdentifierFromSecurityOrigin(context-> securityOrigin());
114 ASSERT(!identifier.isEmpty()); 124 ASSERT(!identifier.isEmpty());
115 m_caches = CacheStorage::create(Platform::current()->cacheStorage(identi fier)); 125 m_caches = CacheStorage::create(Platform::current()->cacheStorage(identi fier));
116 } 126 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 238
229 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe fPtrWillBeRawPtr<ScriptCallStack> callStack) 239 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe fPtrWillBeRawPtr<ScriptCallStack> callStack)
230 { 240 {
231 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL, lineNumber, columnNumber, callStack); 241 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL, lineNumber, columnNumber, callStack);
232 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); 242 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber);
233 consoleMessage->setScriptId(scriptId); 243 consoleMessage->setScriptId(scriptId);
234 consoleMessage->setCallStack(callStack); 244 consoleMessage->setCallStack(callStack);
235 addMessageToWorkerConsole(consoleMessage.release()); 245 addMessageToWorkerConsole(consoleMessage.release());
236 } 246 }
237 247
248 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize)
249 {
250 ++m_scriptCount;
251 m_scriptTotalSize += scriptSize;
252 m_scriptCachedMetadataTotalSize += cachedMetadataSize;
253 }
254
238 } // namespace blink 255 } // namespace blink
OLDNEW
« 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