Add more stats about the use of cookies in prerenders.
For prerender cookie stats, also record whether cookie requests were for
third party cookies, and whether those were for blocking resources.
BUG=353678
[email protected], [email protected], [email protected]

Review URL: https://codereview.chromium.org/203783002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257969 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index d25f629b2..2e9d3e7 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -657,6 +657,19 @@
 
   int render_process_id = -1;
   int render_frame_id = -1;
+
+  // |is_for_blocking_resource| indicates whether the cookies read were for a
+  // blocking resource (eg script, css). It is only temporarily added for
+  // diagnostic purposes, per bug 353678. Will be removed again once data
+  // collection is finished.
+  bool is_for_blocking_resource = false;
+  const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(&request);
+  if (info && ((!info->IsAsync()) ||
+               info->GetResourceType() == ResourceType::STYLESHEET ||
+               info->GetResourceType() == ResourceType::SCRIPT)) {
+    is_for_blocking_resource = true;
+  }
+
   if (content::ResourceRequestInfo::GetRenderFrameForRequest(
           &request, &render_process_id, &render_frame_id)) {
     BrowserThread::PostTask(
@@ -664,7 +677,7 @@
         base::Bind(&TabSpecificContentSettings::CookiesRead,
                    render_process_id, render_frame_id,
                    request.url(), request.first_party_for_cookies(),
-                   cookie_list, !allow));
+                   cookie_list, !allow, is_for_blocking_resource));
   }
 
   return allow;