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

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

Issue 694083002: Service Worker Cache: Simplify exception/rejection processing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add exception state to fixture Created 6 years, 1 month 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 | « Source/modules/serviceworkers/Cache.h ('k') | Source/modules/serviceworkers/Cache.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Cache.cpp
diff --git a/Source/modules/serviceworkers/Cache.cpp b/Source/modules/serviceworkers/Cache.cpp
index db0cb470bc88551208c7dcd01ca497c5b1f3a7b6..a0c1a73250951cab419e27d42e0abdfc553dd702 100644
--- a/Source/modules/serviceworkers/Cache.cpp
+++ b/Source/modules/serviceworkers/Cache.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "modules/serviceworkers/Cache.h"
+#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/V8ThrowException.h"
@@ -148,11 +149,6 @@ private:
RefPtr<ScriptPromiseResolver> m_resolver;
};
-ScriptPromise rejectForCacheError(ScriptState* scriptState, WebServiceWorkerCacheError error)
-{
- return ScriptPromise::rejectWithDOMException(scriptState, Cache::domExceptionForCacheError(error));
-}
-
ScriptPromise rejectAsNotImplemented(ScriptState* scriptState)
{
return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError, "Cache is not implemented"));
@@ -170,14 +166,11 @@ ScriptPromise Cache::match(ScriptState* scriptState, Request* request, const Cac
return matchImpl(scriptState, request, options);
}
-ScriptPromise Cache::match(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options)
+ScriptPromise Cache::match(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options, ExceptionState& exceptionState)
{
- TrackExceptionState exceptionState;
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
- if (exceptionState.hadException()) {
- // FIXME: We should throw the caught error.
- return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFound);
- }
+ if (exceptionState.hadException())
+ return ScriptPromise();
return matchImpl(scriptState, request, options);
}
@@ -186,14 +179,11 @@ ScriptPromise Cache::matchAll(ScriptState* scriptState, Request* request, const
return matchAllImpl(scriptState, request, options);
}
-ScriptPromise Cache::matchAll(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options)
+ScriptPromise Cache::matchAll(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options, ExceptionState& exceptionState)
{
- TrackExceptionState exceptionState;
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
- if (exceptionState.hadException()) {
- // FIXME: We should throw the caught error.
- return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFound);
- }
+ if (exceptionState.hadException())
+ return ScriptPromise();
return matchAllImpl(scriptState, request, options);
}
@@ -202,14 +192,11 @@ ScriptPromise Cache::add(ScriptState* scriptState, Request* request)
return addImpl(scriptState, request);
}
-ScriptPromise Cache::add(ScriptState* scriptState, const String& requestString)
+ScriptPromise Cache::add(ScriptState* scriptState, const String& requestString, ExceptionState& exceptionState)
{
- TrackExceptionState exceptionState;
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
- if (exceptionState.hadException()) {
- // FIXME: We should throw the caught error.
- return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFound);
- }
+ if (exceptionState.hadException())
+ return ScriptPromise();
return addImpl(scriptState, request);
}
@@ -224,14 +211,11 @@ ScriptPromise Cache::deleteFunction(ScriptState* scriptState, Request* request,
return deleteImpl(scriptState, request, options);
}
-ScriptPromise Cache::deleteFunction(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options)
+ScriptPromise Cache::deleteFunction(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options, ExceptionState& exceptionState)
{
- TrackExceptionState exceptionState;
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
- if (exceptionState.hadException()) {
- // FIXME: We should throw the caught error.
- return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFound);
- }
+ if (exceptionState.hadException())
+ return ScriptPromise();
return deleteImpl(scriptState, request, options);
}
@@ -240,14 +224,11 @@ ScriptPromise Cache::put(ScriptState* scriptState, Request* request, Response* r
return putImpl(scriptState, request, response);
}
-ScriptPromise Cache::put(ScriptState* scriptState, const String& requestString, Response* response)
+ScriptPromise Cache::put(ScriptState* scriptState, const String& requestString, Response* response, ExceptionState& exceptionState)
{
- TrackExceptionState exceptionState;
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
- if (exceptionState.hadException()) {
- // FIXME: We should throw the caught error.
- return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFound);
- }
+ if (exceptionState.hadException())
+ return ScriptPromise();
return putImpl(scriptState, request, response);
}
@@ -261,14 +242,11 @@ ScriptPromise Cache::keys(ScriptState* scriptState, Request* request, const Cach
return keysImpl(scriptState, request, options);
}
-ScriptPromise Cache::keys(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options)
+ScriptPromise Cache::keys(ScriptState* scriptState, const String& requestString, const CacheQueryOptions& options, ExceptionState& exceptionState)
{
- TrackExceptionState exceptionState;
Request* request = Request::create(scriptState->executionContext(), requestString, exceptionState);
- if (exceptionState.hadException()) {
- // FIXME: We should throw the caught error.
- return rejectForCacheError(scriptState, WebServiceWorkerCacheErrorNotFound);
- }
+ if (exceptionState.hadException())
+ return ScriptPromise();
return keysImpl(scriptState, request, options);
}
« no previous file with comments | « Source/modules/serviceworkers/Cache.h ('k') | Source/modules/serviceworkers/Cache.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698