Remove 15 unreferenced files in base and build
Delete orphaned Chromium base files and build/full_test.py that are
neither compiled in build/gen.py nor included anywhere in the codebase,
along with base/memory/weak_ptr.{h,cc} which has zero callers.
Change-Id: I4531927287329a48db7a4c6d9203b94882e3c095
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/29100
Reviewed-by: David Turner <digit@google.com>
Commit-Queue: Takuto Ikuta <tikuta@google.com>
diff --git a/build/full_test.py b/build/full_test.py
deleted file mode 100755
index 79b4ac4..0000000
--- a/build/full_test.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2018 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 os
-import shutil
-import subprocess
-import sys
-import timeit
-
-
-IS_WIN = sys.platform.startswith('win')
-
-
-def RemoveDir(d):
- if os.path.isdir(d):
- shutil.rmtree(d)
-
-
-def Trial(gn_path_to_use, save_out_dir=None):
- bin_path = os.path.join('out', 'gntrial')
- if not os.path.isdir(bin_path):
- os.makedirs(bin_path)
- gn_to_run = os.path.join(bin_path, 'gn' + ('.exe' if IS_WIN else ''))
- shutil.copy2(gn_path_to_use, gn_to_run)
- comp_dir = os.path.join('out', 'COMP')
- subprocess.check_call([gn_to_run, 'gen', comp_dir, '-q', '--check'])
- if save_out_dir:
- RemoveDir(save_out_dir)
- shutil.move(comp_dir, save_out_dir)
-
-
-def main():
- if len(sys.argv) < 3 or len(sys.argv) > 4:
- print('Usage: full_test.py /chrome/tree/at/762a25542878 rel_gn_path [clean]')
- return 1
-
- if len(sys.argv) == 4:
- RemoveDir('out')
-
- subprocess.check_call([sys.executable, os.path.join('build', 'gen.py')])
- subprocess.check_call(['ninja', '-C', 'out'])
- subprocess.check_call([os.path.join('out', 'gn_unittests')])
- orig_dir = os.getcwd()
-
- in_chrome_tree_gn = sys.argv[2]
- our_gn = os.path.join(orig_dir, 'out', 'gn' + ('.exe' if IS_WIN else ''))
-
- os.chdir(sys.argv[1])
-
- # Check in-tree vs. ours. Uses:
- # - Chromium tree at 762a25542878 in argv[1] (this can be off by a bit, but
- # is roughly when GN was moved out of the Chrome tree, so matches in case GN
- # semantics/ordering change after that.)
- # - relative path to argv[1] built gn binary in argv[2]
-
- # First, do a comparison to make sure the output between the two gn binaries
- # actually matches.
- print('Confirming output matches...')
- dir_a = os.path.join('out', 'a')
- dir_b = os.path.join('out', 'b')
- Trial(in_chrome_tree_gn, dir_a)
- Trial(our_gn, dir_b)
- subprocess.check_call(['diff', '-r', dir_a, dir_b])
-
- # Then, some time trials.
- TRIALS = 5
- print('Comparing performance... (takes a while)')
- time_a = timeit.timeit('Trial("%s")' % in_chrome_tree_gn, number=TRIALS,
- setup='from __main__ import Trial')
- time_b = timeit.timeit('Trial("%s")' % our_gn, number=TRIALS,
- setup='from __main__ import Trial')
- print('In-tree gn avg: %.3fs' % (time_a / TRIALS))
- print('Our gn avg: %.3fs' % (time_b / TRIALS))
-
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/build/gen.py b/build/gen.py
index b023875..1809572 100755
--- a/build/gen.py
+++ b/build/gen.py
@@ -700,7 +700,6 @@
'src/base/logging.cc',
'src/base/md5.cc',
'src/base/memory/ref_counted.cc',
- 'src/base/memory/weak_ptr.cc',
'src/base/sha1.cc',
'src/base/sha2.cc',
'src/base/strings/string_number_conversions.cc',
diff --git a/src/base/files/file_util.h b/src/base/files/file_util.h
index e58bbd5..c8f2fab 100644
--- a/src/base/files/file_util.h
+++ b/src/base/files/file_util.h
@@ -338,26 +338,6 @@
// the directory |path|, in the number of FilePath::CharType, or -1 on failure.
int GetMaximumPathComponentLength(const base::FilePath& path);
-#if defined(OS_LINUX) || defined(OS_AIX) || defined(OS_BSD)
-// Broad categories of file systems as returned by statfs() on Linux.
-enum FileSystemType {
- FILE_SYSTEM_UNKNOWN, // statfs failed.
- FILE_SYSTEM_0, // statfs.f_type == 0 means unknown, may indicate AFS.
- FILE_SYSTEM_ORDINARY, // on-disk filesystem like ext2
- FILE_SYSTEM_NFS,
- FILE_SYSTEM_SMB,
- FILE_SYSTEM_CODA,
- FILE_SYSTEM_MEMORY, // in-memory file system
- FILE_SYSTEM_CGROUP, // cgroup control.
- FILE_SYSTEM_OTHER, // any other value.
- FILE_SYSTEM_TYPE_COUNT
-};
-
-// Attempts determine the FileSystemType for |path|.
-// Returns false if |path| doesn't exist.
-bool GetFileSystemType(const FilePath& path, FileSystemType* type);
-#endif
-
} // namespace base
#endif // BASE_FILES_FILE_UTIL_H_
diff --git a/src/base/files/file_util_linux.cc b/src/base/files/file_util_linux.cc
deleted file mode 100644
index b230fd9..0000000
--- a/src/base/files/file_util_linux.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "base/files/file_util.h"
-
-#include <errno.h>
-#include <linux/magic.h>
-#include <sys/vfs.h>
-
-#include "base/files/file_path.h"
-
-namespace base {
-
-bool GetFileSystemType(const FilePath& path, FileSystemType* type) {
- struct statfs statfs_buf;
- if (statfs(path.value().c_str(), &statfs_buf) < 0) {
- if (errno == ENOENT)
- return false;
- *type = FILE_SYSTEM_UNKNOWN;
- return true;
- }
-
- // Not all possible |statfs_buf.f_type| values are in linux/magic.h.
- // Missing values are copied from the statfs man page.
- switch (statfs_buf.f_type) {
- case 0:
- *type = FILE_SYSTEM_0;
- break;
- case EXT2_SUPER_MAGIC: // Also ext3 and ext4
- case MSDOS_SUPER_MAGIC:
- case REISERFS_SUPER_MAGIC:
- case BTRFS_SUPER_MAGIC:
- case 0x5346544E: // NTFS
- case 0x58465342: // XFS
- case 0x3153464A: // JFS
- *type = FILE_SYSTEM_ORDINARY;
- break;
- case NFS_SUPER_MAGIC:
- *type = FILE_SYSTEM_NFS;
- break;
- case SMB_SUPER_MAGIC:
- case 0xFF534D42: // CIFS
- *type = FILE_SYSTEM_SMB;
- break;
- case CODA_SUPER_MAGIC:
- *type = FILE_SYSTEM_CODA;
- break;
- case HUGETLBFS_MAGIC:
- case RAMFS_MAGIC:
- case TMPFS_MAGIC:
- *type = FILE_SYSTEM_MEMORY;
- break;
- case CGROUP_SUPER_MAGIC:
- *type = FILE_SYSTEM_CGROUP;
- break;
- default:
- *type = FILE_SYSTEM_OTHER;
- }
- return true;
-}
-
-} // namespace base
diff --git a/src/base/json/json_value_converter.cc b/src/base/json/json_value_converter.cc
deleted file mode 100644
index ee7b094..0000000
--- a/src/base/json/json_value_converter.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-#include "base/json/json_value_converter.h"
-
-namespace base {
-namespace internal {
-
-bool BasicValueConverter<int>::Convert(const base::Value& value,
- int* field) const {
- return value.GetAsInteger(field);
-}
-
-bool BasicValueConverter<std::string>::Convert(const base::Value& value,
- std::string* field) const {
- return value.GetAsString(field);
-}
-
-bool BasicValueConverter<std::u16string>::Convert(const base::Value& value,
- std::u16string* field) const {
- return value.GetAsString(field);
-}
-
-bool BasicValueConverter<double>::Convert(const base::Value& value,
- double* field) const {
- return value.GetAsDouble(field);
-}
-
-bool BasicValueConverter<bool>::Convert(const base::Value& value,
- bool* field) const {
- return value.GetAsBoolean(field);
-}
-
-} // namespace internal
-} // namespace base
diff --git a/src/base/json/json_value_converter.h b/src/base/json/json_value_converter.h
deleted file mode 100644
index c7ee3a3..0000000
--- a/src/base/json/json_value_converter.h
+++ /dev/null
@@ -1,530 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef BASE_JSON_JSON_VALUE_CONVERTER_H_
-#define BASE_JSON_JSON_VALUE_CONVERTER_H_
-
-#include <stddef.h>
-
-#include <memory>
-#include <string>
-#include <string_view>
-#include <vector>
-
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/values.h"
-
-// JSONValueConverter converts a JSON value into a C++ struct in a
-// lightweight way.
-//
-// Usage:
-// For real examples, you may want to refer to _unittest.cc file.
-//
-// Assume that you have a struct like this:
-// struct Message {
-// int foo;
-// std::string bar;
-// static void RegisterJSONConverter(
-// JSONValueConverter<Message>* converter);
-// };
-//
-// And you want to parse a json data into this struct. First, you
-// need to declare RegisterJSONConverter() method in your struct.
-// // static
-// void Message::RegisterJSONConverter(
-// JSONValueConverter<Message>* converter) {
-// converter->RegisterIntField("foo", &Message::foo);
-// converter->RegisterStringField("bar", &Message::bar);
-// }
-//
-// Then, you just instantiate your JSONValueConverter of your type and call
-// Convert() method.
-// Message message;
-// JSONValueConverter<Message> converter;
-// converter.Convert(json, &message);
-//
-// Convert() returns false when it fails. Here "fail" means that the value is
-// structurally different from expected, such like a string value appears
-// for an int field. Do not report failures for missing fields.
-// Also note that Convert() will modify the passed |message| even when it
-// fails for performance reason.
-//
-// For nested field, the internal message also has to implement the registration
-// method. Then, just use RegisterNestedField() from the containing struct's
-// RegisterJSONConverter method.
-// struct Nested {
-// Message foo;
-// static void RegisterJSONConverter(...) {
-// ...
-// converter->RegisterNestedField("foo", &Nested::foo);
-// }
-// };
-//
-// For repeated field, we just assume std::vector<std::unique_ptr<ElementType>>
-// for its container and you can put RegisterRepeatedInt or some other types.
-// Use RegisterRepeatedMessage for nested repeated fields.
-//
-// Sometimes JSON format uses string representations for other types such
-// like enum, timestamp, or URL. You can use RegisterCustomField method
-// and specify a function to convert a std::string_view to your type.
-// bool ConvertFunc(std::string_view s, YourEnum* result) {
-// // do something and return true if succeed...
-// }
-// struct Message {
-// YourEnum ye;
-// ...
-// static void RegisterJSONConverter(...) {
-// ...
-// converter->RegsiterCustomField<YourEnum>(
-// "your_enum", &Message::ye, &ConvertFunc);
-// }
-// };
-
-namespace base {
-
-template <typename StructType>
-class JSONValueConverter;
-
-namespace internal {
-
-template <typename StructType>
-class FieldConverterBase {
- public:
- explicit FieldConverterBase(const std::string& path) : field_path_(path) {}
- virtual ~FieldConverterBase() = default;
- virtual bool ConvertField(const base::Value& value,
- StructType* obj) const = 0;
- const std::string& field_path() const { return field_path_; }
-
- private:
- std::string field_path_;
- FieldConverterBase(const FieldConverterBase&) = delete;
- FieldConverterBase& operator=(const FieldConverterBase&) = delete;
-};
-
-template <typename FieldType>
-class ValueConverter {
- public:
- virtual ~ValueConverter() = default;
- virtual bool Convert(const base::Value& value, FieldType* field) const = 0;
-};
-
-template <typename StructType, typename FieldType>
-class FieldConverter : public FieldConverterBase<StructType> {
- public:
- explicit FieldConverter(const std::string& path,
- FieldType StructType::* field,
- ValueConverter<FieldType>* converter)
- : FieldConverterBase<StructType>(path),
- field_pointer_(field),
- value_converter_(converter) {}
-
- bool ConvertField(const base::Value& value, StructType* dst) const override {
- return value_converter_->Convert(value, &(dst->*field_pointer_));
- }
-
- private:
- FieldType StructType::* field_pointer_;
- std::unique_ptr<ValueConverter<FieldType>> value_converter_;
- FieldConverter(const FieldConverter&) = delete;
- FieldConverter& operator=(const FieldConverter&) = delete;
-};
-
-template <typename FieldType>
-class BasicValueConverter;
-
-template <>
-class BasicValueConverter<int> : public ValueConverter<int> {
- public:
- BasicValueConverter() = default;
-
- bool Convert(const base::Value& value, int* field) const override;
-
- private:
- BasicValueConverter(const BasicValueConverter&) = delete;
- BasicValueConverter& operator=(const BasicValueConverter&) = delete;
-};
-
-template <>
-class BasicValueConverter<std::string> : public ValueConverter<std::string> {
- public:
- BasicValueConverter() = default;
-
- bool Convert(const base::Value& value, std::string* field) const override;
-
- private:
- BasicValueConverter(const BasicValueConverter&) = delete;
- BasicValueConverter& operator=(const BasicValueConverter&) = delete;
-};
-
-template <>
-class BasicValueConverter<std::u16string>
- : public ValueConverter<std::u16string> {
- public:
- BasicValueConverter() = default;
-
- bool Convert(const base::Value& value, std::u16string* field) const override;
-
- private:
- BasicValueConverter(const BasicValueConverter&) = delete;
- BasicValueConverter& operator=(const BasicValueConverter&) = delete;
-};
-
-template <>
-class BasicValueConverter<double> : public ValueConverter<double> {
- public:
- BasicValueConverter() = default;
-
- bool Convert(const base::Value& value, double* field) const override;
-
- private:
- BasicValueConverter(const BasicValueConverter&) = delete;
- BasicValueConverter& operator=(const BasicValueConverter&) = delete;
-};
-
-template <>
-class BasicValueConverter<bool> : public ValueConverter<bool> {
- public:
- BasicValueConverter() = default;
-
- bool Convert(const base::Value& value, bool* field) const override;
-
- private:
- BasicValueConverter(const BasicValueConverter&) = delete;
- BasicValueConverter& operator=(const BasicValueConverter&) = delete;
-};
-
-template <typename FieldType>
-class ValueFieldConverter : public ValueConverter<FieldType> {
- public:
- typedef bool (*ConvertFunc)(const base::Value* value, FieldType* field);
-
- explicit ValueFieldConverter(ConvertFunc convert_func)
- : convert_func_(convert_func) {}
-
- bool Convert(const base::Value& value, FieldType* field) const override {
- return convert_func_(&value, field);
- }
-
- private:
- ConvertFunc convert_func_;
-
- ValueFieldConverter(const ValueFieldConverter&) = delete;
- ValueFieldConverter& operator=(const ValueFieldConverter&) = delete;
-};
-
-template <typename FieldType>
-class CustomFieldConverter : public ValueConverter<FieldType> {
- public:
- typedef bool (*ConvertFunc)(std::string_view value, FieldType* field);
-
- explicit CustomFieldConverter(ConvertFunc convert_func)
- : convert_func_(convert_func) {}
-
- bool Convert(const base::Value& value, FieldType* field) const override {
- std::string string_value;
- return value.GetAsString(&string_value) &&
- convert_func_(string_value, field);
- }
-
- private:
- ConvertFunc convert_func_;
-
- CustomFieldConverter(const CustomFieldConverter&) = delete;
- CustomFieldConverter& operator=(const CustomFieldConverter&) = delete;
-};
-
-template <typename NestedType>
-class NestedValueConverter : public ValueConverter<NestedType> {
- public:
- NestedValueConverter() = default;
-
- bool Convert(const base::Value& value, NestedType* field) const override {
- return converter_.Convert(value, field);
- }
-
- private:
- JSONValueConverter<NestedType> converter_;
- NestedValueConverter(const NestedValueConverter&) = delete;
- NestedValueConverter& operator=(const NestedValueConverter&) = delete;
-};
-
-template <typename Element>
-class RepeatedValueConverter
- : public ValueConverter<std::vector<std::unique_ptr<Element>>> {
- public:
- RepeatedValueConverter() = default;
-
- bool Convert(const base::Value& value,
- std::vector<std::unique_ptr<Element>>* field) const override {
- const base::ListValue* list = NULL;
- if (!value.GetAsList(&list)) {
- // The field is not a list.
- return false;
- }
-
- field->reserve(list->GetSize());
- for (size_t i = 0; i < list->GetSize(); ++i) {
- const base::Value* element = NULL;
- if (!list->Get(i, &element))
- continue;
-
- std::unique_ptr<Element> e(new Element);
- if (basic_converter_.Convert(*element, e.get())) {
- field->push_back(std::move(e));
- } else {
- return false;
- }
- }
- return true;
- }
-
- private:
- BasicValueConverter<Element> basic_converter_;
- RepeatedValueConverter(const RepeatedValueConverter&) = delete;
- RepeatedValueConverter& operator=(const RepeatedValueConverter&) = delete;
-};
-
-template <typename NestedType>
-class RepeatedMessageConverter
- : public ValueConverter<std::vector<std::unique_ptr<NestedType>>> {
- public:
- RepeatedMessageConverter() = default;
-
- bool Convert(const base::Value& value,
- std::vector<std::unique_ptr<NestedType>>* field) const override {
- const base::ListValue* list = NULL;
- if (!value.GetAsList(&list))
- return false;
-
- field->reserve(list->GetSize());
- for (size_t i = 0; i < list->GetSize(); ++i) {
- const base::Value* element = NULL;
- if (!list->Get(i, &element))
- continue;
-
- std::unique_ptr<NestedType> nested(new NestedType);
- if (converter_.Convert(*element, nested.get())) {
- field->push_back(std::move(nested));
- } else {
- return false;
- }
- }
- return true;
- }
-
- private:
- JSONValueConverter<NestedType> converter_;
- RepeatedMessageConverter(const RepeatedMessageConverter&) = delete;
- RepeatedMessageConverter& operator=(const RepeatedMessageConverter&) = delete;
-};
-
-template <typename NestedType>
-class RepeatedCustomValueConverter
- : public ValueConverter<std::vector<std::unique_ptr<NestedType>>> {
- public:
- typedef bool (*ConvertFunc)(const base::Value* value, NestedType* field);
-
- explicit RepeatedCustomValueConverter(ConvertFunc convert_func)
- : convert_func_(convert_func) {}
-
- bool Convert(const base::Value& value,
- std::vector<std::unique_ptr<NestedType>>* field) const override {
- const base::ListValue* list = NULL;
- if (!value.GetAsList(&list))
- return false;
-
- field->reserve(list->GetSize());
- for (size_t i = 0; i < list->GetSize(); ++i) {
- const base::Value* element = NULL;
- if (!list->Get(i, &element))
- continue;
-
- std::unique_ptr<NestedType> nested(new NestedType);
- if ((*convert_func_)(element, nested.get())) {
- field->push_back(std::move(nested));
- } else {
- return false;
- }
- }
- return true;
- }
-
- private:
- ConvertFunc convert_func_;
- RepeatedCustomValueConverter(const RepeatedCustomValueConverter&) = delete;
- RepeatedCustomValueConverter& operator=(const RepeatedCustomValueConverter&) =
- delete;
-};
-
-} // namespace internal
-
-template <class StructType>
-class JSONValueConverter {
- public:
- JSONValueConverter() { StructType::RegisterJSONConverter(this); }
-
- void RegisterIntField(const std::string& field_name,
- int StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, int>>(
- field_name, field, new internal::BasicValueConverter<int>));
- }
-
- void RegisterStringField(const std::string& field_name,
- std::string StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, std::string>>(
- field_name, field, new internal::BasicValueConverter<std::string>));
- }
-
- void RegisterStringField(const std::string& field_name,
- std::u16string StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, std::u16string>>(
- field_name, field,
- new internal::BasicValueConverter<std::u16string>));
- }
-
- void RegisterBoolField(const std::string& field_name,
- bool StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, bool>>(
- field_name, field, new internal::BasicValueConverter<bool>));
- }
-
- void RegisterDoubleField(const std::string& field_name,
- double StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, double>>(
- field_name, field, new internal::BasicValueConverter<double>));
- }
-
- template <class NestedType>
- void RegisterNestedField(const std::string& field_name,
- NestedType StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, NestedType>>(
- field_name, field, new internal::NestedValueConverter<NestedType>));
- }
-
- template <typename FieldType>
- void RegisterCustomField(const std::string& field_name,
- FieldType StructType::* field,
- bool (*convert_func)(std::string_view, FieldType*)) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, FieldType>>(
- field_name, field,
- new internal::CustomFieldConverter<FieldType>(convert_func)));
- }
-
- template <typename FieldType>
- void RegisterCustomValueField(const std::string& field_name,
- FieldType StructType::* field,
- bool (*convert_func)(const base::Value*,
- FieldType*)) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<StructType, FieldType>>(
- field_name, field,
- new internal::ValueFieldConverter<FieldType>(convert_func)));
- }
-
- void RegisterRepeatedInt(
- const std::string& field_name,
- std::vector<std::unique_ptr<int>> StructType::* field) {
- fields_.push_back(std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<int>>>>(
- field_name, field, new internal::RepeatedValueConverter<int>));
- }
-
- void RegisterRepeatedString(
- const std::string& field_name,
- std::vector<std::unique_ptr<std::string>> StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<std::string>>>>(
- field_name, field,
- new internal::RepeatedValueConverter<std::string>));
- }
-
- void RegisterRepeatedString(
- const std::string& field_name,
- std::vector<std::unique_ptr<std::u16string>> StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<std::u16string>>>>(
- field_name, field,
- new internal::RepeatedValueConverter<std::u16string>));
- }
-
- void RegisterRepeatedDouble(
- const std::string& field_name,
- std::vector<std::unique_ptr<double>> StructType::* field) {
- fields_.push_back(std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<double>>>>(
- field_name, field, new internal::RepeatedValueConverter<double>));
- }
-
- void RegisterRepeatedBool(
- const std::string& field_name,
- std::vector<std::unique_ptr<bool>> StructType::* field) {
- fields_.push_back(std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<bool>>>>(
- field_name, field, new internal::RepeatedValueConverter<bool>));
- }
-
- template <class NestedType>
- void RegisterRepeatedCustomValue(
- const std::string& field_name,
- std::vector<std::unique_ptr<NestedType>> StructType::* field,
- bool (*convert_func)(const base::Value*, NestedType*)) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<NestedType>>>>(
- field_name, field,
- new internal::RepeatedCustomValueConverter<NestedType>(
- convert_func)));
- }
-
- template <class NestedType>
- void RegisterRepeatedMessage(
- const std::string& field_name,
- std::vector<std::unique_ptr<NestedType>> StructType::* field) {
- fields_.push_back(
- std::make_unique<internal::FieldConverter<
- StructType, std::vector<std::unique_ptr<NestedType>>>>(
- field_name, field,
- new internal::RepeatedMessageConverter<NestedType>));
- }
-
- bool Convert(const base::Value& value, StructType* output) const {
- const DictionaryValue* dictionary_value = NULL;
- if (!value.GetAsDictionary(&dictionary_value))
- return false;
-
- for (size_t i = 0; i < fields_.size(); ++i) {
- const internal::FieldConverterBase<StructType>* field_converter =
- fields_[i].get();
- const base::Value* field = NULL;
- if (dictionary_value->Get(field_converter->field_path(), &field)) {
- if (!field_converter->ConvertField(*field, output)) {
- return false;
- }
- }
- }
- return true;
- }
-
- private:
- std::vector<std::unique_ptr<internal::FieldConverterBase<StructType>>>
- fields_;
-
- JSONValueConverter(const JSONValueConverter&) = delete;
- JSONValueConverter& operator=(const JSONValueConverter&) = delete;
-};
-
-} // namespace base
-
-#endif // BASE_JSON_JSON_VALUE_CONVERTER_H_
diff --git a/src/base/mac/bundle_locations.h b/src/base/mac/bundle_locations.h
deleted file mode 100644
index 2bda76e..0000000
--- a/src/base/mac/bundle_locations.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef BASE_MAC_BUNDLE_LOCATIONS_H_
-#define BASE_MAC_BUNDLE_LOCATIONS_H_
-
-#include "base/files/file_path.h"
-
-#if defined(__OBJC__)
-#import <Foundation/Foundation.h>
-#else // __OBJC__
-class NSBundle;
-#endif // __OBJC__
-
-namespace base {
-
-class FilePath;
-
-namespace mac {
-
-// This file provides several functions to explicitly request the various
-// component bundles of Chrome. Please use these methods rather than calling
-// +[NSBundle mainBundle] or CFBundleGetMainBundle().
-//
-// Terminology
-// - "Outer Bundle" - This is the main bundle for Chrome; it's what
-// +[NSBundle mainBundle] returns when Chrome is launched normally.
-//
-// - "Main Bundle" - This is the bundle from which Chrome was launched.
-// This will be the same as the outer bundle except when Chrome is launched
-// via an app shortcut, in which case this will return the app shortcut's
-// bundle rather than the main Chrome bundle.
-//
-// - "Framework Bundle" - This is the bundle corresponding to the Chrome
-// framework.
-//
-// Guidelines for use:
-// - To access a resource, the Framework bundle should be used.
-// - If the choice is between the Outer or Main bundles then please choose
-// carefully. Most often the Outer bundle will be the right choice, but for
-// cases such as adding an app to the "launch on startup" list, the Main
-// bundle is probably the one to use.
-
-// Methods for retrieving the various bundles.
-NSBundle* MainBundle();
-FilePath MainBundlePath();
-NSBundle* OuterBundle();
-FilePath OuterBundlePath();
-NSBundle* FrameworkBundle();
-FilePath FrameworkBundlePath();
-
-// Set the bundle that the preceding functions will return, overriding the
-// default values. Restore the default by passing in |nil|.
-void SetOverrideOuterBundle(NSBundle* bundle);
-void SetOverrideFrameworkBundle(NSBundle* bundle);
-
-// Same as above but accepting a FilePath argument.
-void SetOverrideOuterBundlePath(const FilePath& file_path);
-void SetOverrideFrameworkBundlePath(const FilePath& file_path);
-
-} // namespace mac
-} // namespace base
-
-#endif // BASE_MAC_BUNDLE_LOCATIONS_H_
diff --git a/src/base/mac/mac_logging.h b/src/base/mac/mac_logging.h
deleted file mode 100644
index 4a7fd62..0000000
--- a/src/base/mac/mac_logging.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef BASE_MAC_MAC_LOGGING_H_
-#define BASE_MAC_MAC_LOGGING_H_
-
-#include "base/logging.h"
-#include "util/build_config.h"
-
-#if defined(OS_IOS)
-#include <MacTypes.h>
-#else
-#include <libkern/OSTypes.h>
-#endif
-
-// Use the OSSTATUS_LOG family to log messages related to errors in Mac OS X
-// system routines that report status via an OSStatus or OSErr value. It is
-// similar to the PLOG family which operates on errno, but because there is no
-// global (or thread-local) OSStatus or OSErr value, the specific error must
-// be supplied as an argument to the OSSTATUS_LOG macro. The message logged
-// will contain the symbolic constant name corresponding to the status value,
-// along with the value itself.
-//
-// OSErr is just an older 16-bit form of the newer 32-bit OSStatus. Despite
-// the name, OSSTATUS_LOG can be used equally well for OSStatus and OSErr.
-
-namespace logging {
-
-// Returns a UTF8 description from an OS X Status error.
-std::string DescriptionFromOSStatus(OSStatus err);
-
-class OSStatusLogMessage : public logging::LogMessage {
- public:
- OSStatusLogMessage(const char* file_path,
- int line,
- LogSeverity severity,
- OSStatus status);
- ~OSStatusLogMessage();
-
- private:
- OSStatus status_;
-
- OSStatusLogMessage(const OSStatusLogMessage&) = delete;
- OSStatusLogMessage& operator=(const OSStatusLogMessage&) = delete;
-};
-
-} // namespace logging
-
-#define OSSTATUS_LOG_STREAM(severity, status) \
- COMPACT_GOOGLE_LOG_EX_##severity(OSStatusLogMessage, status).stream()
-
-#define OSSTATUS_LOG(severity, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), LOG_IS_ON(severity))
-#define OSSTATUS_LOG_IF(severity, condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), \
- LOG_IS_ON(severity) && (condition))
-
-#define OSSTATUS_CHECK(condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(FATAL, status), !(condition)) \
- << "Check failed: " #condition << ". "
-
-#define OSSTATUS_DLOG(severity, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), DLOG_IS_ON(severity))
-#define OSSTATUS_DLOG_IF(severity, condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(severity, status), \
- DLOG_IS_ON(severity) && (condition))
-
-#define OSSTATUS_DCHECK(condition, status) \
- LAZY_STREAM(OSSTATUS_LOG_STREAM(FATAL, status), \
- DCHECK_IS_ON() && !(condition)) \
- << "Check failed: " #condition << ". "
-
-#endif // BASE_MAC_MAC_LOGGING_H_
diff --git a/src/base/mac/mac_logging.mm b/src/base/mac/mac_logging.mm
deleted file mode 100644
index f7c3052..0000000
--- a/src/base/mac/mac_logging.mm
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2012 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.
-
-#include "base/mac/mac_logging.h"
-
-#import <Foundation/Foundation.h>
-
-#include <iomanip>
-
-#include "util/build_config.h"
-
-#if !defined(OS_IOS)
-#include <CoreServices/CoreServices.h>
-#endif
-
-namespace logging {
-
-std::string DescriptionFromOSStatus(OSStatus err) {
- NSError* error =
- [NSError errorWithDomain:NSOSStatusErrorDomain code:err userInfo:nil];
- return error.description.UTF8String;
-}
-
-OSStatusLogMessage::OSStatusLogMessage(const char* file_path,
- int line,
- LogSeverity severity,
- OSStatus status)
- : LogMessage(file_path, line, severity), status_(status) {}
-
-OSStatusLogMessage::~OSStatusLogMessage() {
-#if defined(OS_IOS)
- // TODO(crbug.com/546375): Consider using NSError with NSOSStatusErrorDomain
- // to try to get a description of the failure.
- stream() << ": " << status_;
-#else
- stream() << ": " << DescriptionFromOSStatus(status_) << " (" << status_
- << ")";
-#endif
-}
-
-} // namespace logging
diff --git a/src/base/memory/free_deleter.h b/src/base/memory/free_deleter.h
deleted file mode 100644
index e12795c..0000000
--- a/src/base/memory/free_deleter.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef BASE_MEMORY_FREE_DELETER_H_
-#define BASE_MEMORY_FREE_DELETER_H_
-
-#include <stdlib.h>
-
-namespace base {
-
-// Function object which invokes 'free' on its parameter, which must be
-// a pointer. Can be used to store malloc-allocated pointers in std::unique_ptr:
-//
-// std::unique_ptr<int, base::FreeDeleter> foo_ptr(
-// static_cast<int*>(malloc(sizeof(int))));
-struct FreeDeleter {
- inline void operator()(void* ptr) const { free(ptr); }
-};
-
-} // namespace base
-
-#endif // BASE_MEMORY_FREE_DELETER_H_
diff --git a/src/base/memory/raw_scoped_refptr_mismatch_checker.h b/src/base/memory/raw_scoped_refptr_mismatch_checker.h
deleted file mode 100644
index 95b9c11..0000000
--- a/src/base/memory/raw_scoped_refptr_mismatch_checker.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef BASE_MEMORY_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
-#define BASE_MEMORY_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
-
-#include <type_traits>
-
-#include "base/template_util.h"
-
-// It is dangerous to post a task with a T* argument where T is a subtype of
-// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
-// object may already have been deleted since it was not held with a
-// scoped_refptr. Example: http://crbug.com/27191
-// The following set of traits are designed to generate a compile error
-// whenever this antipattern is attempted.
-
-namespace base {
-
-// This is a base internal implementation file used by task.h and callback.h.
-// Not for public consumption, so we wrap it in namespace internal.
-namespace internal {
-
-template <typename T, typename = void>
-struct IsRefCountedType : std::false_type {};
-
-template <typename T>
-struct IsRefCountedType<T,
- std::void_t<decltype(std::declval<T*>()->AddRef()),
- decltype(std::declval<T*>()->Release())>>
- : std::true_type {};
-
-template <typename T>
-struct NeedsScopedRefptrButGetsRawPtr {
- static_assert(!std::is_reference<T>::value,
- "NeedsScopedRefptrButGetsRawPtr requires non-reference type.");
-
- enum {
- // Human readable translation: you needed to be a scoped_refptr if you are a
- // raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase)
- // type.
- value = std::is_pointer<T>::value &&
- IsRefCountedType<std::remove_pointer_t<T>>::value
- };
-};
-
-} // namespace internal
-
-} // namespace base
-
-#endif // BASE_MEMORY_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
diff --git a/src/base/memory/weak_ptr.cc b/src/base/memory/weak_ptr.cc
deleted file mode 100644
index 4abeb7f..0000000
--- a/src/base/memory/weak_ptr.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "base/memory/weak_ptr.h"
-
-namespace base {
-namespace internal {
-
-WeakReference::Flag::Flag() : is_valid_(true) {}
-
-void WeakReference::Flag::Invalidate() {
- is_valid_ = false;
-}
-
-bool WeakReference::Flag::IsValid() const {
- return is_valid_;
-}
-
-WeakReference::Flag::~Flag() = default;
-
-WeakReference::WeakReference() = default;
-
-WeakReference::WeakReference(const scoped_refptr<Flag>& flag) : flag_(flag) {}
-
-WeakReference::~WeakReference() = default;
-
-WeakReference::WeakReference(WeakReference&& other) = default;
-
-WeakReference::WeakReference(const WeakReference& other) = default;
-
-bool WeakReference::is_valid() const {
- return flag_ && flag_->IsValid();
-}
-
-WeakReferenceOwner::WeakReferenceOwner() = default;
-
-WeakReferenceOwner::~WeakReferenceOwner() {
- Invalidate();
-}
-
-WeakReference WeakReferenceOwner::GetRef() const {
- // If we hold the last reference to the Flag then create a new one.
- if (!HasRefs())
- flag_ = new WeakReference::Flag();
-
- return WeakReference(flag_);
-}
-
-void WeakReferenceOwner::Invalidate() {
- if (flag_) {
- flag_->Invalidate();
- flag_ = nullptr;
- }
-}
-
-WeakPtrBase::WeakPtrBase() : ptr_(0) {}
-
-WeakPtrBase::~WeakPtrBase() = default;
-
-WeakPtrBase::WeakPtrBase(const WeakReference& ref, uintptr_t ptr)
- : ref_(ref), ptr_(ptr) {
- DCHECK(ptr_);
-}
-
-WeakPtrFactoryBase::WeakPtrFactoryBase(uintptr_t ptr) : ptr_(ptr) {
- DCHECK(ptr_);
-}
-
-WeakPtrFactoryBase::~WeakPtrFactoryBase() {
- ptr_ = 0;
-}
-
-} // namespace internal
-} // namespace base
diff --git a/src/base/memory/weak_ptr.h b/src/base/memory/weak_ptr.h
deleted file mode 100644
index 55a9fe1..0000000
--- a/src/base/memory/weak_ptr.h
+++ /dev/null
@@ -1,380 +0,0 @@
-// Copyright (c) 2012 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.
-
-// Weak pointers are pointers to an object that do not affect its lifetime,
-// and which may be invalidated (i.e. reset to nullptr) by the object, or its
-// owner, at any time, most commonly when the object is about to be deleted.
-
-// Weak pointers are useful when an object needs to be accessed safely by one
-// or more objects other than its owner, and those callers can cope with the
-// object vanishing and e.g. tasks posted to it being silently dropped.
-// Reference-counting such an object would complicate the ownership graph and
-// make it harder to reason about the object's lifetime.
-
-// EXAMPLE:
-//
-// class Controller {
-// public:
-// Controller() : weak_factory_(this) {}
-// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
-// void WorkComplete(const Result& result) { ... }
-// private:
-// // Member variables should appear before the WeakPtrFactory, to ensure
-// // that any WeakPtrs to Controller are invalidated before its members
-// // variable's destructors are executed, rendering them invalid.
-// WeakPtrFactory<Controller> weak_factory_;
-// };
-//
-// class Worker {
-// public:
-// static void StartNew(const WeakPtr<Controller>& controller) {
-// Worker* worker = new Worker(controller);
-// // Kick off asynchronous processing...
-// }
-// private:
-// Worker(const WeakPtr<Controller>& controller)
-// : controller_(controller) {}
-// void DidCompleteAsynchronousProcessing(const Result& result) {
-// if (controller_)
-// controller_->WorkComplete(result);
-// }
-// WeakPtr<Controller> controller_;
-// };
-//
-// With this implementation a caller may use SpawnWorker() to dispatch multiple
-// Workers and subsequently delete the Controller, without waiting for all
-// Workers to have completed.
-
-// ------------------------- IMPORTANT: Thread-safety -------------------------
-
-// Weak pointers may be passed safely between threads, but must always be
-// dereferenced and invalidated on the same SequencedTaskRunner otherwise
-// checking the pointer would be racey.
-//
-// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory
-// is dereferenced, the factory and its WeakPtrs become bound to the calling
-// thread or current SequencedWorkerPool token, and cannot be dereferenced or
-// invalidated on any other task runner. Bound WeakPtrs can still be handed
-// off to other task runners, e.g. to use to post tasks back to object on the
-// bound sequence.
-//
-// If all WeakPtr objects are destroyed or invalidated then the factory is
-// unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be
-// destroyed, or new WeakPtr objects may be used, from a different sequence.
-//
-// Thus, at least one WeakPtr object must exist and have been dereferenced on
-// the correct thread to enforce that other WeakPtr objects will enforce they
-// are used on the desired thread.
-
-#ifndef BASE_MEMORY_WEAK_PTR_H_
-#define BASE_MEMORY_WEAK_PTR_H_
-
-#include <cstddef>
-#include <type_traits>
-
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-
-namespace base {
-
-template <typename T>
-class SupportsWeakPtr;
-template <typename T>
-class WeakPtr;
-
-namespace internal {
-// These classes are part of the WeakPtr implementation.
-// DO NOT USE THESE CLASSES DIRECTLY YOURSELF.
-
-class WeakReference {
- public:
- // Although Flag is bound to a specific SequencedTaskRunner, it may be
- // deleted from another via base::WeakPtr::~WeakPtr().
- class Flag : public RefCountedThreadSafe<Flag> {
- public:
- Flag();
-
- void Invalidate();
- bool IsValid() const;
-
- private:
- friend class base::RefCountedThreadSafe<Flag>;
-
- ~Flag();
-
- bool is_valid_;
- };
-
- WeakReference();
- explicit WeakReference(const scoped_refptr<Flag>& flag);
- ~WeakReference();
-
- WeakReference(WeakReference&& other);
- WeakReference(const WeakReference& other);
- WeakReference& operator=(WeakReference&& other) = default;
- WeakReference& operator=(const WeakReference& other) = default;
-
- bool is_valid() const;
-
- private:
- scoped_refptr<const Flag> flag_;
-};
-
-class WeakReferenceOwner {
- public:
- WeakReferenceOwner();
- ~WeakReferenceOwner();
-
- WeakReference GetRef() const;
-
- bool HasRefs() const { return flag_ && !flag_->HasOneRef(); }
-
- void Invalidate();
-
- private:
- mutable scoped_refptr<WeakReference::Flag> flag_;
-};
-
-// This class simplifies the implementation of WeakPtr's type conversion
-// constructor by avoiding the need for a public accessor for ref_. A
-// WeakPtr<T> cannot access the private members of WeakPtr<U>, so this
-// base class gives us a way to access ref_ in a protected fashion.
-class WeakPtrBase {
- public:
- WeakPtrBase();
- ~WeakPtrBase();
-
- WeakPtrBase(const WeakPtrBase& other) = default;
- WeakPtrBase(WeakPtrBase&& other) = default;
- WeakPtrBase& operator=(const WeakPtrBase& other) = default;
- WeakPtrBase& operator=(WeakPtrBase&& other) = default;
-
- void reset() {
- ref_ = internal::WeakReference();
- ptr_ = 0;
- }
-
- protected:
- WeakPtrBase(const WeakReference& ref, uintptr_t ptr);
-
- WeakReference ref_;
-
- // This pointer is only valid when ref_.is_valid() is true. Otherwise, its
- // value is undefined (as opposed to nullptr).
- uintptr_t ptr_;
-};
-
-// This class provides a common implementation of common functions that would
-// otherwise get instantiated separately for each distinct instantiation of
-// SupportsWeakPtr<>.
-class SupportsWeakPtrBase {
- public:
- // A safe static downcast of a WeakPtr<Base> to WeakPtr<Derived>. This
- // conversion will only compile if there is exists a Base which inherits
- // from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
- // function that makes calling this easier.
- //
- // Precondition: t != nullptr
- template <typename Derived>
- static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
- static_assert(
- std::is_base_of<internal::SupportsWeakPtrBase, Derived>::value,
- "AsWeakPtr argument must inherit from SupportsWeakPtr");
- return AsWeakPtrImpl<Derived>(t);
- }
-
- private:
- // This template function uses type inference to find a Base of Derived
- // which is an instance of SupportsWeakPtr<Base>. We can then safely
- // static_cast the Base* to a Derived*.
- template <typename Derived, typename Base>
- static WeakPtr<Derived> AsWeakPtrImpl(SupportsWeakPtr<Base>* t) {
- WeakPtr<Base> ptr = t->AsWeakPtr();
- return WeakPtr<Derived>(
- ptr.ref_, static_cast<Derived*>(reinterpret_cast<Base*>(ptr.ptr_)));
- }
-};
-
-} // namespace internal
-
-template <typename T>
-class WeakPtrFactory;
-
-// The WeakPtr class holds a weak reference to |T*|.
-//
-// This class is designed to be used like a normal pointer. You should always
-// null-test an object of this class before using it or invoking a method that
-// may result in the underlying object being destroyed.
-//
-// EXAMPLE:
-//
-// class Foo { ... };
-// WeakPtr<Foo> foo;
-// if (foo)
-// foo->method();
-//
-template <typename T>
-class WeakPtr : public internal::WeakPtrBase {
- public:
- WeakPtr() = default;
-
- WeakPtr(std::nullptr_t) {}
-
- // Allow conversion from U to T provided U "is a" T. Note that this
- // is separate from the (implicit) copy and move constructors.
- template <typename U>
- WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other) {
- // Need to cast from U* to T* to do pointer adjustment in case of multiple
- // inheritance. This also enforces the "U is a T" rule.
- T* t = reinterpret_cast<U*>(other.ptr_);
- ptr_ = reinterpret_cast<uintptr_t>(t);
- }
- template <typename U>
- WeakPtr(WeakPtr<U>&& other) : WeakPtrBase(std::move(other)) {
- // Need to cast from U* to T* to do pointer adjustment in case of multiple
- // inheritance. This also enforces the "U is a T" rule.
- T* t = reinterpret_cast<U*>(other.ptr_);
- ptr_ = reinterpret_cast<uintptr_t>(t);
- }
-
- T* get() const {
- return ref_.is_valid() ? reinterpret_cast<T*>(ptr_) : nullptr;
- }
-
- T& operator*() const {
- DCHECK(get() != nullptr);
- return *get();
- }
- T* operator->() const {
- DCHECK(get() != nullptr);
- return get();
- }
-
- // Allow conditionals to test validity, e.g. if (weak_ptr) {...};
- explicit operator bool() const { return get() != nullptr; }
-
- private:
- friend class internal::SupportsWeakPtrBase;
- template <typename U>
- friend class WeakPtr;
- friend class SupportsWeakPtr<T>;
- friend class WeakPtrFactory<T>;
-
- WeakPtr(const internal::WeakReference& ref, T* ptr)
- : WeakPtrBase(ref, reinterpret_cast<uintptr_t>(ptr)) {}
-};
-
-// Allow callers to compare WeakPtrs against nullptr to test validity.
-template <class T>
-bool operator!=(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
- return !(weak_ptr == nullptr);
-}
-template <class T>
-bool operator!=(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
- return weak_ptr != nullptr;
-}
-template <class T>
-bool operator==(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
- return weak_ptr.get() == nullptr;
-}
-template <class T>
-bool operator==(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
- return weak_ptr == nullptr;
-}
-
-namespace internal {
-class WeakPtrFactoryBase {
- protected:
- WeakPtrFactoryBase(uintptr_t ptr);
- ~WeakPtrFactoryBase();
- internal::WeakReferenceOwner weak_reference_owner_;
- uintptr_t ptr_;
-};
-} // namespace internal
-
-// A class may be composed of a WeakPtrFactory and thereby
-// control how it exposes weak pointers to itself. This is helpful if you only
-// need weak pointers within the implementation of a class. This class is also
-// useful when working with primitive types. For example, you could have a
-// WeakPtrFactory<bool> that is used to pass around a weak reference to a bool.
-template <class T>
-class WeakPtrFactory : public internal::WeakPtrFactoryBase {
- public:
- explicit WeakPtrFactory(T* ptr)
- : WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}
-
- ~WeakPtrFactory() = default;
-
- WeakPtr<T> GetWeakPtr() {
- return WeakPtr<T>(weak_reference_owner_.GetRef(),
- reinterpret_cast<T*>(ptr_));
- }
-
- // Call this method to invalidate all existing weak pointers.
- void InvalidateWeakPtrs() {
- DCHECK(ptr_);
- weak_reference_owner_.Invalidate();
- }
-
- // Call this method to determine if any weak pointers exist.
- bool HasWeakPtrs() const {
- DCHECK(ptr_);
- return weak_reference_owner_.HasRefs();
- }
-
- private:
- WeakPtrFactory() = delete;
- WeakPtrFactory(const WeakPtrFactory&) = delete;
- WeakPtrFactory& operator=(const WeakPtrFactory&) = delete;
-};
-
-// A class may extend from SupportsWeakPtr to let others take weak pointers to
-// it. This avoids the class itself implementing boilerplate to dispense weak
-// pointers. However, since SupportsWeakPtr's destructor won't invalidate
-// weak pointers to the class until after the derived class' members have been
-// destroyed, its use can lead to subtle use-after-destroy issues.
-template <class T>
-class SupportsWeakPtr : public internal::SupportsWeakPtrBase {
- public:
- SupportsWeakPtr() = default;
-
- WeakPtr<T> AsWeakPtr() {
- return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
- }
-
- protected:
- ~SupportsWeakPtr() = default;
-
- private:
- internal::WeakReferenceOwner weak_reference_owner_;
- SupportsWeakPtr(const SupportsWeakPtr&) = delete;
- SupportsWeakPtr& operator=(const SupportsWeakPtr&) = delete;
-};
-
-// Helper function that uses type deduction to safely return a WeakPtr<Derived>
-// when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it
-// extends a Base that extends SupportsWeakPtr<Base>.
-//
-// EXAMPLE:
-// class Base : public base::SupportsWeakPtr<Producer> {};
-// class Derived : public Base {};
-//
-// Derived derived;
-// base::WeakPtr<Derived> ptr = base::AsWeakPtr(&derived);
-//
-// Note that the following doesn't work (invalid type conversion) since
-// Derived::AsWeakPtr() is WeakPtr<Base> SupportsWeakPtr<Base>::AsWeakPtr(),
-// and there's no way to safely cast WeakPtr<Base> to WeakPtr<Derived> at
-// the caller.
-//
-// base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails.
-
-template <typename Derived>
-WeakPtr<Derived> AsWeakPtr(Derived* t) {
- return internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
-}
-
-} // namespace base
-
-#endif // BASE_MEMORY_WEAK_PTR_H_
diff --git a/src/base/numerics/math_constants.h b/src/base/numerics/math_constants.h
deleted file mode 100644
index 9a5b8ef..0000000
--- a/src/base/numerics/math_constants.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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.
-
-#ifndef BASE_NUMERICS_MATH_CONSTANTS_H_
-#define BASE_NUMERICS_MATH_CONSTANTS_H_
-
-namespace base {
-
-constexpr double kPiDouble = 3.14159265358979323846;
-constexpr float kPiFloat = 3.14159265358979323846f;
-
-} // namespace base
-
-#endif // BASE_NUMERICS_MATH_CONSTANTS_H_
diff --git a/src/base/numerics/ranges.h b/src/base/numerics/ranges.h
deleted file mode 100644
index f19320c..0000000
--- a/src/base/numerics/ranges.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// 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.
-
-#ifndef BASE_NUMERICS_RANGES_H_
-#define BASE_NUMERICS_RANGES_H_
-
-#include <algorithm>
-#include <cmath>
-
-namespace base {
-
-// To be replaced with std::clamp() from C++17, someday.
-template <class T>
-constexpr const T& ClampToRange(const T& value, const T& min, const T& max) {
- return std::min(std::max(value, min), max);
-}
-
-template <typename T>
-constexpr bool IsApproximatelyEqual(T lhs, T rhs, T tolerance) {
- static_assert(std::is_arithmetic<T>::value, "Argument must be arithmetic");
- return std::abs(rhs - lhs) <= tolerance;
-}
-
-} // namespace base
-
-#endif // BASE_NUMERICS_RANGES_H_
diff --git a/src/base/strings/utf_offset_string_conversions.cc b/src/base/strings/utf_offset_string_conversions.cc
deleted file mode 100644
index 6f2aaf4..0000000
--- a/src/base/strings/utf_offset_string_conversions.cc
+++ /dev/null
@@ -1,266 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "base/strings/utf_offset_string_conversions.h"
-
-#include <stdint.h>
-
-#include <algorithm>
-#include <memory>
-#include <string_view>
-
-#include "base/logging.h"
-#include "base/strings/utf_string_conversion_utils.h"
-
-namespace base {
-
-OffsetAdjuster::Adjustment::Adjustment(size_t original_offset,
- size_t original_length,
- size_t output_length)
- : original_offset(original_offset),
- original_length(original_length),
- output_length(output_length) {}
-
-// static
-void OffsetAdjuster::AdjustOffsets(const Adjustments& adjustments,
- std::vector<size_t>* offsets_for_adjustment,
- size_t limit) {
- DCHECK(offsets_for_adjustment);
- for (std::vector<size_t>::iterator i(offsets_for_adjustment->begin());
- i != offsets_for_adjustment->end(); ++i)
- AdjustOffset(adjustments, &(*i), limit);
-}
-
-// static
-void OffsetAdjuster::AdjustOffset(const Adjustments& adjustments,
- size_t* offset,
- size_t limit) {
- DCHECK(offset);
- if (*offset == std::u16string::npos)
- return;
- int adjustment = 0;
- for (Adjustments::const_iterator i = adjustments.begin();
- i != adjustments.end(); ++i) {
- if (*offset <= i->original_offset)
- break;
- if (*offset < (i->original_offset + i->original_length)) {
- *offset = std::u16string::npos;
- return;
- }
- adjustment += static_cast<int>(i->original_length - i->output_length);
- }
- *offset -= adjustment;
-
- if (*offset > limit)
- *offset = std::u16string::npos;
-}
-
-// static
-void OffsetAdjuster::UnadjustOffsets(
- const Adjustments& adjustments,
- std::vector<size_t>* offsets_for_unadjustment) {
- if (!offsets_for_unadjustment || adjustments.empty())
- return;
- for (std::vector<size_t>::iterator i(offsets_for_unadjustment->begin());
- i != offsets_for_unadjustment->end(); ++i)
- UnadjustOffset(adjustments, &(*i));
-}
-
-// static
-void OffsetAdjuster::UnadjustOffset(const Adjustments& adjustments,
- size_t* offset) {
- if (*offset == std::u16string::npos)
- return;
- int adjustment = 0;
- for (Adjustments::const_iterator i = adjustments.begin();
- i != adjustments.end(); ++i) {
- if (*offset + adjustment <= i->original_offset)
- break;
- adjustment += static_cast<int>(i->original_length - i->output_length);
- if ((*offset + adjustment) < (i->original_offset + i->original_length)) {
- *offset = std::u16string::npos;
- return;
- }
- }
- *offset += adjustment;
-}
-
-// static
-void OffsetAdjuster::MergeSequentialAdjustments(
- const Adjustments& first_adjustments,
- Adjustments* adjustments_on_adjusted_string) {
- Adjustments::iterator adjusted_iter = adjustments_on_adjusted_string->begin();
- Adjustments::const_iterator first_iter = first_adjustments.begin();
- // Simultaneously iterate over all |adjustments_on_adjusted_string| and
- // |first_adjustments|, adding adjustments to or correcting the adjustments
- // in |adjustments_on_adjusted_string| as we go. |shift| keeps track of the
- // current number of characters collapsed by |first_adjustments| up to this
- // point. |currently_collapsing| keeps track of the number of characters
- // collapsed by |first_adjustments| into the current |adjusted_iter|'s
- // length. These are characters that will change |shift| as soon as we're
- // done processing the current |adjusted_iter|; they are not yet reflected in
- // |shift|.
- size_t shift = 0;
- size_t currently_collapsing = 0;
- while (adjusted_iter != adjustments_on_adjusted_string->end()) {
- if ((first_iter == first_adjustments.end()) ||
- ((adjusted_iter->original_offset + shift +
- adjusted_iter->original_length) <= first_iter->original_offset)) {
- // Entire |adjusted_iter| (accounting for its shift and including its
- // whole original length) comes before |first_iter|.
- //
- // Correct the offset at |adjusted_iter| and move onto the next
- // adjustment that needs revising.
- adjusted_iter->original_offset += shift;
- shift += currently_collapsing;
- currently_collapsing = 0;
- ++adjusted_iter;
- } else if ((adjusted_iter->original_offset + shift) >
- first_iter->original_offset) {
- // |first_iter| comes before the |adjusted_iter| (as adjusted by |shift|).
-
- // It's not possible for the adjustments to overlap. (It shouldn't
- // be possible that we have an |adjusted_iter->original_offset| that,
- // when adjusted by the computed |shift|, is in the middle of
- // |first_iter|'s output's length. After all, that would mean the
- // current adjustment_on_adjusted_string somehow points to an offset
- // that was supposed to have been eliminated by the first set of
- // adjustments.)
- DCHECK_LE(first_iter->original_offset + first_iter->output_length,
- adjusted_iter->original_offset + shift);
-
- // Add the |first_adjustment_iter| to the full set of adjustments while
- // making sure |adjusted_iter| continues pointing to the same element.
- // We do this by inserting the |first_adjustment_iter| right before
- // |adjusted_iter|, then incrementing |adjusted_iter| so it points to
- // the following element.
- shift += first_iter->original_length - first_iter->output_length;
- adjusted_iter =
- adjustments_on_adjusted_string->insert(adjusted_iter, *first_iter);
- ++adjusted_iter;
- ++first_iter;
- } else {
- // The first adjustment adjusted something that then got further adjusted
- // by the second set of adjustments. In other words, |first_iter| points
- // to something in the range covered by |adjusted_iter|'s length (after
- // accounting for |shift|). Precisely,
- // adjusted_iter->original_offset + shift
- // <=
- // first_iter->original_offset
- // <=
- // adjusted_iter->original_offset + shift +
- // adjusted_iter->original_length
-
- // Modify the current |adjusted_iter| to include whatever collapsing
- // happened in |first_iter|, then advance to the next |first_adjustments|
- // because we dealt with the current one.
- const int collapse = static_cast<int>(first_iter->original_length) -
- static_cast<int>(first_iter->output_length);
- // This function does not know how to deal with a string that expands and
- // then gets modified, only strings that collapse and then get modified.
- DCHECK_GT(collapse, 0);
- adjusted_iter->original_length += collapse;
- currently_collapsing += collapse;
- ++first_iter;
- }
- }
- DCHECK_EQ(0u, currently_collapsing);
- if (first_iter != first_adjustments.end()) {
- // Only first adjustments are left. These do not need to be modified.
- // (Their offsets are already correct with respect to the original string.)
- // Append them all.
- DCHECK(adjusted_iter == adjustments_on_adjusted_string->end());
- adjustments_on_adjusted_string->insert(
- adjustments_on_adjusted_string->end(), first_iter,
- first_adjustments.end());
- }
-}
-
-// Converts the given source Unicode character type to the given destination
-// Unicode character type as a STL string. The given input buffer and size
-// determine the source, and the given output STL string will be replaced by
-// the result. If non-NULL, |adjustments| is set to reflect the all the
-// alterations to the string that are not one-character-to-one-character.
-// It will always be sorted by increasing offset.
-template <typename SrcChar, typename DestStdString>
-bool ConvertUnicode(const SrcChar* src,
- size_t src_len,
- DestStdString* output,
- OffsetAdjuster::Adjustments* adjustments) {
- if (adjustments)
- adjustments->clear();
- // ICU requires 32-bit numbers.
- bool success = true;
- int32_t src_len32 = static_cast<int32_t>(src_len);
- for (int32_t i = 0; i < src_len32; i++) {
- uint32_t code_point;
- size_t original_i = i;
- size_t chars_written = 0;
- if (ReadUnicodeCharacter(src, src_len32, &i, &code_point)) {
- chars_written = WriteUnicodeCharacter(code_point, output);
- } else {
- chars_written = WriteUnicodeCharacter(0xFFFD, output);
- success = false;
- }
-
- // Only bother writing an adjustment if this modification changed the
- // length of this character.
- // NOTE: ReadUnicodeCharacter() adjusts |i| to point _at_ the last
- // character read, not after it (so that incrementing it in the loop
- // increment will place it at the right location), so we need to account
- // for that in determining the amount that was read.
- if (adjustments && ((i - original_i + 1) != chars_written)) {
- adjustments->push_back(OffsetAdjuster::Adjustment(
- original_i, i - original_i + 1, chars_written));
- }
- }
- return success;
-}
-
-bool UTF8ToUTF16WithAdjustments(
- const char* src,
- size_t src_len,
- std::u16string* output,
- base::OffsetAdjuster::Adjustments* adjustments) {
- PrepareForUTF16Or32Output(src, src_len, output);
- return ConvertUnicode(src, src_len, output, adjustments);
-}
-
-std::u16string UTF8ToUTF16WithAdjustments(
- std::string_view utf8,
- base::OffsetAdjuster::Adjustments* adjustments) {
- std::u16string result;
- UTF8ToUTF16WithAdjustments(utf8.data(), utf8.length(), &result, adjustments);
- return result;
-}
-
-std::u16string UTF8ToUTF16AndAdjustOffsets(
- std::string_view utf8,
- std::vector<size_t>* offsets_for_adjustment) {
- for (size_t& offset : *offsets_for_adjustment) {
- if (offset > utf8.length())
- offset = std::u16string::npos;
- }
- OffsetAdjuster::Adjustments adjustments;
- std::u16string result = UTF8ToUTF16WithAdjustments(utf8, &adjustments);
- OffsetAdjuster::AdjustOffsets(adjustments, offsets_for_adjustment);
- return result;
-}
-
-std::string UTF16ToUTF8AndAdjustOffsets(
- std::u16string_view utf16,
- std::vector<size_t>* offsets_for_adjustment) {
- for (size_t& offset : *offsets_for_adjustment) {
- if (offset > utf16.length())
- offset = std::u16string::npos;
- }
- std::string result;
- PrepareForUTF8Output(utf16.data(), utf16.length(), &result);
- OffsetAdjuster::Adjustments adjustments;
- ConvertUnicode(utf16.data(), utf16.length(), &result, &adjustments);
- OffsetAdjuster::AdjustOffsets(adjustments, offsets_for_adjustment);
- return result;
-}
-
-} // namespace base
diff --git a/src/base/strings/utf_offset_string_conversions.h b/src/base/strings/utf_offset_string_conversions.h
deleted file mode 100644
index 0562e01..0000000
--- a/src/base/strings/utf_offset_string_conversions.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2011 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.
-
-#ifndef BASE_STRINGS_UTF_OFFSET_STRING_CONVERSIONS_H_
-#define BASE_STRINGS_UTF_OFFSET_STRING_CONVERSIONS_H_
-
-#include <stddef.h>
-
-#include <string>
-#include <string_view>
-#include <vector>
-
-namespace base {
-
-// A helper class and associated data structures to adjust offsets into a
-// string in response to various adjustments one might do to that string
-// (e.g., eliminating a range). For details on offsets, see the comments by
-// the AdjustOffsets() function below.
-class OffsetAdjuster {
- public:
- struct Adjustment {
- Adjustment(size_t original_offset,
- size_t original_length,
- size_t output_length);
-
- size_t original_offset;
- size_t original_length;
- size_t output_length;
- };
- typedef std::vector<Adjustment> Adjustments;
-
- // Adjusts all offsets in |offsets_for_adjustment| to reflect the adjustments
- // recorded in |adjustments|. Adjusted offsets greater than |limit| will be
- // set to std::u16string::npos.
- //
- // Offsets represents insertion/selection points between characters: if |src|
- // is "abcd", then 0 is before 'a', 2 is between 'b' and 'c', and 4 is at the
- // end of the string. Valid input offsets range from 0 to |src_len|. On
- // exit, each offset will have been modified to point at the same logical
- // position in the output string. If an offset cannot be successfully
- // adjusted (e.g., because it points into the middle of a multibyte sequence),
- // it will be set to std::u16string::npos.
- static void AdjustOffsets(const Adjustments& adjustments,
- std::vector<size_t>* offsets_for_adjustment,
- size_t limit = std::u16string::npos);
-
- // Adjusts the single |offset| to reflect the adjustments recorded in
- // |adjustments|.
- static void AdjustOffset(const Adjustments& adjustments,
- size_t* offset,
- size_t limit = std::u16string::npos);
-
- // Adjusts all offsets in |offsets_for_unadjustment| to reflect the reverse
- // of the adjustments recorded in |adjustments|. In other words, the offsets
- // provided represent offsets into an adjusted string and the caller wants
- // to know the offsets they correspond to in the original string. If an
- // offset cannot be successfully unadjusted (e.g., because it points into
- // the middle of a multibyte sequence), it will be set to
- // std::u16string::npos.
- static void UnadjustOffsets(const Adjustments& adjustments,
- std::vector<size_t>* offsets_for_unadjustment);
-
- // Adjusts the single |offset| to reflect the reverse of the adjustments
- // recorded in |adjustments|.
- static void UnadjustOffset(const Adjustments& adjustments, size_t* offset);
-
- // Combines two sequential sets of adjustments, storing the combined revised
- // adjustments in |adjustments_on_adjusted_string|. That is, suppose a
- // string was altered in some way, with the alterations recorded as
- // adjustments in |first_adjustments|. Then suppose the resulting string is
- // further altered, with the alterations recorded as adjustments scored in
- // |adjustments_on_adjusted_string|, with the offsets recorded in these
- // adjustments being with respect to the intermediate string. This function
- // combines the two sets of adjustments into one, storing the result in
- // |adjustments_on_adjusted_string|, whose offsets are correct with respect
- // to the original string.
- //
- // Assumes both parameters are sorted by increasing offset.
- //
- // WARNING: Only supports |first_adjustments| that involve collapsing ranges
- // of text, not expanding ranges.
- static void MergeSequentialAdjustments(
- const Adjustments& first_adjustments,
- Adjustments* adjustments_on_adjusted_string);
-};
-
-// Like the conversions in utf_string_conversions.h, but also fills in an
-// |adjustments| parameter that reflects the alterations done to the string.
-// It may be NULL.
-bool UTF8ToUTF16WithAdjustments(const char* src,
- size_t src_len,
- std::u16string* output,
- base::OffsetAdjuster::Adjustments* adjustments);
-std::u16string UTF8ToUTF16WithAdjustments(
- std::string_view utf8,
- base::OffsetAdjuster::Adjustments* adjustments);
-// As above, but instead internally examines the adjustments and applies them
-// to |offsets_for_adjustment|. Input offsets greater than the length of the
-// input string will be set to std::u16string::npos. See comments by
-// AdjustOffsets().
-std::u16string UTF8ToUTF16AndAdjustOffsets(
- std::string_view utf8,
- std::vector<size_t>* offsets_for_adjustment);
-std::string UTF16ToUTF8AndAdjustOffsets(
- std::u16string_view utf16,
- std::vector<size_t>* offsets_for_adjustment);
-
-} // namespace base
-
-#endif // BASE_STRINGS_UTF_OFFSET_STRING_CONVERSIONS_H_