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

Unified Diff: services/url_response_disk_cache/url_response_disk_cache_impl.cc

Issue 1273773002: Do not use the state as a parameter of the key in the url response cache. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/url_response_disk_cache/url_response_disk_cache_impl.cc
diff --git a/services/url_response_disk_cache/url_response_disk_cache_impl.cc b/services/url_response_disk_cache/url_response_disk_cache_impl.cc
index 70a450a5f987f9147c4faa511c4b3798081fc17b..0ef56ca300d9d9911e31dbdd6dfb50da28d0e3ea 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_impl.cc
+++ b/services/url_response_disk_cache/url_response_disk_cache_impl.cc
@@ -68,6 +68,21 @@ Array<uint8_t> PathToArray(const base::FilePath& path) {
return result.Pass();
}
+std::string CanonicalizeURL(const std::string& url) {
ppi 2015/08/05 13:59:19 please add a comment stating that we are matching
qsr 2015/08/05 14:07:57 Done.
+ GURL gurl(url);
+
+ if (!gurl.has_query()) {
+ return gurl.spec();
+ }
+
+ GURL::Replacements repl;
+ repl.SetQueryStr("");
+ std::string result = gurl.ReplaceComponents(repl).spec();
+ // Remove the dangling '?' because it's ugly.
+ base::ReplaceChars(result, "?", "", &result);
+ return result;
+}
+
// Encode a string in ascii. This uses _ as an escape character. It also escapes
// ':' because it is an usual path separator, and '#' because dart refuses it in
// URLs.
@@ -95,7 +110,7 @@ base::FilePath GetDirName(base::FilePath base_directory,
const std::string& url) {
// TODO(qsr): If the speed of directory traversal is problematic, this might
// need to change to use less directories.
- return base_directory.Append(EncodeString(url));
+ return base_directory.Append(EncodeString(CanonicalizeURL(url)));
}
// Returns the directory that the consumer can use to cache its own data.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698