OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_STARTUP_HELPER_H_ | 5 #ifndef EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ |
6 #define EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ | 6 #define EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 // This class sends messages to all renderers started for |browser_context|. | 40 // This class sends messages to all renderers started for |browser_context|. |
41 explicit RendererStartupHelper(content::BrowserContext* browser_context); | 41 explicit RendererStartupHelper(content::BrowserContext* browser_context); |
42 ~RendererStartupHelper() override; | 42 ~RendererStartupHelper() override; |
43 | 43 |
44 // content::NotificationObserver overrides: | 44 // content::NotificationObserver overrides: |
45 void Observe(int type, | 45 void Observe(int type, |
46 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
47 const content::NotificationDetails& details) override; | 47 const content::NotificationDetails& details) override; |
48 | 48 |
49 // Sends a message to the specified |process| activating the given extension | 49 // Sends a message to the specified |process| activating the given extension |
50 // once the process is initialized. | 50 // once the process is initialized. OnExtensionLoaded should have already been |
| 51 // called for the extension. |
51 void ActivateExtensionInProcess(const Extension& extension, | 52 void ActivateExtensionInProcess(const Extension& extension, |
52 content::RenderProcessHost* process); | 53 content::RenderProcessHost* process); |
53 | 54 |
54 // Sends a message to all initialized processes to [un]load the given | 55 // Sends a message to all initialized processes to [un]load the given |
55 // extension. We have explicit calls for these (rather than using an | 56 // extension. We have explicit calls for these (rather than using an |
56 // ExtensionRegistryObserver) because this needs to happen before other | 57 // ExtensionRegistryObserver) because this needs to happen before other |
57 // initialization which might rely on the renderers being notified. | 58 // initialization which might rely on the renderers being notified. |
58 void OnExtensionUnloaded(const Extension& extension); | 59 void OnExtensionUnloaded(const Extension& extension); |
59 void OnExtensionLoaded(const Extension& extension); | 60 void OnExtensionLoaded(const Extension& extension); |
60 | 61 |
61 private: | 62 private: |
| 63 friend class RendererStartupHelperTest; |
| 64 |
62 // Initializes the specified process, informing it of system state and loaded | 65 // Initializes the specified process, informing it of system state and loaded |
63 // extensions. | 66 // extensions. |
64 void InitializeProcess(content::RenderProcessHost* process); | 67 void InitializeProcess(content::RenderProcessHost* process); |
65 | 68 |
66 // Untracks the given process. | 69 // Untracks the given process. |
67 void UntrackProcess(content::RenderProcessHost* process); | 70 void UntrackProcess(content::RenderProcessHost* process); |
68 | 71 |
69 content::BrowserContext* browser_context_; // Not owned. | 72 content::BrowserContext* browser_context_; // Not owned. |
70 | 73 |
| 74 // Tracks the set of loaded extensions and the processes they are loaded in. |
| 75 std::map<ExtensionId, std::set<content::RenderProcessHost*>> |
| 76 extension_process_map_; |
| 77 |
71 // The set of render processes that have had the initial batch of IPC messages | 78 // The set of render processes that have had the initial batch of IPC messages |
72 // sent, including the set of loaded extensions. Further messages that | 79 // sent, including the set of loaded extensions. Further messages that |
73 // activate, load, or unload extensions should not be sent until after this | 80 // activate, load, or unload extensions should not be sent until after this |
74 // happens. | 81 // happens. |
75 std::set<content::RenderProcessHost*> initialized_processes_; | 82 std::set<content::RenderProcessHost*> initialized_processes_; |
76 | 83 |
77 // The set of ids for extensions that are active in a process that has not | 84 // The set of ids for extensions that are active in a process that has not |
78 // been initialized. The activation message will be sent the process is | 85 // been initialized. The activation message will be sent the process is |
79 // initialized. | 86 // initialized. |
80 std::map<content::RenderProcessHost*, std::set<ExtensionId>> | 87 std::map<content::RenderProcessHost*, std::set<ExtensionId>> |
(...skipping 25 matching lines...) Expand all Loading... |
106 content::BrowserContext* GetBrowserContextToUse( | 113 content::BrowserContext* GetBrowserContextToUse( |
107 content::BrowserContext* context) const override; | 114 content::BrowserContext* context) const override; |
108 bool ServiceIsCreatedWithBrowserContext() const override; | 115 bool ServiceIsCreatedWithBrowserContext() const override; |
109 | 116 |
110 DISALLOW_COPY_AND_ASSIGN(RendererStartupHelperFactory); | 117 DISALLOW_COPY_AND_ASSIGN(RendererStartupHelperFactory); |
111 }; | 118 }; |
112 | 119 |
113 } // namespace extensions | 120 } // namespace extensions |
114 | 121 |
115 #endif // EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ | 122 #endif // EXTENSIONS_BROWSER_RENDERER_STARTUP_HELPER_H_ |
OLD | NEW |