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

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: fix webusb ScriptPromiseResolver usage Created 5 years, 4 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 exceptionState.throwDOMException(InvalidAccessError, "Not supported."); 140 exceptionState.throwDOMException(InvalidAccessError, "Not supported.");
141 } 141 }
142 142
143 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState) 143 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState)
144 { 144 {
145 ExecutionContext* executionContext = scriptState->executionContext(); 145 ExecutionContext* executionContext = scriptState->executionContext();
146 // FIXME: short-term fix, see details at: https://codereview.chromium.org/53 5193002/. 146 // FIXME: short-term fix, see details at: https://codereview.chromium.org/53 5193002/.
147 if (!executionContext) 147 if (!executionContext)
148 return ScriptPromise(); 148 return ScriptPromise();
149 149
150 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 150 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
151 ScriptPromise promise = resolver->promise(); 151 ScriptPromise promise = resolver->promise();
152 152
153 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Skip WaitingCallback(resolver)); 153 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Skip WaitingCallback(resolver));
154 return promise; 154 return promise;
155 } 155 }
156 156
157 void ServiceWorkerGlobalScope::setRegistration(WebServiceWorkerRegistration* reg istration) 157 void ServiceWorkerGlobalScope::setRegistration(WebServiceWorkerRegistration* reg istration)
158 { 158 {
159 if (!executionContext()) { 159 if (!executionContext()) {
160 ServiceWorkerRegistration::dispose(registration); 160 ServiceWorkerRegistration::dispose(registration);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize) 238 void ServiceWorkerGlobalScope::scriptLoaded(size_t scriptSize, size_t cachedMeta dataSize)
239 { 239 {
240 ++m_scriptCount; 240 ++m_scriptCount;
241 m_scriptTotalSize += scriptSize; 241 m_scriptTotalSize += scriptSize;
242 m_scriptCachedMetadataTotalSize += cachedMetadataSize; 242 m_scriptCachedMetadataTotalSize += cachedMetadataSize;
243 } 243 }
244 244
245 } // namespace blink 245 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.cpp ('k') | Source/modules/serviceworkers/ServiceWorkerRegistration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698