Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Issue 9704031: Lazy background pages now load in response to message passing. (Closed)

Created:
8 years, 9 months ago by Matt Perry
Modified:
5 years, 5 months ago
CC:
chromium-reviews, Aaron Boodman, mihaip+watch_chromium.org, Elliot Glaysher
Visibility:
Public.

Description

Lazy background pages now load in response to message passing. I refactored the pending event stuff so that it handles generic tasks. The first enqueued task for an extension will start its lazy background page, and tasks are run once the page finishes loading. Events and messages now share this mechanism so that either one can activate the page. BUG=81752 TEST=no Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=127216

Patch Set 1 #

Patch Set 2 : naming #

Patch Set 3 : apitest #

Total comments: 2

Patch Set 4 : rebase #

Total comments: 15

Patch Set 5 : review #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+510 lines, -140 lines) Patch
M chrome/browser/extensions/extension_event_router.h View 3 chunks +3 lines, -15 lines 0 comments Download
M chrome/browser/extensions/extension_event_router.cc View 7 chunks +12 lines, -74 lines 0 comments Download
M chrome/browser/extensions/extension_message_service.h View 1 2 3 4 4 chunks +39 lines, -11 lines 0 comments Download
M chrome/browser/extensions/extension_message_service.cc View 1 2 3 4 8 chunks +173 lines, -39 lines 0 comments Download
M chrome/browser/extensions/lazy_background_page_apitest.cc View 1 2 3 2 chunks +39 lines, -0 lines 0 comments Download
A chrome/browser/extensions/lazy_background_task_queue.h View 1 2 3 4 1 chunk +64 lines, -0 lines 2 comments Download
A chrome/browser/extensions/lazy_background_task_queue.cc View 1 2 3 4 1 chunk +120 lines, -0 lines 0 comments Download
M chrome/browser/profiles/off_the_record_profile_impl.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/profiles/off_the_record_profile_impl.cc View 1 1 chunk +4 lines, -0 lines 0 comments Download
M chrome/browser/profiles/profile.h View 1 2 chunks +5 lines, -0 lines 0 comments Download
M chrome/browser/profiles/profile_impl.h View 1 2 chunks +3 lines, -0 lines 0 comments Download
M chrome/browser/profiles/profile_impl.cc View 1 2 3 4 3 chunks +8 lines, -1 line 0 comments Download
M chrome/chrome_browser_extensions.gypi View 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/test/base/testing_profile.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M chrome/test/base/testing_profile.cc View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/lazy_background_page/messaging/background.js View 1 2 1 chunk +9 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/lazy_background_page/messaging/content.js View 1 2 1 chunk +6 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/api_test/lazy_background_page/messaging/manifest.json View 1 2 1 chunk +17 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Matt Perry
8 years, 9 months ago (2012-03-14 21:31:18 UTC) #1
Matt Perry
+miranda for chrome/browser/profiles OWNERS review. Note that the change to Profile is temporary, until the ...
8 years, 9 months ago (2012-03-14 23:09:36 UTC) #2
Miranda Callahan
LGTM, with comment addressed. cc-ing erg so he knows what's up. http://codereview.chromium.org/9704031/diff/3002/chrome/browser/profiles/profile_impl.cc File chrome/browser/profiles/profile_impl.cc (right): ...
8 years, 9 months ago (2012-03-15 00:12:32 UTC) #3
Matt Perry
http://codereview.chromium.org/9704031/diff/3002/chrome/browser/profiles/profile_impl.cc File chrome/browser/profiles/profile_impl.cc (right): http://codereview.chromium.org/9704031/diff/3002/chrome/browser/profiles/profile_impl.cc#newcode142 chrome/browser/profiles/profile_impl.cc:142: COMPILE_ASSERT(sizeof(ProfileImpl) <= 720u, profile_impl_size_unexpected); On 2012/03/15 00:12:32, Miranda Callahan ...
8 years, 9 months ago (2012-03-15 20:08:32 UTC) #4
Yoyo Zhou
http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc File chrome/browser/extensions/extension_message_service.cc (right): http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc#newcode188 chrome/browser/extensions/extension_message_service.cc:188: ExtensionMessageService::ExtensionMessageService(Profile* profile) Just pass in the LazyBackgroundTaskQueue instead. http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc#newcode236 ...
8 years, 9 months ago (2012-03-15 23:56:02 UTC) #5
Matt Perry
http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc File chrome/browser/extensions/extension_message_service.cc (right): http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc#newcode188 chrome/browser/extensions/extension_message_service.cc:188: ExtensionMessageService::ExtensionMessageService(Profile* profile) On 2012/03/15 23:56:03, Yoyo Zhou wrote: > ...
8 years, 9 months ago (2012-03-16 00:39:30 UTC) #6
Yoyo Zhou
LGTM, just 1 more comment. http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc File chrome/browser/extensions/extension_message_service.cc (right): http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/extension_message_service.cc#newcode236 chrome/browser/extensions/extension_message_service.cc:236: return; On 2012/03/16 00:39:30, ...
8 years, 9 months ago (2012-03-16 01:04:55 UTC) #7
Matt Perry
8 years, 9 months ago (2012-03-16 01:10:31 UTC) #8
http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/ex...
File chrome/browser/extensions/extension_message_service.cc (right):

http://codereview.chromium.org/9704031/diff/5006/chrome/browser/extensions/ex...
chrome/browser/extensions/extension_message_service.cc:236: return;
On 2012/03/16 01:04:55, Yoyo Zhou wrote:
> On 2012/03/16 00:39:30, Matt Perry wrote:
> > On 2012/03/15 23:56:03, Yoyo Zhou wrote:
> > > Can this ever happen?
> > 
> > Yes. This code starts the background page in response to a message from a
> > content script. (See the api test.)
> 
> Hmm, I think I meant to ask if MaybeAddPendingOpenChannelTask could ever
return
> false, i.e. the process is not there but it's not a lazy background page. But
it
> seems like this is handled in OpenChannelImpl.

Ah, yes. It returns false when the extension does not have a background page
(lazy or otherwise). This might happen, for example, if a content script is
trying to send a message to a popup. In that case, we want to call through to
OpenChannelImpl and send the disconnect back.

http://codereview.chromium.org/9704031/diff/7005/chrome/browser/extensions/la...
File chrome/browser/extensions/lazy_background_task_queue.h (right):

http://codereview.chromium.org/9704031/diff/7005/chrome/browser/extensions/la...
chrome/browser/extensions/lazy_background_task_queue.h:51: virtual void
Observe(int type,
On 2012/03/16 01:04:55, Yoyo Zhou wrote:
> This is public in NotificationObserver, so it should be public here too.

It's a matter of style, but I prefer putting interface implementations in the
private section when they should only be called via the interface. There is
precedence for this elsewhere in Chrome.

Powered by Google App Engine
This is Rietveld 408576698