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

Side by Side Diff: components/subresource_filter/core/common/document_subresource_filter.cc

Issue 2894523006: Add instrumentation hooks to mesaure which subresource filter rules are used.
Patch Set: Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
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/subresource_filter/core/common/document_subresource_filter. h" 5 #include "components/subresource_filter/core/common/document_subresource_filter. h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 proto::ACTIVATION_TYPE_GENERICBLOCK)) { 44 proto::ACTIVATION_TYPE_GENERICBLOCK)) {
45 activation_state.generic_blocking_rules_disabled = true; 45 activation_state.generic_blocking_rules_disabled = true;
46 } 46 }
47 return activation_state; 47 return activation_state;
48 } 48 }
49 49
50 DocumentSubresourceFilter::DocumentSubresourceFilter( 50 DocumentSubresourceFilter::DocumentSubresourceFilter(
51 url::Origin document_origin, 51 url::Origin document_origin,
52 ActivationState activation_state, 52 ActivationState activation_state,
53 scoped_refptr<const MemoryMappedRuleset> ruleset) 53 scoped_refptr<const MemoryMappedRuleset> ruleset)
54 : DocumentSubresourceFilter(document_origin,
55 activation_state,
56 ruleset,
57 nullptr) {}
58
59 DocumentSubresourceFilter::DocumentSubresourceFilter(
60 url::Origin document_origin,
61 ActivationState activation_state,
62 scoped_refptr<const MemoryMappedRuleset> ruleset,
63 std::unique_ptr<RuleRecorder> recorder)
54 : activation_state_(activation_state), 64 : activation_state_(activation_state),
55 ruleset_(std::move(ruleset)), 65 ruleset_(std::move(ruleset)),
56 ruleset_matcher_(ruleset_->data(), ruleset_->length()) { 66 ruleset_matcher_(ruleset_->data(),
67 ruleset_->length(),
68 std::move(recorder)) {
57 DCHECK_NE(activation_state_.activation_level, ActivationLevel::DISABLED); 69 DCHECK_NE(activation_state_.activation_level, ActivationLevel::DISABLED);
58 if (!activation_state_.filtering_disabled_for_document) 70 if (!activation_state_.filtering_disabled_for_document)
59 document_origin_.reset(new FirstPartyOrigin(std::move(document_origin))); 71 document_origin_.reset(new FirstPartyOrigin(std::move(document_origin)));
60 } 72 }
61 73
62 DocumentSubresourceFilter::~DocumentSubresourceFilter() = default; 74 DocumentSubresourceFilter::~DocumentSubresourceFilter() = default;
63 75
64 LoadPolicy DocumentSubresourceFilter::GetLoadPolicy( 76 LoadPolicy DocumentSubresourceFilter::GetLoadPolicy(
65 const GURL& subresource_url, 77 const GURL& subresource_url,
66 proto::ElementType subresource_type) { 78 proto::ElementType subresource_type) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ++statistics_.num_loads_disallowed; 111 ++statistics_.num_loads_disallowed;
100 return LoadPolicy::DISALLOW; 112 return LoadPolicy::DISALLOW;
101 } else if (activation_state_.activation_level == ActivationLevel::DRYRUN) { 113 } else if (activation_state_.activation_level == ActivationLevel::DRYRUN) {
102 return LoadPolicy::WOULD_DISALLOW; 114 return LoadPolicy::WOULD_DISALLOW;
103 } 115 }
104 } 116 }
105 return LoadPolicy::ALLOW; 117 return LoadPolicy::ALLOW;
106 } 118 }
107 119
108 } // namespace subresource_filter 120 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698