chromium/components/reporting/util/BUILD.gn

# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")
import("//build/nocompile.gni")
import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")
import("//third_party/protobuf/proto_library.gni")

static_library("backoff_settings") {
  sources = [
    "backoff_settings.cc",
    "backoff_settings.h",
  ]

  deps = [ "//net" ]
}

static_library("file") {
  sources = [
    "file.cc",
    "file.h",
  ]
  deps = [
    ":status",
    "//base",
  ]
}

static_library("status") {
  sources = [
    "reporting_errors.h",
    "status.cc",
    "status.h",
    "statusor.cc",
    "statusor.h",
  ]
  public_deps = [ "//components/reporting/proto:status_proto" ]
  deps = [ "//base" ]
}

source_set("status_macros") {
  sources = [
    "status_macros.cc",
    "status_macros.h",
  ]
  public_deps = [ "//base" ]
  deps = [ ":status" ]
}

source_set("task_runner_context") {
  sources = [ "task_runner_context.h" ]

  deps = [ "//base" ]
}

source_set("test_callbacks_support") {
  testonly = true
  sources = [
    "mock_clock.cc",
    "mock_clock.h",
    "test_support_callbacks.cc",
    "test_support_callbacks.h",
  ]

  deps = [
    "//base",
    "//base/test:test_support",
    "//testing/gtest",
  ]
}

source_set("disconnectable_client") {
  sources = [
    "disconnectable_client.cc",
    "disconnectable_client.h",
  ]

  deps = [
    ":status",
    "//base",
  ]
}

source_set("refcounted_closure_list") {
  sources = [
    "refcounted_closure_list.cc",
    "refcounted_closure_list.h",
  ]

  deps = [ "//base" ]
}

source_set("rate_limiter_interface") {
  sources = [ "rate_limiter_interface.h" ]

  deps = [ "//base" ]
}

source_set("wrapped_rate_limiter") {
  sources = [
    "wrapped_rate_limiter.cc",
    "wrapped_rate_limiter.h",
  ]

  deps = [
    ":rate_limiter_interface",
    "//base",
  ]
}

source_set("rate_limiter_leaky_bucket") {
  sources = [
    "rate_limiter_leaky_bucket.cc",
    "rate_limiter_leaky_bucket.h",
  ]

  deps = [
    ":rate_limiter_interface",
    "//base",
  ]
}

source_set("rate_limiter_token_bucket") {
  sources = [
    "rate_limiter_token_bucket.cc",
    "rate_limiter_token_bucket.h",
  ]

  deps = [
    ":rate_limiter_interface",
    "//base",
  ]
}

source_set("rate_limiter_slide_window") {
  sources = [
    "rate_limiter_slide_window.cc",
    "rate_limiter_slide_window.h",
  ]

  deps = [
    ":rate_limiter_interface",
    "//base",
  ]
}

if (enable_nocompile_tests) {
  nocompile_source_set("reporting_nocompile_tests") {
    sources = [
      "status_macros_assert_ok_nocompile.nc",
      "status_macros_check_ok_nocompile.nc",
      "status_macros_dcheck_ok_nocompile.nc",
      "status_macros_expect_ok_nocompile.nc",
      "status_macros_return_if_error_status_nocompile.nc",
    ]
    deps = [
      ":status_macros",
      "//base",
      "//testing/gtest",
    ]
  }
}

# All unit tests are built as part of the //components:components_unittests
# target.
source_set("unit_tests") {
  testonly = true
  sources = [
    "disconnectable_client_unittest.cc",
    "file_unittest.cc",
    "rate_limiter_leaky_bucket_unittest.cc",
    "rate_limiter_slide_window_unittest.cc",
    "rate_limiter_token_bucket_unittest.cc",
    "refcounted_closure_list_unittest.cc",
    "status_macros_unittest.cc",
    "status_unittest.cc",
    "statusor_unittest.cc",
    "task_runner_context_unittest.cc",
    "wrapped_rate_limiter_unittest.cc",
  ]
  deps = [
    ":disconnectable_client",
    ":file",
    ":rate_limiter_interface",
    ":rate_limiter_leaky_bucket",
    ":rate_limiter_slide_window",
    ":rate_limiter_token_bucket",
    ":refcounted_closure_list",
    ":status",
    ":status_macros",
    ":task_runner_context",
    ":test_callbacks_support",
    ":wrapped_rate_limiter",
    "//base",
    "//base/test:test_support",
    "//components/reporting/proto:status_proto",
    "//testing/gmock",
    "//testing/gtest",
  ]
  if (enable_nocompile_tests) {
    deps += [ ":reporting_nocompile_tests" ]
  }
}