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

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

Issue 2211213002: Revert of [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();
1000 // Extension was activated but was never loaded. This probably means that 999 // Extension was activated but was never loaded. This probably means that
1001 // the renderer failed to load it (or the browser failed to tell us when it 1000 // the renderer failed to load it (or the browser failed to tell us when it
1002 // did). Failures shouldn't happen, but instead of crashing there (which 1001 // did). Failures shouldn't happen, but instead of crashing there (which
1003 // executes on all renderers) be conservative and only crash in the renderer 1002 // executes on all renderers) be conservative and only crash in the renderer
1004 // of the extension which failed to load; this one. 1003 // of the extension which failed to load; this one.
1005 std::string& error = extension_load_errors_[extension_id]; 1004 std::string& error = extension_load_errors_[extension_id];
1006 char minidump[256]; 1005 char minidump[256];
1007 base::debug::Alias(&minidump); 1006 base::debug::Alias(&minidump);
1008 base::snprintf(minidump, 1007 base::snprintf(minidump,
1009 arraysize(minidump), 1008 arraysize(minidump),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 RendererExtensionRegistry::Get(); 1084 RendererExtensionRegistry::Get();
1086 // TODO(kalman): This test is deliberately not a CHECK (though I wish it 1085 // TODO(kalman): This test is deliberately not a CHECK (though I wish it
1087 // could be) and uses extension->id() not params.id: 1086 // could be) and uses extension->id() not params.id:
1088 // 1. For some reason params.id can be empty. I've only seen it with 1087 // 1. For some reason params.id can be empty. I've only seen it with
1089 // the webstore extension, in tests, and I've spent some time trying to 1088 // the webstore extension, in tests, and I've spent some time trying to
1090 // figure out why - but cost/benefit won. 1089 // figure out why - but cost/benefit won.
1091 // 2. The browser only sends this IPC to RenderProcessHosts once, but the 1090 // 2. The browser only sends this IPC to RenderProcessHosts once, but the
1092 // Dispatcher is attached to a RenderThread. Presumably there is a 1091 // Dispatcher is attached to a RenderThread. Presumably there is a
1093 // mismatch there. In theory one would think it's possible for the 1092 // mismatch there. In theory one would think it's possible for the
1094 // browser to figure this out itself - but again, cost/benefit. 1093 // browser to figure this out itself - but again, cost/benefit.
1095 if (!extension_registry->Insert(extension)) { 1094 if (!extension_registry->Contains(extension->id()))
1096 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and 1095 extension_registry->Insert(extension);
1097 // consider making this a release CHECK.
1098 NOTREACHED();
1099 }
1100 } 1096 }
1101 1097
1102 // Update the available bindings for all contexts. These may have changed if 1098 // Update the available bindings for all contexts. These may have changed if
1103 // an externally_connectable extension was loaded that can connect to an 1099 // an externally_connectable extension was loaded that can connect to an
1104 // open webpage. 1100 // open webpage.
1105 UpdateBindings(""); 1101 UpdateBindings("");
1106 } 1102 }
1107 1103
1108 void Dispatcher::OnMessageInvoke(const std::string& extension_id, 1104 void Dispatcher::OnMessageInvoke(const std::string& extension_id,
1109 const std::string& module_name, 1105 const std::string& module_name,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id)); 1147 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id));
1152 } 1148 }
1153 1149
1154 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) { 1150 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) {
1155 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); 1151 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids));
1156 } 1152 }
1157 1153
1158 void Dispatcher::OnUnloaded(const std::string& id) { 1154 void Dispatcher::OnUnloaded(const std::string& id) {
1159 // See comment in OnLoaded for why it would be nice, but perhaps incorrect, 1155 // See comment in OnLoaded for why it would be nice, but perhaps incorrect,
1160 // to CHECK here rather than guarding. 1156 // to CHECK here rather than guarding.
1161 // TODO(devlin): This may be fixed by crbug.com/528026. Monitor, and 1157 if (!RendererExtensionRegistry::Get()->Remove(id))
1162 // consider making this a release CHECK.
1163 if (!RendererExtensionRegistry::Get()->Remove(id)) {
1164 NOTREACHED();
1165 return; 1158 return;
1166 }
1167 1159
1168 active_extension_ids_.erase(id); 1160 active_extension_ids_.erase(id);
1169 1161
1170 script_injection_manager_->OnExtensionUnloaded(id); 1162 script_injection_manager_->OnExtensionUnloaded(id);
1171 1163
1172 // If the extension is later reloaded with a different set of permissions, 1164 // If the extension is later reloaded with a different set of permissions,
1173 // we'd like it to get a new isolated world ID, so that it can pick up the 1165 // we'd like it to get a new isolated world ID, so that it can pick up the
1174 // changed origin whitelist. 1166 // changed origin whitelist.
1175 ScriptInjection::RemoveIsolatedWorld(id); 1167 ScriptInjection::RemoveIsolatedWorld(id);
1176 1168
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 // The "guestViewDeny" module must always be loaded last. It registers 1660 // The "guestViewDeny" module must always be loaded last. It registers
1669 // error-providing custom elements for the GuestView types that are not 1661 // error-providing custom elements for the GuestView types that are not
1670 // available, and thus all of those types must have been checked and loaded 1662 // available, and thus all of those types must have been checked and loaded
1671 // (or not loaded) beforehand. 1663 // (or not loaded) beforehand.
1672 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { 1664 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1673 module_system->Require("guestViewDeny"); 1665 module_system->Require("guestViewDeny");
1674 } 1666 }
1675 } 1667 }
1676 1668
1677 } // namespace extensions 1669 } // 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