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 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_RULESET_SERVICE_DE
LEGATE_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_RULESET_SERVICE_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_RULESET_SERVICE_DE
LEGATE_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_RULESET_SERVICE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/subresource_filter/core/browser/ruleset_service_delegate.h" | 11 #include "components/subresource_filter/core/browser/ruleset_service_delegate.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 | 14 |
15 namespace subresource_filter { | 15 namespace subresource_filter { |
16 | 16 |
17 // The content-layer specific implementation of RulesetServiceDelegate. | 17 class RulesetService; |
| 18 struct UnindexedRulesetInfo; |
| 19 |
| 20 // The content-layer specific implementation of RulesetServiceDelegate. Owns the |
| 21 // underlying RulesetService. |
18 // | 22 // |
19 // Its main responsibility is receiving new versions of subresource filtering | 23 // Its main responsibility is receiving new versions of subresource filtering |
20 // rules from the RulesetService, and distributing them to renderer processes, | 24 // rules from the RulesetService, and distributing them to renderer processes, |
21 // where they will be memory-mapped as-needed by the UnverifiedRulesetDealer. | 25 // where they will be memory-mapped as-needed by the UnverifiedRulesetDealer. |
22 // | 26 // |
23 // The distribution pipeline looks like this: | 27 // The distribution pipeline looks like this: |
24 // | 28 // |
25 // RulesetService | 29 // RulesetService |
26 // | | 30 // | |
27 // v Browser | 31 // v Browser |
28 // RulesetServiceDelegate | 32 // RulesetServiceDelegate |
29 // | | | 33 // | | |
30 // - - - - - - -|- - - - - - - |- - - - - - - - - - | 34 // - - - - - - -|- - - - - - - |- - - - - - - - - - |
31 // | | | | 35 // | | | |
32 // v v | 36 // v v |
33 // *RulesetDealer | *RulesetDealer | 37 // *RulesetDealer | *RulesetDealer |
34 // | | | | 38 // | | | |
35 // | | | v | 39 // | | | v |
36 // v | SubresourceFilterAgent | 40 // v | SubresourceFilterAgent |
37 // SubresourceFilterAgent | v | 41 // SubresourceFilterAgent | v |
38 // SubresourceFilterAgent | 42 // SubresourceFilterAgent |
39 // | | 43 // | |
40 // | 44 // |
41 // Renderer #1 | Renderer #n | 45 // Renderer #1 | Renderer #n |
42 // | 46 // |
43 // Note: UnverifiedRulesetDealer is shortened to *RulesetDealer above. There is | 47 // Note: UnverifiedRulesetDealer is shortened to *RulesetDealer above. There is |
44 // also a VerifiedRulesetDealer which is used similarly on the browser side. | 48 // also a VerifiedRulesetDealer which is used similarly on the browser side. |
45 class ContentRulesetServiceDelegate : public RulesetServiceDelegate, | 49 class ContentRulesetService : public RulesetServiceDelegate, |
46 content::NotificationObserver { | 50 content::NotificationObserver { |
47 public: | 51 public: |
48 ContentRulesetServiceDelegate(); | 52 ContentRulesetService(); |
49 ~ContentRulesetServiceDelegate() override; | 53 ~ContentRulesetService() override; |
50 | 54 |
51 void SetRulesetPublishedCallbackForTesting(base::Closure callback); | 55 void SetRulesetPublishedCallbackForTesting(base::Closure callback); |
52 | 56 |
53 // RulesetServiceDelegate: | 57 // RulesetServiceDelegate: |
54 void PostAfterStartupTask(base::Closure task) override; | 58 void PostAfterStartupTask(base::Closure task) override; |
55 void PublishNewRulesetVersion(base::File ruleset_data) override; | 59 void PublishNewRulesetVersion(base::File ruleset_data) override; |
56 | 60 |
| 61 void set_ruleset_service(std::unique_ptr<RulesetService> ruleset_service); |
| 62 |
| 63 // Forwards calls to the underlying ruleset_service_. |
| 64 void IndexAndStoreAndPublishRulesetIfNeeded( |
| 65 const UnindexedRulesetInfo& unindex_ruleset_info); |
| 66 |
57 private: | 67 private: |
58 // content::NotificationObserver: | 68 // content::NotificationObserver: |
59 void Observe(int type, | 69 void Observe(int type, |
60 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
61 const content::NotificationDetails& details) override; | 71 const content::NotificationDetails& details) override; |
62 | 72 |
63 content::NotificationRegistrar notification_registrar_; | 73 content::NotificationRegistrar notification_registrar_; |
64 base::File ruleset_data_; | 74 base::File ruleset_data_; |
65 base::Closure ruleset_published_callback_; | 75 base::Closure ruleset_published_callback_; |
66 | 76 |
67 DISALLOW_COPY_AND_ASSIGN(ContentRulesetServiceDelegate); | 77 std::unique_ptr<RulesetService> ruleset_service_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(ContentRulesetService); |
68 }; | 80 }; |
69 | 81 |
70 } // namespace subresource_filter | 82 } // namespace subresource_filter |
71 | 83 |
72 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_RULESET_SERVICE
_DELEGATE_H_ | 84 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_RULESET_SERVICE
_H_ |
OLD | NEW |