OLD | NEW |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return ServiceWorkerGlobalScopeClient::from(context)->scope().string(); | 92 return ServiceWorkerGlobalScopeClient::from(context)->scope().string(); |
93 } | 93 } |
94 | 94 |
95 CacheStorage* ServiceWorkerGlobalScope::caches(ExecutionContext* context) | 95 CacheStorage* ServiceWorkerGlobalScope::caches(ExecutionContext* context) |
96 { | 96 { |
97 if (!m_caches) | 97 if (!m_caches) |
98 m_caches = CacheStorage::create(ServiceWorkerGlobalScopeClient::from(con
text)->cacheStorage()); | 98 m_caches = CacheStorage::create(ServiceWorkerGlobalScopeClient::from(con
text)->cacheStorage()); |
99 return m_caches; | 99 return m_caches; |
100 } | 100 } |
101 | 101 |
102 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request*
request) | |
103 { | |
104 if (!m_fetchManager) | |
105 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down.")); | |
106 // "Let |r| be the associated request of the result of invoking the initial | |
107 // value of Request as constructor with |input| and |init| as arguments. If | |
108 // this throws an exception, reject |p| with it." | |
109 TrackExceptionState exceptionState; | |
110 Request* r = Request::create(this, request, exceptionState); | |
111 if (exceptionState.hadException()) { | |
112 // FIXME: We should throw the caught error. | |
113 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), exceptionState.message())); | |
114 } | |
115 return m_fetchManager->fetch(scriptState, r->request()); | |
116 } | |
117 | |
118 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request*
request, const Dictionary& requestInit) | 102 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, Request*
request, const Dictionary& requestInit) |
119 { | 103 { |
120 if (!m_fetchManager) | 104 if (!m_fetchManager) |
121 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down.")); | 105 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down.")); |
122 // "Let |r| be the associated request of the result of invoking the initial | 106 // "Let |r| be the associated request of the result of invoking the initial |
123 // value of Request as constructor with |input| and |init| as arguments. If | 107 // value of Request as constructor with |input| and |init| as arguments. If |
124 // this throws an exception, reject |p| with it." | 108 // this throws an exception, reject |p| with it." |
125 TrackExceptionState exceptionState; | 109 TrackExceptionState exceptionState; |
126 Request* r = Request::create(this, request, requestInit, exceptionState); | 110 Request* r = Request::create(this, request, requestInit, exceptionState); |
127 if (exceptionState.hadException()) { | 111 if (exceptionState.hadException()) { |
128 // FIXME: We should throw the caught error. | 112 // FIXME: We should throw the caught error. |
129 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), exceptionState.message())); | 113 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), exceptionState.message())); |
130 } | 114 } |
131 return m_fetchManager->fetch(scriptState, r->request()); | 115 return m_fetchManager->fetch(scriptState, r->request()); |
132 } | 116 } |
133 | 117 |
134 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const St
ring& urlstring) | |
135 { | |
136 if (!m_fetchManager) | |
137 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down.")); | |
138 // "Let |r| be the associated request of the result of invoking the initial | |
139 // value of Request as constructor with |input| and |init| as arguments. If | |
140 // this throws an exception, reject |p| with it." | |
141 TrackExceptionState exceptionState; | |
142 Request* r = Request::create(this, urlstring, exceptionState); | |
143 if (exceptionState.hadException()) { | |
144 // FIXME: We should throw the caught error. | |
145 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), exceptionState.message())); | |
146 } | |
147 return m_fetchManager->fetch(scriptState, r->request()); | |
148 } | |
149 | |
150 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const St
ring& urlstring, const Dictionary& requestInit) | 118 ScriptPromise ServiceWorkerGlobalScope::fetch(ScriptState* scriptState, const St
ring& urlstring, const Dictionary& requestInit) |
151 { | 119 { |
152 if (!m_fetchManager) | 120 if (!m_fetchManager) |
153 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down.")); | 121 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "ServiceWorkerGlobalScope is shutting down.")); |
154 // "Let |r| be the associated request of the result of invoking the initial | 122 // "Let |r| be the associated request of the result of invoking the initial |
155 // value of Request as constructor with |input| and |init| as arguments. If | 123 // value of Request as constructor with |input| and |init| as arguments. If |
156 // this throws an exception, reject |p| with it." | 124 // this throws an exception, reject |p| with it." |
157 TrackExceptionState exceptionState; | 125 TrackExceptionState exceptionState; |
158 Request* r = Request::create(this, urlstring, requestInit, exceptionState); | 126 Request* r = Request::create(this, urlstring, requestInit, exceptionState); |
159 if (exceptionState.hadException()) { | 127 if (exceptionState.hadException()) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage,
int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe
fPtrWillBeRawPtr<ScriptCallStack> callStack) | 202 void ServiceWorkerGlobalScope::logExceptionToConsole(const String& errorMessage,
int scriptId, const String& sourceURL, int lineNumber, int columnNumber, PassRe
fPtrWillBeRawPtr<ScriptCallStack> callStack) |
235 { | 203 { |
236 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL,
lineNumber, columnNumber, callStack); | 204 WorkerGlobalScope::logExceptionToConsole(errorMessage, scriptId, sourceURL,
lineNumber, columnNumber, callStack); |
237 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J
SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); | 205 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J
SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); |
238 consoleMessage->setScriptId(scriptId); | 206 consoleMessage->setScriptId(scriptId); |
239 consoleMessage->setCallStack(callStack); | 207 consoleMessage->setCallStack(callStack); |
240 addMessageToWorkerConsole(consoleMessage.release()); | 208 addMessageToWorkerConsole(consoleMessage.release()); |
241 } | 209 } |
242 | 210 |
243 } // namespace blink | 211 } // namespace blink |
OLD | NEW |