OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_BROWSER_PROCESS_MAP_H_ | 5 #ifndef EXTENSIONS_BROWSER_PROCESS_MAP_H_ |
6 #define EXTENSIONS_BROWSER_PROCESS_MAP_H_ | 6 #define EXTENSIONS_BROWSER_PROCESS_MAP_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 13 |
| 14 namespace content { |
| 15 class BrowserContext; |
| 16 } |
12 | 17 |
13 namespace extensions { | 18 namespace extensions { |
14 | 19 |
15 // Contains information about which extensions are assigned to which processes. | 20 // Contains information about which extensions are assigned to which processes. |
16 // | 21 // |
17 // The relationship between extensions and processes is complex: | 22 // The relationship between extensions and processes is complex: |
18 // | 23 // |
19 // - Extensions can be either "split" mode or "spanning" mode. | 24 // - Extensions can be either "split" mode or "spanning" mode. |
20 // - In spanning mode, extensions share a single process between all incognito | 25 // - In spanning mode, extensions share a single process between all incognito |
21 // and normal windows. This was the original mode for extensions. | 26 // and normal windows. This was the original mode for extensions. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // care about incognito version of this extension (or vice versa if you're in | 59 // care about incognito version of this extension (or vice versa if you're in |
55 // an incognito profile) then use | 60 // an incognito profile) then use |
56 // extensions::ProcessManager::GetSiteInstanceForURL()->[Has|Get]Process(). | 61 // extensions::ProcessManager::GetSiteInstanceForURL()->[Has|Get]Process(). |
57 // | 62 // |
58 // 3. The process ids contained in this class are *not limited* to the Profile | 63 // 3. The process ids contained in this class are *not limited* to the Profile |
59 // you got this map from. They can also be associated with that profile's | 64 // you got this map from. They can also be associated with that profile's |
60 // incognito/normal twin. If you care about this, use | 65 // incognito/normal twin. If you care about this, use |
61 // RenderProcessHost::FromID() and check the profile of the resulting object. | 66 // RenderProcessHost::FromID() and check the profile of the resulting object. |
62 // | 67 // |
63 // TODO(aa): The above warnings suggest this class could use improvement :). | 68 // TODO(aa): The above warnings suggest this class could use improvement :). |
64 class ProcessMap { | 69 class ProcessMap : public BrowserContextKeyedService { |
65 public: | 70 public: |
66 ProcessMap(); | 71 ProcessMap(); |
67 ~ProcessMap(); | 72 virtual ~ProcessMap(); |
| 73 |
| 74 // Returns the instance for |browser_context|. An instance is shared between |
| 75 // an incognito and a regular context. |
| 76 static ProcessMap* Get(content::BrowserContext* browser_context); |
68 | 77 |
69 size_t size() const { return items_.size(); } | 78 size_t size() const { return items_.size(); } |
70 | 79 |
71 bool Insert(const std::string& extension_id, int process_id, | 80 bool Insert(const std::string& extension_id, int process_id, |
72 int site_instance_id); | 81 int site_instance_id); |
73 | 82 |
74 bool Remove(const std::string& extension_id, int process_id, | 83 bool Remove(const std::string& extension_id, int process_id, |
75 int site_instance_id); | 84 int site_instance_id); |
76 int RemoveAllFromProcess(int process_id); | 85 int RemoveAllFromProcess(int process_id); |
77 | 86 |
78 bool Contains(const std::string& extension_id, int process_id) const; | 87 bool Contains(const std::string& extension_id, int process_id) const; |
79 bool Contains(int process_id) const; | 88 bool Contains(int process_id) const; |
80 | 89 |
81 std::set<std::string> GetExtensionsInProcess(int process_id) const; | 90 std::set<std::string> GetExtensionsInProcess(int process_id) const; |
82 | 91 |
83 private: | 92 private: |
84 struct Item; | 93 struct Item; |
85 | 94 |
86 typedef std::set<Item> ItemSet; | 95 typedef std::set<Item> ItemSet; |
87 ItemSet items_; | 96 ItemSet items_; |
88 | 97 |
89 DISALLOW_COPY_AND_ASSIGN(ProcessMap); | 98 DISALLOW_COPY_AND_ASSIGN(ProcessMap); |
90 }; | 99 }; |
91 | 100 |
92 } // extensions | 101 } // namespace extensions |
93 | 102 |
94 #endif // EXTENSIONS_BROWSER_PROCESS_MAP_H_ | 103 #endif // EXTENSIONS_BROWSER_PROCESS_MAP_H_ |
OLD | NEW |