Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: content/browser/appcache/appcache_disk_cache.cc

Issue 1142193002: Revert of ServiceWorker: Use SimpleCache for the script cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 callback_.Run(rv); 191 callback_.Run(rv);
192 } 192 }
193 193
194 base::WeakPtr<AppCacheDiskCache> owner_; 194 base::WeakPtr<AppCacheDiskCache> owner_;
195 Entry** entry_; 195 Entry** entry_;
196 net::CompletionCallback callback_; 196 net::CompletionCallback callback_;
197 disk_cache::Entry* entry_ptr_; 197 disk_cache::Entry* entry_ptr_;
198 }; 198 };
199 199
200 AppCacheDiskCache::AppCacheDiskCache() 200 AppCacheDiskCache::AppCacheDiskCache()
201 #if defined(APPCACHE_USE_SIMPLE_CACHE) 201 : is_disabled_(false),
202 : AppCacheDiskCache(true) 202 weak_factory_(this) {
203 #else
204 : AppCacheDiskCache(false)
205 #endif
206 {
207 } 203 }
208 204
209 AppCacheDiskCache::~AppCacheDiskCache() { 205 AppCacheDiskCache::~AppCacheDiskCache() {
210 Disable(); 206 Disable();
211 } 207 }
212 208
213 int AppCacheDiskCache::InitWithDiskBackend( 209 int AppCacheDiskCache::InitWithDiskBackend(
214 const base::FilePath& disk_cache_directory, 210 const base::FilePath& disk_cache_directory,
215 int disk_cache_size, 211 int disk_cache_size,
216 bool force, 212 bool force,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 pending_calls_.push_back(PendingCall(DOOM, key, NULL, callback)); 297 pending_calls_.push_back(PendingCall(DOOM, key, NULL, callback));
302 return net::ERR_IO_PENDING; 298 return net::ERR_IO_PENDING;
303 } 299 }
304 300
305 if (!disk_cache_) 301 if (!disk_cache_)
306 return net::ERR_FAILED; 302 return net::ERR_FAILED;
307 303
308 return ActiveCall::DoomEntry(weak_factory_.GetWeakPtr(), key, callback); 304 return ActiveCall::DoomEntry(weak_factory_.GetWeakPtr(), key, callback);
309 } 305 }
310 306
311 AppCacheDiskCache::AppCacheDiskCache(bool use_simple_cache)
312 : use_simple_cache_(use_simple_cache),
313 is_disabled_(false),
314 weak_factory_(this) {
315 }
316
317 AppCacheDiskCache::PendingCall::PendingCall() 307 AppCacheDiskCache::PendingCall::PendingCall()
318 : call_type(CREATE), 308 : call_type(CREATE),
319 key(0), 309 key(0),
320 entry(NULL) { 310 entry(NULL) {
321 } 311 }
322 312
323 AppCacheDiskCache::PendingCall::PendingCall(PendingCallType call_type, 313 AppCacheDiskCache::PendingCall::PendingCall(PendingCallType call_type,
324 int64 key, 314 int64 key,
325 Entry** entry, 315 Entry** entry,
326 const net::CompletionCallback& callback) 316 const net::CompletionCallback& callback)
327 : call_type(call_type), 317 : call_type(call_type),
328 key(key), 318 key(key),
329 entry(entry), 319 entry(entry),
330 callback(callback) { 320 callback(callback) {
331 } 321 }
332 322
333 AppCacheDiskCache::PendingCall::~PendingCall() {} 323 AppCacheDiskCache::PendingCall::~PendingCall() {}
334 324
335 int AppCacheDiskCache::Init( 325 int AppCacheDiskCache::Init(
336 net::CacheType cache_type, 326 net::CacheType cache_type,
337 const base::FilePath& cache_directory, 327 const base::FilePath& cache_directory,
338 int cache_size, 328 int cache_size,
339 bool force, 329 bool force,
340 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread, 330 const scoped_refptr<base::SingleThreadTaskRunner>& cache_thread,
341 const net::CompletionCallback& callback) { 331 const net::CompletionCallback& callback) {
342 DCHECK(!is_initializing() && !disk_cache_.get()); 332 DCHECK(!is_initializing() && !disk_cache_.get());
343 is_disabled_ = false; 333 is_disabled_ = false;
344 create_backend_callback_ = new CreateBackendCallbackShim(this); 334 create_backend_callback_ = new CreateBackendCallbackShim(this);
345 335
336 #if defined(APPCACHE_USE_SIMPLE_CACHE)
337 const net::BackendType backend_type = net::CACHE_BACKEND_SIMPLE;
338 #else
339 const net::BackendType backend_type = net::CACHE_BACKEND_DEFAULT;
340 #endif
346 int rv = disk_cache::CreateCacheBackend( 341 int rv = disk_cache::CreateCacheBackend(
347 cache_type, 342 cache_type,
348 use_simple_cache_ ? net::CACHE_BACKEND_SIMPLE 343 backend_type,
349 : net::CACHE_BACKEND_DEFAULT,
350 cache_directory, 344 cache_directory,
351 cache_size, 345 cache_size,
352 force, 346 force,
353 cache_thread, 347 cache_thread,
354 NULL, 348 NULL,
355 &(create_backend_callback_->backend_ptr_), 349 &(create_backend_callback_->backend_ptr_),
356 base::Bind(&CreateBackendCallbackShim::Callback, 350 base::Bind(&CreateBackendCallbackShim::Callback,
357 create_backend_callback_)); 351 create_backend_callback_));
358 if (rv == net::ERR_IO_PENDING) 352 if (rv == net::ERR_IO_PENDING)
359 init_callback_ = callback; 353 init_callback_ = callback;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 NOTREACHED(); 386 NOTREACHED();
393 break; 387 break;
394 } 388 }
395 if (rv != net::ERR_IO_PENDING) 389 if (rv != net::ERR_IO_PENDING)
396 iter->callback.Run(rv); 390 iter->callback.Run(rv);
397 } 391 }
398 pending_calls_.clear(); 392 pending_calls_.clear();
399 } 393 }
400 394
401 } // namespace content 395 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_disk_cache.h ('k') | content/browser/service_worker/service_worker_disk_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698