OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 | 15 |
16 // Contains information about which extensions are assigned to which processes. | 16 // Contains information about which extensions are assigned to which processes. |
17 // | 17 // |
18 // The relationship between extensions and processes is complex: | 18 // The relationship between extensions and processes is complex: |
19 // - Extensions can be either "split" mode or "spanning" mode. | 19 // - Extensions can be either "split" mode or "spanning" mode. |
20 // - In spanning mode, extensions share a single process between all incognito | 20 // - In spanning mode, extensions share a single process between all incognito |
21 // and normal windows. This was the original mode for extensions. | 21 // and normal windows. This was the original mode for extensions. |
22 // - In split mode, extensions have separate processes in incognito windows. | 22 // - In split mode, extensions have separate processes in incognito windows. |
23 // - There are also hosted apps, which are a kind of extensions, and those | 23 // - There are also hosted apps, which are a kind of extensions, and those |
24 // usually have a process model similar to normal web sites: multiple | 24 // usually have a process model similar to normal web sites: multiple |
25 // processes per-profile. | 25 // processes per-profile. |
26 // | 26 // |
Charlie Reis
2011/12/02 00:45:11
Maybe add a note:
- A single hosted app can have
Aaron Boodman
2011/12/02 05:32:45
Done.
| |
27 // In general, we seem to play with the process model of extensions a lot, so | 27 // In general, we seem to play with the process model of extensions a lot, so |
28 // it is safest to assume it is many-to-many in most places in the codebase. | 28 // it is safest to assume it is many-to-many in most places in the codebase. |
29 // | 29 // |
30 // Note that because of content scripts, frames, and other edge cases in | 30 // Note that because of content scripts, frames, and other edge cases in |
31 // Chrome's process isolation, extension code can still end up running outside | 31 // Chrome's process isolation, extension code can still end up running outside |
32 // an assigned process. | 32 // an assigned process. |
33 // | 33 // |
34 // But we only allow high-privilege operations to be performed by an extension | 34 // But we only allow high-privilege operations to be performed by an extension |
35 // when it is running in an assigned process. | 35 // when it is running in an assigned process. |
36 // | 36 // |
(...skipping 20 matching lines...) Expand all Loading... | |
57 // RenderProcessHost::FromID() and check the profile of the resulting object. | 57 // RenderProcessHost::FromID() and check the profile of the resulting object. |
58 // | 58 // |
59 // TODO(aa): The above warnings suggest this class could use improvement :). | 59 // TODO(aa): The above warnings suggest this class could use improvement :). |
60 class ProcessMap { | 60 class ProcessMap { |
61 public: | 61 public: |
62 ProcessMap(); | 62 ProcessMap(); |
63 ~ProcessMap(); | 63 ~ProcessMap(); |
64 | 64 |
65 size_t size() const { return items_.size(); } | 65 size_t size() const { return items_.size(); } |
66 | 66 |
67 bool Insert(const std::string& extension_id, int process_id); | 67 bool Insert(const std::string& extension_id, int process_id, |
68 bool Remove(const std::string& extension_id, int process_id); | 68 int site_instance_id); |
Charlie Reis
2011/12/02 00:45:11
Ditto.
| |
69 int Remove(int process_id); | 69 |
70 bool Remove(const std::string& extension_id, int process_id, | |
71 int site_instance_id); | |
72 int RemoveAllFromProcess(int process_id); | |
73 | |
70 bool Contains(const std::string& extension_id, int process_id) const; | 74 bool Contains(const std::string& extension_id, int process_id) const; |
71 bool Contains(int process_id) const; | 75 bool Contains(int process_id) const; |
72 | 76 |
73 std::set<std::string> GetExtensionsInProcess(int process_id) const; | 77 std::set<std::string> GetExtensionsInProcess(int process_id) const; |
74 | 78 |
75 private: | 79 private: |
76 struct Item { | 80 struct Item; |
77 Item(); | |
78 Item(const Item& other); | |
79 Item(const std::string& extension_id, int process_id); | |
80 ~Item(); | |
81 | |
82 // Required for set membership. | |
83 bool operator<(const Item& other) const; | |
84 | |
85 std::string extension_id; | |
86 int process_id; | |
87 }; | |
88 | 81 |
89 typedef std::set<Item> ItemSet; | 82 typedef std::set<Item> ItemSet; |
90 std::set<Item> items_; | 83 ItemSet items_; |
91 | 84 |
92 DISALLOW_COPY_AND_ASSIGN(ProcessMap); | 85 DISALLOW_COPY_AND_ASSIGN(ProcessMap); |
93 }; | 86 }; |
94 | 87 |
95 } // extensions | 88 } // extensions |
96 | 89 |
97 #endif // CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ | 90 #endif // CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ |
OLD | NEW |