Move kVlog constants to util file (net/)

When building using jumbo unnamed namespaces gets merged
and variables with the same name conflict. This happens
for the variable kVlogSetCookies in
net/cookies/canonical_cookie.cc and
net/cookies/cookie_monster.cc.

This commit solves the issue by moving the variable
definition to net/cookies/cookie_util.h. Other
kVlog variables defined in net/cookies/cookie_monster.cc
are also moved.

Bug: 772146
Change-Id: I850c27406f687dfffcf682b0957a41ecbeaca291
Reviewed-on: https://chromium-review.googlesource.com/1118382
Reviewed-by: Maks Orlovich <morlovich@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#571842}
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc
index ffd247ea..d3442c5 100644
--- a/net/cookies/canonical_cookie.cc
+++ b/net/cookies/canonical_cookie.cc
@@ -63,8 +63,6 @@
 
 namespace {
 
-const int kVlogSetCookies = 7;
-
 // Determine the cookie domain to use for setting the specified cookie.
 bool GetCookieDomain(const GURL& url,
                      const ParsedCookie& pc,
@@ -195,18 +193,20 @@
   ParsedCookie parsed_cookie(cookie_line);
 
   if (!parsed_cookie.IsValid()) {
-    VLOG(kVlogSetCookies) << "WARNING: Couldn't parse cookie";
+    VLOG(net::cookie_util::kVlogSetCookies) << "WARNING: Couldn't parse cookie";
     return nullptr;
   }
 
   if (options.exclude_httponly() && parsed_cookie.IsHttpOnly()) {
-    VLOG(kVlogSetCookies) << "Create() is not creating a httponly cookie";
+    VLOG(net::cookie_util::kVlogSetCookies)
+        << "Create() is not creating a httponly cookie";
     return nullptr;
   }
 
   std::string cookie_domain;
   if (!GetCookieDomain(url, parsed_cookie, &cookie_domain)) {
-    VLOG(kVlogSetCookies) << "Create() failed to get a cookie domain";
+    VLOG(net::cookie_util::kVlogSetCookies)
+        << "Create() failed to get a cookie domain";
     return nullptr;
   }
 
@@ -215,7 +215,7 @@
   // URL does not have a secure scheme, the cookie should be thrown away.
   // https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone
   if (parsed_cookie.IsSecure() && !url.SchemeIsCryptographic()) {
-    VLOG(kVlogSetCookies)
+    VLOG(net::cookie_util::kVlogSetCookies)
         << "Create() is trying to create a secure cookie from an insecure URL";
     return nullptr;
   }
@@ -236,7 +236,7 @@
   bool is_cookie_valid = IsCookiePrefixValid(prefix, url, parsed_cookie);
   RecordCookiePrefixMetrics(prefix, is_cookie_valid);
   if (!is_cookie_valid) {
-    VLOG(kVlogSetCookies)
+    VLOG(net::cookie_util::kVlogSetCookies)
         << "Create() failed because the cookie violated prefix rules.";
     return nullptr;
   }
diff --git a/net/cookies/cookie_monster.cc b/net/cookies/cookie_monster.cc
index 8218ee3..3f70956 100644
--- a/net/cookies/cookie_monster.cc
+++ b/net/cookies/cookie_monster.cc
@@ -188,10 +188,6 @@
   }
 };
 
-// Constants for use in VLOG
-const int kVlogPerCookieMonster = 1;
-const int kVlogGarbageCollection = 5;
-const int kVlogSetCookies = 7;
 // Mozilla sorts on the path length (longest first), and then it
 // sorts by creation time (oldest first).
 // The RFC says the sort order for the domain attribute is undefined.
@@ -725,7 +721,8 @@
     return;
   }
 
-  VLOG(kVlogSetCookies) << "SetCookie() line: " << cookie_line;
+  VLOG(net::cookie_util::kVlogSetCookies)
+      << "SetCookie() line: " << cookie_line;
 
   Time creation_time = CurrentTime();
   last_time_seen_ = creation_time;
@@ -734,7 +731,8 @@
       CanonicalCookie::Create(url, cookie_line, creation_time, options));
 
   if (!cc.get()) {
-    VLOG(kVlogSetCookies) << "WARNING: Failed to allocate CanonicalCookie";
+    VLOG(net::cookie_util::kVlogSetCookies)
+        << "WARNING: Failed to allocate CanonicalCookie";
     MaybeRunCookieCallback(std::move(callback), false);
     return;
   }
@@ -1242,13 +1240,13 @@
         "SetCookie() not clobbering httponly cookie or secure cookie for "
         "insecure scheme";
 
-    VLOG(kVlogSetCookies) << error;
+    VLOG(net::cookie_util::kVlogSetCookies) << error;
     MaybeRunCookieCallback(std::move(callback), false);
     return;
   }
 
-  VLOG(kVlogSetCookies) << "SetCookie() key: " << key
-                        << " cc: " << cc->DebugString();
+  VLOG(net::cookie_util::kVlogSetCookies)
+      << "SetCookie() key: " << key << " cc: " << cc->DebugString();
 
   // Realize that we might be setting an expired cookie, and the only point
   // was to delete the cookie which we've already done.
@@ -1283,7 +1281,8 @@
 
     InternalInsertCookie(key, std::move(cc), true);
   } else {
-    VLOG(kVlogSetCookies) << "SetCookie() not storing already expired cookie.";
+    VLOG(net::cookie_util::kVlogSetCookies)
+        << "SetCookie() not storing already expired cookie.";
   }
 
   // We assume that hopefully setting a cookie will be less common than
@@ -1359,9 +1358,9 @@
                 "kChangeCauseMapping size should match DeletionCause size");
 
   CanonicalCookie* cc = it->second.get();
-  VLOG(kVlogSetCookies) << "InternalDeleteCookie()"
-                        << ", cause:" << deletion_cause
-                        << ", cc: " << cc->DebugString();
+  VLOG(net::cookie_util::kVlogSetCookies)
+      << "InternalDeleteCookie()"
+      << ", cause:" << deletion_cause << ", cc: " << cc->DebugString();
 
   if ((cc->IsPersistent() || persist_session_cookies_) && store_.get() &&
       sync_to_store)
@@ -1382,7 +1381,8 @@
 
   // Collect garbage for this key, minding cookie priorities.
   if (cookies_.count(key) > kDomainMaxCookies) {
-    VLOG(kVlogGarbageCollection) << "GarbageCollect() key: " << key;
+    VLOG(net::cookie_util::kVlogGarbageCollection)
+        << "GarbageCollect() key: " << key;
 
     CookieItVector* cookie_its;
 
@@ -1392,7 +1392,8 @@
         GarbageCollectExpired(current, cookies_.equal_range(key), cookie_its);
 
     if (cookie_its->size() > kDomainMaxCookies) {
-      VLOG(kVlogGarbageCollection) << "Deep Garbage Collect domain.";
+      VLOG(net::cookie_util::kVlogGarbageCollection)
+          << "Deep Garbage Collect domain.";
       size_t purge_goal =
           cookie_its->size() - (kDomainMaxCookies - kDomainPurgeCookies);
       DCHECK(purge_goal > kDomainPurgeCookies);
@@ -1470,7 +1471,8 @@
   // Collect garbage for everything. With firefox style we want to preserve
   // cookies accessed in kSafeFromGlobalPurgeDays, otherwise evict.
   if (cookies_.size() > kMaxCookies && earliest_access_time_ < safe_date) {
-    VLOG(kVlogGarbageCollection) << "GarbageCollect() everything";
+    VLOG(net::cookie_util::kVlogGarbageCollection)
+        << "GarbageCollect() everything";
     CookieItVector cookie_its;
 
     num_deleted += GarbageCollectExpired(
@@ -1478,7 +1480,8 @@
         &cookie_its);
 
     if (cookie_its.size() > kMaxCookies) {
-      VLOG(kVlogGarbageCollection) << "Deep Garbage Collect everything.";
+      VLOG(net::cookie_util::kVlogGarbageCollection)
+          << "Deep Garbage Collect everything.";
       size_t purge_goal = cookie_its.size() - (kMaxCookies - kPurgeCookies);
       DCHECK(purge_goal > kPurgeCookies);
 
@@ -1694,7 +1697,7 @@
   }
 
   // The scheme didn't match any in our whitelist.
-  VLOG(kVlogPerCookieMonster)
+  VLOG(net::cookie_util::kVlogPerCookieMonster)
       << "WARNING: Unsupported cookie scheme: " << url.scheme();
   return false;
 }
diff --git a/net/cookies/cookie_util.h b/net/cookies/cookie_util.h
index 18a3bfb..669457b 100644
--- a/net/cookies/cookie_util.h
+++ b/net/cookies/cookie_util.h
@@ -18,6 +18,11 @@
 namespace net {
 namespace cookie_util {
 
+// Constants for use in VLOG
+const int kVlogPerCookieMonster = 1;
+const int kVlogSetCookies = 7;
+const int kVlogGarbageCollection = 5;
+
 // Returns the effective TLD+1 for a given host. This only makes sense for http
 // and https schemes. For other schemes, the host will be returned unchanged
 // (minus any leading period).