# Copyright 2014 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.

action("bake_in_configs") {
  visibility = [ ":*" ]
  script = "bake_in_configs.py"

  inputs = [
    "baked_in_configs/accounts_google_com.json",
    "baked_in_configs/ad_doubleclick_net.json",
    "baked_in_configs/apis_google_com.json",
    "baked_in_configs/c_admob_com.json",
    "baked_in_configs/clients2_google_com.json",
    "baked_in_configs/csi_gstatic_com.json",
    "baked_in_configs/ddm_google_com.json",
    "baked_in_configs/docs_google_com.json",
    "baked_in_configs/drive_google_com.json",
    "baked_in_configs/e_admob_com.json",
    "baked_in_configs/fonts_googleapis_com.json",
    "baked_in_configs/googleads4_g_doubleclick_net.json",
    "baked_in_configs/googleads_g_doubleclick_net.json",
    "baked_in_configs/gstatic_com.json",
    "baked_in_configs/lh3_ggpht_com.json",
    "baked_in_configs/lh4_ggpht_com.json",
    "baked_in_configs/lh5_ggpht_com.json",
    "baked_in_configs/lh6_ggpht_com.json",
    "baked_in_configs/mail_google_com.json",
    "baked_in_configs/media_admob_com.json",
    "baked_in_configs/pagead2_googlesyndication_com.json",
    "baked_in_configs/partner_googleadservices_com.json",
    "baked_in_configs/pubads_g_doubleclick_net.json",
    "baked_in_configs/redirector_googlevideo_com.json",
    "baked_in_configs/s0_2mdn_net.json",
    "baked_in_configs/ssl_gstatic_com.json",
    "baked_in_configs/star_admob_com.json",
    "baked_in_configs/star_doubleclick_net.json",
    "baked_in_configs/star_g_doubleclick_net.json",
    "baked_in_configs/star_ggpht_com.json",
    "baked_in_configs/star_google_cn.json",
    "baked_in_configs/star_google_co_uk.json",
    "baked_in_configs/star_google_com.json",
    "baked_in_configs/star_google_com_au.json",
    "baked_in_configs/star_google_de.json",
    "baked_in_configs/star_google_fr.json",
    "baked_in_configs/star_google_it.json",
    "baked_in_configs/star_google_jp.json",
    "baked_in_configs/star_google_org.json",
    "baked_in_configs/star_google_ru.json",
    "baked_in_configs/star_googleadservices_com.json",
    "baked_in_configs/star_googleapis_com.json",
    "baked_in_configs/star_googlesyndication_com.json",
    "baked_in_configs/star_googleusercontent_com.json",
    "baked_in_configs/star_googlevideo_com.json",
    "baked_in_configs/star_gstatic_com.json",
    "baked_in_configs/star_gvt1_com.json",
    "baked_in_configs/star_youtube_com.json",
    "baked_in_configs/star_ytimg_com.json",
    "baked_in_configs/t0_gstatic_com.json",
    "baked_in_configs/t1_gstatic_com.json",
    "baked_in_configs/t2_gstatic_com.json",
    "baked_in_configs/t3_gstatic_com.json",
    "baked_in_configs/themes_googleusercontent_com.json",
    "baked_in_configs/www_google_com.json",
    "baked_in_configs/www_googleadservices_com.json",
    "baked_in_configs/www_gstatic_com.json",
    "baked_in_configs/www_youtube_com.json",
  ]
  outputs = [
    "$target_gen_dir/baked_in_configs.cc",
  ]

  args = rebase_path(inputs, root_build_dir) +
         rebase_path(outputs, root_build_dir)
}

component("domain_reliability") {
  sources = [
    "baked_in_configs.h",
    "beacon.cc",
    "beacon.h",
    "clear_mode.h",
    "config.cc",
    "config.h",
    "context.cc",
    "context.h",
    "dispatcher.cc",
    "dispatcher.h",
    "domain_reliability_export.h",
    "monitor.cc",
    "monitor.h",
    "scheduler.cc",
    "scheduler.h",
    "service.cc",
    "service.h",
    "uploader.cc",
    "uploader.h",
    "util.cc",
    "util.h",
  ]
  sources += get_target_outputs(":bake_in_configs")

  defines = [ "DOMAIN_RELIABILITY_IMPLEMENTATION" ]

  deps = [
    ":bake_in_configs",
    "//base",
    "//components/keyed_service/core",
    "//content/public/browser",
    "//net",
    "//url",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "config_unittest.cc",
    "context_unittest.cc",
    "dispatcher_unittest.cc",
    "monitor_unittest.cc",
    "scheduler_unittest.cc",
    "test_util.cc",
    "test_util.h",
    "uploader_unittest.cc",
    "util_unittest.cc",
  ]

  deps = [
    ":domain_reliability",
    "//testing/gtest",
  ]
}