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

Side by Side Diff: net/http/http_cache.cc

Issue 10909136: Http Cache: Add code for simulating an infinite HTTP cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 10
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 int buf_len) { 345 int buf_len) {
346 if (!buf_len) 346 if (!buf_len)
347 return; 347 return;
348 348
349 // Do lazy initialization of disk cache if needed. 349 // Do lazy initialization of disk cache if needed.
350 if (!disk_cache_.get()) { 350 if (!disk_cache_.get()) {
351 // We don't care about the result. 351 // We don't care about the result.
352 CreateBackend(NULL, net::CompletionCallback()); 352 CreateBackend(NULL, net::CompletionCallback());
353 } 353 }
354 354
355 HttpCache::Transaction* trans = new HttpCache::Transaction(this, NULL); 355 HttpCache::Transaction* trans = new HttpCache::Transaction(this, NULL, NULL);
356 MetadataWriter* writer = new MetadataWriter(trans); 356 MetadataWriter* writer = new MetadataWriter(trans);
357 357
358 // The writer will self destruct when done. 358 // The writer will self destruct when done.
359 writer->Write(url, expected_response_time, buf, buf_len); 359 writer->Write(url, expected_response_time, buf, buf_len);
360 } 360 }
361 361
362 void HttpCache::CloseAllConnections() { 362 void HttpCache::CloseAllConnections() {
363 net::HttpNetworkLayer* network = 363 net::HttpNetworkLayer* network =
364 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); 364 static_cast<net::HttpNetworkLayer*>(network_layer_.get());
365 HttpNetworkSession* session = network->GetSession(); 365 HttpNetworkSession* session = network->GetSession();
(...skipping 17 matching lines...) Expand all
383 HttpRequestInfo request_info; 383 HttpRequestInfo request_info;
384 request_info.url = url; 384 request_info.url = url;
385 request_info.method = http_method; 385 request_info.method = http_method;
386 std::string key = GenerateCacheKey(&request_info); 386 std::string key = GenerateCacheKey(&request_info);
387 disk_cache_->OnExternalCacheHit(key); 387 disk_cache_->OnExternalCacheHit(key);
388 } 388 }
389 389
390 void HttpCache::InitializeInfiniteCache(const FilePath& path) { 390 void HttpCache::InitializeInfiniteCache(const FilePath& path) {
391 if (base::FieldTrialList::FindFullName("InfiniteCache") != "Yes") 391 if (base::FieldTrialList::FindFullName("InfiniteCache") != "Yes")
392 return; 392 return;
393 // TODO(rvargas): initialize the infinite cache 393 // To be enabled after everything is fully wired.
394 // infinite_cache_.Init(path);
394 } 395 }
395 396
396 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans, 397 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans,
397 HttpTransactionDelegate* delegate) { 398 HttpTransactionDelegate* delegate) {
398 // Do lazy initialization of disk cache if needed. 399 // Do lazy initialization of disk cache if needed.
399 if (!disk_cache_.get()) { 400 if (!disk_cache_.get()) {
400 // We don't care about the result. 401 // We don't care about the result.
401 CreateBackend(NULL, net::CompletionCallback()); 402 CreateBackend(NULL, net::CompletionCallback());
402 } 403 }
403 404
404 trans->reset(new HttpCache::Transaction(this, delegate)); 405 InfiniteCacheTransaction* infinite_cache_transaction =
406 infinite_cache_.CreateInfiniteCacheTransaction();
407 trans->reset(new HttpCache::Transaction(this, delegate,
408 infinite_cache_transaction));
405 return OK; 409 return OK;
406 } 410 }
407 411
408 HttpCache* HttpCache::GetCache() { 412 HttpCache* HttpCache::GetCache() {
409 return this; 413 return this;
410 } 414 }
411 415
412 HttpNetworkSession* HttpCache::GetSession() { 416 HttpNetworkSession* HttpCache::GetSession() {
413 net::HttpNetworkLayer* network = 417 net::HttpNetworkLayer* network =
414 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); 418 static_cast<net::HttpNetworkLayer*>(network_layer_.get());
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 building_backend_ = false; 1100 building_backend_ = false;
1097 DeletePendingOp(pending_op); 1101 DeletePendingOp(pending_op);
1098 } 1102 }
1099 1103
1100 // The cache may be gone when we return from the callback. 1104 // The cache may be gone when we return from the callback.
1101 if (!item->DoCallback(result, backend)) 1105 if (!item->DoCallback(result, backend))
1102 item->NotifyTransaction(result, NULL); 1106 item->NotifyTransaction(result, NULL);
1103 } 1107 }
1104 1108
1105 } // namespace net 1109 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698