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

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

Issue 1008723006: Remove HTTP cache Record/Playback support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.cc » ('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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 DCHECK(pending_op->writer); 714 DCHECK(pending_op->writer);
715 pending_op->pending_queue.push_back(item); 715 pending_op->pending_queue.push_back(item);
716 return ERR_IO_PENDING; 716 return ERR_IO_PENDING;
717 } 717 }
718 718
719 // Generate a key that can be used inside the cache. 719 // Generate a key that can be used inside the cache.
720 std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { 720 std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) {
721 // Strip out the reference, username, and password sections of the URL. 721 // Strip out the reference, username, and password sections of the URL.
722 std::string url = HttpUtil::SpecForRequest(request->url); 722 std::string url = HttpUtil::SpecForRequest(request->url);
723 723
724 DCHECK(mode_ != DISABLE); 724 DCHECK_NE(DISABLE, mode_);
725 if (mode_ == NORMAL) { 725 // No valid URL can begin with numerals, so we should not have to worry
726 // No valid URL can begin with numerals, so we should not have to worry 726 // about collisions with normal URLs.
727 // about collisions with normal URLs. 727 if (request->upload_data_stream &&
728 if (request->upload_data_stream && 728 request->upload_data_stream->identifier()) {
729 request->upload_data_stream->identifier()) { 729 url.insert(0,
730 url.insert(0, base::StringPrintf( 730 base::StringPrintf("%" PRId64 "/",
731 "%" PRId64 "/", request->upload_data_stream->identifier())); 731 request->upload_data_stream->identifier()));
732 }
733 return url;
734 } 732 }
735 733 return url;
736 // In playback and record mode, we cache everything.
737
738 // Lazily initialize.
739 if (playback_cache_map_ == NULL)
740 playback_cache_map_.reset(new PlaybackCacheMap());
741
742 // Each time we request an item from the cache, we tag it with a
743 // generation number. During playback, multiple fetches for the same
744 // item will use the same generation number and pull the proper
745 // instance of an URL from the cache.
746 int generation = 0;
747 DCHECK(playback_cache_map_ != NULL);
748 if (playback_cache_map_->find(url) != playback_cache_map_->end())
749 generation = (*playback_cache_map_)[url];
750 (*playback_cache_map_)[url] = generation + 1;
751
752 // The key into the cache is GENERATION # + METHOD + URL.
753 std::string result = base::IntToString(generation);
754 result.append(request->method);
755 result.append(url);
756 return result;
757 } 734 }
758 735
759 void HttpCache::DoomActiveEntry(const std::string& key) { 736 void HttpCache::DoomActiveEntry(const std::string& key) {
760 ActiveEntriesMap::iterator it = active_entries_.find(key); 737 ActiveEntriesMap::iterator it = active_entries_.find(key);
761 if (it == active_entries_.end()) 738 if (it == active_entries_.end())
762 return; 739 return;
763 740
764 // This is not a performance critical operation, this is handling an error 741 // This is not a performance critical operation, this is handling an error
765 // condition so it is OK to look up the entry again. 742 // condition so it is OK to look up the entry again.
766 int rv = DoomEntry(key, NULL); 743 int rv = DoomEntry(key, NULL);
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 building_backend_ = false; 1395 building_backend_ = false;
1419 DeletePendingOp(pending_op); 1396 DeletePendingOp(pending_op);
1420 } 1397 }
1421 1398
1422 // The cache may be gone when we return from the callback. 1399 // The cache may be gone when we return from the callback.
1423 if (!item->DoCallback(result, disk_cache_.get())) 1400 if (!item->DoCallback(result, disk_cache_.get()))
1424 item->NotifyTransaction(result, NULL); 1401 item->NotifyTransaction(result, NULL);
1425 } 1402 }
1426 1403
1427 } // namespace net 1404 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698