[Cronet] Extract common CronetURLRequestContext from Android CronetURLRequestContextAdapter.

Note:
- Patchset 1 copies android/cronet_url_request_context_adapter.* into cronet_url_request_context.*
- android/cronet_url_request_context_adapter.* use cronet_url_request_context.*
- cronet_global_state.h defines cross-platform API used to initialize and maintain Cronet state shared by multiple engines.

Bug: 786559
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester
Change-Id: I1cbe2162584745580e54bd0838a4a2303d7e6970
Reviewed-on: https://chromium-review.googlesource.com/840702
Commit-Queue: Misha Efimov <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Paul Jensen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#528628}
diff --git a/components/cronet/BUILD.gn b/components/cronet/BUILD.gn
new file mode 100644
index 0000000..429c4c30
--- /dev/null
+++ b/components/cronet/BUILD.gn
@@ -0,0 +1,65 @@
+# Copyright 2017 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.
+
+import("//build/util/process_version.gni")
+import("//build/util/version.gni")
+import("//testing/test.gni")
+
+process_version("cronet_version_header") {
+  template_file = "//components/cronet/version.h.in"
+  sources = [
+    "//chrome/VERSION",
+  ]
+  output = "$target_gen_dir/version.h"
+  extra_args = [
+    "-e",
+    "VERSION_FULL=\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)",
+  ]
+}
+
+# Cronet common implementation.
+source_set("cronet_common") {
+  sources = [
+    "cronet_global_state.h",
+    "cronet_prefs_manager.cc",
+    "cronet_prefs_manager.h",
+    "cronet_url_request_context.cc",
+    "cronet_url_request_context.h",
+    "histogram_manager.cc",
+    "histogram_manager.h",
+    "host_cache_persistence_manager.cc",
+    "host_cache_persistence_manager.h",
+    "stale_host_resolver.cc",
+    "stale_host_resolver.h",
+    "url_request_context_config.cc",
+    "url_request_context_config.h",
+  ]
+  deps = [
+    ":cronet_version_header",
+    "//base",
+    "//components/metrics:metrics",
+    "//components/prefs:prefs",
+    "//net",
+    "//third_party/metrics_proto",
+  ]
+}
+
+# Unit tests for Cronet common implementation.
+source_set("cronet_common_unittests") {
+  testonly = true
+
+  deps = [
+    ":cronet_common",
+    "//components/prefs:test_support",
+    "//net:test_support",
+  ]
+
+  sources = [
+    "histogram_manager_unittest.cc",
+    "host_cache_persistence_manager_unittest.cc",
+    "run_all_unittests.cc",
+    "stale_host_resolver_unittest.cc",
+    "url_request_context_config_unittest.cc",
+  ]
+}