| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/cachestorage/InspectorCacheStorageAgent.h" | 5 #include "modules/cachestorage/InspectorCacheStorageAgent.h" |
| 6 | 6 |
| 7 #include "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 #include "platform/inspector_protocol/DispatcherBase.h" | 8 #include "platform/inspector_protocol/DispatcherBase.h" |
| 9 #include "platform/inspector_protocol/Values.h" | 9 #include "platform/inspector_protocol/Values.h" |
| 10 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 399 |
| 400 InspectorCacheStorageAgent::InspectorCacheStorageAgent() = default; | 400 InspectorCacheStorageAgent::InspectorCacheStorageAgent() = default; |
| 401 | 401 |
| 402 InspectorCacheStorageAgent::~InspectorCacheStorageAgent() = default; | 402 InspectorCacheStorageAgent::~InspectorCacheStorageAgent() = default; |
| 403 | 403 |
| 404 DEFINE_TRACE(InspectorCacheStorageAgent) | 404 DEFINE_TRACE(InspectorCacheStorageAgent) |
| 405 { | 405 { |
| 406 InspectorBaseAgent::trace(visitor); | 406 InspectorBaseAgent::trace(visitor); |
| 407 } | 407 } |
| 408 | 408 |
| 409 void InspectorCacheStorageAgent::requestCacheNames(ErrorString* errorString, con
st String& securityOrigin, std::unique_ptr<RequestCacheNamesCallback> callback) | 409 void InspectorCacheStorageAgent::requestCacheNames(const String& securityOrigin,
std::unique_ptr<RequestCacheNamesCallback> callback) |
| 410 { | 410 { |
| 411 RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(security
Origin); | 411 RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(security
Origin); |
| 412 | 412 |
| 413 // Cache Storage API is restricted to trustworthy origins. | 413 // Cache Storage API is restricted to trustworthy origins. |
| 414 if (!secOrigin->isPotentiallyTrustworthy()) { | 414 if (!secOrigin->isPotentiallyTrustworthy()) { |
| 415 // Don't treat this as an error, just don't attempt to open and enumerat
e the caches. | 415 // Don't treat this as an error, just don't attempt to open and enumerat
e the caches. |
| 416 callback->sendSuccess(Array<protocol::CacheStorage::Cache>::create()); | 416 callback->sendSuccess(Array<protocol::CacheStorage::Cache>::create()); |
| 417 return; | 417 return; |
| 418 } | 418 } |
| 419 | 419 |
| 420 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(err
orString, securityOrigin); | 420 ErrorString errorString; |
| 421 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(&er
rorString, securityOrigin); |
| 421 if (!cache) { | 422 if (!cache) { |
| 422 callback->sendFailure(*errorString); | 423 callback->sendFailure(errorString); |
| 423 return; | 424 return; |
| 424 } | 425 } |
| 425 cache->dispatchKeys(new RequestCacheNames(securityOrigin, std::move(callback
))); | 426 cache->dispatchKeys(new RequestCacheNames(securityOrigin, std::move(callback
))); |
| 426 } | 427 } |
| 427 | 428 |
| 428 void InspectorCacheStorageAgent::requestEntries(ErrorString* errorString, const
String& cacheId, int skipCount, int pageSize, std::unique_ptr<RequestEntriesCall
back> callback) | 429 void InspectorCacheStorageAgent::requestEntries(const String& cacheId, int skipC
ount, int pageSize, std::unique_ptr<RequestEntriesCallback> callback) |
| 429 { | 430 { |
| 431 ErrorString errorString; |
| 430 String cacheName; | 432 String cacheName; |
| 431 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndN
ameForId(errorString, cacheId, &cacheName); | 433 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndN
ameForId(&errorString, cacheId, &cacheName); |
| 432 if (!cache) { | 434 if (!cache) { |
| 433 callback->sendFailure(*errorString); | 435 callback->sendFailure(errorString); |
| 434 return; | 436 return; |
| 435 } | 437 } |
| 436 DataRequestParams params; | 438 DataRequestParams params; |
| 437 params.cacheName = cacheName; | 439 params.cacheName = cacheName; |
| 438 params.pageSize = pageSize; | 440 params.pageSize = pageSize; |
| 439 params.skipCount = skipCount; | 441 params.skipCount = skipCount; |
| 440 cache->dispatchOpen(new GetCacheForRequestData(params, std::move(callback)),
WebString(cacheName)); | 442 cache->dispatchOpen(new GetCacheForRequestData(params, std::move(callback)),
WebString(cacheName)); |
| 441 } | 443 } |
| 442 | 444 |
| 443 void InspectorCacheStorageAgent::deleteCache(ErrorString* errorString, const Str
ing& cacheId, std::unique_ptr<DeleteCacheCallback> callback) | 445 void InspectorCacheStorageAgent::deleteCache(const String& cacheId, std::unique_
ptr<DeleteCacheCallback> callback) |
| 444 { | 446 { |
| 445 String cacheName; | 447 String cacheName; |
| 446 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndN
ameForId(errorString, cacheId, &cacheName); | 448 ErrorString errorString; |
| 449 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndN
ameForId(&errorString, cacheId, &cacheName); |
| 447 if (!cache) { | 450 if (!cache) { |
| 448 callback->sendFailure(*errorString); | 451 callback->sendFailure(errorString); |
| 449 return; | 452 return; |
| 450 } | 453 } |
| 451 cache->dispatchDelete(new DeleteCache(std::move(callback)), WebString(cacheN
ame)); | 454 cache->dispatchDelete(new DeleteCache(std::move(callback)), WebString(cacheN
ame)); |
| 452 } | 455 } |
| 453 | 456 |
| 454 void InspectorCacheStorageAgent::deleteEntry(ErrorString* errorString, const Str
ing& cacheId, const String& request, std::unique_ptr<DeleteEntryCallback> callba
ck) | 457 void InspectorCacheStorageAgent::deleteEntry(const String& cacheId, const String
& request, std::unique_ptr<DeleteEntryCallback> callback) |
| 455 { | 458 { |
| 456 String cacheName; | 459 String cacheName; |
| 457 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndN
ameForId(errorString, cacheId, &cacheName); | 460 ErrorString errorString; |
| 461 std::unique_ptr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndN
ameForId(&errorString, cacheId, &cacheName); |
| 458 if (!cache) { | 462 if (!cache) { |
| 459 callback->sendFailure(*errorString); | 463 callback->sendFailure(errorString); |
| 460 return; | 464 return; |
| 461 } | 465 } |
| 462 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, std::move
(callback)), WebString(cacheName)); | 466 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, std::move
(callback)), WebString(cacheName)); |
| 463 } | 467 } |
| 464 | 468 |
| 465 | 469 |
| 466 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |