Defer extension process creation until IO data initialized
When a new extension is loaded, profile data on the IO
thread (namely the extension's entry in InfoMap) is updated
asynchronously. This data is needed to fulfill
chrome-extension URL requests coming from the extension
process.
It's possible for the extension process to start up and
request a resource (e.g. its background page) before this
async update actually executes on the IO thread, causing
the resource request to fail.
This CL prevents the extension process from starting until
the necessary IO data has been successfully updated.
BUG=514459
[email protected]
Review URL: https://codereview.chromium.org/1257193003
Cr-Commit-Position: refs/heads/master@{#340917}
diff --git a/chrome/browser/extensions/extension_system_impl.cc b/chrome/browser/extensions/extension_system_impl.cc
index b4ef0d9358..f9901e9 100644
--- a/chrome/browser/extensions/extension_system_impl.cc
+++ b/chrome/browser/extensions/extension_system_impl.cc
@@ -348,7 +348,8 @@
}
void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
- const Extension* extension) {
+ const Extension* extension,
+ const base::Closure& callback) {
base::Time install_time;
if (extension->location() != Manifest::COMPONENT) {
install_time = ExtensionPrefs::Get(profile_)->
@@ -368,11 +369,12 @@
!notification_service->IsNotifierEnabled(notifier_id);
#endif
- BrowserThread::PostTask(
+ BrowserThread::PostTaskAndReply(
BrowserThread::IO, FROM_HERE,
base::Bind(&InfoMap::AddExtension, info_map(),
- make_scoped_refptr(extension), install_time,
- incognito_enabled, notifications_disabled));
+ make_scoped_refptr(extension), install_time, incognito_enabled,
+ notifications_disabled),
+ callback);
}
void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(