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

Side by Side Diff: components/subresource_filter/content/common/document_subresource_filter.h

Issue 2683413003: Introduce AsyncDocumentSubresourceFilter. (Closed)
Patch Set: Fix fix blink test build. Created 3 years, 10 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 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_COMMON_DOCUMENT_SUBRESOURCE_FILTER _H_ 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_COMMON_DOCUMENT_SUBRESOURCE_FILTER _H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_COMMON_DOCUMENT_SUBRESOURCE_FILTER _H_ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_COMMON_DOCUMENT_SUBRESOURCE_FILTER _H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "components/subresource_filter/content/common/document_load_statistics. h" 18 #include "components/subresource_filter/content/common/document_load_statistics. h"
19 #include "components/subresource_filter/core/common/activation_level.h" 19 #include "components/subresource_filter/core/common/activation_level.h"
20 #include "components/subresource_filter/core/common/activation_state.h" 20 #include "components/subresource_filter/core/common/activation_state.h"
21 #include "components/subresource_filter/core/common/indexed_ruleset.h" 21 #include "components/subresource_filter/core/common/indexed_ruleset.h"
22 #include "components/subresource_filter/core/common/proto/rules.pb.h" 22 #include "components/subresource_filter/core/common/proto/rules.pb.h"
23 #include "third_party/WebKit/public/platform/WebDocumentSubresourceFilter.h" 23 #include "third_party/WebKit/public/platform/WebDocumentSubresourceFilter.h"
24 #include "third_party/WebKit/public/platform/WebDocumentSubresourceFilterLoadPol icy.h"
jochen (gone - plz use gerrit) 2017/02/16 14:46:21 please change subresource_filter/content/common/DE
pkalinnikov 2017/02/17 17:51:38 Now common/ doesn't depend on blink.
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 #include "url/origin.h" 26 #include "url/origin.h"
26 27
27 namespace subresource_filter { 28 namespace subresource_filter {
28 29
29 class FirstPartyOrigin; 30 class FirstPartyOrigin;
30 class MemoryMappedRuleset; 31 class MemoryMappedRuleset;
31 32
32 // Computes whether/how subresource filtering should be activated while loading 33 // Computes whether/how subresource filtering should be activated while loading
33 // |document_url| in a frame, based on the parent document's |activation_state|, 34 // |document_url| in a frame, based on the parent document's |activation_state|,
(...skipping 16 matching lines...) Expand all
50 ActivationLevel activation_level, 51 ActivationLevel activation_level,
51 bool measure_performance, 52 bool measure_performance,
52 const std::vector<GURL>& ancestor_document_urls, 53 const std::vector<GURL>& ancestor_document_urls,
53 const MemoryMappedRuleset* ruleset); 54 const MemoryMappedRuleset* ruleset);
54 55
55 // Performs filtering of subresource loads in the scope of a given document. 56 // Performs filtering of subresource loads in the scope of a given document.
56 class DocumentSubresourceFilter 57 class DocumentSubresourceFilter
57 : public blink::WebDocumentSubresourceFilter, 58 : public blink::WebDocumentSubresourceFilter,
58 public base::SupportsWeakPtr<DocumentSubresourceFilter> { 59 public base::SupportsWeakPtr<DocumentSubresourceFilter> {
59 public: 60 public:
61 using LoadPolicy = blink::WebDocumentSubresourceFilterLoadPolicy;
62
60 // Constructs a new filter that will: 63 // Constructs a new filter that will:
61 // -- Operate in a manner prescribed in |activation_state|. 64 // -- Operate in a manner prescribed in |activation_state|.
62 // -- Filter subresource loads in the scope of a document loaded from 65 // -- Filter subresource loads in the scope of a document loaded from
63 // |document_origin|. 66 // |document_origin|.
64 // -- Hold a reference to and use |ruleset| for its entire lifetime. 67 // -- Hold a reference to and use |ruleset| for its entire lifetime.
65 // -- Invoke |first_disallowed_load_callback|, if it is non-null, on the 68 // -- Invoke |first_disallowed_load_callback|, if it is non-null, on the
66 // first disallowed subresource load. 69 // first reportDisallowedLoad() call.
67 DocumentSubresourceFilter(url::Origin document_origin, 70 DocumentSubresourceFilter(url::Origin document_origin,
68 ActivationState activation_state, 71 ActivationState activation_state,
69 scoped_refptr<const MemoryMappedRuleset> ruleset, 72 scoped_refptr<const MemoryMappedRuleset> ruleset,
70 base::OnceClosure first_disallowed_load_callback); 73 base::OnceClosure first_disallowed_load_callback);
71 74
72 ~DocumentSubresourceFilter() override; 75 ~DocumentSubresourceFilter() override;
73 76
74 const DocumentLoadStatistics& statistics() const { return statistics_; } 77 const DocumentLoadStatistics& statistics() const { return statistics_; }
75 78
76 // blink::WebDocumentSubresourceFilter: 79 // blink::WebDocumentSubresourceFilter:
(...skipping 16 matching lines...) Expand all
93 96
94 base::OnceClosure first_disallowed_load_callback_; 97 base::OnceClosure first_disallowed_load_callback_;
95 DocumentLoadStatistics statistics_; 98 DocumentLoadStatistics statistics_;
96 99
97 DISALLOW_COPY_AND_ASSIGN(DocumentSubresourceFilter); 100 DISALLOW_COPY_AND_ASSIGN(DocumentSubresourceFilter);
98 }; 101 };
99 102
100 } // namespace subresource_filter 103 } // namespace subresource_filter
101 104
102 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_COMMON_DOCUMENT_SUBRESOURCE_FIL TER_H_ 105 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_COMMON_DOCUMENT_SUBRESOURCE_FIL TER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698