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

Issue 2300453002: [Extensions] Begin making Extension port initialization asynchronous (Closed)

Created:
4 years, 3 months ago by Devlin
Modified:
4 years, 3 months ago
Reviewers:
Lei Zhang, lazyboy, nasko
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Extensions] Begin making Extension port initialization asynchronous Currently, extension port initialization requires a synchronous IPC to the browser. This is bad, as this can happen during very performance- sensitive times, such as a content script running at document_start. Make the port initialization process asynchronous. To do this, introduce the concept of local vs global ids. A local id is the id of the port in the javascript context, and the global id is used by the core extension system. The local id is set synchronously; the global is set asynchronously. This change also allows us to determine more quickly whether or not a port exists in a given context. Because ports are supposed to be able to be used synchronously, also instrument message caching that will wait until the port is fully initialized before dispatching any messages. To begin, this change only modifies the behavior for extension message ports constructed through runtime.connect(). Ports constructed through tabs.connect() or runtime.connectNative() will be addressed in subsequent patches. This also required updated a number of extensions tests which made incorrect assumptions about the order of APIs finishing (in particular, that a port's message would be sent prior to a script executing). This was never in any way guaranteed. Drive-by change: Make the extension not having connectNative permissions in trying to connect to a native app a hard failure. BUG=642380 Committed: https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3 Cr-Commit-Position: refs/heads/master@{#417784}

Patch Set 1 : Ready #

Total comments: 41

Patch Set 2 : lazyboys #

Total comments: 4

Patch Set 3 : Rebase #

Total comments: 4

Patch Set 4 : Nasko's #

Unified diffs Side-by-side diffs Delta from patch set Stats (+560 lines, -294 lines) Patch
M chrome/browser/renderer_host/chrome_extension_message_filter.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/renderer_host/chrome_extension_message_filter.cc View 1 chunk +5 lines, -3 lines 0 comments Download
M chrome/renderer/BUILD.gn View 1 2 1 chunk +0 lines, -2 lines 0 comments Download
M chrome/renderer/chrome_mock_render_thread.h View 1 chunk +1 line, -1 line 0 comments Download
M chrome/renderer/chrome_mock_render_thread.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc View 2 chunks +0 lines, -4 lines 0 comments Download
D chrome/renderer/extensions/tabs_custom_bindings.h View 1 chunk +0 lines, -24 lines 0 comments Download
D chrome/renderer/extensions/tabs_custom_bindings.cc View 1 2 1 chunk +0 lines, -61 lines 0 comments Download
M chrome/renderer/resources/extensions/tabs_custom_bindings.js View 1 chunk +1 line, -2 lines 0 comments Download
M chrome/test/data/extensions/api_test/executescript/in_frame/test.js View 1 2 3 chunks +21 lines, -11 lines 0 comments Download
M chrome/test/data/extensions/api_test/executescript/removed_frames/test.js View 5 chunks +28 lines, -17 lines 0 comments Download
M extensions/common/extension_messages.h View 1 2 3 1 chunk +14 lines, -9 lines 0 comments Download
M extensions/renderer/BUILD.gn View 1 1 chunk +2 lines, -0 lines 0 comments Download
M extensions/renderer/extension_frame_helper.h View 3 chunks +14 lines, -0 lines 0 comments Download
M extensions/renderer/extension_frame_helper.cc View 1 2 3 5 chunks +26 lines, -0 lines 0 comments Download
A extensions/renderer/extension_port.h View 1 1 chunk +78 lines, -0 lines 0 comments Download
A extensions/renderer/extension_port.cc View 1 1 chunk +64 lines, -0 lines 0 comments Download
M extensions/renderer/messaging_bindings.h View 1 3 chunks +39 lines, -0 lines 0 comments Download
M extensions/renderer/messaging_bindings.cc View 1 2 13 chunks +260 lines, -63 lines 0 comments Download
M extensions/renderer/resources/messaging.js View 4 chunks +0 lines, -15 lines 0 comments Download
M extensions/renderer/resources/runtime_custom_bindings.js View 3 chunks +4 lines, -3 lines 0 comments Download
M extensions/renderer/runtime_custom_bindings.h View 1 chunk +0 lines, -6 lines 0 comments Download
M extensions/renderer/runtime_custom_bindings.cc View 1 2 3 chunks +0 lines, -70 lines 0 comments Download

Messages

Total messages: 76 (64 generated)
Devlin
Hey lazyboy@, mind taking a look? It's a little complicated, but hopefully not too bad.
4 years, 3 months ago (2016-09-02 23:04:38 UTC) #43
lazyboy
Overall seems good, I have few comments. Sorry, a bunch of them are from old ...
4 years, 3 months ago (2016-09-08 00:05:40 UTC) #44
Devlin
https://codereview.chromium.org/2300453002/diff/140001/extensions/renderer/extension_port.h File extensions/renderer/extension_port.h (right): https://codereview.chromium.org/2300453002/diff/140001/extensions/renderer/extension_port.h#newcode22 extensions/renderer/extension_port.h:22: // A class to handle sending message port-related IPCs ...
4 years, 3 months ago (2016-09-08 19:15:31 UTC) #49
lazyboy
lgtm. https://codereview.chromium.org/2300453002/diff/140001/extensions/renderer/extension_port.h File extensions/renderer/extension_port.h (right): https://codereview.chromium.org/2300453002/diff/140001/extensions/renderer/extension_port.h#newcode44 extensions/renderer/extension_port.h:44: bool initialized() const { return global_id_ != -1; ...
4 years, 3 months ago (2016-09-08 21:59:16 UTC) #50
Devlin
https://codereview.chromium.org/2300453002/diff/160001/chrome/test/data/extensions/api_test/executescript/in_frame/test.js File chrome/test/data/extensions/api_test/executescript/in_frame/test.js (right): https://codereview.chromium.org/2300453002/diff/160001/chrome/test/data/extensions/api_test/executescript/in_frame/test.js#newcode35 chrome/test/data/extensions/api_test/executescript/in_frame/test.js:35: counter++; On 2016/09/08 21:59:16, lazyboy wrote: > asertTrue(counter<=5), i.e. ...
4 years, 3 months ago (2016-09-09 16:10:34 UTC) #56
Devlin
+thestig@ for chrome/renderer/chrome_mock_render_thread +nasko@ for extension_messages (less sync IPC!)
4 years, 3 months ago (2016-09-09 16:18:32 UTC) #60
Lei Zhang
lgtm
4 years, 3 months ago (2016-09-09 21:00:16 UTC) #63
nasko
IPC LGTM and some nits. https://codereview.chromium.org/2300453002/diff/180001/extensions/common/extension_messages.h File extensions/common/extension_messages.h (right): https://codereview.chromium.org/2300453002/diff/180001/extensions/common/extension_messages.h#newcode689 extensions/common/extension_messages.h:689: int /*port_id, */, nit: ...
4 years, 3 months ago (2016-09-09 21:11:34 UTC) #64
Devlin
https://codereview.chromium.org/2300453002/diff/180001/extensions/common/extension_messages.h File extensions/common/extension_messages.h (right): https://codereview.chromium.org/2300453002/diff/180001/extensions/common/extension_messages.h#newcode689 extensions/common/extension_messages.h:689: int /*port_id, */, On 2016/09/09 21:11:34, nasko (slow) wrote: ...
4 years, 3 months ago (2016-09-10 00:42:38 UTC) #69
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2300453002/200001
4 years, 3 months ago (2016-09-10 00:43:49 UTC) #72
commit-bot: I haz the power
Committed patchset #4 (id:200001)
4 years, 3 months ago (2016-09-10 00:48:23 UTC) #74
commit-bot: I haz the power
4 years, 3 months ago (2016-09-10 00:51:56 UTC) #76
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/dbbe69e7a03b50940d5b7e615c04de531511cac3
Cr-Commit-Position: refs/heads/master@{#417784}

Powered by Google App Engine
This is Rietveld 408576698