Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/data_use_measurement/content/content_url_request_classifier .h" | 5 #include "components/data_use_measurement/content/content_url_request_classifier .h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | |
| 8 #include "base/metrics/sparse_histogram.h" | |
| 7 #include "content/public/browser/resource_request_info.h" | 9 #include "content/public/browser/resource_request_info.h" |
| 8 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
| 11 #include "ui/base/page_transition_types.h" | |
| 9 | 12 |
| 10 namespace data_use_measurement { | 13 namespace data_use_measurement { |
| 11 | 14 |
| 12 bool IsUserRequest(const net::URLRequest& request) { | 15 bool IsUserRequest(const net::URLRequest& request) { |
| 13 // The presence of ResourecRequestInfo in |request| implies that this request | 16 // The presence of ResourecRequestInfo in |request| implies that this request |
| 14 // was created for a content::WebContents. For now we could add a condition to | 17 // was created for a content::WebContents. For now we could add a condition to |
| 15 // check ProcessType in info is content::PROCESS_TYPE_RENDERER, but it won't | 18 // check ProcessType in info is content::PROCESS_TYPE_RENDERER, but it won't |
| 16 // be compatible with upcoming PlzNavigate architecture. So just existence of | 19 // be compatible with upcoming PlzNavigate architecture. So just existence of |
| 17 // ResourceRequestInfo is verified, and the current check should be compatible | 20 // ResourceRequestInfo is verified, and the current check should be compatible |
| 18 // with upcoming changes in PlzNavigate. | 21 // with upcoming changes in PlzNavigate. |
| 19 // TODO(rajendrant): Verify this condition for different use cases. See | 22 // TODO(rajendrant): Verify this condition for different use cases. See |
| 20 // crbug.com/626063. | 23 // crbug.com/626063. |
| 21 return content::ResourceRequestInfo::ForRequest(&request) != nullptr; | 24 return content::ResourceRequestInfo::ForRequest(&request) != nullptr; |
| 22 } | 25 } |
| 23 | 26 |
| 24 bool ContentURLRequestClassifier::IsUserRequest( | 27 bool ContentURLRequestClassifier::IsUserRequest( |
| 25 const net::URLRequest& request) const { | 28 const net::URLRequest& request) const { |
| 26 return data_use_measurement::IsUserRequest(request); | 29 return data_use_measurement::IsUserRequest(request); |
| 27 } | 30 } |
| 28 | 31 |
| 32 void ContentURLRequestClassifier::RecordPageTransitionUMA( | |
| 33 int32_t page_transition, | |
| 34 int64_t received_bytes) const { | |
| 35 ui::PageTransition core_page_transition = ui::PageTransitionStripQualifier( | |
|
RyanSturm
2017/01/10 18:32:23
Like I mentioned before, this shouldn't be necessa
Raj
2017/01/10 22:21:57
Done.
| |
| 36 static_cast<ui::PageTransition>(page_transition)); | |
| 37 if (core_page_transition > ui::PAGE_TRANSITION_LAST_CORE) | |
| 38 return; | |
| 39 if (received_bytes <= 0) | |
| 40 return; | |
| 41 | |
| 42 // Use the more primitive STATIC_HISTOGRAM_POINTER_BLOCK macro because the | |
| 43 // simple UMA_HISTOGRAM_ENUMERATION macros don't expose 'AddCount'. | |
| 44 STATIC_HISTOGRAM_POINTER_BLOCK( | |
| 45 "DataUse.PageTransition.UserTraffic", | |
|
RyanSturm
2017/01/10 18:32:23
Do you need to address the issue mpearson raised o
Raj
2017/01/10 22:21:57
Its not clear whether the overflow bug should be f
| |
| 46 AddCount(core_page_transition, received_bytes), | |
| 47 base::LinearHistogram::FactoryGet( | |
| 48 "DataUse.PageTransition.UserTraffic", 1, | |
| 49 ui::PAGE_TRANSITION_LAST_CORE, ui::PAGE_TRANSITION_LAST_CORE + 1, | |
| 50 base::HistogramBase::kUmaTargetedHistogramFlag)); | |
| 51 } | |
| 52 | |
| 29 } // namespace data_use_measurement | 53 } // namespace data_use_measurement |
| OLD | NEW |