chromium/components/services/storage/BUILD.gn

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

import("//third_party/protobuf/proto_library.gni")

source_set("storage") {
  sources = [
    "dom_storage/async_dom_storage_database.cc",
    "dom_storage/async_dom_storage_database.h",
    "dom_storage/dom_storage_constants.cc",
    "dom_storage/dom_storage_constants.h",
    "dom_storage/dom_storage_database.cc",
    "dom_storage/dom_storage_database.h",
    "dom_storage/features.cc",
    "dom_storage/features.h",
    "dom_storage/local_storage_impl.cc",
    "dom_storage/local_storage_impl.h",
    "dom_storage/session_storage_area_impl.cc",
    "dom_storage/session_storage_area_impl.h",
    "dom_storage/session_storage_data_map.cc",
    "dom_storage/session_storage_data_map.h",
    "dom_storage/session_storage_impl.cc",
    "dom_storage/session_storage_impl.h",
    "dom_storage/session_storage_metadata.cc",
    "dom_storage/session_storage_metadata.h",
    "dom_storage/session_storage_namespace_impl.cc",
    "dom_storage/session_storage_namespace_impl.h",
    "dom_storage/storage_area_impl.cc",
    "dom_storage/storage_area_impl.h",
    "indexed_db/leveldb/leveldb_state.cc",
    "indexed_db/leveldb/leveldb_state.h",
    "indexed_db/locks/partitioned_lock.cc",
    "indexed_db/locks/partitioned_lock.h",
    "indexed_db/locks/partitioned_lock_id.cc",
    "indexed_db/locks/partitioned_lock_id.h",
    "indexed_db/locks/partitioned_lock_manager.cc",
    "indexed_db/locks/partitioned_lock_manager.h",
    "indexed_db/scopes/leveldb_scope.cc",
    "indexed_db/scopes/leveldb_scope.h",
    "indexed_db/scopes/leveldb_scope_deletion_mode.h",
    "indexed_db/scopes/leveldb_scopes.cc",
    "indexed_db/scopes/leveldb_scopes.h",
    "indexed_db/scopes/leveldb_scopes_coding.cc",
    "indexed_db/scopes/leveldb_scopes_coding.h",
    "indexed_db/scopes/leveldb_scopes_tasks.cc",
    "indexed_db/scopes/leveldb_scopes_tasks.h",
    "indexed_db/scopes/varint_coding.cc",
    "indexed_db/scopes/varint_coding.h",
    "indexed_db/transactional_leveldb/leveldb_write_batch.cc",
    "indexed_db/transactional_leveldb/leveldb_write_batch.h",
    "indexed_db/transactional_leveldb/transactional_leveldb_database.cc",
    "indexed_db/transactional_leveldb/transactional_leveldb_database.h",
    "indexed_db/transactional_leveldb/transactional_leveldb_factory.cc",
    "indexed_db/transactional_leveldb/transactional_leveldb_factory.h",
    "indexed_db/transactional_leveldb/transactional_leveldb_iterator.cc",
    "indexed_db/transactional_leveldb/transactional_leveldb_iterator.h",
    "indexed_db/transactional_leveldb/transactional_leveldb_transaction.cc",
    "indexed_db/transactional_leveldb/transactional_leveldb_transaction.h",
    "origin_context_impl.cc",
    "origin_context_impl.h",
    "partition_impl.cc",
    "partition_impl.h",
    "sandboxed_vfs_delegate.cc",
    "sandboxed_vfs_delegate.h",
    "service_worker/service_worker_database.cc",
    "service_worker/service_worker_database.h",
    "service_worker/service_worker_disk_cache.cc",
    "service_worker/service_worker_disk_cache.h",
    "service_worker/service_worker_resource_ops.cc",
    "service_worker/service_worker_resource_ops.h",
    "service_worker/service_worker_storage.cc",
    "service_worker/service_worker_storage.h",
    "service_worker/service_worker_storage_control_impl.cc",
    "service_worker/service_worker_storage_control_impl.h",
    "shared_storage/async_shared_storage_database.h",
    "shared_storage/async_shared_storage_database_impl.cc",
    "shared_storage/async_shared_storage_database_impl.h",
    "shared_storage/shared_storage_database.cc",
    "shared_storage/shared_storage_database.h",
    "shared_storage/shared_storage_database_migrations.cc",
    "shared_storage/shared_storage_database_migrations.h",
    "shared_storage/shared_storage_manager.cc",
    "shared_storage/shared_storage_manager.h",
    "shared_storage/shared_storage_options.cc",
    "shared_storage/shared_storage_options.h",
    "storage_service_impl.cc",
    "storage_service_impl.h",
  ]

  public_deps = [
    ":test_api_stubs",
    "//base",
    "//components/services/storage/dom_storage:local_storage_proto",
    "//components/services/storage/indexed_db/scopes:scopes_metadata_proto",
    "//components/services/storage/privileged/cpp",
    "//components/services/storage/privileged/mojom",
    "//components/services/storage/public/mojom",
    "//components/services/storage/service_worker:service_worker_proto",
    "//mojo/public/cpp/bindings",
    "//sql",
    "//third_party/abseil-cpp:absl",
    "//third_party/blink/public/common",
    "//third_party/leveldatabase",
    "//url",
  ]

  deps = [
    ":filesystem_proxy_factory",
    "//components/services/storage/public/cpp",
    "//net",
    "//services/network/public/cpp",
    "//services/network/public/mojom",
    "//storage/browser",
    "//storage/common",
  ]
}

# This is its own component target because it exposes global state to multiple
# independent libraries in component builds.
component("filesystem_proxy_factory") {
  sources = [
    "filesystem_proxy_factory.cc",
    "filesystem_proxy_factory.h",
  ]
  public_deps = [
    "//base",
    "//components/services/storage/public/cpp/filesystem",
  ]
  defines = [ "IS_FILESYSTEM_PROXY_FACTORY_IMPL" ]
}

# A separate component target which merely defines storage for a global testing
# API binder implementations to be injected. No actual testing logic should be
# included in this target.
component("test_api_stubs") {
  sources = [
    "test_api_stubs.cc",
    "test_api_stubs.h",
  ]

  public_deps = [
    "//base",
    "//mojo/public/cpp/system",
  ]

  defines = [ "IS_STORAGE_SERVICE_TEST_API_STUBS_IMPL" ]
}

bundle_data("tests_bundle_data") {
  visibility = [ ":tests" ]
  testonly = true
  sources = [
    "//components/test/data/storage/shared_storage.init_too_new.sql",
    "//components/test/data/storage/shared_storage.v0.sql",
    "//components/test/data/storage/shared_storage.v1.no_budget_table.sql",
    "//components/test/data/storage/shared_storage.v1.sql",
    "//components/test/data/storage/shared_storage.v2.sql",
    "//components/test/data/storage/shared_storage.v3.iterator.sql",
    "//components/test/data/storage/shared_storage.v3.sql",
    "//components/test/data/storage/shared_storage.v4.filescheme.sql",
    "//components/test/data/storage/shared_storage.v4.sql",
    "//components/test/data/storage/shared_storage.v5.sql",
    "//components/test/data/storage/shared_storage.v6.empty_values_mapping.5origins.sql",
    "//components/test/data/storage/shared_storage.v6.empty_values_mapping.6origins.sql",
    "//components/test/data/storage/shared_storage.v6.empty_values_mapping.7origins.sql",
    "//components/test/data/storage/shared_storage.v6.empty_values_mapping.8origins.sql",
    "//components/test/data/storage/shared_storage.v6.single_origin.sql",
    "//components/test/data/storage/shared_storage.v6.sql",
  ]
  outputs = [ "{{bundle_resources_dir}}/" +
              "{{source_root_relative_dir}}/{{source_file_part}}" ]
}

source_set("tests") {
  testonly = true

  sources = [
    "dom_storage/dom_storage_database_unittest.cc",
    "dom_storage/local_storage_impl_unittest.cc",
    "dom_storage/session_storage_area_impl_unittest.cc",
    "dom_storage/session_storage_data_map_unittest.cc",
    "dom_storage/session_storage_impl_unittest.cc",
    "dom_storage/session_storage_metadata_unittest.cc",
    "dom_storage/session_storage_namespace_impl_unittest.cc",
    "dom_storage/storage_area_impl_unittest.cc",
    "indexed_db/locks/partitioned_lock_manager_unittest.cc",
    "indexed_db/scopes/leveldb_scope_unittest.cc",
    "indexed_db/scopes/leveldb_scopes_coding_unittest.cc",
    "indexed_db/scopes/leveldb_scopes_tasks_unittest.cc",
    "indexed_db/scopes/leveldb_scopes_unittest.cc",
    "indexed_db/scopes/varint_coding_unittest.cc",
    "indexed_db/transactional_leveldb/transactional_leveldb_transaction_unittest.cc",
    "indexed_db/transactional_leveldb/transactional_leveldb_unittest.cc",
    "partition_impl_unittest.cc",
    "privileged/mojom/bucket_client_info_mojom_traits_unittest.cc",
    "service_worker/service_worker_database_unittest.cc",
    "service_worker/service_worker_disk_cache_unittest.cc",
    "service_worker/service_worker_storage_control_impl_unittest.cc",
    "service_worker/service_worker_storage_test_utils.cc",
    "service_worker/service_worker_storage_test_utils.h",
    "service_worker/service_worker_storage_unittest.cc",
    "shared_storage/async_shared_storage_database_impl_unittest.cc",
    "shared_storage/shared_storage_database_migrations_unittest.cc",
    "shared_storage/shared_storage_database_unittest.cc",
    "shared_storage/shared_storage_manager_unittest.cc",
    "storage_service_impl_unittest.cc",
  ]

  deps = [
    ":storage",
    ":test_support",
    ":tests_bundle_data",
    "//base",
    "//base/test:test_support",
    "//components/services/storage/public/cpp",
    "//components/services/storage/public/cpp/filesystem:tests",
    "//components/services/storage/public/mojom",
    "//components/services/storage/public/mojom:tests",
    "//mojo/public/cpp/bindings",
    "//mojo/public/cpp/system",
    "//mojo/public/cpp/test_support:test_utils",
    "//net",
    "//net:test_support",
    "//sql",
    "//sql:test_support",
    "//storage/browser:browser",
    "//storage/browser:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]

  if (is_ios) {
    deps += [ "//components/test:service_worker_test_bundle_data" ]
  }

  data = [ "//components/services/storage/test_data/" ]
}

source_set("test_support") {
  testonly = true

  sources = [
    "dom_storage/storage_area_test_util.cc",
    "dom_storage/storage_area_test_util.h",
    "dom_storage/testing_legacy_session_storage_database.cc",
    "dom_storage/testing_legacy_session_storage_database.h",
    "indexed_db/leveldb/fake_leveldb_factory.cc",
    "indexed_db/leveldb/fake_leveldb_factory.h",
    "indexed_db/leveldb/mock_level_db.cc",
    "indexed_db/leveldb/mock_level_db.h",
    "indexed_db/scopes/leveldb_scopes_test_utils.cc",
    "indexed_db/scopes/leveldb_scopes_test_utils.h",
    "shared_storage/shared_storage_test_utils.cc",
    "shared_storage/shared_storage_test_utils.h",
  ]

  deps = [
    ":storage",
    "//base/test:test_support",
    "//sql:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/leveldatabase",
  ]

  public_deps = [
    "//base",
    "//mojo/public/cpp/bindings",
    "//testing/gmock",
  ]
}