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

Side by Side Diff: extensions/browser/api/declarative_net_request/ruleset_manager.h

Issue 2881453002: DNR Prototype: With flatbuffers
Patch Set: -- Created 3 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULESET_MANAGER_H_
6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULESET_MANAGER_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <vector>
12
13 #include <base/macros.h>
14 #include "base/files/memory_mapped_file.h"
15 #include "base/time/time.h"
16 #include "extensions/browser/api/declarative_net_request/matcher_util.h"
17 #include "extensions/common/extension_id.h"
18
19 namespace base {
20 class Time;
21 }
22
23 namespace extensions {
24 class InfoMap;
25
26 namespace declarative_net_request {
27 class ExtensionIndexedRulesetMatcher;
28
29 // Owned by InfoMap. Like InfoMap, it can be created/destroyed on any thread,
30 // but all the other methods must be called on the IO thread. Also, since it's
31 // owned by InfoMap, it's implicitly associated with a BrowserContext.
32 class RulesetManager {
33 public:
34 struct ExtensionKey {
35 ExtensionKey(ExtensionId, base::Time);
36 ~ExtensionKey();
37 const ExtensionId id;
38 const base::Time install_time;
39 };
40
41 struct ExtensionKeyComparator {
42 bool operator()(const ExtensionKey& lhs, const ExtensionKey& rhs) const;
43 };
44
45 using RulesMap = std::map<ExtensionKey,
46 std::unique_ptr<ExtensionIndexedRulesetMatcher>,
47 ExtensionKeyComparator>;
48
49 RulesetManager(InfoMap* info_map);
50 ~RulesetManager();
51 void AddRuleset(
52 ExtensionId extension_id,
53 std::unique_ptr<ExtensionIndexedRulesetMatcher> ruleset_matcher);
54 void RemoveRuleset(ExtensionId extension_id);
55
56 const RulesMap* rules_map() const { return &rules_; }
57
58 private:
59 InfoMap* info_map_; // Weak. Owns us.
60 RulesMap rules_;
61
62 DISALLOW_COPY_AND_ASSIGN(RulesetManager);
63 };
64
65 } // namespace declarative_net_request
66 } // namespace extensions
67
68 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULESET_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698