Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc

Issue 2569693002: Introduce performance measurement varitation parameter for SubresourceFilter. (Closed)
Patch Set: Change include. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc
index e7b47a523771fc1aa624353330e4402bf89600ce..6ffd88d8da3afbbcfef66cd95b2f02d58e9fcadc 100644
--- a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc
+++ b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc
@@ -5,6 +5,7 @@
#include "components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h"
#include "base/metrics/histogram_macros.h"
+#include "base/rand_util.h"
#include "components/subresource_filter/content/browser/content_subresource_filter_driver.h"
#include "components/subresource_filter/content/common/subresource_filter_messages.h"
#include "components/subresource_filter/core/browser/subresource_filter_client.h"
@@ -24,6 +25,10 @@ std::string DistillURLToHostAndPath(const GURL& url) {
return url.host() + url.path();
}
+bool ShouldMeasurePerformance(double rate) {
+ return base::RandDouble() < rate;
+}
+
} // namespace
// static
@@ -54,7 +59,8 @@ ContentSubresourceFilterDriverFactory::ContentSubresourceFilterDriverFactory(
std::unique_ptr<SubresourceFilterClient> client)
: content::WebContentsObserver(web_contents),
client_(std::move(client)),
- activation_state_(ActivationState::DISABLED) {
+ activation_state_(ActivationState::DISABLED),
+ measure_performance_(false) {
content::RenderFrameHost* main_frame_host = web_contents->GetMainFrame();
if (main_frame_host && main_frame_host->IsRenderFrameLive())
CreateDriverForFrameHostIfNeeded(main_frame_host);
@@ -122,14 +128,10 @@ void ContentSubresourceFilterDriverFactory::ActivateForFrameHostIfNeeded(
content::RenderFrameHost* render_frame_host,
const GURL& url) {
if (activation_state_ != ActivationState::DISABLED) {
- // TODO(pkalinnikov): Introduce a variation parameter controlling how often
- // the |measure_performance| bit is set. crbug/672519
- constexpr bool measure_performance = true;
-
auto* driver = DriverFromFrameHost(render_frame_host);
DCHECK(driver);
driver->ActivateForProvisionalLoad(GetMaximumActivationState(), url,
- measure_performance);
+ measure_performance_);
}
}
@@ -209,6 +211,8 @@ void ContentSubresourceFilterDriverFactory::ReadyToCommitNavigationInternal(
RecordRedirectChainMatchPattern();
if (ShouldActivateForMainFrameURL(url)) {
activation_state_ = GetMaximumActivationState();
+ measure_performance_ =
+ ShouldMeasurePerformance(GetCurrentPerfMeasurementRate());
ActivateForFrameHostIfNeeded(render_frame_host, url);
} else {
activation_state_ = ActivationState::DISABLED;
engedy 2016/12/12 15:32:36 Same here, reset |measure_performance_|.
pkalinnikov 2016/12/12 18:47:29 Done.

Powered by Google App Engine
This is Rietveld 408576698