Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: extensions/renderer/dispatcher.cc

Issue 2213123002: [Extensions] Ensure ordering of extension [un]loaded, activated messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/renderer_startup_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "extensions/renderer/dispatcher.h" 5 #include "extensions/renderer/dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 script_context_set_->ForEach( 989 script_context_set_->ForEach(
990 std::string(), nullptr, 990 std::string(), nullptr,
991 base::Bind(&ScriptContextSet::Remove, 991 base::Bind(&ScriptContextSet::Remove,
992 base::Unretained(script_context_set_.get()))); 992 base::Unretained(script_context_set_.get())));
993 } 993 }
994 994
995 void Dispatcher::OnActivateExtension(const std::string& extension_id) { 995 void Dispatcher::OnActivateExtension(const std::string& extension_id) {
996 const Extension* extension = 996 const Extension* extension =
997 RendererExtensionRegistry::Get()->GetByID(extension_id); 997 RendererExtensionRegistry::Get()->GetByID(extension_id);
998 if (!extension) { 998 if (!extension) {
999 NOTREACHED();
999 // Extension was activated but was never loaded. This probably means that 1000 // Extension was activated but was never loaded. This probably means that
1000 // the renderer failed to load it (or the browser failed to tell us when it 1001 // the renderer failed to load it (or the browser failed to tell us when it
1001 // did). Failures shouldn't happen, but instead of crashing there (which 1002 // did). Failures shouldn't happen, but instead of crashing there (which
1002 // executes on all renderers) be conservative and only crash in the renderer 1003 // executes on all renderers) be conservative and only crash in the renderer
1003 // of the extension which failed to load; this one. 1004 // of the extension which failed to load; this one.
1004 std::string& error = extension_load_errors_[extension_id]; 1005 std::string& error = extension_load_errors_[extension_id];
1005 char minidump[256]; 1006 char minidump[256];
1006 base::debug::Alias(&minidump); 1007 base::debug::Alias(&minidump);
1007 base::snprintf(minidump, 1008 base::snprintf(minidump,
1008 arraysize(minidump), 1009 arraysize(minidump),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 RendererExtensionRegistry::Get(); 1085 RendererExtensionRegistry::Get();
1085 // TODO(kalman): This test is deliberately not a CHECK (though I wish it 1086 // TODO(kalman): This test is deliberately not a CHECK (though I wish it
1086 // could be) and uses extension->id() not params.id: 1087 // could be) and uses extension->id() not params.id:
1087 // 1. For some reason params.id can be empty. I've only seen it with 1088 // 1. For some reason params.id can be empty. I've only seen it with
1088 // the webstore extension, in tests, and I've spent some time trying to 1089 // the webstore extension, in tests, and I've spent some time trying to
1089 // figure out why - but cost/benefit won. 1090 // figure out why - but cost/benefit won.
1090 // 2. The browser only sends this IPC to RenderProcessHosts once, but the 1091 // 2. The browser only sends this IPC to RenderProcessHosts once, but the
1091 // Dispatcher is attached to a RenderThread. Presumably there is a 1092 // Dispatcher is attached to a RenderThread. Presumably there is a
1092 // mismatch there. In theory one would think it's possible for the 1093 // mismatch there. In theory one would think it's possible for the
1093 // browser to figure this out itself - but again, cost/benefit. 1094 // browser to figure this out itself - but again, cost/benefit.
1094 if (!extension_registry->Contains(extension->id())) 1095 if (!extension_registry->Insert(extension)) {
1095 extension_registry->Insert(extension); 1096 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and
1097 // consider making this a release CHECK.
1098 NOTREACHED();
1099 }
1096 } 1100 }
1097 1101
1098 // Update the available bindings for all contexts. These may have changed if 1102 // Update the available bindings for all contexts. These may have changed if
1099 // an externally_connectable extension was loaded that can connect to an 1103 // an externally_connectable extension was loaded that can connect to an
1100 // open webpage. 1104 // open webpage.
1101 UpdateBindings(""); 1105 UpdateBindings("");
1102 } 1106 }
1103 1107
1104 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 1108 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
1105 const std::string& module_name, 1109 const std::string& module_name,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id)); 1151 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id));
1148 } 1152 }
1149 1153
1150 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) { 1154 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) {
1151 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); 1155 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids));
1152 } 1156 }
1153 1157
1154 void Dispatcher::OnUnloaded(const std::string& id) { 1158 void Dispatcher::OnUnloaded(const std::string& id) {
1155 // See comment in OnLoaded for why it would be nice, but perhaps incorrect, 1159 // See comment in OnLoaded for why it would be nice, but perhaps incorrect,
1156 // to CHECK here rather than guarding. 1160 // to CHECK here rather than guarding.
1157 if (!RendererExtensionRegistry::Get()->Remove(id)) 1161 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and
1162 // consider making this a release CHECK.
1163 if (!RendererExtensionRegistry::Get()->Remove(id)) {
1164 NOTREACHED();
1158 return; 1165 return;
1166 }
1159 1167
1160 active_extension_ids_.erase(id); 1168 active_extension_ids_.erase(id);
1161 1169
1162 script_injection_manager_->OnExtensionUnloaded(id); 1170 script_injection_manager_->OnExtensionUnloaded(id);
1163 1171
1164 // If the extension is later reloaded with a different set of permissions, 1172 // If the extension is later reloaded with a different set of permissions,
1165 // we'd like it to get a new isolated world ID, so that it can pick up the 1173 // we'd like it to get a new isolated world ID, so that it can pick up the
1166 // changed origin whitelist. 1174 // changed origin whitelist.
1167 ScriptInjection::RemoveIsolatedWorld(id); 1175 ScriptInjection::RemoveIsolatedWorld(id);
1168 1176
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 // The "guestViewDeny" module must always be loaded last. It registers 1668 // The "guestViewDeny" module must always be loaded last. It registers
1661 // error-providing custom elements for the GuestView types that are not 1669 // error-providing custom elements for the GuestView types that are not
1662 // available, and thus all of those types must have been checked and loaded 1670 // available, and thus all of those types must have been checked and loaded
1663 // (or not loaded) beforehand. 1671 // (or not loaded) beforehand.
1664 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1672 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1665 module_system->Require("guestViewDeny"); 1673 module_system->Require("guestViewDeny");
1666 } 1674 }
1667 } 1675 }
1668 1676
1669 } // namespace extensions 1677 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/renderer_startup_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698