| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/cache_storage/cache_storage_dispatcher_host.h" | 5 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "content/public/common/origin_util.h" | 25 #include "content/public/common/origin_util.h" |
| 26 #include "storage/browser/blob/blob_data_handle.h" | 26 #include "storage/browser/blob/blob_data_handle.h" |
| 27 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCacheError.h" | 27 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerCacheError.h" |
| 28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 #include "url/origin.h" | 29 #include "url/origin.h" |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const uint32_t kFilteredMessageClasses[] = {CacheStorageMsgStart}; | 35 const uint32_t kFilteredMessageClassesCache[] = {CacheStorageMsgStart}; |
| 36 const int32_t kCachePreservationSeconds = 5; | 36 const int32_t kCachePreservationSeconds = 5; |
| 37 | 37 |
| 38 blink::WebServiceWorkerCacheError ToWebServiceWorkerCacheError( | 38 blink::WebServiceWorkerCacheError ToWebServiceWorkerCacheError( |
| 39 CacheStorageError err) { | 39 CacheStorageError err) { |
| 40 switch (err) { | 40 switch (err) { |
| 41 case CACHE_STORAGE_OK: | 41 case CACHE_STORAGE_OK: |
| 42 NOTREACHED(); | 42 NOTREACHED(); |
| 43 return blink::kWebServiceWorkerCacheErrorNotImplemented; | 43 return blink::kWebServiceWorkerCacheErrorNotImplemented; |
| 44 case CACHE_STORAGE_ERROR_EXISTS: | 44 case CACHE_STORAGE_ERROR_EXISTS: |
| 45 return blink::kWebServiceWorkerCacheErrorExists; | 45 return blink::kWebServiceWorkerCacheErrorExists; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 bool OriginCanAccessCacheStorage(const url::Origin& origin) { | 63 bool OriginCanAccessCacheStorage(const url::Origin& origin) { |
| 64 return !origin.unique() && IsOriginSecure(origin.GetURL()); | 64 return !origin.unique() && IsOriginSecure(origin.GetURL()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void StopPreservingCache( | 67 void StopPreservingCache( |
| 68 std::unique_ptr<CacheStorageCacheHandle> cache_handle) {} | 68 std::unique_ptr<CacheStorageCacheHandle> cache_handle) {} |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 CacheStorageDispatcherHost::CacheStorageDispatcherHost() | 72 CacheStorageDispatcherHost::CacheStorageDispatcherHost() |
| 73 : BrowserMessageFilter(kFilteredMessageClasses, | 73 : BrowserMessageFilter(kFilteredMessageClassesCache, |
| 74 arraysize(kFilteredMessageClasses)) {} | 74 arraysize(kFilteredMessageClassesCache)) {} |
| 75 | 75 |
| 76 CacheStorageDispatcherHost::~CacheStorageDispatcherHost() { | 76 CacheStorageDispatcherHost::~CacheStorageDispatcherHost() { |
| 77 } | 77 } |
| 78 | 78 |
| 79 void CacheStorageDispatcherHost::Init(CacheStorageContextImpl* context) { | 79 void CacheStorageDispatcherHost::Init(CacheStorageContextImpl* context) { |
| 80 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 80 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 81 BrowserThread::PostTask( | 81 BrowserThread::PostTask( |
| 82 BrowserThread::IO, FROM_HERE, | 82 BrowserThread::IO, FROM_HERE, |
| 83 base::BindOnce(&CacheStorageDispatcherHost::CreateCacheListener, this, | 83 base::BindOnce(&CacheStorageDispatcherHost::CreateCacheListener, this, |
| 84 base::RetainedRef(context))); | 84 base::RetainedRef(context))); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); | 533 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); |
| 534 if (it == blob_handle_store_.end()) | 534 if (it == blob_handle_store_.end()) |
| 535 return; | 535 return; |
| 536 DCHECK(!it->second.empty()); | 536 DCHECK(!it->second.empty()); |
| 537 it->second.pop_front(); | 537 it->second.pop_front(); |
| 538 if (it->second.empty()) | 538 if (it->second.empty()) |
| 539 blob_handle_store_.erase(it); | 539 blob_handle_store_.erase(it); |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace content | 542 } // namespace content |
| OLD | NEW |