| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 26 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 27 #include "content/browser/cache_storage/cache_storage_cache.h" | 27 #include "content/browser/cache_storage/cache_storage_cache.h" |
| 28 #include "content/browser/cache_storage/cache_storage_cache_handle.h" |
| 28 #include "content/browser/cache_storage/cache_storage_context_impl.h" | 29 #include "content/browser/cache_storage/cache_storage_context_impl.h" |
| 29 #include "content/browser/cache_storage/cache_storage_manager.h" | 30 #include "content/browser/cache_storage/cache_storage_manager.h" |
| 30 #include "content/browser/service_worker/embedded_worker_instance.h" | 31 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 31 #include "content/browser/service_worker/embedded_worker_registry.h" | 32 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 32 #include "content/browser/service_worker/embedded_worker_status.h" | 33 #include "content/browser/service_worker/embedded_worker_status.h" |
| 33 #include "content/browser/service_worker/service_worker_context_core.h" | 34 #include "content/browser/service_worker/service_worker_context_core.h" |
| 34 #include "content/browser/service_worker/service_worker_context_observer.h" | 35 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 35 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 36 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 36 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 37 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
| 37 #include "content/browser/service_worker/service_worker_registration.h" | 38 #include "content/browser/service_worker/service_worker_registration.h" |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 RunOnIOThread(base::Bind(&self::OpenCacheOnIOThread, this, &result)); | 1651 RunOnIOThread(base::Bind(&self::OpenCacheOnIOThread, this, &result)); |
| 1651 return result; | 1652 return result; |
| 1652 } | 1653 } |
| 1653 | 1654 |
| 1654 void OpenCacheOnIOThread(int* result, const base::Closure& continuation) { | 1655 void OpenCacheOnIOThread(int* result, const base::Closure& continuation) { |
| 1655 cache_storage_context_->cache_manager()->OpenCache( | 1656 cache_storage_context_->cache_manager()->OpenCache( |
| 1656 origin_, cache_name_, base::Bind(&self::OnCacheStorageOpenCallback, | 1657 origin_, cache_name_, base::Bind(&self::OnCacheStorageOpenCallback, |
| 1657 this, result, continuation)); | 1658 this, result, continuation)); |
| 1658 } | 1659 } |
| 1659 | 1660 |
| 1660 void OnCacheStorageOpenCallback(int* result, | 1661 void OnCacheStorageOpenCallback( |
| 1661 const base::Closure& continuation, | 1662 int* result, |
| 1662 scoped_refptr<CacheStorageCache> cache, | 1663 const base::Closure& continuation, |
| 1663 CacheStorageError error) { | 1664 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 1665 CacheStorageError error) { |
| 1664 ASSERT_EQ(CACHE_STORAGE_OK, error); | 1666 ASSERT_EQ(CACHE_STORAGE_OK, error); |
| 1665 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( | 1667 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( |
| 1666 new ServiceWorkerFetchRequest()); | 1668 new ServiceWorkerFetchRequest()); |
| 1667 scoped_request->url = url_; | 1669 scoped_request->url = url_; |
| 1668 cache->Match(std::move(scoped_request), | 1670 CacheStorageCache* cache = cache_handle->value(); |
| 1669 base::Bind(&self::OnCacheStorageCacheMatchCallback, this, | 1671 cache->Match( |
| 1670 result, continuation)); | 1672 std::move(scoped_request), |
| 1673 base::Bind(&self::OnCacheStorageCacheMatchCallback, this, result, |
| 1674 continuation, base::Passed(std::move(cache_handle)))); |
| 1671 } | 1675 } |
| 1672 | 1676 |
| 1673 void OnCacheStorageCacheMatchCallback( | 1677 void OnCacheStorageCacheMatchCallback( |
| 1674 int* result, | 1678 int* result, |
| 1675 const base::Closure& continuation, | 1679 const base::Closure& continuation, |
| 1680 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 1676 CacheStorageError error, | 1681 CacheStorageError error, |
| 1677 std::unique_ptr<ServiceWorkerResponse> response, | 1682 std::unique_ptr<ServiceWorkerResponse> response, |
| 1678 std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { | 1683 std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { |
| 1679 ASSERT_EQ(CACHE_STORAGE_OK, error); | 1684 ASSERT_EQ(CACHE_STORAGE_OK, error); |
| 1680 blob_data_handle_ = std::move(blob_data_handle); | 1685 blob_data_handle_ = std::move(blob_data_handle); |
| 1681 blob_reader_ = blob_data_handle_->CreateReader( | 1686 blob_reader_ = blob_data_handle_->CreateReader( |
| 1682 file_system_context_, | 1687 file_system_context_, |
| 1683 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get()); | 1688 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get()); |
| 1684 const storage::BlobReader::Status status = blob_reader_->CalculateSize( | 1689 const storage::BlobReader::Status status = blob_reader_->CalculateSize( |
| 1685 base::Bind(&self::OnBlobReaderCalculateSizeCallback, this, result, | 1690 base::Bind(&self::OnBlobReaderCalculateSizeCallback, this, result, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 NavigateToTestPage(); | 1872 NavigateToTestPage(); |
| 1868 // The V8 code cache must be stored to the CacheStorage which must be bigger | 1873 // The V8 code cache must be stored to the CacheStorage which must be bigger |
| 1869 // than 12 byte. | 1874 // than 12 byte. |
| 1870 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); | 1875 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); |
| 1871 | 1876 |
| 1872 NavigateToTestPage(); | 1877 NavigateToTestPage(); |
| 1873 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); | 1878 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); |
| 1874 } | 1879 } |
| 1875 | 1880 |
| 1876 } // namespace content | 1881 } // namespace content |
| OLD | NEW |