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

Unified Diff: Source/modules/cachestorage/Cache.cpp

Issue 1211293003: CacheStorage: Cache::putImpl should call onError in early-return cases (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/cachestorage/Cache.cpp
diff --git a/Source/modules/cachestorage/Cache.cpp b/Source/modules/cachestorage/Cache.cpp
index bc3e950c758ba8c18ff00eccee5913b2ad3cbdbf..d2c9e5fb112e1e5d0877272dd31c682680976102 100644
--- a/Source/modules/cachestorage/Cache.cpp
+++ b/Source/modules/cachestorage/Cache.cpp
@@ -203,10 +203,15 @@ public:
if (m_completed)
return;
m_completed = true;
+ m_resolver->reject(exception);
+ }
- ScriptState* state = m_resolver->scriptState();
- ScriptState::Scope scope(state);
- m_resolver->reject(V8ThrowException::createTypeError(state->isolate(), exception->toString()));
+ void onError(v8::Local<v8::Value> exception)
+ {
+ if (m_completed)
+ return;
+ m_completed = true;
+ m_resolver->reject(exception);
}
DEFINE_INLINE_VIRTUAL_TRACE()
@@ -429,14 +434,22 @@ ScriptPromise Cache::putImpl(ScriptState* scriptState, const HeapVector<Member<R
for (size_t i = 0; i < requests.size(); ++i) {
KURL url(KURL(), requests[i]->url());
- if (!url.protocolIsInHTTPFamily())
- return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Request scheme '" + url.protocol() + "' is unsupported"));
- if (requests[i]->method() != "GET")
- return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Request method '" + requests[i]->method() + "' is unsupported"));
- if (requests[i]->hasBody() && requests[i]->bodyUsed())
- return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Request body is already used"));
- if (responses[i]->hasBody() && responses[i]->bodyUsed())
- return ScriptPromise::reject(scriptState, V8ThrowException::createTypeError(scriptState->isolate(), "Response body is already used"));
+ if (!url.protocolIsInHTTPFamily()) {
+ barrierCallback->onError(V8ThrowException::createTypeError(scriptState->isolate(), "Request scheme '" + url.protocol() + "' is unsupported"));
+ return promise;
+ }
+ if (requests[i]->method() != "GET") {
+ barrierCallback->onError(V8ThrowException::createTypeError(scriptState->isolate(), "Request method '" + requests[i]->method() + "' is unsupported"));
+ return promise;
+ }
+ if (requests[i]->hasBody() && requests[i]->bodyUsed()) {
+ barrierCallback->onError(V8ThrowException::createTypeError(scriptState->isolate(), "Request body is already used"));
+ return promise;
+ }
+ if (responses[i]->hasBody() && responses[i]->bodyUsed()) {
+ barrierCallback->onError(V8ThrowException::createTypeError(scriptState->isolate(), "Response body is already used"));
+ return promise;
+ }
if (requests[i]->hasBody())
requests[i]->lockBody(Body::PassBody);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698