| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE
_FILTER_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE
_FILTER_H_ |
| 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE
_FILTER_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ASYNC_DOCUMENT_SUBRESOURCE
_FILTER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // thread via |result_callback|. If MemoryMappedRuleset is not present or | 97 // thread via |result_callback|. If MemoryMappedRuleset is not present or |
| 98 // malformed, then a LoadPolicy::Allow is returned. | 98 // malformed, then a LoadPolicy::Allow is returned. |
| 99 void GetLoadPolicyForSubdocument(const GURL& subdocument_url, | 99 void GetLoadPolicyForSubdocument(const GURL& subdocument_url, |
| 100 LoadPolicyCallback result_callback); | 100 LoadPolicyCallback result_callback); |
| 101 | 101 |
| 102 // Invokes |first_disallowed_load_callback|, if necessary, and posts a task to | 102 // Invokes |first_disallowed_load_callback|, if necessary, and posts a task to |
| 103 // call DocumentSubresourceFilter::reportDisallowedCallback() on the | 103 // call DocumentSubresourceFilter::reportDisallowedCallback() on the |
| 104 // |task_runner|. | 104 // |task_runner|. |
| 105 void ReportDisallowedLoad(); | 105 void ReportDisallowedLoad(); |
| 106 | 106 |
| 107 // Must be called after activation state computation is finished. |
| 108 const ActivationState& activation_state() const { |
| 109 return activation_state_.value(); |
| 110 } |
| 111 |
| 107 private: | 112 private: |
| 113 void OnActivateStateCalculated( |
| 114 base::Callback<void(ActivationState)> activation_state_callback, |
| 115 ActivationState activation_state); |
| 116 |
| 108 // Note: Raw pointer, |core_| already holds a reference to |task_runner_|. | 117 // Note: Raw pointer, |core_| already holds a reference to |task_runner_|. |
| 109 base::SequencedTaskRunner* task_runner_; | 118 base::SequencedTaskRunner* task_runner_; |
| 110 std::unique_ptr<Core, base::OnTaskRunnerDeleter> core_; | 119 std::unique_ptr<Core, base::OnTaskRunnerDeleter> core_; |
| 111 base::OnceClosure first_disallowed_load_callback_; | 120 base::OnceClosure first_disallowed_load_callback_; |
| 112 | 121 |
| 122 base::Optional<ActivationState> activation_state_; |
| 123 |
| 113 base::ThreadChecker thread_checker_; | 124 base::ThreadChecker thread_checker_; |
| 114 | 125 |
| 126 base::WeakPtrFactory<AsyncDocumentSubresourceFilter> weak_ptr_factory_; |
| 127 |
| 115 DISALLOW_COPY_AND_ASSIGN(AsyncDocumentSubresourceFilter); | 128 DISALLOW_COPY_AND_ASSIGN(AsyncDocumentSubresourceFilter); |
| 116 }; | 129 }; |
| 117 | 130 |
| 118 // Holds a DocumentSubresourceFilter that is created in a deferred manner in | 131 // Holds a DocumentSubresourceFilter that is created in a deferred manner in |
| 119 // Initialize(), provided there is a valid ruleset to work with. | 132 // Initialize(), provided there is a valid ruleset to work with. |
| 120 class AsyncDocumentSubresourceFilter::Core { | 133 class AsyncDocumentSubresourceFilter::Core { |
| 121 public: | 134 public: |
| 122 Core(); | 135 Core(); |
| 123 ~Core(); | 136 ~Core(); |
| 124 | 137 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 139 | 152 |
| 140 base::Optional<DocumentSubresourceFilter> filter_; | 153 base::Optional<DocumentSubresourceFilter> filter_; |
| 141 base::ThreadChecker thread_checker_; | 154 base::ThreadChecker thread_checker_; |
| 142 | 155 |
| 143 DISALLOW_COPY_AND_ASSIGN(Core); | 156 DISALLOW_COPY_AND_ASSIGN(Core); |
| 144 }; | 157 }; |
| 145 | 158 |
| 146 } // namespace subresource_filter | 159 } // namespace subresource_filter |
| 147 | 160 |
| 148 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ASYNC_DOCUMENT_SUBRESOU
RCE_FILTER_H_ | 161 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ASYNC_DOCUMENT_SUBRESOU
RCE_FILTER_H_ |
| OLD | NEW |