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

Unified Diff: net/cookies/cookie_store_test_helpers.cc

Issue 1378273003: Decouple CookieMonsterTest from CookieStoreTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved (and renamed) URLHelper into own class/file Created 5 years, 2 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 | « net/cookies/cookie_store_test_helpers.h ('k') | net/cookies/cookie_store_unittest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_store_test_helpers.cc
diff --git a/net/cookies/cookie_store_test_helpers.cc b/net/cookies/cookie_store_test_helpers.cc
index 49f9d9ac83dba07a500bf60eba0b67d45cc94370..e75039c1484128ffbe24d2b008786bebee5aef42 100644
--- a/net/cookies/cookie_store_test_helpers.cc
+++ b/net/cookies/cookie_store_test_helpers.cc
@@ -7,7 +7,27 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/single_thread_task_runner.h"
+#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
+#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
+
+using net::registry_controlled_domains::GetDomainAndRegistry;
+using net::registry_controlled_domains::GetRegistryLength;
+using net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES;
+using net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES;
+
+namespace {
+
+std::string GetRegistry(const GURL& url) {
+ size_t registry_length = GetRegistryLength(url, INCLUDE_UNKNOWN_REGISTRIES,
+ INCLUDE_PRIVATE_REGISTRIES);
+ if (registry_length == 0)
+ return std::string();
+ return std::string(url.host(), url.host().length() - registry_length,
+ registry_length);
+}
+
+} // namespace
namespace net {
@@ -143,4 +163,25 @@ DelayedCookieMonster::AddCallbackForCookie(
return scoped_ptr<CookieStore::CookieChangedSubscription>();
}
+//
+// CookieURLHelper
+//
+CookieURLHelper::CookieURLHelper(const std::string& url_string)
+ : url_(url_string),
+ registry_(GetRegistry(url_)),
+ domain_and_registry_(
+ GetDomainAndRegistry(url_, INCLUDE_PRIVATE_REGISTRIES)) {}
+
+const GURL CookieURLHelper::AppendPath(const std::string& path) const {
+ return GURL(url_.spec() + path);
+}
+
+std::string CookieURLHelper::Format(const std::string& format_string) const {
+ std::string new_string = format_string;
+ base::ReplaceSubstringsAfterOffset(&new_string, 0, "%D",
+ domain_and_registry_);
+ base::ReplaceSubstringsAfterOffset(&new_string, 0, "%R", registry_);
+ return new_string;
+}
+
} // namespace net
« no previous file with comments | « net/cookies/cookie_store_test_helpers.h ('k') | net/cookies/cookie_store_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698