OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/extensions/extension_process_manager.h" | 5 #include "chrome/browser/extensions/extension_process_manager.h" |
6 | 6 |
7 #include "chrome/browser/browsing_instance.h" | 7 #include "chrome/browser/browsing_instance.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extensions_service.h" | 9 #include "chrome/browser/extensions/extensions_service.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( | 78 ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( |
79 Extension* extension, const GURL& url) { | 79 Extension* extension, const GURL& url) { |
80 ExtensionHost* host = | 80 ExtensionHost* host = |
81 new ExtensionHost(extension, GetSiteInstanceForURL(url), url); | 81 new ExtensionHost(extension, GetSiteInstanceForURL(url), url); |
82 host->CreateRenderView(NULL); // create a RenderViewHost with no view | 82 host->CreateRenderView(NULL); // create a RenderViewHost with no view |
83 OnExtensionHostCreated(host, true); | 83 OnExtensionHostCreated(host, true); |
84 return host; | 84 return host; |
85 } | 85 } |
86 | 86 |
87 void ExtensionProcessManager::RegisterExtensionProcess( | 87 void ExtensionProcessManager::RegisterExtensionProcess( |
88 std::string extension_id, int process_id) { | 88 const std::string& extension_id, int process_id) { |
89 ProcessIDMap::const_iterator it = process_ids_.find(extension_id); | 89 ProcessIDMap::const_iterator it = process_ids_.find(extension_id); |
90 if (it != process_ids_.end() && (*it).second == process_id) | 90 if (it != process_ids_.end() && (*it).second == process_id) |
91 return; | 91 return; |
92 | 92 |
| 93 // Extension ids should get removed from the map before the process ids get |
| 94 // reused from a dead renderer. |
| 95 DCHECK(it == process_ids_.end()); |
93 process_ids_[extension_id] = process_id; | 96 process_ids_[extension_id] = process_id; |
94 | 97 |
95 ExtensionsService* extension_service = | 98 ExtensionsService* extension_service = |
96 browsing_instance_->profile()->GetExtensionsService(); | 99 browsing_instance_->profile()->GetExtensionsService(); |
97 | 100 |
98 std::vector<std::string> page_action_ids; | 101 std::vector<std::string> page_action_ids; |
99 Extension* extension = extension_service->GetExtensionById(extension_id); | 102 Extension* extension = extension_service->GetExtensionById(extension_id); |
100 for (PageActionMap::const_iterator i = extension->page_actions().begin(); | 103 for (PageActionMap::const_iterator i = extension->page_actions().begin(); |
101 i != extension->page_actions().end(); ++i) { | 104 i != extension->page_actions().end(); ++i) { |
102 page_action_ids.push_back(i->first); | 105 page_action_ids.push_back(i->first); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, | 179 void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, |
177 bool is_background) { | 180 bool is_background) { |
178 all_hosts_.insert(host); | 181 all_hosts_.insert(host); |
179 if (is_background) | 182 if (is_background) |
180 background_hosts_.insert(host); | 183 background_hosts_.insert(host); |
181 NotificationService::current()->Notify( | 184 NotificationService::current()->Notify( |
182 NotificationType::EXTENSION_HOST_CREATED, | 185 NotificationType::EXTENSION_HOST_CREATED, |
183 Source<ExtensionProcessManager>(this), | 186 Source<ExtensionProcessManager>(this), |
184 Details<ExtensionHost>(host)); | 187 Details<ExtensionHost>(host)); |
185 } | 188 } |
OLD | NEW |