Import logging utilities from FXL. (#5310)

This commit is contained in:
Chinmay Garde 2018-05-18 15:43:49 -07:00 committed by GitHub
parent 088e1c00ad
commit fbf07dc332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 472 additions and 84 deletions

View File

@ -7,19 +7,26 @@ source_set("fml") {
"build_config.h",
"compiler_specific.h",
"eintr_wrapper.h",
"export.h",
"file.h",
"icu_util.cc",
"icu_util.h",
"log_level.h",
"log_settings.cc",
"log_settings.h",
"log_settings_state.cc",
"logging.cc",
"logging.h",
"mapping.cc",
"mapping.h",
"memory/thread_checker.h",
"memory/weak_ptr.h",
"memory/weak_ptr_internal.cc",
"memory/weak_ptr_internal.h",
"memory/ref_counted.h",
"memory/ref_counted_internal.h",
"memory/ref_ptr.h",
"memory/ref_ptr_internal.h",
"memory/thread_checker.h",
"memory/weak_ptr.h",
"memory/weak_ptr_internal.cc",
"memory/weak_ptr_internal.h",
"message_loop.cc",
"message_loop.h",
"message_loop_impl.cc",
@ -136,8 +143,8 @@ executable("fml_unittests") {
testonly = true
sources = [
"memory/weak_ptr_unittest.cc",
"memory/ref_counted_unittest.cc",
"memory/weak_ptr_unittest.cc",
"message_loop_unittests.cc",
"thread_local_unittests.cc",
"thread_unittests.cc",

16
fml/export.h Normal file
View File

@ -0,0 +1,16 @@
// Copyright 2017 The Fuchsia 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 FLUTTER_FML_EXPORT_H_
#define FLUTTER_FML_EXPORT_H_
#include "flutter/fml/build_config.h"
#if OS_WIN
#define FML_EXPORT __declspec(dllimport)
#else
#define FML_EXPORT __attribute__((visibility("default")))
#endif
#endif // FLUTTER_FML_EXPORT_H_

View File

@ -8,9 +8,9 @@
#include <mutex>
#include "flutter/fml/build_config.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/mapping.h"
#include "flutter/fml/paths.h"
#include "lib/fxl/logging.h"
#include "third_party/icu/source/common/unicode/udata.h"
namespace fml {
@ -92,7 +92,7 @@ class ICUContext {
void InitializeICUOnce(const std::string& icu_data_path) {
static ICUContext* context = new ICUContext(icu_data_path);
FXL_CHECK(context->IsValid())
FML_CHECK(context->IsValid())
<< "Must be able to initialize the ICU context. Tried: " << icu_data_path;
}

28
fml/log_level.h Normal file
View File

@ -0,0 +1,28 @@
// Copyright 2016 The Fuchsia 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 FLUTTER_FML_LOG_LEVEL_H_
#define FLUTTER_FML_LOG_LEVEL_H_
namespace fml {
typedef int LogSeverity;
// Default log levels. Negative values can be used for verbose log levels.
constexpr LogSeverity LOG_INFO = 0;
constexpr LogSeverity LOG_WARNING = 1;
constexpr LogSeverity LOG_ERROR = 2;
constexpr LogSeverity LOG_FATAL = 3;
constexpr LogSeverity LOG_NUM_SEVERITIES = 4;
// LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode
#ifdef NDEBUG
const LogSeverity LOG_DFATAL = LOG_ERROR;
#else
const LogSeverity LOG_DFATAL = LOG_FATAL;
#endif
} // namespace fml
#endif // FLUTTER_FML_LOG_LEVEL_H_

37
fml/log_settings.cc Normal file
View File

@ -0,0 +1,37 @@
// Copyright 2016 The Fuchsia 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 "flutter/fml/log_settings.h"
#include <fcntl.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include "flutter/fml/logging.h"
namespace fml {
namespace state {
// Defined in log_settings_state.cc.
extern LogSettings g_log_settings;
} // namespace state
void SetLogSettings(const LogSettings& settings) {
// Validate the new settings as we set them.
state::g_log_settings.min_log_level =
std::min(LOG_FATAL, settings.min_log_level);
}
LogSettings GetLogSettings() {
return state::g_log_settings;
}
int GetMinLogLevel() {
return std::min(state::g_log_settings.min_log_level, LOG_FATAL);
}
} // namespace fml

40
fml/log_settings.h Normal file
View File

@ -0,0 +1,40 @@
// Copyright 2016 The Fuchsia 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 FLUTTER_FML_LOG_SETTINGS_H_
#define FLUTTER_FML_LOG_SETTINGS_H_
#include "flutter/fml/log_level.h"
#include <string>
namespace fml {
// Settings which control the behavior of FML logging.
struct LogSettings {
// The minimum logging level.
// Anything at or above this level will be logged (if applicable).
// Anything below this level will be silently ignored.
//
// The log level defaults to 0 (LOG_INFO).
//
// Log messages for FML_VLOG(x) (from flutter/fml/logging.h) are logged
// at level -x, so setting the min log level to negative values enables
// verbose logging.
LogSeverity min_log_level = LOG_INFO;
};
// Gets the active log settings for the current process.
void SetLogSettings(const LogSettings& settings);
// Sets the active log settings for the current process.
LogSettings GetLogSettings();
// Gets the minimum log level for the current process. Never returs a value
// higher than LOG_FATAL.
int GetMinLogLevel();
} // namespace fml
#endif // FLUTTER_FML_LOG_SETTINGS_H_

14
fml/log_settings_state.cc Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2016 The Fuchsia 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 "flutter/fml/log_settings.h"
namespace fml {
namespace state {
// Declared in log_settings.cc.
LogSettings g_log_settings;
} // namespace state
} // namespace fml

104
fml/logging.cc Normal file
View File

@ -0,0 +1,104 @@
// Copyright 2016 The Fuchsia 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 <algorithm>
#include <iostream>
#include "flutter/fml/build_config.h"
#include "flutter/fml/log_settings.h"
#include "flutter/fml/logging.h"
#if defined(OS_ANDROID)
#include <android/log.h>
#elif defined(OS_IOS)
#include <syslog.h>
#endif
namespace fml {
namespace {
const char* const kLogSeverityNames[LOG_NUM_SEVERITIES] = {"INFO", "WARNING",
"ERROR", "FATAL"};
const char* GetNameForLogSeverity(LogSeverity severity) {
if (severity >= LOG_INFO && severity < LOG_NUM_SEVERITIES)
return kLogSeverityNames[severity];
return "UNKNOWN";
}
const char* StripDots(const char* path) {
while (strncmp(path, "../", 3) == 0)
path += 3;
return path;
}
const char* StripPath(const char* path) {
auto p = strrchr(path, '/');
if (p)
return p + 1;
else
return path;
}
} // namespace
LogMessage::LogMessage(LogSeverity severity,
const char* file,
int line,
const char* condition)
: severity_(severity), file_(file), line_(line) {
stream_ << "[";
if (severity >= LOG_INFO)
stream_ << GetNameForLogSeverity(severity);
else
stream_ << "VERBOSE" << -severity;
stream_ << ":" << (severity > LOG_INFO ? StripDots(file_) : StripPath(file_))
<< "(" << line_ << ")] ";
if (condition)
stream_ << "Check failed: " << condition << ". ";
}
LogMessage::~LogMessage() {
stream_ << std::endl;
#if defined(OS_ANDROID)
android_LogPriority priority =
(severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN;
switch (severity_) {
case LOG_INFO:
priority = ANDROID_LOG_INFO;
break;
case LOG_WARNING:
priority = ANDROID_LOG_WARN;
break;
case LOG_ERROR:
priority = ANDROID_LOG_ERROR;
break;
case LOG_FATAL:
priority = ANDROID_LOG_FATAL;
break;
}
__android_log_write(priority, "flutter", stream_.str().c_str());
#elif defined(OS_IOS)
syslog(LOG_ALERT, "%s", stream_.str().c_str());
#else
std::cerr << stream_.str();
std::cerr.flush();
#endif
if (severity_ >= LOG_FATAL) {
abort();
}
}
int GetVlogVerbosity() {
return std::max(-1, LOG_INFO - GetMinLogLevel());
}
bool ShouldCreateLogMessage(LogSeverity severity) {
return severity >= GetMinLogLevel();
}
} // namespace fml

95
fml/logging.h Normal file
View File

@ -0,0 +1,95 @@
// Copyright 2016 The Fuchsia 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 FLUTTER_FML_LOGGING_H_
#define FLUTTER_FML_LOGGING_H_
#include <sstream>
#include "flutter/fml/log_level.h"
#include "flutter/fml/macros.h"
namespace fml {
class LogMessageVoidify {
public:
void operator&(std::ostream&) {}
};
class LogMessage {
public:
LogMessage(LogSeverity severity,
const char* file,
int line,
const char* condition);
~LogMessage();
std::ostream& stream() { return stream_; }
private:
std::ostringstream stream_;
const LogSeverity severity_;
const char* file_;
const int line_;
FML_DISALLOW_COPY_AND_ASSIGN(LogMessage);
};
// Gets the FML_VLOG default verbosity level.
int GetVlogVerbosity();
// Returns true if |severity| is at or above the current minimum log level.
// LOG_FATAL and above is always true.
bool ShouldCreateLogMessage(LogSeverity severity);
} // namespace fml
#define FML_LOG_STREAM(severity) \
::fml::LogMessage(::fml::LOG_##severity, __FILE__, __LINE__, nullptr).stream()
#define FML_LAZY_STREAM(stream, condition) \
!(condition) ? (void)0 : ::fml::LogMessageVoidify() & (stream)
#define FML_EAT_STREAM_PARAMETERS(ignored) \
true || (ignored) \
? (void)0 \
: ::fml::LogMessageVoidify() & \
::fml::LogMessage(::fml::LOG_FATAL, 0, 0, nullptr).stream()
#define FML_LOG_IS_ON(severity) \
(::fml::ShouldCreateLogMessage(::fml::LOG_##severity))
#define FML_LOG(severity) \
FML_LAZY_STREAM(FML_LOG_STREAM(severity), FML_LOG_IS_ON(severity))
#define FML_CHECK(condition) \
FML_LAZY_STREAM( \
::fml::LogMessage(::fml::LOG_FATAL, __FILE__, __LINE__, #condition) \
.stream(), \
!(condition))
#define FML_VLOG_IS_ON(verbose_level) \
((verbose_level) <= ::fml::GetVlogVerbosity())
// The VLOG macros log with negative verbosities.
#define FML_VLOG_STREAM(verbose_level) \
::fml::LogMessage(-verbose_level, __FILE__, __LINE__, nullptr).stream()
#define FML_VLOG(verbose_level) \
FML_LAZY_STREAM(FML_VLOG_STREAM(verbose_level), FML_VLOG_IS_ON(verbose_level))
#ifndef NDEBUG
#define FML_DLOG(severity) FML_LOG(severity)
#define FML_DCHECK(condition) FML_CHECK(condition)
#else
#define FML_DLOG(severity) FML_EAT_STREAM_PARAMETERS(true)
#define FML_DCHECK(condition) FML_EAT_STREAM_PARAMETERS(condition)
#endif
#define FML_NOTREACHED() FML_DCHECK(false)
#define FML_NOTIMPLEMENTED() \
FML_LOG(ERROR) << "Not implemented in: " << __PRETTY_FUNCTION__
#endif // FLUTTER_FML_LOGGING_H_

View File

@ -9,8 +9,8 @@
#include <atomic>
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "lib/fxl/logging.h"
namespace fml {
namespace internal {
@ -20,8 +20,8 @@ class RefCountedThreadSafeBase {
public:
void AddRef() const {
#ifndef NDEBUG
FXL_DCHECK(!adoption_required_);
FXL_DCHECK(!destruction_started_);
FML_DCHECK(!adoption_required_);
FML_DCHECK(!destruction_started_);
#endif
ref_count_.fetch_add(1u, std::memory_order_relaxed);
}
@ -30,7 +30,7 @@ class RefCountedThreadSafeBase {
return ref_count_.load(std::memory_order_acquire) == 1u;
}
void AssertHasOneRef() const { FXL_DCHECK(HasOneRef()); }
void AssertHasOneRef() const { FML_DCHECK(HasOneRef()); }
protected:
RefCountedThreadSafeBase();
@ -39,10 +39,10 @@ class RefCountedThreadSafeBase {
// Returns true if the object should self-delete.
bool Release() const {
#ifndef NDEBUG
FXL_DCHECK(!adoption_required_);
FXL_DCHECK(!destruction_started_);
FML_DCHECK(!adoption_required_);
FML_DCHECK(!destruction_started_);
#endif
FXL_DCHECK(ref_count_.load(std::memory_order_acquire) != 0u);
FML_DCHECK(ref_count_.load(std::memory_order_acquire) != 0u);
// TODO(vtl): We could add the following:
// if (ref_count_.load(std::memory_order_relaxed) == 1u) {
// #ifndef NDEBUG
@ -67,7 +67,7 @@ class RefCountedThreadSafeBase {
#ifndef NDEBUG
void Adopt() {
FXL_DCHECK(adoption_required_);
FML_DCHECK(adoption_required_);
adoption_required_ = false;
}
#endif
@ -95,9 +95,9 @@ inline RefCountedThreadSafeBase::RefCountedThreadSafeBase()
inline RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
#ifndef NDEBUG
FXL_DCHECK(!adoption_required_);
FML_DCHECK(!adoption_required_);
// Should only be destroyed as a result of |Release()|.
FXL_DCHECK(destruction_started_);
FML_DCHECK(destruction_started_);
#endif
}

View File

@ -12,9 +12,9 @@
#include <functional>
#include <utility>
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/memory/ref_ptr_internal.h"
#include "lib/fxl/logging.h"
namespace fml {
@ -107,12 +107,12 @@ class RefPtr final {
T* get() const { return ptr_; }
T& operator*() const {
FXL_DCHECK(ptr_);
FML_DCHECK(ptr_);
return *ptr_;
}
T* operator->() const {
FXL_DCHECK(ptr_);
FML_DCHECK(ptr_);
return ptr_;
}
@ -189,7 +189,7 @@ class RefPtr final {
friend RefPtr<T> AdoptRef<T>(T*);
enum AdoptTag { ADOPT };
RefPtr(T* ptr, AdoptTag) : ptr_(ptr) { FXL_DCHECK(ptr_); }
RefPtr(T* ptr, AdoptTag) : ptr_(ptr) { FML_DCHECK(ptr_); }
T* ptr_;
};

View File

@ -16,8 +16,8 @@
#include <pthread.h>
#endif
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "lib/fxl/logging.h"
namespace fml {
@ -58,7 +58,7 @@ class ThreadChecker final {
#ifndef NDEBUG
#define FML_DECLARE_THREAD_CHECKER(c) fml::ThreadChecker c
#define FML_DCHECK_CREATION_THREAD_IS_CURRENT(c) \
FXL_DCHECK((c).IsCreationThreadCurrent())
FML_DCHECK((c).IsCreationThreadCurrent())
#else
#define FML_DECLARE_THREAD_CHECKER(c)
#define FML_DCHECK_CREATION_THREAD_IS_CURRENT(c) ((void)0)

View File

@ -10,10 +10,10 @@
#include <utility>
#include "flutter/fml/logging.h"
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/memory/thread_checker.h"
#include "flutter/fml/memory/weak_ptr_internal.h"
#include "lib/fxl/logging.h"
namespace fml {
@ -86,13 +86,13 @@ class WeakPtr {
T& operator*() const {
FML_DCHECK_CREATION_THREAD_IS_CURRENT(checker_.checker);
FXL_DCHECK(*this);
FML_DCHECK(*this);
return *get();
}
T* operator->() const {
FML_DCHECK_CREATION_THREAD_IS_CURRENT(checker_.checker);
FXL_DCHECK(*this);
FML_DCHECK(*this);
return get();
}
@ -161,7 +161,7 @@ class WeakPtrFactory {
public:
explicit WeakPtrFactory(T* ptr)
: ptr_(ptr), flag_(fml::MakeRefCounted<fml::internal::WeakPtrFlag>()) {
FXL_DCHECK(ptr_);
FML_DCHECK(ptr_);
}
~WeakPtrFactory() {

View File

@ -4,7 +4,7 @@
#include "flutter/fml/memory/weak_ptr_internal.h"
#include "lib/fxl/logging.h"
#include "flutter/fml/logging.h"
namespace fml {
namespace internal {
@ -13,12 +13,12 @@ WeakPtrFlag::WeakPtrFlag() : is_valid_(true) {}
WeakPtrFlag::~WeakPtrFlag() {
// Should be invalidated before destruction.
FXL_DCHECK(!is_valid_);
FML_DCHECK(!is_valid_);
}
void WeakPtrFlag::Invalidate() {
// Invalidation should happen exactly once.
FXL_DCHECK(is_valid_);
FML_DCHECK(is_valid_);
is_valid_ = false;
}

View File

@ -19,7 +19,7 @@ namespace internal {
// This class in not thread-safe, though references may be released on any
// thread (allowing weak pointers to be destroyed/reset/reassigned on any
// thread).
class FXL_EXPORT WeakPtrFlag : public fml::RefCountedThreadSafe<WeakPtrFlag> {
class WeakPtrFlag : public fml::RefCountedThreadSafe<WeakPtrFlag> {
public:
WeakPtrFlag();

View File

@ -20,7 +20,7 @@ FML_THREAD_LOCAL ThreadLocal tls_message_loop([](intptr_t value) {
MessageLoop& MessageLoop::GetCurrent() {
auto loop = reinterpret_cast<MessageLoop*>(tls_message_loop.Get());
FXL_CHECK(loop != nullptr)
FML_CHECK(loop != nullptr)
<< "MessageLoop::EnsureInitializedForCurrentThread was not called on "
"this thread prior to message loop use.";
return *loop;
@ -41,8 +41,8 @@ bool MessageLoop::IsInitializedForCurrentThread() {
MessageLoop::MessageLoop()
: loop_(MessageLoopImpl::Create()),
task_runner_(fxl::MakeRefCounted<fml::TaskRunner>(loop_)) {
FXL_CHECK(loop_);
FXL_CHECK(task_runner_);
FML_CHECK(loop_);
FML_CHECK(task_runner_);
}
MessageLoop::~MessageLoop() = default;

View File

@ -10,6 +10,7 @@
#include <vector>
#include "flutter/fml/build_config.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/trace_event.h"
#if OS_MACOSX
@ -43,7 +44,7 @@ MessageLoopImpl::MessageLoopImpl() : order_(0), terminated_(false) {}
MessageLoopImpl::~MessageLoopImpl() = default;
void MessageLoopImpl::PostTask(fxl::Closure task, fxl::TimePoint target_time) {
FXL_DCHECK(task != nullptr);
FML_DCHECK(task != nullptr);
RegisterTask(task, target_time);
}
@ -52,15 +53,15 @@ void MessageLoopImpl::RunExpiredTasksNow() {
}
void MessageLoopImpl::AddTaskObserver(intptr_t key, fxl::Closure callback) {
FXL_DCHECK(callback != nullptr);
FXL_DCHECK(MessageLoop::GetCurrent().GetLoopImpl().get() == this)
FML_DCHECK(callback != nullptr);
FML_DCHECK(MessageLoop::GetCurrent().GetLoopImpl().get() == this)
<< "Message loop task observer must be added on the same thread as the "
"loop.";
task_observers_[key] = std::move(callback);
}
void MessageLoopImpl::RemoveTaskObserver(intptr_t key) {
FXL_DCHECK(MessageLoop::GetCurrent().GetLoopImpl().get() == this)
FML_DCHECK(MessageLoop::GetCurrent().GetLoopImpl().get() == this)
<< "Message loop task observer must be removed from the same thread as "
"the loop.";
task_observers_.erase(key);
@ -100,7 +101,7 @@ void MessageLoopImpl::DoTerminate() {
void MessageLoopImpl::RegisterTask(fxl::Closure task,
fxl::TimePoint target_time) {
FXL_DCHECK(task != nullptr);
FML_DCHECK(task != nullptr);
if (terminated_) {
// If the message loop has already been terminated, PostTask should destruct
// |task| synchronously within this function.

View File

@ -7,26 +7,26 @@
#include <codecvt>
#include <string>
#include "lib/fxl/logging.h"
#include "flutter/fml/logging.h"
namespace fml {
namespace jni {
static JavaVM* g_jvm = nullptr;
#define ASSERT_NO_EXCEPTION() FXL_CHECK(env->ExceptionCheck() == JNI_FALSE);
#define ASSERT_NO_EXCEPTION() FML_CHECK(env->ExceptionCheck() == JNI_FALSE);
void InitJavaVM(JavaVM* vm) {
FXL_DCHECK(g_jvm == nullptr);
FML_DCHECK(g_jvm == nullptr);
g_jvm = vm;
}
JNIEnv* AttachCurrentThread() {
FXL_DCHECK(g_jvm != nullptr)
FML_DCHECK(g_jvm != nullptr)
<< "Trying to attach to current thread without calling InitJavaVM first.";
JNIEnv* env = nullptr;
jint ret = g_jvm->AttachCurrentThread(&env, nullptr);
FXL_DCHECK(JNI_OK == ret);
FML_DCHECK(JNI_OK == ret);
return env;
}
@ -97,10 +97,10 @@ std::vector<std::string> StringArrayToVector(JNIEnv* env, jobjectArray array) {
ScopedJavaLocalRef<jobjectArray> VectorToStringArray(
JNIEnv* env,
const std::vector<std::string>& vector) {
FXL_DCHECK(env);
FML_DCHECK(env);
ScopedJavaLocalRef<jclass> string_clazz(env,
env->FindClass("java/lang/String"));
FXL_DCHECK(!string_clazz.is_null());
FML_DCHECK(!string_clazz.is_null());
jobjectArray joa =
env->NewObjectArray(vector.size(), string_clazz.obj(), NULL);
ASSERT_NO_EXCEPTION();

View File

@ -4,8 +4,8 @@
#include "flutter/fml/platform/android/jni_weak_ref.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/platform/android/jni_util.h"
#include "lib/fxl/logging.h"
namespace fml {
namespace jni {
@ -20,7 +20,7 @@ JavaObjectWeakGlobalRef::JavaObjectWeakGlobalRef(
JavaObjectWeakGlobalRef::JavaObjectWeakGlobalRef(JNIEnv* env, jobject obj)
: obj_(env->NewWeakGlobalRef(obj)) {
FXL_DCHECK(obj_);
FML_DCHECK(obj_);
}
JavaObjectWeakGlobalRef::~JavaObjectWeakGlobalRef() {
@ -46,8 +46,9 @@ ScopedJavaLocalRef<jobject> GetRealObject(JNIEnv* env, jweak obj) {
jobject real = NULL;
if (obj) {
real = env->NewLocalRef(obj);
if (!real)
FXL_DLOG(ERROR) << "The real object has been deleted!";
if (!real) {
FML_DLOG(ERROR) << "The real object has been deleted!";
}
}
return ScopedJavaLocalRef<jobject>(env, real);
}

View File

@ -32,8 +32,8 @@ MessageLoopAndroid::MessageLoopAndroid()
: looper_(AcquireLooperForThread()),
timer_fd_(::timerfd_create(kClockType, TFD_NONBLOCK | TFD_CLOEXEC)),
running_(false) {
FXL_CHECK(looper_.is_valid());
FXL_CHECK(timer_fd_.is_valid());
FML_CHECK(looper_.is_valid());
FML_CHECK(timer_fd_.is_valid());
static const int kWakeEvents = ALOOPER_EVENT_INPUT;
@ -51,16 +51,16 @@ MessageLoopAndroid::MessageLoopAndroid()
read_event_fd, // callback
this // baton
);
FXL_CHECK(add_result == 1);
FML_CHECK(add_result == 1);
}
MessageLoopAndroid::~MessageLoopAndroid() {
int remove_result = ::ALooper_removeFd(looper_.get(), timer_fd_.get());
FXL_CHECK(remove_result == 1);
FML_CHECK(remove_result == 1);
}
void MessageLoopAndroid::Run() {
FXL_DCHECK(looper_.get() == ALooper_forThread());
FML_DCHECK(looper_.get() == ALooper_forThread());
running_ = true;
@ -84,7 +84,7 @@ void MessageLoopAndroid::Terminate() {
void MessageLoopAndroid::WakeUp(fxl::TimePoint time_point) {
bool result = TimerRearm(timer_fd_.get(), time_point);
FXL_DCHECK(result);
FML_DCHECK(result);
}
void MessageLoopAndroid::OnEventFired() {

View File

@ -4,8 +4,8 @@
#include "flutter/fml/platform/android/scoped_java_ref.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/platform/android/jni_util.h"
#include "lib/fxl/logging.h"
namespace fml {
namespace jni {
@ -14,13 +14,13 @@ static const int kDefaultLocalFrameCapacity = 16;
ScopedJavaLocalFrame::ScopedJavaLocalFrame(JNIEnv* env) : env_(env) {
int failed = env_->PushLocalFrame(kDefaultLocalFrameCapacity);
FXL_DCHECK(!failed);
FML_DCHECK(!failed);
}
ScopedJavaLocalFrame::ScopedJavaLocalFrame(JNIEnv* env, int capacity)
: env_(env) {
int failed = env_->PushLocalFrame(capacity);
FXL_DCHECK(!failed);
FML_DCHECK(!failed);
}
ScopedJavaLocalFrame::~ScopedJavaLocalFrame() {
@ -31,7 +31,7 @@ JavaRef<jobject>::JavaRef() : obj_(NULL) {}
JavaRef<jobject>::JavaRef(JNIEnv* env, jobject obj) : obj_(obj) {
if (obj) {
FXL_DCHECK(env && env->GetObjectRefType(obj) == JNILocalRefType);
FML_DCHECK(env && env->GetObjectRefType(obj) == JNILocalRefType);
}
}
@ -41,7 +41,7 @@ JNIEnv* JavaRef<jobject>::SetNewLocalRef(JNIEnv* env, jobject obj) {
if (!env) {
env = AttachCurrentThread();
} else {
FXL_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
FML_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
}
if (obj)
obj = env->NewLocalRef(obj);
@ -55,7 +55,7 @@ void JavaRef<jobject>::SetNewGlobalRef(JNIEnv* env, jobject obj) {
if (!env) {
env = AttachCurrentThread();
} else {
FXL_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
FML_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
}
if (obj)
obj = env->NewGlobalRef(obj);
@ -66,7 +66,7 @@ void JavaRef<jobject>::SetNewGlobalRef(JNIEnv* env, jobject obj) {
void JavaRef<jobject>::ResetLocalRef(JNIEnv* env) {
if (obj_) {
FXL_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
FML_DCHECK(env == AttachCurrentThread()); // Is |env| on correct thread.
env->DeleteLocalRef(obj_);
obj_ = NULL;
}

View File

@ -7,13 +7,15 @@
#include <CoreFoundation/CFRunLoop.h>
#include <Foundation/Foundation.h>
#include "flutter/fml/logging.h"
namespace fml {
static constexpr CFTimeInterval kDistantFuture = 1.0e10;
MessageLoopDarwin::MessageLoopDarwin()
: running_(false), loop_((CFRunLoopRef)CFRetain(CFRunLoopGetCurrent())) {
FXL_DCHECK(loop_ != nullptr);
FML_DCHECK(loop_ != nullptr);
// Setup the delayed wake source.
CFRunLoopTimerContext timer_context = {
@ -25,7 +27,7 @@ MessageLoopDarwin::MessageLoopDarwin()
reinterpret_cast<CFRunLoopTimerCallBack>(&MessageLoopDarwin::OnTimerFire)
/* callout */,
&timer_context /* context */));
FXL_DCHECK(delayed_wake_timer_ != nullptr);
FML_DCHECK(delayed_wake_timer_ != nullptr);
CFRunLoopAddTimer(loop_, delayed_wake_timer_, kCFRunLoopCommonModes);
}
@ -35,7 +37,7 @@ MessageLoopDarwin::~MessageLoopDarwin() {
}
void MessageLoopDarwin::Run() {
FXL_DCHECK(loop_ == CFRunLoopGetCurrent());
FML_DCHECK(loop_ == CFRunLoopGetCurrent());
running_ = true;

View File

@ -18,15 +18,15 @@ MessageLoopLinux::MessageLoopLinux()
: epoll_fd_(FML_HANDLE_EINTR(::epoll_create(1 /* unused */))),
timer_fd_(::timerfd_create(kClockType, TFD_NONBLOCK | TFD_CLOEXEC)),
running_(false) {
FXL_CHECK(epoll_fd_.is_valid());
FXL_CHECK(timer_fd_.is_valid());
FML_CHECK(epoll_fd_.is_valid());
FML_CHECK(timer_fd_.is_valid());
bool added_source = AddOrRemoveTimerSource(true);
FXL_CHECK(added_source);
FML_CHECK(added_source);
}
MessageLoopLinux::~MessageLoopLinux() {
bool removed_source = AddOrRemoveTimerSource(false);
FXL_CHECK(removed_source);
FML_CHECK(removed_source);
}
bool MessageLoopLinux::AddOrRemoveTimerSource(bool add) {
@ -78,7 +78,7 @@ void MessageLoopLinux::Terminate() {
void MessageLoopLinux::WakeUp(fxl::TimePoint time_point) {
bool result = TimerRearm(timer_fd_.get(), time_point);
FXL_DCHECK(result);
FML_DCHECK(result);
}
void MessageLoopLinux::OnEventFired() {

View File

@ -8,7 +8,7 @@ namespace fml {
MessageLoopWin::MessageLoopWin()
: timer_(CreateWaitableTimer(NULL, FALSE, NULL)) {
FXL_CHECK(timer_.is_valid());
FML_CHECK(timer_.is_valid());
}
MessageLoopWin::~MessageLoopWin() = default;
@ -17,7 +17,7 @@ void MessageLoopWin::Run() {
running_ = true;
while (running_) {
FXL_CHECK(WaitForSingleObject(timer_.get(), INFINITE) == 0);
FML_CHECK(WaitForSingleObject(timer_.get(), INFINITE) == 0);
RunExpiredTasksNow();
}
}
@ -33,7 +33,7 @@ void MessageLoopWin::WakeUp(fxl::TimePoint time_point) {
if (time_point > now) {
due_time.QuadPart = (time_point - now).ToNanoseconds() / -100;
}
FXL_CHECK(SetWaitableTimer(timer_.get(), &due_time, 0, NULL, NULL, FALSE));
FML_CHECK(SetWaitableTimer(timer_.get(), &due_time, 0, NULL, NULL, FALSE));
}
} // namespace fml

View File

@ -8,6 +8,7 @@
#include <utility>
#include "flutter/fml/logging.h"
#include "flutter/fml/message_loop.h"
#include "flutter/fml/message_loop_impl.h"
@ -15,7 +16,7 @@ namespace fml {
TaskRunner::TaskRunner(fxl::RefPtr<MessageLoopImpl> loop)
: loop_(std::move(loop)) {
FXL_CHECK(loop_);
FML_CHECK(loop_);
}
TaskRunner::~TaskRunner() = default;
@ -42,7 +43,7 @@ bool TaskRunner::RunsTasksOnCurrentThread() {
void TaskRunner::RunNowOrPostTask(fxl::RefPtr<fxl::TaskRunner> runner,
fxl::Closure task) {
FXL_DCHECK(runner);
FML_DCHECK(runner);
if (runner->RunsTasksOnCurrentThread()) {
task();
} else {

View File

@ -8,8 +8,8 @@
#include <functional>
#include "flutter/fml/build_config.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "lib/fxl/logging.h"
#define FML_THREAD_LOCAL_PTHREADS OS_MACOSX || OS_LINUX || OS_ANDROID
@ -59,7 +59,7 @@ class ThreadLocal {
};
static inline void ThreadLocalDestroy(void* value) {
FXL_CHECK(value != nullptr);
FML_CHECK(value != nullptr);
auto box = reinterpret_cast<Box*>(value);
box->DestroyValue();
delete box;
@ -71,14 +71,14 @@ class ThreadLocal {
ThreadLocal(ThreadLocalDestroyCallback destroy) : destroy_(destroy) {
auto callback =
reinterpret_cast<void (*)(void*)>(&ThreadLocal::ThreadLocalDestroy);
FXL_CHECK(pthread_key_create(&_key, callback) == 0);
FML_CHECK(pthread_key_create(&_key, callback) == 0);
}
void Set(intptr_t value) {
auto box = reinterpret_cast<Box*>(pthread_getspecific(_key));
if (box == nullptr) {
box = new Box(destroy_, value);
FXL_CHECK(pthread_setspecific(_key, box) == 0);
FML_CHECK(pthread_setspecific(_key, box) == 0);
} else {
box->SetValue(value);
}
@ -99,7 +99,7 @@ class ThreadLocal {
delete reinterpret_cast<Box*>(pthread_getspecific(_key));
// Finally, collect the key
FXL_CHECK(pthread_key_delete(_key) == 0);
FML_CHECK(pthread_key_delete(_key) == 0);
}
private:

View File

@ -4,6 +4,7 @@
#include <thread>
#include "flutter/fml/logging.h"
#include "flutter/fml/thread_local.h"
#include "gtest/gtest.h"

View File

@ -8,8 +8,8 @@
#include <utility>
#include "flutter/fml/compiler_specific.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#include "lib/fxl/logging.h"
namespace fml {
@ -60,7 +60,7 @@ class UniqueObject {
}
void reset(const T& value = Traits::InvalidValue()) {
FXL_CHECK(data_.generic == Traits::InvalidValue() ||
FML_CHECK(data_.generic == Traits::InvalidValue() ||
data_.generic != value);
FreeIfNecessary();
data_.generic = value;

View File

@ -655,6 +655,41 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../garnet/LICENSE
TYPE: LicenseType.bsd
FILE: ../../../flutter/fml/export.h
----------------------------------------------------------------------------------------------------
Copyright 2017 The Fuchsia Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================================================
====================================================================================================
LIBRARY: engine
ORIGIN: ../../../third_party/icu/scripts/LICENSE
@ -817,6 +852,12 @@ TYPE: LicenseType.bsd
FILE: ../../../flutter/fml/build_config.h
FILE: ../../../flutter/fml/compiler_specific.h
FILE: ../../../flutter/fml/eintr_wrapper.h
FILE: ../../../flutter/fml/log_level.h
FILE: ../../../flutter/fml/log_settings.cc
FILE: ../../../flutter/fml/log_settings.h
FILE: ../../../flutter/fml/log_settings_state.cc
FILE: ../../../flutter/fml/logging.cc
FILE: ../../../flutter/fml/logging.h
FILE: ../../../flutter/fml/memory/ref_counted.h
FILE: ../../../flutter/fml/memory/ref_counted_internal.h
FILE: ../../../flutter/fml/memory/ref_counted_unittest.cc
@ -1141,4 +1182,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
====================================================================================================
Total license count: 11
Total license count: 12