| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prerender/prerender_util.h" | 5 #include "chrome/browser/prerender/prerender_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 bool IsGoogleSearchResultURL(const GURL& url) { | 73 bool IsGoogleSearchResultURL(const GURL& url) { |
| 74 if (!IsGoogleDomain(url)) | 74 if (!IsGoogleDomain(url)) |
| 75 return false; | 75 return false; |
| 76 return (url.path().empty() || | 76 return (url.path().empty() || |
| 77 StartsWithASCII(url.path(), std::string("/search"), true) || | 77 StartsWithASCII(url.path(), std::string("/search"), true) || |
| 78 (url.path() == "/") || | 78 (url.path() == "/") || |
| 79 StartsWithASCII(url.path(), std::string("/webhp"), true)); | 79 StartsWithASCII(url.path(), std::string("/webhp"), true)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool IsWebURL(const GURL& url) { | |
| 83 return url.SchemeIs("http") || url.SchemeIs("https"); | |
| 84 } | |
| 85 | |
| 86 bool IsNoSwapInExperiment(uint8 experiment_id) { | 82 bool IsNoSwapInExperiment(uint8 experiment_id) { |
| 87 // Currently, experiments 5 and 6 fall in this category. | 83 // Currently, experiments 5 and 6 fall in this category. |
| 88 return experiment_id == 5 || experiment_id == 6; | 84 return experiment_id == 5 || experiment_id == 6; |
| 89 } | 85 } |
| 90 | 86 |
| 91 bool IsControlGroupExperiment(uint8 experiment_id) { | 87 bool IsControlGroupExperiment(uint8 experiment_id) { |
| 92 // Currently, experiments 7 and 8 fall in this category. | 88 // Currently, experiments 7 and 8 fall in this category. |
| 93 return experiment_id == 7 || experiment_id == 8; | 89 return experiment_id == 7 || experiment_id == 8; |
| 94 } | 90 } |
| 95 | 91 |
| 96 void URLRequestResponseStarted(net::URLRequest* request) { | 92 void URLRequestResponseStarted(net::URLRequest* request) { |
| 97 static const char* kModPagespeedHeader = "X-Mod-Pagespeed"; | 93 static const char* kModPagespeedHeader = "X-Mod-Pagespeed"; |
| 98 static const char* kModPagespeedHistogram = "Prerender.ModPagespeedHeader"; | 94 static const char* kModPagespeedHistogram = "Prerender.ModPagespeedHeader"; |
| 99 const content::ResourceRequestInfo* info = | 95 const content::ResourceRequestInfo* info = |
| 100 content::ResourceRequestInfo::ForRequest(request); | 96 content::ResourceRequestInfo::ForRequest(request); |
| 101 // Gather histogram information about the X-Mod-Pagespeed header. | 97 // Gather histogram information about the X-Mod-Pagespeed header. |
| 102 if (info->GetResourceType() == ResourceType::MAIN_FRAME && | 98 if (info->GetResourceType() == ResourceType::MAIN_FRAME && |
| 103 IsWebURL(request->url())) { | 99 request->url().SchemeIsHTTPOrHTTPS()) { |
| 104 UMA_HISTOGRAM_SPARSE_SLOWLY(kModPagespeedHistogram, 0); | 100 UMA_HISTOGRAM_SPARSE_SLOWLY(kModPagespeedHistogram, 0); |
| 105 if (request->response_headers() && | 101 if (request->response_headers() && |
| 106 request->response_headers()->HasHeader(kModPagespeedHeader)) { | 102 request->response_headers()->HasHeader(kModPagespeedHeader)) { |
| 107 UMA_HISTOGRAM_SPARSE_SLOWLY(kModPagespeedHistogram, 1); | 103 UMA_HISTOGRAM_SPARSE_SLOWLY(kModPagespeedHistogram, 1); |
| 108 | 104 |
| 109 // Attempt to parse the version number, and encode it in buckets | 105 // Attempt to parse the version number, and encode it in buckets |
| 110 // 2 through 99. 0 and 1 are used to store all pageviews and | 106 // 2 through 99. 0 and 1 are used to store all pageviews and |
| 111 // # pageviews with the MPS header (see above). | 107 // # pageviews with the MPS header (see above). |
| 112 void* iter = NULL; | 108 void* iter = NULL; |
| 113 std::string mps_version; | 109 std::string mps_version; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 127 if (output < 2 || output >= 99) | 123 if (output < 2 || output >= 99) |
| 128 output = 99; | 124 output = 99; |
| 129 UMA_HISTOGRAM_SPARSE_SLOWLY(kModPagespeedHistogram, output); | 125 UMA_HISTOGRAM_SPARSE_SLOWLY(kModPagespeedHistogram, output); |
| 130 } | 126 } |
| 131 } | 127 } |
| 132 } | 128 } |
| 133 } | 129 } |
| 134 } | 130 } |
| 135 | 131 |
| 136 } // namespace prerender | 132 } // namespace prerender |
| OLD | NEW |