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") || | |
darin (slow to review)
2012/08/11 06:18:36
weren't you going to modify this to stop recording
| |
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; |
105 DVLOG(4) << "contents hash: " << contents_hash; | 109 DVLOG(4) << "contents hash: " << contents_hash; |
106 DVLOG(4) << "hash with url: " << hashed_with_url; | 110 DVLOG(4) << "hash with url: " << hashed_with_url; |
107 | 111 |
108 std::set<MH_UINT32>* content_matches = | 112 std::set<MH_UINT32>* content_matches = |
109 GlobalDuplicateRecords::GetInstance()->content_matches(); | 113 GlobalDuplicateRecords::GetInstance()->content_matches(); |
110 std::set<MH_UINT32>* content_and_url_matches = | 114 std::set<MH_UINT32>* content_and_url_matches = |
111 GlobalDuplicateRecords::GetInstance()->content_and_url_matches(); | 115 GlobalDuplicateRecords::GetInstance()->content_and_url_matches(); |
112 | 116 |
113 const bool did_match_contents = content_matches->count(contents_hash) > 0; | 117 const bool did_match_contents = content_matches->count(contents_hash) > 0; |
114 const bool did_match_contents_and_url = | 118 const bool did_match_contents_and_url = |
115 content_and_url_matches->count(hashed_with_url) > 0; | 119 content_and_url_matches->count(hashed_with_url) > 0; |
116 | 120 |
117 UMA_HISTOGRAM_BOOLEAN("Duplicate.Hits", did_match_contents); | 121 UMA_HISTOGRAM_BOOLEAN("Duplicate.Hits", did_match_contents); |
118 UMA_HISTOGRAM_BOOLEAN("Duplicate.HitsSameUrl", | 122 UMA_HISTOGRAM_BOOLEAN("Duplicate.HitsSameUrl", |
119 did_match_contents && did_match_contents_and_url); | 123 did_match_contents && did_match_contents_and_url); |
124 UMA_HISTOGRAM_ENUMERATION("Duplicate.ResourceType.All", resource_type_, | |
darin (slow to review)
2012/08/11 06:18:36
this was part of the other CL, right?
| |
125 ResourceType::LAST_TYPE); | |
120 if (did_match_contents && !did_match_contents_and_url) { | 126 if (did_match_contents && !did_match_contents_and_url) { |
121 content_and_url_matches->insert(hashed_with_url); | 127 content_and_url_matches->insert(hashed_with_url); |
122 UMA_HISTOGRAM_CUSTOM_COUNTS("Duplicate.Size.HashHitUrlMiss", bytes_read_, | 128 UMA_HISTOGRAM_CUSTOM_COUNTS("Duplicate.Size.HashHitUrlMiss", bytes_read_, |
123 1, 0x7FFFFFFF, 50); | 129 1, 0x7FFFFFFF, 50); |
124 UMA_HISTOGRAM_ENUMERATION("Duplicate.ResourceType.HashHitUrlMiss", | 130 UMA_HISTOGRAM_ENUMERATION("Duplicate.ResourceType.HashHitUrlMiss", |
125 resource_type_, ResourceType::LAST_TYPE); | 131 resource_type_, ResourceType::LAST_TYPE); |
126 } | 132 } |
127 content_matches->insert(contents_hash); | 133 content_matches->insert(contents_hash); |
128 content_and_url_matches->insert(hashed_with_url); | 134 content_and_url_matches->insert(hashed_with_url); |
129 | 135 |
130 bytes_read_ = 0; | 136 bytes_read_ = 0; |
131 read_buffer_ = NULL; | 137 read_buffer_ = NULL; |
132 } | 138 } |
133 | 139 |
134 } // namespace content | 140 } // namespace content |
OLD | NEW |