[go: nahoru, domu]

Fix mojom typemap dependencies

public_headers and traits_headers entries were incorrectly being slurped
into generated C++ bindings targets' |sources| lists. This is not correct
and caused GN to miss a whole bunch of legitimately missing dependencies.

Fixes the mojom GN rule behavior and updates affected targets.

This change also for some reason (I'm assuming breakage of obscure
transitive dependencies) started triggering a few other non-mojom
targets to fail gn check for legitimate reasons, so those issues have
been corrected as well.

Bug: 801308
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ia6e70f9b7c9bf969ef05054d32928d44d6171971

TBR=danakj@chromium.org,sky@chromium.org,mfoltz@chromium.org,bradnelson@chromium.org,nparker@chromium.org,miu@chromium.org

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ia6e70f9b7c9bf969ef05054d32928d44d6171971
Reviewed-on: https://chromium-review.googlesource.com/862702
Commit-Queue: Ken Rockot <rockot@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Ken Rockot <rockot@chromium.org>
Reviewed-by: Varun Khaneja <vakh@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529864}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index adcdb98..1baeacd 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -801,6 +801,7 @@
     "//gpu",
     "//gpu:test_support",
     "//gpu/command_buffer/client:gles2_implementation",
+    "//gpu/ipc/common:struct_traits",
     "//media",
     "//mojo/edk/system",
     "//mojo/public/cpp/bindings",
diff --git a/chrome/browser/media/router/BUILD.gn b/chrome/browser/media/router/BUILD.gn
index 1781510..8f58165a 100644
--- a/chrome/browser/media/router/BUILD.gn
+++ b/chrome/browser/media/router/BUILD.gn
@@ -20,6 +20,7 @@
   ]
   public_deps = [
     "//chrome/common/media_router:router",
+    "//chrome/common/media_router/mojo:media_router",
   ]
   sources = [
     "issue_manager.cc",
diff --git a/chrome/browser/vr/elements/audio_permission_prompt_texture.cc b/chrome/browser/vr/elements/audio_permission_prompt_texture.cc
index b443ed4..719ded1 100644
--- a/chrome/browser/vr/elements/audio_permission_prompt_texture.cc
+++ b/chrome/browser/vr/elements/audio_permission_prompt_texture.cc
@@ -25,8 +25,8 @@
 constexpr float kHeight = 0.218f;
 constexpr float kButtonHeight = 0.064f;
 constexpr float kCornerRadius = 0.006f;
-constexpr float kPadding = 0.028;
-constexpr float kIconSize = 0.042;
+constexpr float kPadding = 0.028f;
+constexpr float kIconSize = 0.042f;
 constexpr float kFontSizePromptText = 0.028f;
 constexpr float kTextTopMargin = 0.007f;
 constexpr float kTextLeftMargin = 0.010f;
diff --git a/chrome/browser/vr/ui_scene_constants.h b/chrome/browser/vr/ui_scene_constants.h
index b9b603e8..00e349e 100644
--- a/chrome/browser/vr/ui_scene_constants.h
+++ b/chrome/browser/vr/ui_scene_constants.h
@@ -10,7 +10,7 @@
 namespace vr {
 
 static constexpr int kWarningTimeoutSeconds = 30;
-static constexpr float kWarningDistance = 1.0;
+static constexpr float kWarningDistance = 1.0f;
 static constexpr float kWarningAngleRadians = gfx::DegToRad(16.3f);
 static constexpr float kPermanentWarningHeightDMM = 0.049f;
 static constexpr float kPermanentWarningWidthDMM = 0.1568f;
@@ -24,7 +24,7 @@
 static constexpr float kExitWarningYPaddingDMM = 0.023f;
 static constexpr float kExitWarningCornerRadiusDMM = 0.008f;
 
-static constexpr float kContentDistance = 2.5;
+static constexpr float kContentDistance = 2.5f;
 static constexpr float kContentWidthDMM = 0.96f;
 static constexpr float kContentHeightDMM = 0.64f;
 static constexpr float kContentWidth = kContentWidthDMM * kContentDistance;
@@ -35,10 +35,10 @@
 static constexpr float kContentCornerRadius = 0.005f * kContentWidth;
 static constexpr float kContentShadowOffset = 0.09f;
 static constexpr float kContentShadowIntesity = 0.3f;
-static constexpr float kBackplaneSize = 1000.0;
+static constexpr float kBackplaneSize = 1000.0f;
 static constexpr float kBackgroundDistanceMultiplier = 1.414f;
 
-static constexpr float kFullscreenDistance = 3;
+static constexpr float kFullscreenDistance = 3.0f;
 // Make sure that the aspect ratio for fullscreen is 16:9. Otherwise, we may
 // experience visual artefacts for fullscreened videos.
 static constexpr float kFullscreenHeightDMM = 0.64f;
@@ -53,7 +53,7 @@
 static constexpr float kExitPromptHeight = 0.2f * kContentDistance;
 
 static constexpr float kExitPromptVerticalOffset = -0.09f * kContentDistance;
-static constexpr float kPromptBackplaneSize = 1000.0;
+static constexpr float kPromptBackplaneSize = 1000.0f;
 
 static constexpr float kUrlBarDistance = 2.4f;
 static constexpr float kUrlBarWidthDMM = 0.672f;
@@ -87,7 +87,7 @@
 
 static constexpr float kWebVrUrlToastWidthDMM = 0.472f;
 static constexpr float kWebVrUrlToastHeightDMM = 0.064f;
-static constexpr float kWebVrUrlToastDistance = 1.0;
+static constexpr float kWebVrUrlToastDistance = 1.0f;
 static constexpr float kWebVrUrlToastWidth =
     kWebVrUrlToastWidthDMM * kWebVrUrlToastDistance;
 static constexpr float kWebVrUrlToastHeight =
@@ -96,7 +96,7 @@
 static constexpr float kWebVrUrlToastOpacity = 0.8f;
 static constexpr float kWebVrUrlToastRotationRad = gfx::DegToRad(14.0f);
 
-static constexpr float kWebVrToastDistance = 1.0;
+static constexpr float kWebVrToastDistance = 1.0f;
 static constexpr float kToastWidthDMM = 0.512f;
 static constexpr float kToastHeightDMM = 0.064f;
 static constexpr float kToastOffsetDMM = 0.004f;
@@ -116,10 +116,10 @@
 static constexpr float kSplashScreenTextFontHeightDMM = 0.05f;
 static constexpr float kSplashScreenTextWidthDMM = 0.9f;
 static constexpr float kSplashScreenTextVerticalOffsetDMM = -0.072f;
-static constexpr float kSplashScreenMinDurationSeconds = 2;
+static constexpr float kSplashScreenMinDurationSeconds = 2.0f;
 
 static constexpr float kButtonDiameterDMM = 0.088f;
-static constexpr float kButtonZOffsetHoverDMM = 0.048;
+static constexpr float kButtonZOffsetHoverDMM = 0.048f;
 
 static constexpr float kCloseButtonDistance = 2.4f;
 static constexpr float kCloseButtonVerticalOffset =
@@ -141,8 +141,8 @@
 static constexpr float kLoadingIndicatorDepthOffset =
     (kUrlBarDistance - kContentDistance) / 2;
 
-static constexpr float kSceneSize = 25.0;
-static constexpr float kSceneHeight = 4.0;
+static constexpr float kSceneSize = 25.0f;
+static constexpr float kSceneHeight = 4.0f;
 static constexpr int kFloorGridlineCount = 40;
 
 static constexpr float kVoiceSearchUIGroupButtonDMM = 0.096f;
diff --git a/chrome/browser/vr/ui_scene_creator.cc b/chrome/browser/vr/ui_scene_creator.cc
index 8ff387a..17e7518 100644
--- a/chrome/browser/vr/ui_scene_creator.cc
+++ b/chrome/browser/vr/ui_scene_creator.cc
@@ -1469,7 +1469,7 @@
   omnibox_outer_layout->SetName(kOmniboxOuterLayout);
   omnibox_outer_layout->set_margin(kSuggestionGapDMM);
   omnibox_outer_layout->SetTranslate(
-      0, kUrlBarVerticalOffsetDMM - 0.5 * kOmniboxHeightDMM,
+      0, kUrlBarVerticalOffsetDMM - 0.5f * kOmniboxHeightDMM,
       kOmniboxShadowOffset);
   omnibox_outer_layout->AddBinding(std::make_unique<Binding<bool>>(
       VR_BIND_LAMBDA([](Model* m) { return m->omnibox_editing_enabled(); },
diff --git a/chrome/common/media_router/BUILD.gn b/chrome/common/media_router/BUILD.gn
index 1b8b309..6349c12 100644
--- a/chrome/common/media_router/BUILD.gn
+++ b/chrome/common/media_router/BUILD.gn
@@ -4,7 +4,6 @@
 
 static_library("router") {
   public_deps = [
-    "mojo:media_controller",
     "//base:base",
     "//base:i18n",
     "//net:net",
@@ -35,8 +34,4 @@
     "route_request_result.cc",
     "route_request_result.h",
   ]
-
-  if (!is_android) {
-    public_deps += [ "mojo:media_router" ]
-  }
 }
diff --git a/chrome/common/media_router/mojo/media_router.typemap b/chrome/common/media_router/mojo/media_router.typemap
index 0c7cb478..bda1e13 100644
--- a/chrome/common/media_router/mojo/media_router.typemap
+++ b/chrome/common/media_router/mojo/media_router.typemap
@@ -14,8 +14,11 @@
   "//content/public/common/presentation_connection_message.h",
   "//content/public/common/presentation_info.h",
 ]
-deps = [
+public_deps = [
+  "//chrome/common/media_router:router",
   "//content/public/common",
+]
+deps = [
   "//net",
   "//third_party/icu",  # For issue.h
   "//url",
diff --git a/chrome/utility/BUILD.gn b/chrome/utility/BUILD.gn
index c9eea93..329f447 100644
--- a/chrome/utility/BUILD.gn
+++ b/chrome/utility/BUILD.gn
@@ -95,6 +95,7 @@
     deps += [
       "//chrome/common:mojo_bindings",
       "//chrome/common/importer:interfaces",
+      "//components/autofill/core/common",
       "//services/data_decoder:lib",
       "//services/proxy_resolver:lib",
     ]
diff --git a/components/nacl/renderer/BUILD.gn b/components/nacl/renderer/BUILD.gn
index 1b41d6b9..22081bd 100644
--- a/components/nacl/renderer/BUILD.gn
+++ b/components/nacl/renderer/BUILD.gn
@@ -36,6 +36,7 @@
   deps = [
     "//base",
     "//components/nacl/common",
+    "//components/nacl/common:nacl_error_code",
     "//components/nacl/renderer/plugin:nacl_trusted_plugin",
     "//content/public/common",
     "//content/public/renderer",
diff --git a/components/safe_browsing/renderer/BUILD.gn b/components/safe_browsing/renderer/BUILD.gn
index 271efd9..d4f8aad 100644
--- a/components/safe_browsing/renderer/BUILD.gn
+++ b/components/safe_browsing/renderer/BUILD.gn
@@ -55,6 +55,7 @@
     "//base:base",
     "//base/test:test_support",
     "//components/safe_browsing/common:interfaces",
+    "//content/public/common",
     "//ipc",
     "//testing/gmock",
     "//testing/gtest",
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
index 16c1fdf..f6b9fcb 100644
--- a/content/browser/BUILD.gn
+++ b/content/browser/BUILD.gn
@@ -106,6 +106,7 @@
     "//media/mojo/interfaces:constants",
     "//media/mojo/services",
     "//mojo/common",
+    "//mojo/common:values_struct_traits",
     "//mojo/edk/system",
     "//mojo/public/cpp/bindings",
     "//mojo/public/js:resources",
@@ -1825,7 +1826,10 @@
         "media/capture/cursor_renderer_mac.h",
         "media/capture/cursor_renderer_mac.mm",
       ]
-      deps += [ "//sandbox/mac:seatbelt" ]
+      deps += [
+        "//sandbox/mac:seatbelt",
+        "//sandbox/mac:seatbelt_extension",
+      ]
     }
     if (enable_webrtc) {
       sources += [
diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn
index 526d80c..9291e3f 100644
--- a/content/public/common/BUILD.gn
+++ b/content/public/common/BUILD.gn
@@ -257,6 +257,7 @@
     ":service_names",
     "//content/common",
     "//ipc",
+    "//media/capture:capture_base",
     "//mojo/edk/system",
     "//mojo/public/cpp/bindings",
     "//net",
diff --git a/content/public/common/manifest.typemap b/content/public/common/manifest.typemap
index 3584ce3a..b2cdec5 100644
--- a/content/public/common/manifest.typemap
+++ b/content/public/common/manifest.typemap
@@ -6,7 +6,18 @@
 public_headers = [ "//content/public/common/manifest.h" ]
 traits_headers = [ "//content/public/common/manifest_struct_traits.h" ]
 sources = [
+  # Because this mojom is effectively linked as part of content/public/common,
+  # and it cannot express a dependency on that target; yet manifest.h belongs to
+  # that target, so gn check will complain about its inclusion by the traits
+  # given the lack of explicit dependency. We work around this awkward situation
+  # by claiming that manifest.h is part of the mojom sources. As long as
+  # everything is still effectively part of content/public/common, this is fine.
+  "//content/public/common/manifest.h",
   "//content/public/common/manifest_struct_traits.cc",
+  "//content/public/common/manifest_struct_traits.h",
+]
+deps = [
+  "//ui/gfx/geometry/mojo:struct_traits",
 ]
 type_mappings = [
   "blink.mojom.Manifest=content::Manifest[nullable_is_same_type]",
diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn
index 071aa5e..24e5672 100644
--- a/extensions/browser/BUILD.gn
+++ b/extensions/browser/BUILD.gn
@@ -590,6 +590,7 @@
     "//components/update_client",
     "//components/url_matcher",
     "//components/user_prefs",
+    "//components/version_info",
     "//content/test:test_support",
     "//device/bluetooth:mocks",
     "//extensions:extensions_browser_resources",
diff --git a/media/capture/mojo/video_capture_types.typemap b/media/capture/mojo/video_capture_types.typemap
index 70e9a398..60c46651 100644
--- a/media/capture/mojo/video_capture_types.typemap
+++ b/media/capture/mojo/video_capture_types.typemap
@@ -22,9 +22,11 @@
 
 deps = [
   "//media",
+  "//media/base/ipc",
   "//media/capture:capture_base",
   "//media/capture/ipc",
   "//media/mojo/interfaces",
+  "//ui/gfx/geometry/mojo:struct_traits",
 ]
 
 type_mappings = [
diff --git a/mojo/public/cpp/bindings/README.md b/mojo/public/cpp/bindings/README.md
index 6b85ff0a..cbe12dc 100644
--- a/mojo/public/cpp/bindings/README.md
+++ b/mojo/public/cpp/bindings/README.md
@@ -1159,7 +1159,10 @@
 mojom = "//ui/gfx/geometry/mojo/geometry.mojom"
 public_headers = [ "//ui/gfx/geometry/rect.h" ]
 traits_headers = [ "//ui/gfx/geometry/mojo/geometry_struct_traits.h" ]
-sources = [ "//ui/gfx/geometry/mojo/geometry_struct_traits.cc" ]
+sources = [
+  "//ui/gfx/geometry/mojo/geometry_struct_traits.cc",
+  "//ui/gfx/geometry/mojo/geometry_struct_traits.h",
+]
 public_deps = [ "//ui/gfx/geometry" ]
 type_mappings = [
   "gfx.mojom.Rect=gfx::Rect",
@@ -1177,8 +1180,9 @@
   here.
 * `traits_headers`: Headers which contain the relevant `StructTraits`
   specialization(s) for any type mappings described by this file.
-* `sources`: Any private implementation sources needed for the `StructTraits`
-  definition.
+* `sources`: Any implementation sources and headers needed for the
+  `StructTraits` definition. These sources are compiled directly into the
+  generated C++ bindings target for a `mojom` file applying this typemap.
 * `public_deps`: Target dependencies exposed by the `public_headers` and
   `traits_headers`.
 * `deps`: Target dependencies exposed by `sources` but not already covered by
diff --git a/mojo/public/cpp/bindings/tests/BUILD.gn b/mojo/public/cpp/bindings/tests/BUILD.gn
index efa46f4..4ab1ff1 100644
--- a/mojo/public/cpp/bindings/tests/BUILD.gn
+++ b/mojo/public/cpp/bindings/tests/BUILD.gn
@@ -75,7 +75,10 @@
       "struct_traits_unittest.cc",
     ]
 
-    deps += [ "//mojo/public/interfaces/bindings/tests:test_interfaces_blink" ]
+    deps += [
+      "//mojo/public/cpp/bindings/tests:struct_with_traits_impl",
+      "//mojo/public/interfaces/bindings/tests:test_interfaces_blink",
+    ]
   }
 }
 
diff --git a/mojo/public/tools/bindings/mojom.gni b/mojo/public/tools/bindings/mojom.gni
index b7872fe..0bba833 100644
--- a/mojo/public/tools/bindings/mojom.gni
+++ b/mojo/public/tools/bindings/mojom.gni
@@ -867,12 +867,6 @@
         _typemap_config = {
         }
         _typemap_config = typemap.config
-        if (defined(_typemap_config.public_headers)) {
-          sources += _typemap_config.public_headers
-        }
-        if (defined(_typemap_config.traits_headers)) {
-          sources += _typemap_config.traits_headers
-        }
         if (defined(_typemap_config.sources)) {
           sources += _typemap_config.sources
         }
diff --git a/services/preferences/BUILD.gn b/services/preferences/BUILD.gn
index 7b1279f..c9a04a6 100644
--- a/services/preferences/BUILD.gn
+++ b/services/preferences/BUILD.gn
@@ -23,6 +23,7 @@
   ]
   deps = [
     "//components/prefs",
+    "//mojo/common:values_struct_traits",
     "//services/preferences/public/cpp",
     "//services/preferences/public/cpp/lib",
     "//services/preferences/public/interfaces",
diff --git a/services/preferences/public/cpp/BUILD.gn b/services/preferences/public/cpp/BUILD.gn
index fb4d1ce..f6cb549 100644
--- a/services/preferences/public/cpp/BUILD.gn
+++ b/services/preferences/public/cpp/BUILD.gn
@@ -28,6 +28,7 @@
   ]
 
   deps = [
+    "//mojo/common:values_struct_traits",
     "//mojo/public/cpp/bindings",
     "//services/preferences/public/cpp/lib",
   ]
diff --git a/services/resource_coordinator/public/cpp/BUILD.gn b/services/resource_coordinator/public/cpp/BUILD.gn
index b45e4f0a..a0f04d5 100644
--- a/services/resource_coordinator/public/cpp/BUILD.gn
+++ b/services/resource_coordinator/public/cpp/BUILD.gn
@@ -2,11 +2,23 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-component("resource_coordinator_cpp") {
+component("resource_coordinator_cpp_base") {
   sources = [
     "coordination_unit_id.cc",
     "coordination_unit_id.h",
     "coordination_unit_types.h",
+  ]
+
+  defines = [ "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION" ]
+
+  deps = [
+    "//base",
+    "//third_party/smhasher:cityhash",
+  ]
+}
+
+component("resource_coordinator_cpp") {
+  sources = [
     "frame_resource_coordinator.cc",
     "frame_resource_coordinator.h",
     "memory_instrumentation/client_process_impl.cc",
@@ -46,41 +58,16 @@
 
   defines = [ "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION" ]
 
-  deps = [
-    ":struct_traits",
-  ]
-
+  deps = []
   if (is_win) {
     deps += [ "//base/win:pe_image" ]
   }
 
   public_deps = [
+    ":resource_coordinator_cpp_base",
     "//base",
     "//mojo/public/cpp/bindings",
-    "//services/resource_coordinator/public/interfaces:interfaces_internal",
-    "//services/resource_coordinator/public/interfaces:interfaces_internal_blink",
+    "//services/resource_coordinator/public/interfaces",
     "//services/service_manager/public/cpp",
-    "//third_party/smhasher:cityhash",
-  ]
-
-  allow_circular_includes_from = [
-    "//services/resource_coordinator/public/interfaces:interfaces_internal",
-    "//services/resource_coordinator/public/interfaces:interfaces_internal_blink",
-  ]
-}
-
-source_set("struct_traits") {
-  sources = [
-    "coordination_unit_struct_traits.cc",
-    "coordination_unit_struct_traits.h",
-    "memory_instrumentation/memory_instrumentation_struct_traits.cc",
-    "memory_instrumentation/memory_instrumentation_struct_traits.h",
-  ]
-
-  defines = [ "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION" ]
-
-  public_deps = [
-    "//base",
-    "//services/resource_coordinator/public/interfaces:interfaces_internal",
   ]
 }
diff --git a/services/resource_coordinator/public/cpp/coordination_unit.typemap b/services/resource_coordinator/public/cpp/coordination_unit.typemap
index eadf9d2c..3eaaeca 100644
--- a/services/resource_coordinator/public/cpp/coordination_unit.typemap
+++ b/services/resource_coordinator/public/cpp/coordination_unit.typemap
@@ -10,8 +10,13 @@
   "//services/resource_coordinator/public/cpp/coordination_unit_types.h",
 ]
 traits_headers = [ "//services/resource_coordinator/public/cpp/coordination_unit_struct_traits.h" ]
-
-deps = []
+sources = [
+  "//services/resource_coordinator/public/cpp/coordination_unit_struct_traits.cc",
+  "//services/resource_coordinator/public/cpp/coordination_unit_struct_traits.h",
+]
+public_deps = [
+  "//services/resource_coordinator/public/cpp:resource_coordinator_cpp_base",
+]
 
 type_mappings = [
   "resource_coordinator.mojom.CoordinationUnitType=::resource_coordinator::CoordinationUnitType",
diff --git a/services/resource_coordinator/public/cpp/coordination_unit_id.h b/services/resource_coordinator/public/cpp/coordination_unit_id.h
index f63ac7d..320a6e0 100644
--- a/services/resource_coordinator/public/cpp/coordination_unit_id.h
+++ b/services/resource_coordinator/public/cpp/coordination_unit_id.h
@@ -8,7 +8,7 @@
 #include <tuple>
 
 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
-#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
+#include "services/resource_coordinator/public/cpp/resource_coordinator_base_export.h"
 
 namespace resource_coordinator {
 
@@ -17,7 +17,7 @@
 // would like to move it to base/ as easily as possible at that point.
 // TODO(oysteine): Rename to CoordinationUnitGUID to better differentiate the
 // class from the internal id
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT CoordinationUnitID {
+struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT CoordinationUnitID {
   typedef uint64_t CoordinationUnitTypeId;
 
   CoordinationUnitID();
diff --git a/services/resource_coordinator/public/cpp/coordination_unit_struct_traits.h b/services/resource_coordinator/public/cpp/coordination_unit_struct_traits.h
index 79e7614..cd74154 100644
--- a/services/resource_coordinator/public/cpp/coordination_unit_struct_traits.h
+++ b/services/resource_coordinator/public/cpp/coordination_unit_struct_traits.h
@@ -7,12 +7,14 @@
 
 #include "services/resource_coordinator/public/cpp/coordination_unit_types.h"
 #include "services/resource_coordinator/public/interfaces/coordination_unit.mojom.h"
+#include "services/resource_coordinator/public/interfaces/interfaces_export.h"
 
 namespace mojo {
 
 template <>
-struct EnumTraits<resource_coordinator::mojom::CoordinationUnitType,
-                  resource_coordinator::CoordinationUnitType> {
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
+    EnumTraits<resource_coordinator::mojom::CoordinationUnitType,
+               resource_coordinator::CoordinationUnitType> {
   static resource_coordinator::mojom::CoordinationUnitType ToMojom(
       resource_coordinator::CoordinationUnitType type);
   static bool FromMojom(resource_coordinator::mojom::CoordinationUnitType input,
@@ -20,8 +22,9 @@
 };
 
 template <>
-struct StructTraits<resource_coordinator::mojom::CoordinationUnitIDDataView,
-                    resource_coordinator::CoordinationUnitID> {
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
+    StructTraits<resource_coordinator::mojom::CoordinationUnitIDDataView,
+                 resource_coordinator::CoordinationUnitID> {
   static uint64_t id(const resource_coordinator::CoordinationUnitID& id) {
     return id.id;
   }
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h b/services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h
index adaed66..ecb4819 100644
--- a/services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h
+++ b/services/resource_coordinator/public/cpp/memory_instrumentation/global_memory_dump.h
@@ -6,6 +6,7 @@
 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_INSTRUMENTATION_GLOBAL_MEMORY_DUMP_H_
 
 #include "base/optional.h"
+#include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
 #include "services/resource_coordinator/public/interfaces/memory_instrumentation/memory_instrumentation.mojom.h"
 
 namespace memory_instrumentation {
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.typemap b/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.typemap
index 7468048..e5348552 100644
--- a/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.typemap
+++ b/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.typemap
@@ -11,6 +11,10 @@
   "//base/trace_event/memory_dump_manager.h",
 ]
 traits_headers = [ "//services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h" ]
+sources = [
+  "//services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.cc",
+  "//services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h",
+]
 deps = [
   "//base",
 ]
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h b/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h
index 890f608..67e3c54a 100644
--- a/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h
+++ b/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h
@@ -10,12 +10,13 @@
 #include "base/trace_event/memory_dump_request_args.h"
 #include "mojo/common/common_custom_types_struct_traits.h"
 #include "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
+#include "services/resource_coordinator/public/interfaces/interfaces_export.h"
 #include "services/resource_coordinator/public/interfaces/memory_instrumentation/memory_instrumentation.mojom.h"
 
 namespace mojo {
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     EnumTraits<memory_instrumentation::mojom::DumpType,
                base::trace_event::MemoryDumpType> {
   static memory_instrumentation::mojom::DumpType ToMojom(
@@ -25,7 +26,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     EnumTraits<memory_instrumentation::mojom::LevelOfDetail,
                base::trace_event::MemoryDumpLevelOfDetail> {
   static memory_instrumentation::mojom::LevelOfDetail ToMojom(
@@ -35,7 +36,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     EnumTraits<memory_instrumentation::mojom::HeapProfilingMode,
                base::trace_event::HeapProfilingMode> {
   static memory_instrumentation::mojom::HeapProfilingMode ToMojom(
@@ -45,7 +46,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     StructTraits<memory_instrumentation::mojom::RequestArgsDataView,
                  base::trace_event::MemoryDumpRequestArgs> {
   static uint64_t dump_guid(
@@ -65,7 +66,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT StructTraits<
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT StructTraits<
     memory_instrumentation::mojom::RawAllocatorDumpEdgeDataView,
     base::trace_event::ProcessMemoryDump::MemoryAllocatorDumpEdge> {
   static uint64_t source_id(
@@ -94,7 +95,7 @@
 };
 
 template <>
-struct UnionTraits<
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT UnionTraits<
     memory_instrumentation::mojom::RawAllocatorDumpEntryValueDataView,
     base::trace_event::MemoryAllocatorDump::Entry> {
   static memory_instrumentation::mojom::RawAllocatorDumpEntryValue::Tag GetTag(
@@ -128,7 +129,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     StructTraits<memory_instrumentation::mojom::RawAllocatorDumpEntryDataView,
                  base::trace_event::MemoryAllocatorDump::Entry> {
   static const std::string& name(
@@ -149,7 +150,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     StructTraits<memory_instrumentation::mojom::RawAllocatorDumpDataView,
                  std::unique_ptr<base::trace_event::MemoryAllocatorDump>> {
   static uint64_t id(
@@ -178,7 +179,7 @@
 };
 
 template <>
-struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT
+struct RESOURCE_COORDINATOR_PUBLIC_INTERFACES_EXPORT
     StructTraits<memory_instrumentation::mojom::RawProcessMemoryDumpDataView,
                  std::unique_ptr<base::trace_event::ProcessMemoryDump>> {
   // TODO(primiano): Remove this wrapping vector to adapt the underlying map<>
diff --git a/services/resource_coordinator/public/cpp/resource_coordinator_base_export.h b/services/resource_coordinator/public/cpp/resource_coordinator_base_export.h
new file mode 100644
index 0000000..1dd7f905
--- /dev/null
+++ b/services/resource_coordinator/public/cpp/resource_coordinator_base_export.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_BASE_EXPORT_H_
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_BASE_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION)
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT \
+  __declspec(dllexport)
+#else
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT \
+  __declspec(dllimport)
+#endif  // defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION)
+
+#else  // defined(WIN32)
+#if defined(SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_IMPLEMENTATION)
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT \
+  __attribute__((visibility("default")))
+#else
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT
+#endif
+#endif
+
+#else  // defined(COMPONENT_BUILD)
+#define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_BASE_EXPORT
+#endif
+
+#endif  // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_RESOURCE_COORDINATOR_BASE_EXPORT_H_
diff --git a/services/resource_coordinator/public/interfaces/BUILD.gn b/services/resource_coordinator/public/interfaces/BUILD.gn
index 01823fb..a6263d6 100644
--- a/services/resource_coordinator/public/interfaces/BUILD.gn
+++ b/services/resource_coordinator/public/interfaces/BUILD.gn
@@ -4,8 +4,9 @@
 
 import("//mojo/public/tools/bindings/mojom.gni")
 
-mojom("interfaces_internal") {
-  visibility = [ "//services/resource_coordinator/public/cpp:*" ]
+mojom_component("interfaces") {
+  output_prefix = "resource_coordinator_public_interfaces"
+  macro_prefix = "RESOURCE_COORDINATOR_PUBLIC_INTERFACES"
 
   sources = [
     "coordination_unit.mojom",
@@ -25,19 +26,6 @@
     "//services/metrics/public/interfaces",
   ]
 
-  component_output_prefix = "resource_coordinator_public_interfaces_internal"
-  export_class_attribute = "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT"
-  export_define = "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION=1"
-  export_header =
-      "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
-
-  export_class_attribute_blink =
-      "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT"
-  export_define_blink =
-      "SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_IMPLEMENTATION=1"
-  export_header_blink =
-      "services/resource_coordinator/public/cpp/resource_coordinator_export.h"
-
   # TODO(crbug.com/714018): Convert the implementation to use OnceCallback.
   use_once_callback = false
 }
diff --git a/services/ui/public/interfaces/BUILD.gn b/services/ui/public/interfaces/BUILD.gn
index 9978dc5..7465988 100644
--- a/services/ui/public/interfaces/BUILD.gn
+++ b/services/ui/public/interfaces/BUILD.gn
@@ -90,5 +90,6 @@
     "//testing/gtest",
     "//ui/display/types",
     "//ui/gfx:test_support",
+    "//ui/gfx/range/mojo:struct_traits",
   ]
 }
diff --git a/services/ui/public/interfaces/cursor/cursor.typemap b/services/ui/public/interfaces/cursor/cursor.typemap
index c4d6181..b64a81c54 100644
--- a/services/ui/public/interfaces/cursor/cursor.typemap
+++ b/services/ui/public/interfaces/cursor/cursor.typemap
@@ -17,6 +17,7 @@
 ]
 deps = [
   "//ui/gfx/geometry",
+  "//ui/gfx/geometry/mojo:struct_traits",
 ]
 
 type_mappings = [
diff --git a/services/ui/public/interfaces/ime/ime.typemap b/services/ui/public/interfaces/ime/ime.typemap
index 51ee8a4..1e764ba 100644
--- a/services/ui/public/interfaces/ime/ime.typemap
+++ b/services/ui/public/interfaces/ime/ime.typemap
@@ -19,6 +19,7 @@
 ]
 deps = [
   "//ui/gfx/range",
+  "//ui/gfx/range/mojo:struct_traits",
 ]
 
 type_mappings = [
diff --git a/services/viz/public/cpp/compositing/BUILD.gn b/services/viz/public/cpp/compositing/BUILD.gn
index c9f9613..4ae9d32a 100644
--- a/services/viz/public/cpp/compositing/BUILD.gn
+++ b/services/viz/public/cpp/compositing/BUILD.gn
@@ -13,6 +13,7 @@
     "//base/test:test_support",
     "//components/viz/common:common",
     "//components/viz/test:test_support",
+    "//gpu/ipc/common:struct_traits",
     "//media/capture/mojo:capture_types",
     "//services/service_manager/public/cpp",
     "//services/service_manager/public/cpp:service_test_support",
@@ -20,5 +21,7 @@
     "//skia/public/interfaces",
     "//testing/gtest",
     "//ui/gfx:test_support",
+    "//ui/gfx/geometry/mojo:struct_traits",
+    "//ui/gfx/ipc/color:color",
   ]
 }
diff --git a/services/viz/public/cpp/compositing/transferable_resource.typemap b/services/viz/public/cpp/compositing/transferable_resource.typemap
index 40c5152..d286183 100644
--- a/services/viz/public/cpp/compositing/transferable_resource.typemap
+++ b/services/viz/public/cpp/compositing/transferable_resource.typemap
@@ -5,8 +5,13 @@
 mojom =
     "//services/viz/public/interfaces/compositing/transferable_resource.mojom"
 public_headers = [ "//components/viz/common/resources/transferable_resource.h" ]
-traits_headers = [ "//services/viz/public/cpp/compositing/transferable_resource_struct_traits.h" ]
+traits_headers = [
+  "//services/viz/public/cpp/compositing/transferable_resource_struct_traits.h",
+]
 sources = [
   "//services/viz/public/cpp/compositing/transferable_resource_struct_traits.cc",
 ]
 type_mappings = [ "viz.mojom.TransferableResource=viz::TransferableResource" ]
+deps = [
+  "//gpu/ipc/common:struct_traits",
+]
diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn
index cea671ae..4883d632 100644
--- a/third_party/WebKit/Source/platform/BUILD.gn
+++ b/third_party/WebKit/Source/platform/BUILD.gn
@@ -213,6 +213,7 @@
     "//services/network/public/interfaces",
     "//services/network/public/interfaces:interfaces_blink",
     "//services/resource_coordinator/public/cpp:resource_coordinator_cpp",
+    "//services/resource_coordinator/public/interfaces:interfaces_blink",
     "//services/service_manager/public/interfaces:interfaces_blink",
     "//skia",
     "//third_party:jpeg",
diff --git a/ui/display/mojo/display.typemap b/ui/display/mojo/display.typemap
index 35d8b1d..868cdc5 100644
--- a/ui/display/mojo/display.typemap
+++ b/ui/display/mojo/display.typemap
@@ -13,6 +13,7 @@
 ]
 deps = [
   "//ui/gfx/geometry",
+  "//ui/gfx/geometry/mojo:struct_traits",
 ]
 
 type_mappings = [
diff --git a/ui/events/devices/mojo/input_device.typemap b/ui/events/devices/mojo/input_device.typemap
index ef7c1bc..992418b9 100644
--- a/ui/events/devices/mojo/input_device.typemap
+++ b/ui/events/devices/mojo/input_device.typemap
@@ -17,6 +17,7 @@
 ]
 deps = [
   "//ui/gfx/geometry",
+  "//ui/gfx/geometry/mojo:struct_traits",
 ]
 
 type_mappings = [
diff --git a/ui/gfx/mojo/ca_layer_params.typemap b/ui/gfx/mojo/ca_layer_params.typemap
index 215f58b3..33cd6fd 100644
--- a/ui/gfx/mojo/ca_layer_params.typemap
+++ b/ui/gfx/mojo/ca_layer_params.typemap
@@ -11,4 +11,7 @@
 public_deps = [
   "//ui/gfx",
 ]
+deps = [
+  "//ui/gfx/geometry/mojo:struct_traits",
+]
 type_mappings = [ "gfx.mojom.CALayerParams=gfx::CALayerParams" ]
diff --git a/ui/ozone/public/interfaces/BUILD.gn b/ui/ozone/public/interfaces/BUILD.gn
index f66bf8a..b9e7663b 100644
--- a/ui/ozone/public/interfaces/BUILD.gn
+++ b/ui/ozone/public/interfaces/BUILD.gn
@@ -44,6 +44,7 @@
 
   deps = [
     ":interfaces",
+    ":struct_traits",
     "//testing/gtest",
     "//ui/gfx/geometry",
   ]
diff --git a/ui/ozone/public/interfaces/overlay_surface_candidate.typemap b/ui/ozone/public/interfaces/overlay_surface_candidate.typemap
index d946169d1a..2cb22b6 100644
--- a/ui/ozone/public/interfaces/overlay_surface_candidate.typemap
+++ b/ui/ozone/public/interfaces/overlay_surface_candidate.typemap
@@ -5,6 +5,7 @@
 mojom = "//ui/ozone/public/interfaces/overlay_surface_candidate.mojom"
 public_headers = [ "//ui/ozone/public/overlay_surface_candidate.h" ]
 public_deps = [
+  "//ui/gfx/geometry/mojo:struct_traits",
   "//ui/ozone:ozone_base",
 ]
 traits_headers =