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

Issue 2547753002: [Extensions] Extension Port Ids and Initialization 2.0 (Closed)

Created:
4 years ago by Devlin
Modified:
4 years ago
Reviewers:
lazyboy, dcheng, rkaplow, sky, robwu
CC:
chromium-reviews, extensions-reviews_chromium.org, dglazkov+blink, blink-reviews, chromium-apps-reviews_chromium.org, kinuko+watch, blink-reviews-api_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Extensions] Extension Port Ids and Initialization 2.0 Extensions can open message ports to communicate between different contexts. A port can have n different receivers, and communication can flow bidirectionally. Currently, this is implemented by the port having a global id, vended by the browser process, which uniquely identifies a port (amongst all contexts). In making port creation asynchronous (crbug.com/642380), we also added the concept of a "local id" to be used in Javascript that identified a port uniquely in the context. This allowed us to have the browser asynchronously message us back a global id for the port to use. Unfortunately, this still has a number of problems: - Asynchronous port creation doesn't work in onunload (crbug.com/660706); this also required exposing the unload state from blink. - The time-to-message is slower, since we wait on an IPC round trip (crbug.com/649942). Instead, construct a new PortId concept as a combination of three members: context id (a globally-unique id for the context), port number (a port id within that context), and whether or not the port is an opener. This allows us to: - Make a port ID on the renderer, thus making it entirely synchronous and even faster than before (we don't need the browser involved at all). Also without exposing knowledge of unload state. - Identify whether the opposite end of the port was created in the same context (solving the issue of re-opening extension ports in a same- process renderer, crbug.com/597698). Test added courtesy of rob@robwu.nl. - Increase difficulty in sending bad IPCs since an attacker would have to guess another context's GUID (rather than just being able to know that a port with id '1' exists somewhere). Additionally, eliminate a few hundred lines of code. BUG=649942 BUG=597698 Committed: https://crrev.com/8e744a465d70e2ab1bf7959a66c3c65bd3850092 Cr-Commit-Position: refs/heads/master@{#436655}

Patch Set 1 #

Patch Set 2 : Rob's test #

Total comments: 8

Patch Set 3 : Rob's #

Total comments: 2

Patch Set 4 : rebase + unguessable token #

Total comments: 19

Patch Set 5 : Remove test #

Patch Set 6 : lazyboy's #

Total comments: 3

Patch Set 7 : rkaplow #

Unified diffs Side-by-side diffs Delta from patch set Stats (+499 lines, -720 lines) Patch
M chrome/browser/extensions/api/messaging/extension_message_port.h View 3 chunks +4 lines, -3 lines 0 comments Download
M chrome/browser/extensions/api/messaging/extension_message_port.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/extensions/api/messaging/message_service.h View 1 2 9 chunks +39 lines, -36 lines 0 comments Download
M chrome/browser/extensions/api/messaging/message_service.cc View 1 2 3 27 chunks +59 lines, -84 lines 0 comments Download
M chrome/browser/extensions/api/messaging/native_message_port.h View 3 chunks +3 lines, -2 lines 0 comments Download
M chrome/browser/extensions/api/messaging/native_message_port.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/renderer_host/chrome_extension_message_filter.h View 2 chunks +10 lines, -29 lines 0 comments Download
M chrome/browser/renderer_host/chrome_extension_message_filter.cc View 1 2 3 4 5 7 chunks +23 lines, -104 lines 0 comments Download
M chrome/renderer/chrome_mock_render_thread.h View 2 chunks +0 lines, -17 lines 0 comments Download
M chrome/renderer/chrome_mock_render_thread.cc View 2 chunks +0 lines, -34 lines 0 comments Download
M chrome/test/data/extensions/api_test/messaging/background_only/test.js View 1 1 chunk +54 lines, -0 lines 0 comments Download
M extensions/common/BUILD.gn View 1 chunk +2 lines, -0 lines 0 comments Download
A extensions/common/api/messaging/port_id.h View 1 2 3 1 chunk +76 lines, -0 lines 0 comments Download
A extensions/common/api/messaging/port_id.cc View 1 2 3 1 chunk +31 lines, -0 lines 0 comments Download
M extensions/common/extension_messages.h View 6 chunks +17 lines, -25 lines 0 comments Download
M extensions/renderer/dispatcher.h View 2 chunks +5 lines, -4 lines 0 comments Download
M extensions/renderer/dispatcher.cc View 3 chunks +4 lines, -4 lines 0 comments Download
M extensions/renderer/extension_frame_helper.h View 6 chunks +5 lines, -30 lines 0 comments Download
M extensions/renderer/extension_frame_helper.cc View 8 chunks +7 lines, -104 lines 0 comments Download
M extensions/renderer/extension_port.h View 1 2 3 4 5 2 chunks +13 lines, -35 lines 0 comments Download
M extensions/renderer/extension_port.cc View 1 chunk +10 lines, -33 lines 0 comments Download
M extensions/renderer/messaging_bindings.h View 1 2 3 4 5 5 chunks +22 lines, -29 lines 0 comments Download
M extensions/renderer/messaging_bindings.cc View 1 2 3 4 5 22 chunks +85 lines, -126 lines 0 comments Download
M third_party/WebKit/Source/web/WebDocument.cpp View 1 2 3 1 chunk +0 lines, -8 lines 0 comments Download
M third_party/WebKit/public/web/WebDocument.h View 1 2 3 1 chunk +0 lines, -6 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 4 5 6 3 chunks +27 lines, -4 lines 0 comments Download

Messages

Total messages: 46 (28 generated)
Devlin
Hey folks, please take a look. Sorry for the size. Rob, I believe this fixes ...
4 years ago (2016-12-02 02:00:02 UTC) #5
robwu
lgtm with nits. Incidentally, (script) context ID + local port ID is also exactly how ...
4 years ago (2016-12-02 11:58:54 UTC) #8
Devlin
https://codereview.chromium.org/2547753002/diff/20001/chrome/browser/extensions/api/messaging/message_service.cc File chrome/browser/extensions/api/messaging/message_service.cc (right): https://codereview.chromium.org/2547753002/diff/20001/chrome/browser/extensions/api/messaging/message_service.cc#newcode76 chrome/browser/extensions/api/messaging/message_service.cc:76: !source_port_id.is_opener)) On 2016/12/02 11:58:54, robwu wrote: > Can GET_CHANNEL_ID ...
4 years ago (2016-12-02 17:16:32 UTC) #10
dcheng
Yay! https://codereview.chromium.org/2547753002/diff/40001/extensions/renderer/messaging_bindings.h File extensions/renderer/messaging_bindings.h (right): https://codereview.chromium.org/2547753002/diff/40001/extensions/renderer/messaging_bindings.h#newcode131 extensions/renderer/messaging_bindings.h:131: const std::string context_id_; How would you feel about ...
4 years ago (2016-12-02 19:32:04 UTC) #14
Devlin
+sky@ as well for chrome/renderer/chrome_mock_render_thread.cc (purely code deletion, yay!) https://codereview.chromium.org/2547753002/diff/40001/extensions/renderer/messaging_bindings.h File extensions/renderer/messaging_bindings.h (right): https://codereview.chromium.org/2547753002/diff/40001/extensions/renderer/messaging_bindings.h#newcode131 extensions/renderer/messaging_bindings.h:131: ...
4 years ago (2016-12-02 20:25:50 UTC) #17
sky
LGTM
4 years ago (2016-12-02 21:18:46 UTC) #19
dcheng
https://codereview.chromium.org/2547753002/diff/60001/base/unguessable_token_unittest.cc File base/unguessable_token_unittest.cc (right): https://codereview.chromium.org/2547753002/diff/60001/base/unguessable_token_unittest.cc#newcode123 base/unguessable_token_unittest.cc:123: ASSERT_TRUE(tokens.insert(UnguessableToken::Create()).second); How long does this take to run? Honestly, ...
4 years ago (2016-12-03 00:50:56 UTC) #22
Devlin
https://codereview.chromium.org/2547753002/diff/60001/base/unguessable_token_unittest.cc File base/unguessable_token_unittest.cc (right): https://codereview.chromium.org/2547753002/diff/60001/base/unguessable_token_unittest.cc#newcode123 base/unguessable_token_unittest.cc:123: ASSERT_TRUE(tokens.insert(UnguessableToken::Create()).second); On 2016/12/03 00:50:56, dcheng wrote: > How long ...
4 years ago (2016-12-03 01:46:12 UTC) #24
dcheng
ipc+blink lgtm
4 years ago (2016-12-03 03:19:39 UTC) #26
lazyboy
https://codereview.chromium.org/2547753002/diff/60001/chrome/browser/renderer_host/chrome_extension_message_filter.cc File chrome/browser/renderer_host/chrome_extension_message_filter.cc (right): https://codereview.chromium.org/2547753002/diff/60001/chrome/browser/renderer_host/chrome_extension_message_filter.cc#newcode12 chrome/browser/renderer_host/chrome_extension_message_filter.cc:12: #include "base/guid.h" Revert. https://codereview.chromium.org/2547753002/diff/60001/extensions/renderer/extension_port.h File extensions/renderer/extension_port.h (right): https://codereview.chromium.org/2547753002/diff/60001/extensions/renderer/extension_port.h#newcode21 extensions/renderer/extension_port.h:21: ...
4 years ago (2016-12-03 03:53:27 UTC) #29
Devlin
https://codereview.chromium.org/2547753002/diff/60001/chrome/browser/renderer_host/chrome_extension_message_filter.cc File chrome/browser/renderer_host/chrome_extension_message_filter.cc (right): https://codereview.chromium.org/2547753002/diff/60001/chrome/browser/renderer_host/chrome_extension_message_filter.cc#newcode12 chrome/browser/renderer_host/chrome_extension_message_filter.cc:12: #include "base/guid.h" On 2016/12/03 03:53:26, lazyboy wrote: > Revert. ...
4 years ago (2016-12-05 17:07:43 UTC) #30
Devlin
+rkaplow for metrics https://codereview.chromium.org/2547753002/diff/100001/tools/metrics/histograms/histograms.xml File tools/metrics/histograms/histograms.xml (left): https://codereview.chromium.org/2547753002/diff/100001/tools/metrics/histograms/histograms.xml#oldcode108600 tools/metrics/histograms/histograms.xml:108600: label="Created during an event handler for ...
4 years ago (2016-12-05 17:09:01 UTC) #32
lazyboy
lgtm
4 years ago (2016-12-05 20:39:03 UTC) #33
rkaplow
lgtm https://codereview.chromium.org/2547753002/diff/100001/tools/metrics/histograms/histograms.xml File tools/metrics/histograms/histograms.xml (left): https://codereview.chromium.org/2547753002/diff/100001/tools/metrics/histograms/histograms.xml#oldcode108600 tools/metrics/histograms/histograms.xml:108600: label="Created during an event handler for the 'unload' ...
4 years ago (2016-12-05 23:01:15 UTC) #34
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/2547753002/120001
4 years ago (2016-12-06 17:53:50 UTC) #40
commit-bot: I haz the power
Committed patchset #7 (id:120001)
4 years ago (2016-12-06 18:41:01 UTC) #43
commit-bot: I haz the power
Patchset 7 (id:??) landed as https://crrev.com/8e744a465d70e2ab1bf7959a66c3c65bd3850092 Cr-Commit-Position: refs/heads/master@{#436655}
4 years ago (2016-12-06 18:44:15 UTC) #45
Devlin
4 years ago (2016-12-08 16:09:44 UTC) #46
Message was sent while issue was closed.
Whoops, forgot to update.  (Comment was addressed in the patchset that landed.)

https://codereview.chromium.org/2547753002/diff/100001/tools/metrics/histogra...
File tools/metrics/histograms/histograms.xml (left):

https://codereview.chromium.org/2547753002/diff/100001/tools/metrics/histogra...
tools/metrics/histograms/histograms.xml:108600: label="Created during an event
handler for the 'unload' event."/>
On 2016/12/05 23:01:15, rkaplow wrote:
> On 2016/12/05 17:09:01, Devlin wrote:
> > rkaplow: the above suffixes are no longer being recorded, but the new one
is. 
> > Can we mark suffixes as obsolete?  Or should we just make a new metric, even
> > though it's conceptually similar?  Or something else?
> 
> yes, you can add obsolete tags to a suffix. See
ModuleIntegrityVerificationType
> for an example.
> 
> 

Thanks!  Done.

Powered by Google App Engine
This is Rietveld 408576698