| 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 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 RunOnIOThread(base::Bind(&self::OpenCacheOnIOThread, this, &result)); | 1650 RunOnIOThread(base::Bind(&self::OpenCacheOnIOThread, this, &result)); |
| 1650 return result; | 1651 return result; |
| 1651 } | 1652 } |
| 1652 | 1653 |
| 1653 void OpenCacheOnIOThread(int* result, const base::Closure& continuation) { | 1654 void OpenCacheOnIOThread(int* result, const base::Closure& continuation) { |
| 1654 cache_storage_context_->cache_manager()->OpenCache( | 1655 cache_storage_context_->cache_manager()->OpenCache( |
| 1655 origin_, cache_name_, base::Bind(&self::OnCacheStorageOpenCallback, | 1656 origin_, cache_name_, base::Bind(&self::OnCacheStorageOpenCallback, |
| 1656 this, result, continuation)); | 1657 this, result, continuation)); |
| 1657 } | 1658 } |
| 1658 | 1659 |
| 1659 void OnCacheStorageOpenCallback(int* result, | 1660 void OnCacheStorageOpenCallback( |
| 1660 const base::Closure& continuation, | 1661 int* result, |
| 1661 scoped_refptr<CacheStorageCache> cache, | 1662 const base::Closure& continuation, |
| 1662 CacheStorageError error) { | 1663 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 1664 CacheStorageError error) { |
| 1663 ASSERT_EQ(CACHE_STORAGE_OK, error); | 1665 ASSERT_EQ(CACHE_STORAGE_OK, error); |
| 1664 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( | 1666 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( |
| 1665 new ServiceWorkerFetchRequest()); | 1667 new ServiceWorkerFetchRequest()); |
| 1666 scoped_request->url = url_; | 1668 scoped_request->url = url_; |
| 1667 cache->Match(std::move(scoped_request), | 1669 CacheStorageCache* cache = cache_handle->value(); |
| 1668 base::Bind(&self::OnCacheStorageCacheMatchCallback, this, | 1670 cache->Match( |
| 1669 result, continuation)); | 1671 std::move(scoped_request), |
| 1672 base::Bind(&self::OnCacheStorageCacheMatchCallback, this, result, |
| 1673 continuation, base::Passed(std::move(cache_handle)))); |
| 1670 } | 1674 } |
| 1671 | 1675 |
| 1672 void OnCacheStorageCacheMatchCallback( | 1676 void OnCacheStorageCacheMatchCallback( |
| 1673 int* result, | 1677 int* result, |
| 1674 const base::Closure& continuation, | 1678 const base::Closure& continuation, |
| 1679 std::unique_ptr<CacheStorageCacheHandle> cache_handle, |
| 1675 CacheStorageError error, | 1680 CacheStorageError error, |
| 1676 std::unique_ptr<ServiceWorkerResponse> response, | 1681 std::unique_ptr<ServiceWorkerResponse> response, |
| 1677 std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { | 1682 std::unique_ptr<storage::BlobDataHandle> blob_data_handle) { |
| 1678 ASSERT_EQ(CACHE_STORAGE_OK, error); | 1683 ASSERT_EQ(CACHE_STORAGE_OK, error); |
| 1679 blob_data_handle_ = std::move(blob_data_handle); | 1684 blob_data_handle_ = std::move(blob_data_handle); |
| 1680 blob_reader_ = blob_data_handle_->CreateReader( | 1685 blob_reader_ = blob_data_handle_->CreateReader( |
| 1681 file_system_context_, | 1686 file_system_context_, |
| 1682 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get()); | 1687 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get()); |
| 1683 const storage::BlobReader::Status status = blob_reader_->CalculateSize( | 1688 const storage::BlobReader::Status status = blob_reader_->CalculateSize( |
| 1684 base::Bind(&self::OnBlobReaderCalculateSizeCallback, this, result, | 1689 base::Bind(&self::OnBlobReaderCalculateSizeCallback, this, result, |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 NavigateToTestPage(); | 1871 NavigateToTestPage(); |
| 1867 // The V8 code cache must be stored to the CacheStorage which must be bigger | 1872 // The V8 code cache must be stored to the CacheStorage which must be bigger |
| 1868 // than 12 byte. | 1873 // than 12 byte. |
| 1869 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); | 1874 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); |
| 1870 | 1875 |
| 1871 NavigateToTestPage(); | 1876 NavigateToTestPage(); |
| 1872 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); | 1877 EXPECT_GT(GetSideDataSize(), kV8CacheTimeStampDataSize); |
| 1873 } | 1878 } |
| 1874 | 1879 |
| 1875 } // namespace content | 1880 } // namespace content |
| OLD | NEW |