New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 621177 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jul 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug

Blocking:
issue 607208



Sign in to add a comment

WTF leaks into content/ via Blink public API (mojo + notifications)

Project Member Reported by jbroman@chromium.org, Jun 17 2016

Issue description

I recently ran into a compile failure on Windows in content/renderer/notification_permission_dispatcher.cc. This occurred because, due to a change of mine, a warning was emitted in a wtf/text/WTFString.h (conversion of pointer to bool, which MSVC complains about by default).

https://build.chromium.org/p/chromium/builders/Win%20x64/builds/1671/steps/compile/logs/stdio

This is common in Blink; enough so that throughout all of Blink (i.e. everything authorized to include WTF) it is suppressed. content, however, does not suppress this warning.

The include chain is:
content/renderer/notification_permission_dispatcher.cc
third_party/WebKit/public/web/modules/notifications/WebNotificationPermissionCallback.h
third_party/WebKit/public/platform/modules/permissions/permission_status.mojom-blink.h
third_party/WebKit/Source/wtf/text/WTFString.h

We go to substantial lengths at the moment to stop WTF from leaking out in the public API (INSIDE_BLINK/BLINK_IMPLEMENTATION guards and so on). So it seems to me that the public API should not be including the Blink (i.e. WTF) variant of the mojom header.

In this particular case, simply forward-declaring the enum class ought to work (unlike plain enums, you _can_ forward declare them), but I'm not clear on what the preferred approach for mojom enums appearing in public/ headers should be.

Some possibilities here:

1. Forward-declare enums like this. (If so, that prevents default arguments for enum parameters, and some similar things.)
2. Use the chromium variant be used instead in Blink public/ headers.
3. Header declares another enum separate from the two that the .mojom generates.
4. mojom generator puts the enums into some separate header shared between the variants (which can be safely included in public/ headers).

Bluetooth code currently does #2, but this still requires the code on the receiving end to include both the blink and chromium variants, with a static_cast from one enum type to the other (whereas notification_permission_dispatcher.cc does the include-both thing on the content side).
 
(Possibly this should be moved to the platform-architecture-dev or chromium-mojo mailing list, if the answer isn't obvious to either of you.)
Blocking: 607208
Summary: WTF leaks into content/ via Blink public API (mojo + notifications) (was: WTF leaks into content/ via Blink public API (notifications))

Comment 4 by yzshen@chromium.org, Jun 20 2016

Cc: roc...@chromium.org
I don't think we want to allow WTF things in content/, so #2 seems an acceptable temp solution.

Please see https://bugs.chromium.org/p/chromium/issues/detail?id=610415 for previous discussion for the bluetooth case. AFAIK, the bluetooth code is supposed to be onion-souped so the current solution is temporary.


Cc: peter@chromium.org
Permissions should also be Onion Souped :)

Comment 6 by peter@chromium.org, Jun 20 2016

While I definitely agree that not relying on WTF in //content/ would be the cleanest option, this creates for some practical issues in Onion Soup migration ordering.

To give an example, the event dispatching machinery for Service Workers still lives in //content/, which is non-trivial to migrate.

For features building on top of that, given option (2) and until Service Workers gets souped, would we have the browser->renderer Mojo services living in //content using the regular Mojo variant, pass those types to Blink, then have regular->Blink mojo variant converters living in Blink?

That's *a lot* of additional plumbing.

Could we instead consider a policy where it's OK to use WTF (through Mojo) in //content/{child,renderer}/ when said feature is intended to be Onion Souped?

The alternative is to block souping such features (push, notifications) until their dependencies (Service Workers) have boiled.

Comment 7 by yzshen@chromium.org, Jun 20 2016

Is it true that all we care about is enum? Maybe the custom typemapping feature is useful here?

Instead of using a mojo-defined enum type Foo in WebKit public API, we can use a C++-defined enum type CustomFoo.

Mojo supports custom typemapping for enum. Two ways to do it:
- Fully define Foo in mojom, and provide an EnumTraits to convert between CustomFoo and Foo.
- Declare Foo in mojom as a native-only enum (no definition), and use IPC::ParamTraits to convert between CustomFoo and Foo.

Either way, we can generate Mojo interfaces (blink/non-blink variants) to directly use CustomFoo as parameters.


All of that seems worse than just generating a -enums.h header separate from the interface. It's less manual, keeps the whole api in the .mojom, and solves this issue everywhere instead of as a one off every time.

Comment 9 by yzshen@chromium.org, Jun 20 2016

Having the blink-variant interfaces depend on the non-blink-variant enum types may be a little confusing since the two are not in the same namespace.

I guess I just haven't understood why enum is special. Imagine we have a simple mojo struct:

struct Size {
  int32 x;
  int32 y;
};

The generated result is nothing WTF-specific. Do we want to allow Size in WebKit public API and generate a separate header for it to be shared between blink/non-blink variants? I guess the answer is probably "no".

WDYT? Thanks!
Hmm, that is true :/
#6, it's not just a matter of policy allowing the includes in particular files.

Code in WTF expects include dirs, build flags, etc. that aren't specified (leading to unexpected breakage like the one that made me open this bug). We could make //content/{renderer,child,...} explicitly depend on WTF, but that is a pretty big change.

Comment 12 by tkent@chromium.org, Jun 23 2016

Components: -Blink>Architecture Blink>Internals
Renaming Blink>Architecture to Blink>Internals

Project Member

Comment 13 by bugdroid1@chromium.org, Jun 24 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4db41c4c92314447a07a2255d97c344547f97ce7

commit 4db41c4c92314447a07a2255d97c344547f97ce7
Author: jbroman <jbroman@chromium.org>
Date: Fri Jun 24 17:40:51 2016

Reland: WTF: Simplify RefPtr::operator bool.

The problematic case in String::find on ARM should now be gone, and so this
should be both simpler and equally fast.

Comparing to nullptr is used to coerce to boolean to work around  bug 621177 
(even though this is usually not the preferred way to do this in Blink).

BUG= 607208 , 621177 

Review-Url: https://codereview.chromium.org/2090973002
Cr-Commit-Position: refs/heads/master@{#401897}

[modify] https://crrev.com/4db41c4c92314447a07a2255d97c344547f97ce7/third_party/WebKit/Source/wtf/PassRefPtr.h
[modify] https://crrev.com/4db41c4c92314447a07a2255d97c344547f97ce7/third_party/WebKit/Source/wtf/RefPtr.h

Owner: ortuno@chromium.org
Status: Fixed (was: Assigned)
Fixed by ortuno's CL, https://codereview.chromium.org/2145993003

Sign in to add a comment