From 1c68b123c6953a35dc8b58ecf3bc33d4bd3bd621 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 3 Aug 2016 12:54:48 -0700 Subject: [PATCH] Reland "Remove more //base dependencies" (#2857)" Hopefully this will build this time. --- sky/engine/bindings/dart_mojo_internal.h | 4 +-- sky/engine/bindings/dart_runtime_hooks.cc | 9 +++---- sky/engine/bindings/dart_runtime_hooks.h | 4 +-- sky/engine/bindings/dart_ui.h | 4 +-- sky/engine/bindings/mojo_services.h | 3 ++- sky/engine/core/script/dart_controller.h | 4 +-- .../core/script/dart_service_isolate.cc | 26 +++++++++---------- sky/engine/core/script/embedder_resources.cc | 12 +++++---- sky/engine/core/text/TextBox.cpp | 4 +-- sky/engine/platform/exported/sky_settings.cc | 17 ++++++------ .../platform/fonts/FontFallbackList.cpp | 2 -- .../platform/fonts/apple/FontCacheIOS.mm | 10 +++---- sky/engine/platform/mojo/data_pipe.cc | 3 ++- sky/engine/public/sky/sky_view.cc | 2 +- sky/engine/public/sky/sky_view.h | 7 ++--- sky/engine/wtf/BUILD.gn | 4 +++ sky/engine/wtf/dtoa/bignum.h | 2 +- sky/engine/wtf/dtoa/double-conversion.h | 4 +-- sky/engine/wtf/dtoa/utils.h | 5 ++-- 19 files changed, 64 insertions(+), 62 deletions(-) diff --git a/sky/engine/bindings/dart_mojo_internal.h b/sky/engine/bindings/dart_mojo_internal.h index 208d6d412..32fe9567e 100644 --- a/sky/engine/bindings/dart_mojo_internal.h +++ b/sky/engine/bindings/dart_mojo_internal.h @@ -5,7 +5,7 @@ #ifndef SKY_ENGINE_BINDINGS_DART_MOJO_INTERNAL_H_ #define SKY_ENGINE_BINDINGS_DART_MOJO_INTERNAL_H_ -#include "base/macros.h" +#include "lib/ftl/macros.h" #include "mojo/public/cpp/system/handle.h" namespace blink { @@ -17,7 +17,7 @@ class DartMojoInternal { static void SetHandleWatcherProducerHandle(MojoHandle handle); private: - DISALLOW_IMPLICIT_CONSTRUCTORS(DartMojoInternal); + FTL_DISALLOW_IMPLICIT_CONSTRUCTORS(DartMojoInternal); }; } // namespace blink diff --git a/sky/engine/bindings/dart_runtime_hooks.cc b/sky/engine/bindings/dart_runtime_hooks.cc index b16419903..e36ac01bf 100644 --- a/sky/engine/bindings/dart_runtime_hooks.cc +++ b/sky/engine/bindings/dart_runtime_hooks.cc @@ -8,10 +8,6 @@ #include #include -#include "base/bind.h" -#include "base/logging.h" -#include "base/macros.h" -#include "base/time/time.h" #include "dart/runtime/bin/embedded_dart_io.h" #include "dart/runtime/include/dart_api.h" #include "dart/runtime/include/dart_tools_api.h" @@ -23,6 +19,7 @@ #include "flutter/tonic/dart_library_natives.h" #include "flutter/tonic/dart_microtask_queue.h" #include "flutter/tonic/dart_state.h" +#include "lib/ftl/logging.h" #include "sky/engine/core/script/ui_dart_state.h" #include "sky/engine/wtf/text/WTFString.h" @@ -86,7 +83,7 @@ static void InitDartInternal(Dart_Handle builtin_library, DART_CHECK_VALID(isolate_lib); DART_CHECK_VALID(Dart_Invoke(isolate_lib, method_name, 0, NULL)); } else { - CHECK(isolate_type == DartRuntimeHooks::SecondaryIsolate); + FTL_CHECK(isolate_type == DartRuntimeHooks::SecondaryIsolate); Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io")); DART_CHECK_VALID(io_lib); Dart_Handle setup_hooks = Dart_NewStringFromCString("_setupHooks"); @@ -111,7 +108,7 @@ static void InitDartAsync(Dart_Handle builtin_library, schedule_microtask = GetClosure(builtin_library, "_getScheduleMicrotaskClosure"); } else { - CHECK(isolate_type == DartRuntimeHooks::SecondaryIsolate); + FTL_CHECK(isolate_type == DartRuntimeHooks::SecondaryIsolate); Dart_Handle isolate_lib = Dart_LookupLibrary(ToDart("dart:isolate")); Dart_Handle method_name = Dart_NewStringFromCString("_getIsolateScheduleImmediateClosure"); diff --git a/sky/engine/bindings/dart_runtime_hooks.h b/sky/engine/bindings/dart_runtime_hooks.h index 505c98279..993565e93 100644 --- a/sky/engine/bindings/dart_runtime_hooks.h +++ b/sky/engine/bindings/dart_runtime_hooks.h @@ -5,9 +5,9 @@ #ifndef SKY_ENGINE_BINDINGS_DART_RUNTIME_HOOKS_H_ #define SKY_ENGINE_BINDINGS_DART_RUNTIME_HOOKS_H_ -#include "base/macros.h" #include "dart/runtime/include/dart_api.h" #include "flutter/tonic/dart_library_natives.h" +#include "lib/ftl/macros.h" namespace blink { @@ -22,7 +22,7 @@ class DartRuntimeHooks { static void RegisterNatives(DartLibraryNatives* natives); private: - DISALLOW_IMPLICIT_CONSTRUCTORS(DartRuntimeHooks); + FTL_DISALLOW_IMPLICIT_CONSTRUCTORS(DartRuntimeHooks); }; } // namespace blink diff --git a/sky/engine/bindings/dart_ui.h b/sky/engine/bindings/dart_ui.h index 3e19fcfc0..9cc9efa04 100644 --- a/sky/engine/bindings/dart_ui.h +++ b/sky/engine/bindings/dart_ui.h @@ -5,7 +5,7 @@ #ifndef SKY_ENGINE_BINDINGS_DART_UI_H_ #define SKY_ENGINE_BINDINGS_DART_UI_H_ -#include "base/macros.h" +#include "lib/ftl/macros.h" namespace blink { @@ -15,7 +15,7 @@ class DartUI { static void InitForIsolate(); private: - DISALLOW_IMPLICIT_CONSTRUCTORS(DartUI); + FTL_DISALLOW_IMPLICIT_CONSTRUCTORS(DartUI); }; } // namespace blink diff --git a/sky/engine/bindings/mojo_services.h b/sky/engine/bindings/mojo_services.h index 05a32167e..75a4e8298 100644 --- a/sky/engine/bindings/mojo_services.h +++ b/sky/engine/bindings/mojo_services.h @@ -6,6 +6,7 @@ #define SKY_ENGINE_BINDINGS_MOJO_SERVICES_H_ #include "dart/runtime/include/dart_api.h" +#include "lib/ftl/macros.h" #include "mojo/public/cpp/application/service_provider_impl.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" #include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h" @@ -51,7 +52,7 @@ class MojoServices { // https://github.com/domokit/mojo/issues/536 mojo::ServiceProviderPtr services_from_dart_; - MOJO_DISALLOW_COPY_AND_ASSIGN(MojoServices); + FTL_DISALLOW_COPY_AND_ASSIGN(MojoServices); }; } // namespace blink diff --git a/sky/engine/core/script/dart_controller.h b/sky/engine/core/script/dart_controller.h index 779a35ca5..7c978b394 100644 --- a/sky/engine/core/script/dart_controller.h +++ b/sky/engine/core/script/dart_controller.h @@ -8,9 +8,9 @@ #include #include "base/callback_forward.h" -#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "dart/runtime/include/dart_api.h" +#include "lib/ftl/macros.h" #include "mojo/public/cpp/system/data_pipe.h" #include "sky/engine/wtf/OwnPtr.h" #include "sky/engine/wtf/text/AtomicString.h" @@ -55,7 +55,7 @@ class DartController { base::WeakPtrFactory weak_factory_; - DISALLOW_COPY_AND_ASSIGN(DartController); + FTL_DISALLOW_COPY_AND_ASSIGN(DartController); }; } diff --git a/sky/engine/core/script/dart_service_isolate.cc b/sky/engine/core/script/dart_service_isolate.cc index 6ebd685f3..795b7aa07 100644 --- a/sky/engine/core/script/dart_service_isolate.cc +++ b/sky/engine/core/script/dart_service_isolate.cc @@ -4,11 +4,11 @@ #include "dart_service_isolate.h" -#include "base/logging.h" #include "dart/runtime/include/dart_api.h" #include "flutter/tonic/dart_converter.h" #include "flutter/tonic/dart_error.h" #include "flutter/tonic/dart_library_natives.h" +#include "lib/ftl/logging.h" #include "sky/engine/core/script/embedder_resources.h" #define RETURN_ERROR_HANDLE(handle) \ @@ -44,12 +44,12 @@ static int observatory_port_; Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, bool* auto_setup_scope) { - CHECK(g_natives); + FTL_CHECK(g_natives); return g_natives->GetNativeFunction(name, argument_count, auto_setup_scope); } const uint8_t* GetSymbol(Dart_NativeFunction native_function) { - CHECK(g_natives); + FTL_CHECK(g_natives); return g_natives->GetSymbol(native_function); } @@ -57,9 +57,9 @@ const uint8_t* GetSymbol(Dart_NativeFunction native_function) { void DartServiceIsolate::TriggerResourceLoad(Dart_NativeArguments args) { Dart_Handle library = Dart_RootLibrary(); - DCHECK(!Dart_IsError(library)); + FTL_DCHECK(!Dart_IsError(library)); Dart_Handle result = LoadResources(library); - DCHECK(!Dart_IsError(result)); + FTL_DCHECK(!Dart_IsError(result)); } void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) { @@ -85,11 +85,11 @@ bool DartServiceIsolate::Startup(std::string server_ip, bool disable_origin_check, char** error) { Dart_Isolate isolate = Dart_CurrentIsolate(); - CHECK(isolate); + FTL_CHECK(isolate); // Remember the embedder's library tag handler. g_embedder_tag_handler = embedder_tag_handler; - CHECK(g_embedder_tag_handler); + FTL_CHECK(g_embedder_tag_handler); // Setup native entries. if (!g_natives) { @@ -120,7 +120,7 @@ bool DartServiceIsolate::Startup(std::string server_ip, Dart_SetLibraryTagHandler(DartServiceIsolate::LibraryTagHandler); // Load main script. Dart_Handle library = LoadScript(kServiceIsolateScript); - DCHECK(library != Dart_Null()); + FTL_DCHECK(library != Dart_Null()); SHUTDOWN_ON_ERROR(library); // Setup native entry resolution. result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol); @@ -205,7 +205,7 @@ Dart_Handle DartServiceIsolate::LoadResource(Dart_Handle library, const char* data_buffer = NULL; int data_buffer_length = g_resources->ResourceLookup(resource_name, &data_buffer); - DCHECK(data_buffer_length != EmbedderResources::kNoSuchInstance); + FTL_DCHECK(data_buffer_length != EmbedderResources::kNoSuchInstance); Dart_Handle data_list = Dart_NewTypedData(Dart_TypedData_kUint8, data_buffer_length); RETURN_ERROR_HANDLE(data_list); @@ -216,9 +216,9 @@ Dart_Handle DartServiceIsolate::LoadResource(Dart_Handle library, &data_list_buffer, &data_list_buffer_length); RETURN_ERROR_HANDLE(result); - DCHECK(data_buffer_length == data_list_buffer_length); - DCHECK(data_list_buffer != NULL); - DCHECK(type = Dart_TypedData_kUint8); + FTL_DCHECK(data_buffer_length == data_list_buffer_length); + FTL_DCHECK(data_list_buffer != NULL); + FTL_DCHECK(type = Dart_TypedData_kUint8); memmove(data_list_buffer, &data_buffer[0], data_buffer_length); result = Dart_TypedDataReleaseData(data_list); RETURN_ERROR_HANDLE(result); @@ -272,7 +272,7 @@ Dart_Handle DartServiceIsolate::LibraryTagHandler(Dart_LibraryTag tag, // Embedder handles all requests for external libraries. return g_embedder_tag_handler(tag, library, url); } - DCHECK((tag == Dart_kSourceTag) || (tag == Dart_kCanonicalizeUrl)); + FTL_DCHECK((tag == Dart_kSourceTag) || (tag == Dart_kCanonicalizeUrl)); if (tag == Dart_kCanonicalizeUrl) { // url is already canonicalized. return url; diff --git a/sky/engine/core/script/embedder_resources.cc b/sky/engine/core/script/embedder_resources.cc index ecbb0d01d..a96677a5b 100644 --- a/sky/engine/core/script/embedder_resources.cc +++ b/sky/engine/core/script/embedder_resources.cc @@ -4,7 +4,9 @@ #include "sky/engine/core/script/embedder_resources.h" -#include "base/logging.h" +#include + +#include "lib/ftl/logging.h" namespace blink { @@ -20,7 +22,7 @@ int EmbedderResources::ResourceLookup(const char* path, const char** resource) { const ResourcesEntry& entry = resources_table_[i]; if (strcmp(path, entry.path_) == 0) { *resource = entry.resource_; - DCHECK(entry.length_ > 0); + FTL_DCHECK(entry.length_ > 0); return entry.length_; } } @@ -28,17 +30,17 @@ int EmbedderResources::ResourceLookup(const char* path, const char** resource) { } const char* EmbedderResources::Path(int idx) { - DCHECK(idx >= 0); + FTL_DCHECK(idx >= 0); ResourcesEntry* entry = At(idx); if (entry == nullptr) { return nullptr; } - DCHECK(entry->path_ != nullptr); + FTL_DCHECK(entry->path_ != nullptr); return entry->path_; } ResourcesEntry* EmbedderResources::At(int idx) { - DCHECK(idx >= 0); + FTL_DCHECK(idx >= 0); for (int i = 0; resources_table_[i].path_ != nullptr; i++) { if (idx == i) { return &resources_table_[i]; diff --git a/sky/engine/core/text/TextBox.cpp b/sky/engine/core/text/TextBox.cpp index 185370df3..c8f40be27 100644 --- a/sky/engine/core/text/TextBox.cpp +++ b/sky/engine/core/text/TextBox.cpp @@ -4,9 +4,9 @@ #include "sky/engine/core/text/TextBox.h" -#include "base/logging.h" #include "flutter/tonic/dart_class_library.h" #include "flutter/tonic/dart_error.h" +#include "lib/ftl/logging.h" #include "sky/engine/core/script/ui_dart_state.h" namespace blink { @@ -17,7 +17,7 @@ Dart_Handle DartConverter::ToDart(const TextBox& val) { DartClassLibrary& class_library = DartState::Current()->class_library(); Dart_Handle type = Dart_HandleFromPersistent( class_library.GetClass("ui", "TextBox")); - DCHECK(!LogIfError(type)); + FTL_DCHECK(!LogIfError(type)); const int argc = 5; Dart_Handle argv[argc] = { blink::ToDart(val.sk_rect.fLeft), diff --git a/sky/engine/platform/exported/sky_settings.cc b/sky/engine/platform/exported/sky_settings.cc index fbda26cc6..8ad3f0d19 100644 --- a/sky/engine/platform/exported/sky_settings.cc +++ b/sky/engine/platform/exported/sky_settings.cc @@ -6,23 +6,24 @@ #include -#include "base/lazy_instance.h" -#include "base/logging.h" +#include "lib/ftl/logging.h" namespace blink { +namespace { -static base::LazyInstance s_settings = LAZY_INSTANCE_INITIALIZER; +SkySettings* g_settings = nullptr; -static bool s_have_settings = false; +} // namespace const SkySettings& SkySettings::Get() { - return s_settings.Get(); + FTL_CHECK(g_settings); + return *g_settings; } void SkySettings::Set(const SkySettings& settings) { - CHECK(!s_have_settings); - s_settings.Get() = settings; - s_have_settings = true; + FTL_CHECK(!g_settings); + g_settings = new SkySettings(); + *g_settings = settings; } } // namespace blink diff --git a/sky/engine/platform/fonts/FontFallbackList.cpp b/sky/engine/platform/fonts/FontFallbackList.cpp index bc2ab098a..02c8b24e8 100644 --- a/sky/engine/platform/fonts/FontFallbackList.cpp +++ b/sky/engine/platform/fonts/FontFallbackList.cpp @@ -34,8 +34,6 @@ #include "sky/engine/platform/fonts/SegmentedFontData.h" #include "sky/engine/wtf/unicode/CharacterNames.h" -#include "base/logging.h" - namespace blink { FontFallbackList::FontFallbackList() diff --git a/sky/engine/platform/fonts/apple/FontCacheIOS.mm b/sky/engine/platform/fonts/apple/FontCacheIOS.mm index 8353d0b66..07e73144d 100644 --- a/sky/engine/platform/fonts/apple/FontCacheIOS.mm +++ b/sky/engine/platform/fonts/apple/FontCacheIOS.mm @@ -33,12 +33,12 @@ #import #import -#include "sky/engine/platform/fonts/FontCache.h" -#include "base/mac/scoped_nsautorelease_pool.h" -#include "base/mac/scoped_nsobject.h" #include "base/lazy_instance.h" -#include "base/macros.h" #include "base/logging.h" +#include "base/mac/scoped_nsautorelease_pool.h" +#include "base/mac/scoped_nsobject.h" +#include "lib/ftl/macros.h" +#include "sky/engine/platform/fonts/FontCache.h" namespace blink { @@ -129,7 +129,7 @@ class FontFallbackSelector { private: CFRef _prototype; - DISALLOW_COPY_AND_ASSIGN(FontFallbackSelector); + FTL_DISALLOW_COPY_AND_ASSIGN(FontFallbackSelector); }; static base::LazyInstance g_fallback_selector = diff --git a/sky/engine/platform/mojo/data_pipe.cc b/sky/engine/platform/mojo/data_pipe.cc index 0843e2613..60f4f3723 100644 --- a/sky/engine/platform/mojo/data_pipe.cc +++ b/sky/engine/platform/mojo/data_pipe.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "lib/ftl/macros.h" #include "mojo/data_pipe_utils/data_pipe_drainer.h" #include "sky/engine/platform/mojo/data_pipe.h" #include "sky/engine/public/platform/Platform.h" @@ -41,7 +42,7 @@ class DrainJob : public mojo::common::DataPipeDrainer::Client { RefPtr buffer_; std::unique_ptr drainer_; - DISALLOW_COPY_AND_ASSIGN(DrainJob); + FTL_DISALLOW_COPY_AND_ASSIGN(DrainJob); }; } // namespace diff --git a/sky/engine/public/sky/sky_view.cc b/sky/engine/public/sky/sky_view.cc index 93563ef1c..0ab7cc69f 100644 --- a/sky/engine/public/sky/sky_view.cc +++ b/sky/engine/public/sky/sky_view.cc @@ -20,7 +20,7 @@ std::unique_ptr SkyView::Create(SkyViewClient* client) { } SkyView::SkyView(SkyViewClient* client) - : client_(client), weak_factory_(this) {} + : client_(client) {} SkyView::~SkyView() {} diff --git a/sky/engine/public/sky/sky_view.h b/sky/engine/public/sky/sky_view.h index 87dda54af..ef6346e76 100644 --- a/sky/engine/public/sky/sky_view.h +++ b/sky/engine/public/sky/sky_view.h @@ -7,9 +7,8 @@ #include -#include "base/memory/weak_ptr.h" -#include "base/time/time.h" #include "flow/layers/layer_tree.h" +#include "lib/ftl/macros.h" #include "mojo/public/cpp/system/data_pipe.h" #include "mojo/services/network/interfaces/url_loader.mojom.h" #include "sky/engine/bindings/flutter_dart_state.h" @@ -71,9 +70,7 @@ class SkyView : public WindowClient, public IsolateClient { std::string country_code_; std::unique_ptr dart_controller_; - base::WeakPtrFactory weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(SkyView); + FTL_DISALLOW_COPY_AND_ASSIGN(SkyView); }; } // namespace blink diff --git a/sky/engine/wtf/BUILD.gn b/sky/engine/wtf/BUILD.gn index 9b4592c80..3e55b851d 100644 --- a/sky/engine/wtf/BUILD.gn +++ b/sky/engine/wtf/BUILD.gn @@ -187,6 +187,10 @@ component("wtf") { direct_dependent_configs = [ "//sky/engine:features" ] + public_deps = [ + "//lib/ftl", + ] + deps = [ "//base", "//third_party/icu", diff --git a/sky/engine/wtf/dtoa/bignum.h b/sky/engine/wtf/dtoa/bignum.h index b6ed62bee..ec540f549 100644 --- a/sky/engine/wtf/dtoa/bignum.h +++ b/sky/engine/wtf/dtoa/bignum.h @@ -135,7 +135,7 @@ namespace double_conversion { // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize). int exponent_; - DISALLOW_COPY_AND_ASSIGN(Bignum); + FTL_DISALLOW_COPY_AND_ASSIGN(Bignum); }; } // namespace double_conversion diff --git a/sky/engine/wtf/dtoa/double-conversion.h b/sky/engine/wtf/dtoa/double-conversion.h index dc1a741d5..0d3b3bf2e 100644 --- a/sky/engine/wtf/dtoa/double-conversion.h +++ b/sky/engine/wtf/dtoa/double-conversion.h @@ -355,7 +355,7 @@ namespace double_conversion { const int max_leading_padding_zeroes_in_precision_mode_; const int max_trailing_padding_zeroes_in_precision_mode_; - DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); + FTL_DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); }; @@ -367,7 +367,7 @@ namespace double_conversion { static double StringToDouble(const char* buffer, size_t length, size_t* processed_characters_count); private: - DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); + FTL_DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); }; } // namespace double_conversion diff --git a/sky/engine/wtf/dtoa/utils.h b/sky/engine/wtf/dtoa/utils.h index 962fbac21..7a4e673b7 100644 --- a/sky/engine/wtf/dtoa/utils.h +++ b/sky/engine/wtf/dtoa/utils.h @@ -29,7 +29,8 @@ #define SKY_ENGINE_WTF_DTOA_UTILS_H_ #include -#include "base/macros.h" + +#include "lib/ftl/macros.h" #include "sky/engine/wtf/Assertions.h" #define UNIMPLEMENTED ASSERT_NOT_REACHED @@ -220,7 +221,7 @@ namespace double_conversion { bool is_finalized() const { return position_ < 0; } - DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); + FTL_DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); }; // The type-based aliasing rule allows the compiler to assume that pointers of -- GitLab