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

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

Issue 783423003: Make ScriptPromiseResolver RefCountedWillBeRefCountedGarbageCollected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "platform/weborigin/KURL.h" 54 #include "platform/weborigin/KURL.h"
55 #include "public/platform/WebServiceWorkerSkipWaitingCallbacks.h" 55 #include "public/platform/WebServiceWorkerSkipWaitingCallbacks.h"
56 #include "public/platform/WebURL.h" 56 #include "public/platform/WebURL.h"
57 #include "wtf/CurrentTime.h" 57 #include "wtf/CurrentTime.h"
58 58
59 namespace blink { 59 namespace blink {
60 60
61 class ServiceWorkerGlobalScope::SkipWaitingCallback final : public WebServiceWor kerSkipWaitingCallbacks { 61 class ServiceWorkerGlobalScope::SkipWaitingCallback final : public WebServiceWor kerSkipWaitingCallbacks {
62 WTF_MAKE_NONCOPYABLE(SkipWaitingCallback); 62 WTF_MAKE_NONCOPYABLE(SkipWaitingCallback);
63 public: 63 public:
64 explicit SkipWaitingCallback(PassRefPtr<ScriptPromiseResolver> resolver) 64 explicit SkipWaitingCallback(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> r esolver)
65 : m_resolver(resolver) { } 65 : m_resolver(resolver) { }
66 ~SkipWaitingCallback() { } 66 ~SkipWaitingCallback() { }
67 67
68 void onSuccess() override 68 void onSuccess() override
69 { 69 {
70 m_resolver->resolve(); 70 m_resolver->resolve();
71 } 71 }
72 72
73 private: 73 private:
74 RefPtr<ScriptPromiseResolver> m_resolver; 74 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
75 }; 75 };
76 76
77 PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat e(ServiceWorkerThread* thread, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData> s tartupData) 77 PassRefPtrWillBeRawPtr<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::creat e(ServiceWorkerThread* thread, PassOwnPtrWillBeRawPtr<WorkerThreadStartupData> s tartupData)
78 { 78 {
79 RefPtrWillBeRawPtr<ServiceWorkerGlobalScope> context = adoptRefWillBeNoop(ne w ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, t hread, monotonicallyIncreasingTime(), startupData->m_starterOrigin, startupData- >m_workerClients.release())); 79 RefPtrWillBeRawPtr<ServiceWorkerGlobalScope> context = adoptRefWillBeNoop(ne w ServiceWorkerGlobalScope(startupData->m_scriptURL, startupData->m_userAgent, t hread, monotonicallyIncreasingTime(), startupData->m_starterOrigin, startupData- >m_workerClients.release()));
80 80
81 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType); 81 context->applyContentSecurityPolicyFromString(startupData->m_contentSecurity Policy, startupData->m_contentSecurityPolicyType);
82 82
83 return context.release(); 83 return context.release();
84 } 84 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return m_clients; 125 return m_clients;
126 } 126 }
127 127
128 void ServiceWorkerGlobalScope::close(ExceptionState& exceptionState) 128 void ServiceWorkerGlobalScope::close(ExceptionState& exceptionState)
129 { 129 {
130 exceptionState.throwDOMException(InvalidAccessError, "Not supported."); 130 exceptionState.throwDOMException(InvalidAccessError, "Not supported.");
131 } 131 }
132 132
133 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState) 133 ScriptPromise ServiceWorkerGlobalScope::skipWaiting(ScriptState* scriptState)
134 { 134 {
135 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 135 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
136 ScriptPromise promise = resolver->promise(); 136 ScriptPromise promise = resolver->promise();
137 137
138 ExecutionContext* executionContext = scriptState->executionContext(); 138 ExecutionContext* executionContext = scriptState->executionContext();
139 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Skip WaitingCallback(resolver)); 139 ServiceWorkerGlobalScopeClient::from(executionContext)->skipWaiting(new Skip WaitingCallback(resolver));
140 return promise; 140 return promise;
141 } 141 }
142 142
143 bool ServiceWorkerGlobalScope::addEventListener(const AtomicString& eventType, P assRefPtr<EventListener> listener, bool useCapture) 143 bool ServiceWorkerGlobalScope::addEventListener(const AtomicString& eventType, P assRefPtr<EventListener> listener, bool useCapture)
144 { 144 {
145 if (m_didEvaluateScript) { 145 if (m_didEvaluateScript) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe fPtrWillBeRawPtr<ScriptCallStack> callStack) 199 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe fPtrWillBeRawPtr<ScriptCallStack> callStack)
200 { 200 {
201 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL, lineNumber, columnNumber, callStack); 201 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL, lineNumber, columnNumber, callStack);
202 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); 202 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber);
203 consoleMessage->setScriptId(scriptId); 203 consoleMessage->setScriptId(scriptId);
204 consoleMessage->setCallStack(callStack); 204 consoleMessage->setCallStack(callStack);
205 addMessageToWorkerConsole(consoleMessage.release()); 205 addMessageToWorkerConsole(consoleMessage.release());
206 } 206 }
207 207
208 } // namespace blink 208 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698