Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/appcache/appcache_disk_cache.h" | 5 #include "content/browser/appcache/appcache_disk_cache.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 } | 171 } |
| 172 | 172 |
| 173 Entry** entry_; | 173 Entry** entry_; |
| 174 net::CompletionCallback callback_; | 174 net::CompletionCallback callback_; |
| 175 AppCacheDiskCache* owner_; | 175 AppCacheDiskCache* owner_; |
| 176 disk_cache::Entry* entry_ptr_; | 176 disk_cache::Entry* entry_ptr_; |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 AppCacheDiskCache::AppCacheDiskCache() | 179 AppCacheDiskCache::AppCacheDiskCache() |
| 180 : is_disabled_(false) { | 180 : is_disabled_(false) { |
| 181 #if defined(APPCACHE_USE_SIMPLE_CACHE) | |
| 182 use_simple_cache_ = true; | |
|
michaeln
2015/05/14 23:35:26
nit: initializer list instead of the method body
nhiroki
2015/05/15 02:12:51
Done.
| |
| 183 #endif | |
| 181 } | 184 } |
| 182 | 185 |
| 183 AppCacheDiskCache::~AppCacheDiskCache() { | 186 AppCacheDiskCache::~AppCacheDiskCache() { |
| 184 Disable(); | 187 Disable(); |
| 185 } | 188 } |
| 186 | 189 |
| 187 int AppCacheDiskCache::InitWithDiskBackend( | 190 int AppCacheDiskCache::InitWithDiskBackend( |
| 188 const base::FilePath& disk_cache_directory, | 191 const base::FilePath& disk_cache_directory, |
| 189 int disk_cache_size, | 192 int disk_cache_size, |
| 190 bool force, | 193 bool force, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 net::CacheType cache_type, | 306 net::CacheType cache_type, |
| 304 const base::FilePath& cache_directory, | 307 const base::FilePath& cache_directory, |
| 305 int cache_size, | 308 int cache_size, |
| 306 bool force, | 309 bool force, |
| 307 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, | 310 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, |
| 308 const net::CompletionCallback& callback) { | 311 const net::CompletionCallback& callback) { |
| 309 DCHECK(!is_initializing() && !disk_cache_.get()); | 312 DCHECK(!is_initializing() && !disk_cache_.get()); |
| 310 is_disabled_ = false; | 313 is_disabled_ = false; |
| 311 create_backend_callback_ = new CreateBackendCallbackShim(this); | 314 create_backend_callback_ = new CreateBackendCallbackShim(this); |
| 312 | 315 |
| 313 #if defined(APPCACHE_USE_SIMPLE_CACHE) | |
| 314 const net::BackendType backend_type = net::CACHE_BACKEND_SIMPLE; | |
| 315 #else | |
| 316 const net::BackendType backend_type = net::CACHE_BACKEND_DEFAULT; | |
| 317 #endif | |
| 318 int rv = disk_cache::CreateCacheBackend( | 316 int rv = disk_cache::CreateCacheBackend( |
| 319 cache_type, | 317 cache_type, |
| 320 backend_type, | 318 use_simple_cache_ ? net::CACHE_BACKEND_SIMPLE |
| 319 : net::CACHE_BACKEND_DEFAULT, | |
| 321 cache_directory, | 320 cache_directory, |
| 322 cache_size, | 321 cache_size, |
| 323 force, | 322 force, |
| 324 cache_thread, | 323 cache_thread, |
| 325 NULL, | 324 NULL, |
| 326 &(create_backend_callback_->backend_ptr_), | 325 &(create_backend_callback_->backend_ptr_), |
| 327 base::Bind(&CreateBackendCallbackShim::Callback, | 326 base::Bind(&CreateBackendCallbackShim::Callback, |
| 328 create_backend_callback_)); | 327 create_backend_callback_)); |
| 329 if (rv == net::ERR_IO_PENDING) | 328 if (rv == net::ERR_IO_PENDING) |
| 330 init_callback_ = callback; | 329 init_callback_ = callback; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 NOTREACHED(); | 362 NOTREACHED(); |
| 364 break; | 363 break; |
| 365 } | 364 } |
| 366 if (rv != net::ERR_IO_PENDING) | 365 if (rv != net::ERR_IO_PENDING) |
| 367 iter->callback.Run(rv); | 366 iter->callback.Run(rv); |
| 368 } | 367 } |
| 369 pending_calls_.clear(); | 368 pending_calls_.clear(); |
| 370 } | 369 } |
| 371 | 370 |
| 372 } // namespace content | 371 } // namespace content |
| OLD | NEW |