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

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: Follow review 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..1642f4a5efe320c27463e901aaf082aa5e89c246 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,24 @@ Array<uint8_t> PathToArray(const base::FilePath& path) {
return result.Pass();
}
+// This method remove the query string of an url if one is present. It does
+// match the behavior of the application manager, which connects to the same app
+// if requested twice with different query parameters.
+std::string CanonicalizeURL(const std::string& url) {
+ 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 +113,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