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

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

Issue 1233173002: Have ScriptPromiseResolver on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: keepAliveWhilePending() comment Created 5 years, 5 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "public/platform/Platform.h" 60 #include "public/platform/Platform.h"
61 #include "public/platform/WebServiceWorkerSkipWaitingCallbacks.h" 61 #include "public/platform/WebServiceWorkerSkipWaitingCallbacks.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 class ServiceWorkerGlobalScope::SkipWaitingCallback final : public WebServiceWor kerSkipWaitingCallbacks { 67 class ServiceWorkerGlobalScope::SkipWaitingCallback final : public WebServiceWor kerSkipWaitingCallbacks {
68 WTF_MAKE_NONCOPYABLE(SkipWaitingCallback); 68 WTF_MAKE_NONCOPYABLE(SkipWaitingCallback);
69 public: 69 public:
70 explicit SkipWaitingCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> r esolver) 70 explicit SkipWaitingCallback(ScriptPromiseResolver* resolver)
71 : m_resolver(resolver) { } 71 : m_resolver(resolver) { }
72 ~SkipWaitingCallback() { } 72 ~SkipWaitingCallback() { }
73 73
74 void onSuccess() override 74 void onSuccess() override
75 { 75 {
76 m_resolver->resolve(); 76 m_resolver->resolve();
77 } 77 }
78 78
79 private: 79 private:
80 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; 80 Persistent<ScriptPromiseResolver> m_resolver;
81 }; 81 };
82 82
83 PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat e(ServiceWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData) 83 PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat e(ServiceWorkerThread* thread, PassOwnPtr<WorkerThreadStartupData> startupData)
84 { 84 {
85 // Note: startupData is finalized on return. After the relevant parts has be en 85 // Note: startupData is finalized on return. After the relevant parts has be en
86 // passed along to the created 'context'. 86 // passed along to the created 'context'.
87 RefPtrWillBeRawPtr<ServiceWorkerGlobalScope> context = adoptRefWillBeNoop(ne w ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, t hread, monotonicallyIncreasingTime(), startupData->m_starterOrigin, startupData- >m_workerClients.release())); 87 RefPtrWillBeRawPtr<ServiceWorkerGlobalScope> context = adoptRefWillBeNoop(ne w ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, t hread, monotonicallyIncreasingTime(), startupData->m_starterOrigin, startupData- >m_workerClients.release()));
88 88
89 context->setV8CacheOptions(startupData->m_v8CacheOptions); 89 context->setV8CacheOptions(startupData->m_v8CacheOptions);
90 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit yPolicyHeaders); 90 context->applyContentSecurityPolicyFromVector(*startupData->m_contentSecurit yPolicyHeaders);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 exceptionState.throwDOMException(InvalidAccessError, "Not supported."); 147 exceptionState.throwDOMException(InvalidAccessError, "Not supported.");
148 } 148 }
149 149
150 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState) 150 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState)
151 { 151 {
152 ExecutionContext* executionContext = scriptState->executionContext(); 152 ExecutionContext* executionContext = scriptState->executionContext();
153 // FIXME: short-term fix, see details at: https://codereview.chromium.org/53 5193002/. 153 // FIXME: short-term fix, see details at: https://codereview.chromium.org/53 5193002/.
154 if (!executionContext) 154 if (!executionContext)
155 return ScriptPromise(); 155 return ScriptPromise();
156 156
157 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 157 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
158 ScriptPromise promise = resolver->promise(); 158 ScriptPromise promise = resolver->promise();
159 159
160 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Skip WaitingCallback(resolver)); 160 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Skip WaitingCallback(resolver));
161 return promise; 161 return promise;
162 } 162 }
163 163
164 void ServiceWorkerGlobalScope::setRegistration(WebServiceWorkerRegistration* reg istration) 164 void ServiceWorkerGlobalScope::setRegistration(WebServiceWorkerRegistration* reg istration)
165 { 165 {
166 if (!executionContext()) { 166 if (!executionContext()) {
167 ServiceWorkerRegistration::dispose(registration); 167 ServiceWorkerRegistration::dispose(registration);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize) 246 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize)
247 { 247 {
248 ++m_scriptCount; 248 ++m_scriptCount;
249 m_scriptTotalSize += scriptSize; 249 m_scriptTotalSize += scriptSize;
250 m_scriptCachedMetadataTotalSize += cachedMetadataSize; 250 m_scriptCachedMetadataTotalSize += cachedMetadataSize;
251 } 251 }
252 252
253 } // namespace blink 253 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698