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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp

Issue 1864243004: Remove RawPtr from Source/modules Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "modules/serviceworkers/WaitUntilObserver.h" 57 #include "modules/serviceworkers/WaitUntilObserver.h"
58 #include "platform/Histogram.h" 58 #include "platform/Histogram.h"
59 #include "platform/network/ResourceRequest.h" 59 #include "platform/network/ResourceRequest.h"
60 #include "platform/weborigin/KURL.h" 60 #include "platform/weborigin/KURL.h"
61 #include "public/platform/Platform.h" 61 #include "public/platform/Platform.h"
62 #include "public/platform/WebURL.h" 62 #include "public/platform/WebURL.h"
63 #include "wtf/CurrentTime.h" 63 #include "wtf/CurrentTime.h"
64 64
65 namespace blink { 65 namespace blink {
66 66
67 RawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(ServiceWorkerT hread* thread, PassOwnPtr<WorkerThreadStartupData> startupData) 67 ServiceWorkerGlobalScope* ServiceWorkerGlobalScope::create(ServiceWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData)
68 { 68 {
69 // Note: startupData is finalized on return. After the relevant parts has be en 69 // Note: startupData is finalized on return. After the relevant parts has be en
70 // passed along to the created 'context'. 70 // passed along to the created 'context'.
71 RawPtr<ServiceWorkerGlobalScope> context = new ServiceWorkerGlobalScope(star tupData->m_scriptURL, startupData->m_userAgent, thread, monotonicallyIncreasingT ime(), startupData->m_starterOriginPrivilegeData.release(), startupData->m_worke rClients.release()); 71 ServiceWorkerGlobalScope* context = new ServiceWorkerGlobalScope(startupData ->m_scriptURL, startupData->m_userAgent, thread, monotonicallyIncreasingTime(), startupData->m_starterOriginPrivilegeData.release(), startupData->m_workerClient s.release());
72 72
73 context->setV8CacheOptions(startupData->m_v8CacheOptions); 73 context->setV8CacheOptions(startupData->m_v8CacheOptions);
74 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit yPolicyHeaders); 74 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit yPolicyHeaders);
75 context->setAddressSpace(startupData->m_addressSpace); 75 context->setAddressSpace(startupData->m_addressSpace);
76 76
77 return context.release(); 77 return context;
78 } 78 }
79 79
80 ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String & userAgent, ServiceWorkerThread* thread, double timeOrigin, PassOwnPtr<Security Origin::PrivilegeData> starterOriginPrivilegeData, RawPtr<WorkerClients> workerC lients) 80 ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const KURL& url, const String & userAgent, ServiceWorkerThread* thread, double timeOrigin, PassOwnPtr<Security Origin::PrivilegeData> starterOriginPrivilegeData, WorkerClients* workerClients)
81 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivile geData, workerClients) 81 : WorkerGlobalScope(url, userAgent, thread, timeOrigin, starterOriginPrivile geData, workerClients)
82 , m_didEvaluateScript(false) 82 , m_didEvaluateScript(false)
83 , m_hadErrorInTopLevelEventHandler(false) 83 , m_hadErrorInTopLevelEventHandler(false)
84 , m_eventNestingLevel(0) 84 , m_eventNestingLevel(0)
85 , m_scriptCount(0) 85 , m_scriptCount(0)
86 , m_scriptTotalSize(0) 86 , m_scriptTotalSize(0)
87 , m_scriptCachedMetadataTotalSize(0) 87 , m_scriptCachedMetadataTotalSize(0)
88 { 88 {
89 } 89 }
90 90
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 { 145 {
146 if (!getExecutionContext()) 146 if (!getExecutionContext())
147 return; 147 return;
148 m_registration = ServiceWorkerRegistration::getOrCreate(getExecutionContext( ), handle.release()); 148 m_registration = ServiceWorkerRegistration::getOrCreate(getExecutionContext( ), handle.release());
149 } 149 }
150 150
151 bool ServiceWorkerGlobalScope::addEventListenerInternal(const AtomicString& even tType, EventListener* listener, const EventListenerOptions& options) 151 bool ServiceWorkerGlobalScope::addEventListenerInternal(const AtomicString& even tType, EventListener* listener, const EventListenerOptions& options)
152 { 152 {
153 if (m_didEvaluateScript) { 153 if (m_didEvaluateScript) {
154 if (eventType == EventTypeNames::install) { 154 if (eventType == EventTypeNames::install) {
155 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMes sageSource, WarningMessageLevel, "Event handler of 'install' event must be added on the initial evaluation of worker script."); 155 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSou rce, WarningMessageLevel, "Event handler of 'install' event must be added on the initial evaluation of worker script.");
156 addMessageToWorkerConsole(consoleMessage.release()); 156 addMessageToWorkerConsole(consoleMessage);
157 } else if (eventType == EventTypeNames::activate) { 157 } else if (eventType == EventTypeNames::activate) {
158 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMes sageSource, WarningMessageLevel, "Event handler of 'activate' event must be adde d on the initial evaluation of worker script."); 158 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSou rce, WarningMessageLevel, "Event handler of 'activate' event must be added on th e initial evaluation of worker script.");
159 addMessageToWorkerConsole(consoleMessage.release()); 159 addMessageToWorkerConsole(consoleMessage);
160 } 160 }
161 } 161 }
162 return WorkerGlobalScope::addEventListenerInternal(eventType, listener, opti ons); 162 return WorkerGlobalScope::addEventListenerInternal(eventType, listener, opti ons);
163 } 163 }
164 164
165 const AtomicString& ServiceWorkerGlobalScope::interfaceName() const 165 const AtomicString& ServiceWorkerGlobalScope::interfaceName() const
166 { 166 {
167 return EventTargetNames::ServiceWorkerGlobalScope; 167 return EventTargetNames::ServiceWorkerGlobalScope;
168 } 168 }
169 169
170 DispatchEventResult ServiceWorkerGlobalScope::dispatchEventInternal(Event* event ) 170 DispatchEventResult ServiceWorkerGlobalScope::dispatchEventInternal(Event* event )
171 { 171 {
172 m_eventNestingLevel++; 172 m_eventNestingLevel++;
173 DispatchEventResult dispatchResult = WorkerGlobalScope::dispatchEventInterna l(event); 173 DispatchEventResult dispatchResult = WorkerGlobalScope::dispatchEventInterna l(event);
174 if (event->interfaceName() == EventNames::ErrorEvent && m_eventNestingLevel == 2) 174 if (event->interfaceName() == EventNames::ErrorEvent && m_eventNestingLevel == 2)
175 m_hadErrorInTopLevelEventHandler = true; 175 m_hadErrorInTopLevelEventHandler = true;
176 m_eventNestingLevel--; 176 m_eventNestingLevel--;
177 return dispatchResult; 177 return dispatchResult;
178 } 178 }
179 179
180 void ServiceWorkerGlobalScope::dispatchExtendableEvent(RawPtr<Event> event, Wait UntilObserver* observer) 180 void ServiceWorkerGlobalScope::dispatchExtendableEvent(Event* event, WaitUntilOb server* observer)
181 { 181 {
182 ASSERT(m_eventNestingLevel == 0); 182 ASSERT(m_eventNestingLevel == 0);
183 m_hadErrorInTopLevelEventHandler = false; 183 m_hadErrorInTopLevelEventHandler = false;
184 184
185 observer->willDispatchEvent(); 185 observer->willDispatchEvent();
186 dispatchEvent(event); 186 dispatchEvent(event);
187 if (thread()->terminated()) 187 if (thread()->terminated())
188 m_hadErrorInTopLevelEventHandler = true; 188 m_hadErrorInTopLevelEventHandler = true;
189 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler); 189 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler);
190 } 190 }
(...skipping 16 matching lines...) Expand all
207 } 207 }
208 208
209 RawPtr<CachedMetadataHandler> ServiceWorkerGlobalScope::createWorkerScriptCached MetadataHandler(const KURL& scriptURL, const Vector<char>* metaData) 209 RawPtr<CachedMetadataHandler> ServiceWorkerGlobalScope::createWorkerScriptCached MetadataHandler(const KURL& scriptURL, const Vector<char>* metaData)
210 { 210 {
211 return ServiceWorkerScriptCachedMetadataHandler::create(this, scriptURL, met aData); 211 return ServiceWorkerScriptCachedMetadataHandler::create(this, scriptURL, met aData);
212 } 212 }
213 213
214 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe fPtr<ScriptCallStack> callStack) 214 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe fPtr<ScriptCallStack> callStack)
215 { 215 {
216 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL, lineNumber, columnNumber, callStack); 216 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL, lineNumber, columnNumber, callStack);
217 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSour ce, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNumber); 217 ConsoleMessage* consoleMessage = ConsoleMessage::create(JSMessageSource, Err orMessageLevel, errorMessage, sourceURL, lineNumber, columnNumber);
218 consoleMessage->setScriptId(scriptId); 218 consoleMessage->setScriptId(scriptId);
219 consoleMessage->setCallStack(callStack); 219 consoleMessage->setCallStack(callStack);
220 addMessageToWorkerConsole(consoleMessage.release()); 220 addMessageToWorkerConsole(consoleMessage);
221 } 221 }
222 222
223 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize) 223 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize)
224 { 224 {
225 ++m_scriptCount; 225 ++m_scriptCount;
226 m_scriptTotalSize += scriptSize; 226 m_scriptTotalSize += scriptSize;
227 m_scriptCachedMetadataTotalSize += cachedMetadataSize; 227 m_scriptCachedMetadataTotalSize += cachedMetadataSize;
228 } 228 }
229 229
230 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698