OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/service_worker/service_worker_storage.h" | 5 #include "content/browser/service_worker/service_worker_storage.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 next_resource_id(kInvalidServiceWorkerResourceId) { | 155 next_resource_id(kInvalidServiceWorkerResourceId) { |
156 } | 156 } |
157 | 157 |
158 ServiceWorkerStorage::InitialData::~InitialData() { | 158 ServiceWorkerStorage::InitialData::~InitialData() { |
159 } | 159 } |
160 | 160 |
161 ServiceWorkerStorage::ServiceWorkerStorage( | 161 ServiceWorkerStorage::ServiceWorkerStorage( |
162 const base::FilePath& path, | 162 const base::FilePath& path, |
163 base::WeakPtr<ServiceWorkerContextCore> context, | 163 base::WeakPtr<ServiceWorkerContextCore> context, |
164 base::SequencedTaskRunner* database_task_runner, | 164 base::SequencedTaskRunner* database_task_runner, |
| 165 base::MessageLoopProxy* disk_cache_thread, |
165 quota::QuotaManagerProxy* quota_manager_proxy) | 166 quota::QuotaManagerProxy* quota_manager_proxy) |
166 : next_registration_id_(kInvalidServiceWorkerRegistrationId), | 167 : next_registration_id_(kInvalidServiceWorkerRegistrationId), |
167 next_version_id_(kInvalidServiceWorkerVersionId), | 168 next_version_id_(kInvalidServiceWorkerVersionId), |
168 next_resource_id_(kInvalidServiceWorkerResourceId), | 169 next_resource_id_(kInvalidServiceWorkerResourceId), |
169 state_(UNINITIALIZED), | 170 state_(UNINITIALIZED), |
170 context_(context), | 171 context_(context), |
171 database_task_runner_(database_task_runner), | 172 database_task_runner_(database_task_runner), |
| 173 disk_cache_thread_(disk_cache_thread), |
172 quota_manager_proxy_(quota_manager_proxy), | 174 quota_manager_proxy_(quota_manager_proxy), |
173 weak_factory_(this) { | 175 weak_factory_(this) { |
174 if (!path.empty()) { | 176 if (!path.empty()) { |
175 path_ = path.Append(kServiceWorkerDirectory); | 177 path_ = path.Append(kServiceWorkerDirectory); |
176 database_.reset(new ServiceWorkerDatabase(path_.Append(kDatabaseName))); | 178 database_.reset(new ServiceWorkerDatabase(path_.Append(kDatabaseName))); |
177 } else { | 179 } else { |
178 // Create an in-memory database. | 180 // Create an in-memory database. |
179 database_.reset(new ServiceWorkerDatabase(base::FilePath())); | 181 database_.reset(new ServiceWorkerDatabase(base::FilePath())); |
180 } | 182 } |
181 } | 183 } |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 // TODO(michaeln): Store data on disk and do error checking. | 760 // TODO(michaeln): Store data on disk and do error checking. |
759 disk_cache_.reset(new ServiceWorkerDiskCache); | 761 disk_cache_.reset(new ServiceWorkerDiskCache); |
760 int rv = disk_cache_->InitWithMemBackend( | 762 int rv = disk_cache_->InitWithMemBackend( |
761 kMaxMemDiskCacheSize, | 763 kMaxMemDiskCacheSize, |
762 base::Bind(&EmptyCompletionCallback)); | 764 base::Bind(&EmptyCompletionCallback)); |
763 DCHECK_EQ(net::OK, rv); | 765 DCHECK_EQ(net::OK, rv); |
764 return disk_cache_.get(); | 766 return disk_cache_.get(); |
765 } | 767 } |
766 | 768 |
767 } // namespace content | 769 } // namespace content |
OLD | NEW |