OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/duplicate_content_resource_handler.h" | 5 #include "content/browser/renderer_host/duplicate_content_resource_handler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (status.is_success()) | 85 if (status.is_success()) |
86 RecordContentMetrics(); | 86 RecordContentMetrics(); |
87 | 87 |
88 return next_handler_->OnResponseCompleted(request_id, status, security_info); | 88 return next_handler_->OnResponseCompleted(request_id, status, security_info); |
89 } | 89 } |
90 | 90 |
91 void DuplicateContentResourceHandler::RecordContentMetrics() { | 91 void DuplicateContentResourceHandler::RecordContentMetrics() { |
92 MH_UINT32 contents_hash = PMurHash32_Result(pmurhash_ph1_, | 92 MH_UINT32 contents_hash = PMurHash32_Result(pmurhash_ph1_, |
93 pmurhash_pcarry_, bytes_read_); | 93 pmurhash_pcarry_, bytes_read_); |
94 | 94 |
| 95 bool is_http_or_https = request_->url().SchemeIs("http") || |
| 96 request_->url().SchemeIs("https"); |
| 97 UMA_HISTOGRAM_BOOLEAN("Duplicate.IsHttpOrHttps", is_http_or_https); |
| 98 |
95 // Combine the contents_hash with the url, so we can test if future content | 99 // Combine the contents_hash with the url, so we can test if future content |
96 // identical resources have the same original url or not. | 100 // identical resources have the same original url or not. |
97 MH_UINT32 hashed_with_url; | 101 MH_UINT32 hashed_with_url; |
98 const std::string& url_spec = request_->url().spec(); | 102 const std::string& url_spec = request_->url().spec(); |
99 PMurHash32_Process(&pmurhash_ph1_, &pmurhash_pcarry_, | 103 PMurHash32_Process(&pmurhash_ph1_, &pmurhash_pcarry_, |
100 url_spec.data(), url_spec.length()); | 104 url_spec.data(), url_spec.length()); |
101 hashed_with_url = PMurHash32_Result(pmurhash_ph1_, pmurhash_pcarry_, | 105 hashed_with_url = PMurHash32_Result(pmurhash_ph1_, pmurhash_pcarry_, |
102 url_spec.length() + bytes_read_); | 106 url_spec.length() + bytes_read_); |
103 | 107 |
104 DVLOG(4) << "url: " << url_spec; | 108 DVLOG(4) << "url: " << url_spec; |
(...skipping 22 matching lines...) Expand all Loading... |
127 resource_type_, ResourceType::LAST_TYPE); | 131 resource_type_, ResourceType::LAST_TYPE); |
128 } | 132 } |
129 content_matches->insert(contents_hash); | 133 content_matches->insert(contents_hash); |
130 content_and_url_matches->insert(hashed_with_url); | 134 content_and_url_matches->insert(hashed_with_url); |
131 | 135 |
132 bytes_read_ = 0; | 136 bytes_read_ = 0; |
133 read_buffer_ = NULL; | 137 read_buffer_ = NULL; |
134 } | 138 } |
135 | 139 |
136 } // namespace content | 140 } // namespace content |
OLD | NEW |