Fixing ResourceType build dependencies

The mojo type ResourceType used the public resource_type.h
header without depending on the build target where that header
was declared. Depending directly on that target would
create a dependency cycle so a new "resource_type_header" target
was created.

The dependency cycle would have been:
//content/public/common:resource_type_bindings ->
//content/public/common:common ->
//content:content
//content/public/app:both_sources ->
//content/public/common:common_sources ->
//content/public/common:interfaces ->
//content/public/common:resource_type_bindings ->

The exact error this fixes is:

ERROR at //out/Default/gen/content/public/common/resource_type.mojom-forward.h:35:11: Include not allowed.
          ^------------------------------------
It is not in any dependency of
  //content/public/common:resource_type_bindings
The include file is in the target(s):
  //content/public/common:common_sources
which should somehow be reachable.
___________________

Bug 938893

Change-Id: I350bff6a53a5be72f992e1226f7a3adce46f709d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1535856
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#644358}
diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn
index 7b8ed92..3ac0aa0 100644
--- a/content/public/common/BUILD.gn
+++ b/content/public/common/BUILD.gn
@@ -186,7 +186,6 @@
     "resource_request_body_android.cc",
     "resource_request_body_android.h",
     "resource_type.cc",
-    "resource_type.h",
     "resource_usage_reporter_type_converters.cc",
     "resource_usage_reporter_type_converters.h",
     "result_codes.h",
@@ -232,6 +231,7 @@
 
   public_deps = [
     ":interfaces",
+    ":resource_type_header",
     ":service_names",
     "//content/common",
     "//ipc",
@@ -311,6 +311,24 @@
   }
 }
 
+# This target exists because mojo bindings use this header and depending
+# on the whole of content/common would create a dependency cycle
+# //content/public/common:resource_type_bindings ->
+# //content/public/common:common ->
+# //content:content
+# //content/public/app:both_sources ->
+# //content/public/common:common_sources ->
+# //content/public/common:interfaces ->
+# //content/public/common:resource_type_bindings ->
+source_set("resource_type_header") {
+  sources = [
+    "resource_type.h",
+  ]
+  public_deps = [
+    "//content:export",
+  ]
+}
+
 buildflag_header("buildflags") {
   header = "buildflags.h"
   flags = [ "RTC_USE_H264=$rtc_use_h264" ]
diff --git a/content/public/common/resource_type.typemap b/content/public/common/resource_type.typemap
index 799c9fc..02fdf906 100644
--- a/content/public/common/resource_type.typemap
+++ b/content/public/common/resource_type.typemap
@@ -8,6 +8,9 @@
 sources = [
   "//content/public/common/resource_type_struct_traits.cc",
 ]
+public_deps = [
+  "//content/public/common:resource_type_header",
+]
 deps = [
   "//content:export",
 ]