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> |
(...skipping 15 matching lines...) Expand all Loading... |
26 // | 26 // |
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 // |
| 37 // =========================================================================== |
| 38 // WARNINGS - PLEASE UNDERSTAND THESE BEFORE CALLING OR MODIFYING THIS CLASS |
| 39 // =========================================================================== |
| 40 // |
| 41 // 1. This class contains the processes for hosted apps as well as extensions |
| 42 // and packaged apps. Just because a process is present here *does not* mean |
| 43 // it is an "extension process" (e.g., for UI purposes). It may contain only |
| 44 // hosted apps. See crbug.com/102533. |
| 45 // |
| 46 // 2. An extension can show be in multiple processes. That is why there is no |
| 47 // GetExtensionProcess() method here. There are two cases: a) The extension |
| 48 // is actually a hosted app, in which case this is normal, or b) there is an |
| 49 // incognito window open and the extension is "split mode". It is *not safe* |
| 50 // to assume that there is one process per extension. If you only care about |
| 51 // extensions (not hosted apps), and you are on the UI thread, then use |
| 52 // ExtensionProcessManager::GetSiteInstanceForURL()->[Has|Get]Process(). |
| 53 // |
| 54 // 3. The process ids contained in this class are *not limited* to the Profile |
| 55 // you got this map from. They can also be associated with that profile's |
| 56 // incognito/normal twin. If you care about this, use |
| 57 // RenderProcessHost::FromID() and check the profile of the resulting object. |
| 58 // |
| 59 // TODO(aa): The above warnings suggest this class could use improvement :). |
36 class ProcessMap { | 60 class ProcessMap { |
37 public: | 61 public: |
38 ProcessMap(); | 62 ProcessMap(); |
39 ~ProcessMap(); | 63 ~ProcessMap(); |
40 | 64 |
41 size_t size() const { return items_.size(); } | 65 size_t size() const { return items_.size(); } |
42 | 66 |
43 bool Insert(const std::string& extension_id, int process_id); | 67 bool Insert(const std::string& extension_id, int process_id); |
44 bool Remove(const std::string& extension_id, int process_id); | 68 bool Remove(const std::string& extension_id, int process_id); |
45 int Remove(int process_id); | 69 int Remove(int process_id); |
(...skipping 18 matching lines...) Expand all Loading... |
64 | 88 |
65 typedef std::set<Item> ItemSet; | 89 typedef std::set<Item> ItemSet; |
66 std::set<Item> items_; | 90 std::set<Item> items_; |
67 | 91 |
68 DISALLOW_COPY_AND_ASSIGN(ProcessMap); | 92 DISALLOW_COPY_AND_ASSIGN(ProcessMap); |
69 }; | 93 }; |
70 | 94 |
71 } // extensions | 95 } // extensions |
72 | 96 |
73 #endif // CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ | 97 #endif // CHROME_BROWSER_EXTENSIONS_PROCESS_MAP_H_ |
OLD | NEW |