| Index: third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp
|
| diff --git a/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp b/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp
|
| index e56047d961a130763bfa82c3d6ffecc4462b799c..d2c2860ab2c3a9a1271622f4af2a23f798451682 100644
|
| --- a/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp
|
| +++ b/third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp
|
| @@ -30,9 +30,11 @@
|
| #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h"
|
|
|
| using blink::protocol::Array;
|
| -using blink::protocol::CacheStorage::Cache;
|
| +// Renaming Cache since there is another blink::Cache.
|
| +using ProtocolCache = blink::protocol::CacheStorage::Cache;
|
| using blink::protocol::CacheStorage::DataEntry;
|
| -using blink::protocol::Response;
|
| +// Renaming Response since there is another blink::Response.
|
| +using ProtocolResponse = blink::protocol::Response;
|
|
|
| typedef blink::protocol::CacheStorage::Backend::DeleteCacheCallback
|
| DeleteCacheCallback;
|
| @@ -55,41 +57,44 @@ String BuildCacheId(const String& security_origin, const String& cache_name) {
|
| return id;
|
| }
|
|
|
| -Response ParseCacheId(const String& id,
|
| - String* security_origin,
|
| - String* cache_name) {
|
| +ProtocolResponse ParseCacheId(const String& id,
|
| + String* security_origin,
|
| + String* cache_name) {
|
| size_t pipe = id.find('|');
|
| if (pipe == WTF::kNotFound)
|
| - return Response::Error("Invalid cache id.");
|
| + return ProtocolResponse::Error("Invalid cache id.");
|
| *security_origin = id.Substring(0, pipe);
|
| *cache_name = id.Substring(pipe + 1);
|
| - return Response::OK();
|
| + return ProtocolResponse::OK();
|
| }
|
|
|
| -Response AssertCacheStorage(
|
| +ProtocolResponse AssertCacheStorage(
|
| const String& security_origin,
|
| std::unique_ptr<WebServiceWorkerCacheStorage>& result) {
|
| RefPtr<SecurityOrigin> sec_origin =
|
| SecurityOrigin::CreateFromString(security_origin);
|
|
|
| // Cache Storage API is restricted to trustworthy origins.
|
| - if (!sec_origin->IsPotentiallyTrustworthy())
|
| - return Response::Error(sec_origin->IsPotentiallyTrustworthyErrorMessage());
|
| + if (!sec_origin->IsPotentiallyTrustworthy()) {
|
| + return ProtocolResponse::Error(
|
| + sec_origin->IsPotentiallyTrustworthyErrorMessage());
|
| + }
|
|
|
| std::unique_ptr<WebServiceWorkerCacheStorage> cache =
|
| Platform::Current()->CreateCacheStorage(WebSecurityOrigin(sec_origin));
|
| if (!cache)
|
| - return Response::Error("Could not find cache storage.");
|
| + return ProtocolResponse::Error("Could not find cache storage.");
|
| result = std::move(cache);
|
| - return Response::OK();
|
| + return ProtocolResponse::OK();
|
| }
|
|
|
| -Response AssertCacheStorageAndNameForId(
|
| +ProtocolResponse AssertCacheStorageAndNameForId(
|
| const String& cache_id,
|
| String* cache_name,
|
| std::unique_ptr<WebServiceWorkerCacheStorage>& result) {
|
| String security_origin;
|
| - Response response = ParseCacheId(cache_id, &security_origin, cache_name);
|
| + ProtocolResponse response =
|
| + ParseCacheId(cache_id, &security_origin, cache_name);
|
| if (!response.isSuccess())
|
| return response;
|
| return AssertCacheStorage(security_origin, result);
|
| @@ -129,11 +134,12 @@ class RequestCacheNames
|
| ~RequestCacheNames() override {}
|
|
|
| void OnSuccess(const WebVector<WebString>& caches) override {
|
| - std::unique_ptr<Array<Cache>> array = Array<Cache>::create();
|
| + std::unique_ptr<Array<ProtocolCache>> array =
|
| + Array<ProtocolCache>::create();
|
| for (size_t i = 0; i < caches.size(); i++) {
|
| String name = String(caches[i]);
|
| - std::unique_ptr<Cache> entry =
|
| - Cache::create()
|
| + std::unique_ptr<ProtocolCache> entry =
|
| + ProtocolCache::create()
|
| .setSecurityOrigin(security_origin_)
|
| .setCacheName(name)
|
| .setCacheId(BuildCacheId(security_origin_, name))
|
| @@ -144,7 +150,7 @@ class RequestCacheNames
|
| }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - callback_->sendFailure(Response::Error(
|
| + callback_->sendFailure(ProtocolResponse::Error(
|
| String::Format("Error requesting cache names: %s",
|
| ServiceWorkerCacheErrorString(error).data())));
|
| }
|
| @@ -218,7 +224,9 @@ class ResponsesAccumulator : public RefCounted<ResponsesAccumulator> {
|
| callback_->sendSuccess(std::move(array), has_more);
|
| }
|
|
|
| - void SendFailure(const Response& error) { callback_->sendFailure(error); }
|
| + void SendFailure(const ProtocolResponse& error) {
|
| + callback_->sendFailure(error);
|
| + }
|
|
|
| private:
|
| DataRequestParams params_;
|
| @@ -243,7 +251,7 @@ class GetCacheResponsesForRequestData
|
| }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - accumulator_->SendFailure(Response::Error(
|
| + accumulator_->SendFailure(ProtocolResponse::Error(
|
| String::Format("Error requesting responses for cache %s: %s",
|
| params_.cache_name.Utf8().data(),
|
| ServiceWorkerCacheErrorString(error).data())));
|
| @@ -289,7 +297,7 @@ class GetCacheKeysForRequestData
|
| }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - callback_->sendFailure(Response::Error(
|
| + callback_->sendFailure(ProtocolResponse::Error(
|
| String::Format("Error requesting requests for cache %s: %s",
|
| params_.cache_name.Utf8().data(),
|
| ServiceWorkerCacheErrorString(error).data())));
|
| @@ -320,7 +328,7 @@ class GetCacheForRequestData
|
| }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - callback_->sendFailure(Response::Error(String::Format(
|
| + callback_->sendFailure(ProtocolResponse::Error(String::Format(
|
| "Error requesting cache %s: %s", params_.cache_name.Utf8().data(),
|
| ServiceWorkerCacheErrorString(error).data())));
|
| }
|
| @@ -341,7 +349,7 @@ class DeleteCache : public WebServiceWorkerCacheStorage::CacheStorageCallbacks {
|
| void OnSuccess() override { callback_->sendSuccess(); }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - callback_->sendFailure(Response::Error(
|
| + callback_->sendFailure(ProtocolResponse::Error(
|
| String::Format("Error requesting cache names: %s",
|
| ServiceWorkerCacheErrorString(error).data())));
|
| }
|
| @@ -361,7 +369,7 @@ class DeleteCacheEntry : public WebServiceWorkerCache::CacheBatchCallbacks {
|
| void OnSuccess() override { callback_->sendSuccess(); }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - callback_->sendFailure(Response::Error(
|
| + callback_->sendFailure(ProtocolResponse::Error(
|
| String::Format("Error requesting cache names: %s",
|
| ServiceWorkerCacheErrorString(error).data())));
|
| }
|
| @@ -397,7 +405,7 @@ class GetCacheForDeleteEntry
|
| }
|
|
|
| void OnError(WebServiceWorkerCacheError error) override {
|
| - callback_->sendFailure(Response::Error(String::Format(
|
| + callback_->sendFailure(ProtocolResponse::Error(String::Format(
|
| "Error requesting cache %s: %s", cache_name_.Utf8().data(),
|
| ServiceWorkerCacheErrorString(error).data())));
|
| }
|
| @@ -428,12 +436,12 @@ void InspectorCacheStorageAgent::requestCacheNames(
|
| if (!sec_origin->IsPotentiallyTrustworthy()) {
|
| // Don't treat this as an error, just don't attempt to open and enumerate
|
| // the caches.
|
| - callback->sendSuccess(Array<protocol::CacheStorage::Cache>::create());
|
| + callback->sendSuccess(Array<ProtocolCache>::create());
|
| return;
|
| }
|
|
|
| std::unique_ptr<WebServiceWorkerCacheStorage> cache;
|
| - Response response = AssertCacheStorage(security_origin, cache);
|
| + ProtocolResponse response = AssertCacheStorage(security_origin, cache);
|
| if (!response.isSuccess()) {
|
| callback->sendFailure(response);
|
| return;
|
| @@ -449,7 +457,7 @@ void InspectorCacheStorageAgent::requestEntries(
|
| std::unique_ptr<RequestEntriesCallback> callback) {
|
| String cache_name;
|
| std::unique_ptr<WebServiceWorkerCacheStorage> cache;
|
| - Response response =
|
| + ProtocolResponse response =
|
| AssertCacheStorageAndNameForId(cache_id, &cache_name, cache);
|
| if (!response.isSuccess()) {
|
| callback->sendFailure(response);
|
| @@ -469,7 +477,7 @@ void InspectorCacheStorageAgent::deleteCache(
|
| std::unique_ptr<DeleteCacheCallback> callback) {
|
| String cache_name;
|
| std::unique_ptr<WebServiceWorkerCacheStorage> cache;
|
| - Response response =
|
| + ProtocolResponse response =
|
| AssertCacheStorageAndNameForId(cache_id, &cache_name, cache);
|
| if (!response.isSuccess()) {
|
| callback->sendFailure(response);
|
| @@ -485,7 +493,7 @@ void InspectorCacheStorageAgent::deleteEntry(
|
| std::unique_ptr<DeleteEntryCallback> callback) {
|
| String cache_name;
|
| std::unique_ptr<WebServiceWorkerCacheStorage> cache;
|
| - Response response =
|
| + ProtocolResponse response =
|
| AssertCacheStorageAndNameForId(cache_id, &cache_name, cache);
|
| if (!response.isSuccess()) {
|
| callback->sendFailure(response);
|
|
|