| 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 "webkit/appcache/appcache_disk_cache.h" | 5 #include "webkit/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/file_path.h" | 9 #include "base/file_path.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 157   if (create_backend_callback_) { | 157   if (create_backend_callback_) { | 
| 158     create_backend_callback_->Cancel(); | 158     create_backend_callback_->Cancel(); | 
| 159     create_backend_callback_ = NULL; | 159     create_backend_callback_ = NULL; | 
| 160     OnCreateBackendComplete(net::ERR_ABORTED); | 160     OnCreateBackendComplete(net::ERR_ABORTED); | 
| 161   } | 161   } | 
| 162   disk_cache_.reset(); | 162   disk_cache_.reset(); | 
| 163   STLDeleteElements(&active_calls_); | 163   STLDeleteElements(&active_calls_); | 
| 164 } | 164 } | 
| 165 | 165 | 
| 166 int AppCacheDiskCache::InitWithDiskBackend( | 166 int AppCacheDiskCache::InitWithDiskBackend( | 
| 167     const FilePath& disk_cache_directory, int disk_cache_size, bool force, | 167     const base::FilePath& disk_cache_directory, int disk_cache_size, bool force, | 
| 168     base::MessageLoopProxy* cache_thread, | 168     base::MessageLoopProxy* cache_thread, | 
| 169     const net::CompletionCallback& callback) { | 169     const net::CompletionCallback& callback) { | 
| 170   return Init(net::APP_CACHE, disk_cache_directory, | 170   return Init(net::APP_CACHE, disk_cache_directory, | 
| 171               disk_cache_size, force, cache_thread, callback); | 171               disk_cache_size, force, cache_thread, callback); | 
| 172 } | 172 } | 
| 173 | 173 | 
| 174 int AppCacheDiskCache::InitWithMemBackend( | 174 int AppCacheDiskCache::InitWithMemBackend( | 
| 175     int mem_cache_size, const net::CompletionCallback& callback) { | 175     int mem_cache_size, const net::CompletionCallback& callback) { | 
| 176   return Init(net::MEMORY_CACHE, FilePath(), mem_cache_size, false, NULL, | 176   return Init(net::MEMORY_CACHE, base::FilePath(), mem_cache_size, false, NULL, | 
| 177               callback); | 177               callback); | 
| 178 } | 178 } | 
| 179 | 179 | 
| 180 void AppCacheDiskCache::Disable() { | 180 void AppCacheDiskCache::Disable() { | 
| 181   if (is_disabled_) | 181   if (is_disabled_) | 
| 182     return; | 182     return; | 
| 183 | 183 | 
| 184   is_disabled_ = true; | 184   is_disabled_ = true; | 
| 185 | 185 | 
| 186   if (create_backend_callback_) { | 186   if (create_backend_callback_) { | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 255     const net::CompletionCallback& callback) | 255     const net::CompletionCallback& callback) | 
| 256     : call_type(call_type), | 256     : call_type(call_type), | 
| 257       key(key), | 257       key(key), | 
| 258       entry(entry), | 258       entry(entry), | 
| 259       callback(callback) { | 259       callback(callback) { | 
| 260 } | 260 } | 
| 261 | 261 | 
| 262 AppCacheDiskCache::PendingCall::~PendingCall() {} | 262 AppCacheDiskCache::PendingCall::~PendingCall() {} | 
| 263 | 263 | 
| 264 int AppCacheDiskCache::Init(net::CacheType cache_type, | 264 int AppCacheDiskCache::Init(net::CacheType cache_type, | 
| 265                             const FilePath& cache_directory, | 265                             const base::FilePath& cache_directory, | 
| 266                             int cache_size, bool force, | 266                             int cache_size, bool force, | 
| 267                             base::MessageLoopProxy* cache_thread, | 267                             base::MessageLoopProxy* cache_thread, | 
| 268                             const net::CompletionCallback& callback) { | 268                             const net::CompletionCallback& callback) { | 
| 269   DCHECK(!is_initializing() && !disk_cache_.get()); | 269   DCHECK(!is_initializing() && !disk_cache_.get()); | 
| 270   is_disabled_ = false; | 270   is_disabled_ = false; | 
| 271   create_backend_callback_ = new CreateBackendCallbackShim(this); | 271   create_backend_callback_ = new CreateBackendCallbackShim(this); | 
| 272 | 272 | 
| 273   int rv = disk_cache::CreateCacheBackend( | 273   int rv = disk_cache::CreateCacheBackend( | 
| 274       cache_type, cache_directory, cache_size, force, cache_thread, NULL, | 274       cache_type, cache_directory, cache_size, force, cache_thread, NULL, | 
| 275       &(create_backend_callback_->backend_ptr_), | 275       &(create_backend_callback_->backend_ptr_), | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 313         NOTREACHED(); | 313         NOTREACHED(); | 
| 314         break; | 314         break; | 
| 315     } | 315     } | 
| 316     if (rv != net::ERR_IO_PENDING) | 316     if (rv != net::ERR_IO_PENDING) | 
| 317       iter->callback.Run(rv); | 317       iter->callback.Run(rv); | 
| 318   } | 318   } | 
| 319   pending_calls_.clear(); | 319   pending_calls_.clear(); | 
| 320 } | 320 } | 
| 321 | 321 | 
| 322 }  // namespace appcache | 322 }  // namespace appcache | 
| OLD | NEW | 
|---|