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

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

Issue 10907241: Revert 156846 - 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, NULL); 355 HttpCache::Transaction* trans = new HttpCache::Transaction(this, 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 // To be enabled after everything is fully wired. 393 // TODO(rvargas): initialize the infinite cache
394 // infinite_cache_.Init(path);
395 } 394 }
396 395
397 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans, 396 int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans,
398 HttpTransactionDelegate* delegate) { 397 HttpTransactionDelegate* delegate) {
399 // Do lazy initialization of disk cache if needed. 398 // Do lazy initialization of disk cache if needed.
400 if (!disk_cache_.get()) { 399 if (!disk_cache_.get()) {
401 // We don't care about the result. 400 // We don't care about the result.
402 CreateBackend(NULL, net::CompletionCallback()); 401 CreateBackend(NULL, net::CompletionCallback());
403 } 402 }
404 403
405 InfiniteCacheTransaction* infinite_cache_transaction = 404 trans->reset(new HttpCache::Transaction(this, delegate));
406 infinite_cache_.CreateInfiniteCacheTransaction();
407 trans->reset(new HttpCache::Transaction(this, delegate,
408 infinite_cache_transaction));
409 return OK; 405 return OK;
410 } 406 }
411 407
412 HttpCache* HttpCache::GetCache() { 408 HttpCache* HttpCache::GetCache() {
413 return this; 409 return this;
414 } 410 }
415 411
416 HttpNetworkSession* HttpCache::GetSession() { 412 HttpNetworkSession* HttpCache::GetSession() {
417 net::HttpNetworkLayer* network = 413 net::HttpNetworkLayer* network =
418 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); 414 static_cast<net::HttpNetworkLayer*>(network_layer_.get());
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 building_backend_ = false; 1096 building_backend_ = false;
1101 DeletePendingOp(pending_op); 1097 DeletePendingOp(pending_op);
1102 } 1098 }
1103 1099
1104 // The cache may be gone when we return from the callback. 1100 // The cache may be gone when we return from the callback.
1105 if (!item->DoCallback(result, backend)) 1101 if (!item->DoCallback(result, backend))
1106 item->NotifyTransaction(result, NULL); 1102 item->NotifyTransaction(result, NULL);
1107 } 1103 }
1108 1104
1109 } // namespace net 1105 } // 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