diff --git a/README.md b/README.md index e69de29..984f3f3 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,11 @@ +# emsdk 构建 +$ git clone https://github.com/juj/emsdk.git +$ cd emsdk +$ ./emsdk install latest +$ ./emsdk activate latest + +## emsdk 简单命令 +emcc main.cpp -std=c++11 -s WASM=1 -s USE_SDL=2 -O3 -o index.js + +## emsdk 构建cmake 工程 + emcmake cmake .\CMakeLists.txt -G "Visual Studio 17 2022" -B ./embuild diff --git a/Thirdparty/libcef/Resources/chrome_100_percent.pak b/Thirdparty/libcef/Resources/chrome_100_percent.pak new file mode 100644 index 0000000..9b24604 Binary files /dev/null and b/Thirdparty/libcef/Resources/chrome_100_percent.pak differ diff --git a/Thirdparty/libcef/Resources/chrome_200_percent.pak b/Thirdparty/libcef/Resources/chrome_200_percent.pak new file mode 100644 index 0000000..96673f4 Binary files /dev/null and b/Thirdparty/libcef/Resources/chrome_200_percent.pak differ diff --git a/Thirdparty/libcef/Resources/icudtl.dat b/Thirdparty/libcef/Resources/icudtl.dat new file mode 100644 index 0000000..9255d35 Binary files /dev/null and b/Thirdparty/libcef/Resources/icudtl.dat differ diff --git a/Thirdparty/libcef/Resources/locales/af.pak b/Thirdparty/libcef/Resources/locales/af.pak new file mode 100644 index 0000000..16c7e13 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/af.pak differ diff --git a/Thirdparty/libcef/Resources/locales/am.pak b/Thirdparty/libcef/Resources/locales/am.pak new file mode 100644 index 0000000..351d660 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/am.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ar.pak b/Thirdparty/libcef/Resources/locales/ar.pak new file mode 100644 index 0000000..9800faa Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ar.pak differ diff --git a/Thirdparty/libcef/Resources/locales/bg.pak b/Thirdparty/libcef/Resources/locales/bg.pak new file mode 100644 index 0000000..33b6df2 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/bg.pak differ diff --git a/Thirdparty/libcef/Resources/locales/bn.pak b/Thirdparty/libcef/Resources/locales/bn.pak new file mode 100644 index 0000000..c931246 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/bn.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ca.pak b/Thirdparty/libcef/Resources/locales/ca.pak new file mode 100644 index 0000000..ae989fc Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ca.pak differ diff --git a/Thirdparty/libcef/Resources/locales/cs.pak b/Thirdparty/libcef/Resources/locales/cs.pak new file mode 100644 index 0000000..6a2130e Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/cs.pak differ diff --git a/Thirdparty/libcef/Resources/locales/da.pak b/Thirdparty/libcef/Resources/locales/da.pak new file mode 100644 index 0000000..fcfdaa3 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/da.pak differ diff --git a/Thirdparty/libcef/Resources/locales/de.pak b/Thirdparty/libcef/Resources/locales/de.pak new file mode 100644 index 0000000..c634ce0 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/de.pak differ diff --git a/Thirdparty/libcef/Resources/locales/el.pak b/Thirdparty/libcef/Resources/locales/el.pak new file mode 100644 index 0000000..d8648de Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/el.pak differ diff --git a/Thirdparty/libcef/Resources/locales/en-GB.pak b/Thirdparty/libcef/Resources/locales/en-GB.pak new file mode 100644 index 0000000..0a7562a Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/en-GB.pak differ diff --git a/Thirdparty/libcef/Resources/locales/en-US.pak b/Thirdparty/libcef/Resources/locales/en-US.pak new file mode 100644 index 0000000..f28e835 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/en-US.pak differ diff --git a/Thirdparty/libcef/Resources/locales/es-419.pak b/Thirdparty/libcef/Resources/locales/es-419.pak new file mode 100644 index 0000000..9b14847 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/es-419.pak differ diff --git a/Thirdparty/libcef/Resources/locales/es.pak b/Thirdparty/libcef/Resources/locales/es.pak new file mode 100644 index 0000000..1c3cd83 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/es.pak differ diff --git a/Thirdparty/libcef/Resources/locales/et.pak b/Thirdparty/libcef/Resources/locales/et.pak new file mode 100644 index 0000000..2297c20 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/et.pak differ diff --git a/Thirdparty/libcef/Resources/locales/fa.pak b/Thirdparty/libcef/Resources/locales/fa.pak new file mode 100644 index 0000000..1ae4b44 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/fa.pak differ diff --git a/Thirdparty/libcef/Resources/locales/fi.pak b/Thirdparty/libcef/Resources/locales/fi.pak new file mode 100644 index 0000000..46c120f Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/fi.pak differ diff --git a/Thirdparty/libcef/Resources/locales/fil.pak b/Thirdparty/libcef/Resources/locales/fil.pak new file mode 100644 index 0000000..8d6a919 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/fil.pak differ diff --git a/Thirdparty/libcef/Resources/locales/fr.pak b/Thirdparty/libcef/Resources/locales/fr.pak new file mode 100644 index 0000000..171c77c Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/fr.pak differ diff --git a/Thirdparty/libcef/Resources/locales/gu.pak b/Thirdparty/libcef/Resources/locales/gu.pak new file mode 100644 index 0000000..260f1d1 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/gu.pak differ diff --git a/Thirdparty/libcef/Resources/locales/he.pak b/Thirdparty/libcef/Resources/locales/he.pak new file mode 100644 index 0000000..5fe3dd6 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/he.pak differ diff --git a/Thirdparty/libcef/Resources/locales/hi.pak b/Thirdparty/libcef/Resources/locales/hi.pak new file mode 100644 index 0000000..715e6ff Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/hi.pak differ diff --git a/Thirdparty/libcef/Resources/locales/hr.pak b/Thirdparty/libcef/Resources/locales/hr.pak new file mode 100644 index 0000000..b37e264 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/hr.pak differ diff --git a/Thirdparty/libcef/Resources/locales/hu.pak b/Thirdparty/libcef/Resources/locales/hu.pak new file mode 100644 index 0000000..234e39a Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/hu.pak differ diff --git a/Thirdparty/libcef/Resources/locales/id.pak b/Thirdparty/libcef/Resources/locales/id.pak new file mode 100644 index 0000000..f3c6278 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/id.pak differ diff --git a/Thirdparty/libcef/Resources/locales/it.pak b/Thirdparty/libcef/Resources/locales/it.pak new file mode 100644 index 0000000..a41c8a9 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/it.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ja.pak b/Thirdparty/libcef/Resources/locales/ja.pak new file mode 100644 index 0000000..16fc7e1 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ja.pak differ diff --git a/Thirdparty/libcef/Resources/locales/kn.pak b/Thirdparty/libcef/Resources/locales/kn.pak new file mode 100644 index 0000000..e64a31d Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/kn.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ko.pak b/Thirdparty/libcef/Resources/locales/ko.pak new file mode 100644 index 0000000..eedffc4 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ko.pak differ diff --git a/Thirdparty/libcef/Resources/locales/lt.pak b/Thirdparty/libcef/Resources/locales/lt.pak new file mode 100644 index 0000000..2063409 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/lt.pak differ diff --git a/Thirdparty/libcef/Resources/locales/lv.pak b/Thirdparty/libcef/Resources/locales/lv.pak new file mode 100644 index 0000000..2c43182 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/lv.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ml.pak b/Thirdparty/libcef/Resources/locales/ml.pak new file mode 100644 index 0000000..b5afe63 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ml.pak differ diff --git a/Thirdparty/libcef/Resources/locales/mr.pak b/Thirdparty/libcef/Resources/locales/mr.pak new file mode 100644 index 0000000..3112dba Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/mr.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ms.pak b/Thirdparty/libcef/Resources/locales/ms.pak new file mode 100644 index 0000000..1e75877 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ms.pak differ diff --git a/Thirdparty/libcef/Resources/locales/nb.pak b/Thirdparty/libcef/Resources/locales/nb.pak new file mode 100644 index 0000000..0df5660 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/nb.pak differ diff --git a/Thirdparty/libcef/Resources/locales/nl.pak b/Thirdparty/libcef/Resources/locales/nl.pak new file mode 100644 index 0000000..9c1b4a0 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/nl.pak differ diff --git a/Thirdparty/libcef/Resources/locales/pl.pak b/Thirdparty/libcef/Resources/locales/pl.pak new file mode 100644 index 0000000..a603a30 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/pl.pak differ diff --git a/Thirdparty/libcef/Resources/locales/pt-BR.pak b/Thirdparty/libcef/Resources/locales/pt-BR.pak new file mode 100644 index 0000000..f75ed1c Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/pt-BR.pak differ diff --git a/Thirdparty/libcef/Resources/locales/pt-PT.pak b/Thirdparty/libcef/Resources/locales/pt-PT.pak new file mode 100644 index 0000000..4d499ca Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/pt-PT.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ro.pak b/Thirdparty/libcef/Resources/locales/ro.pak new file mode 100644 index 0000000..10172d9 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ro.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ru.pak b/Thirdparty/libcef/Resources/locales/ru.pak new file mode 100644 index 0000000..949cd98 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ru.pak differ diff --git a/Thirdparty/libcef/Resources/locales/sk.pak b/Thirdparty/libcef/Resources/locales/sk.pak new file mode 100644 index 0000000..e69bf0a Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/sk.pak differ diff --git a/Thirdparty/libcef/Resources/locales/sl.pak b/Thirdparty/libcef/Resources/locales/sl.pak new file mode 100644 index 0000000..83bd345 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/sl.pak differ diff --git a/Thirdparty/libcef/Resources/locales/sr.pak b/Thirdparty/libcef/Resources/locales/sr.pak new file mode 100644 index 0000000..eceeaeb Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/sr.pak differ diff --git a/Thirdparty/libcef/Resources/locales/sv.pak b/Thirdparty/libcef/Resources/locales/sv.pak new file mode 100644 index 0000000..0edd22b Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/sv.pak differ diff --git a/Thirdparty/libcef/Resources/locales/sw.pak b/Thirdparty/libcef/Resources/locales/sw.pak new file mode 100644 index 0000000..35ea1bf Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/sw.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ta.pak b/Thirdparty/libcef/Resources/locales/ta.pak new file mode 100644 index 0000000..42f0905 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ta.pak differ diff --git a/Thirdparty/libcef/Resources/locales/te.pak b/Thirdparty/libcef/Resources/locales/te.pak new file mode 100644 index 0000000..1db18f5 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/te.pak differ diff --git a/Thirdparty/libcef/Resources/locales/th.pak b/Thirdparty/libcef/Resources/locales/th.pak new file mode 100644 index 0000000..f1f0ce7 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/th.pak differ diff --git a/Thirdparty/libcef/Resources/locales/tr.pak b/Thirdparty/libcef/Resources/locales/tr.pak new file mode 100644 index 0000000..8d75501 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/tr.pak differ diff --git a/Thirdparty/libcef/Resources/locales/uk.pak b/Thirdparty/libcef/Resources/locales/uk.pak new file mode 100644 index 0000000..e3e5b36 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/uk.pak differ diff --git a/Thirdparty/libcef/Resources/locales/ur.pak b/Thirdparty/libcef/Resources/locales/ur.pak new file mode 100644 index 0000000..1e674d0 Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/ur.pak differ diff --git a/Thirdparty/libcef/Resources/locales/vi.pak b/Thirdparty/libcef/Resources/locales/vi.pak new file mode 100644 index 0000000..d6c222c Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/vi.pak differ diff --git a/Thirdparty/libcef/Resources/locales/zh-CN.pak b/Thirdparty/libcef/Resources/locales/zh-CN.pak new file mode 100644 index 0000000..5592ced Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/zh-CN.pak differ diff --git a/Thirdparty/libcef/Resources/locales/zh-TW.pak b/Thirdparty/libcef/Resources/locales/zh-TW.pak new file mode 100644 index 0000000..14d4bfb Binary files /dev/null and b/Thirdparty/libcef/Resources/locales/zh-TW.pak differ diff --git a/Thirdparty/libcef/Resources/resources.pak b/Thirdparty/libcef/Resources/resources.pak new file mode 100644 index 0000000..9f015bf Binary files /dev/null and b/Thirdparty/libcef/Resources/resources.pak differ diff --git a/Thirdparty/libcef/include/base/cef_atomic_flag.h b/Thirdparty/libcef/include/base/cef_atomic_flag.h new file mode 100644 index 0000000..3730838 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_atomic_flag.h @@ -0,0 +1,88 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_ +#define CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/synchronization/atomic_flag.h" + +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include + +#include "include/base/cef_thread_checker.h" + +namespace base { + +// A flag that can safely be set from one thread and read from other threads. +// +// This class IS NOT intended for synchronization between threads. +class AtomicFlag { + public: + AtomicFlag(); + + AtomicFlag(const AtomicFlag&) = delete; + AtomicFlag& operator=(const AtomicFlag&) = delete; + + ~AtomicFlag(); + + // Set the flag. Must always be called from the same thread. + void Set(); + + // Returns true iff the flag was set. If this returns true, the current thread + // is guaranteed to be synchronized with all memory operations on the thread + // which invoked Set() up until at least the first call to Set() on it. + bool IsSet() const { + // Inline here: this has a measurable performance impact on base::WeakPtr. + return flag_.load(std::memory_order_acquire) != 0; + } + + // Resets the flag. Be careful when using this: callers might not expect + // IsSet() to return false after returning true once. + void UnsafeResetForTesting(); + + private: + std::atomic flag_{0}; + base::ThreadChecker set_thread_checker_; +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_ diff --git a/Thirdparty/libcef/include/base/cef_atomic_ref_count.h b/Thirdparty/libcef/include/base/cef_atomic_ref_count.h new file mode 100644 index 0000000..8fb0cc6 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_atomic_ref_count.h @@ -0,0 +1,111 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +// This is a low level implementation of atomic semantics for reference +// counting. Please use cef_ref_counted.h directly instead. +// +// The Chromium implementation includes annotations to avoid some false +// positives when using data race detection tools. Annotations are not +// currently supported by the CEF implementation. + +#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ +#define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/atomic_ref_count.h" + +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +namespace base { + +class AtomicRefCount { + public: + constexpr AtomicRefCount() : ref_count_(0) {} + explicit constexpr AtomicRefCount(int initial_value) + : ref_count_(initial_value) {} + + // Increment a reference count. + // Returns the previous value of the count. + int Increment() { return Increment(1); } + + // Increment a reference count by "increment", which must exceed 0. + // Returns the previous value of the count. + int Increment(int increment) { + return ref_count_.fetch_add(increment, std::memory_order_relaxed); + } + + // Decrement a reference count, and return whether the result is non-zero. + // Insert barriers to ensure that state written before the reference count + // became zero will be visible to a thread that has just made the count zero. + bool Decrement() { + // TODO(jbroman): Technically this doesn't need to be an acquire operation + // unless the result is 1 (i.e., the ref count did indeed reach zero). + // However, there are toolchain issues that make that not work as well at + // present (notably TSAN doesn't like it). + return ref_count_.fetch_sub(1, std::memory_order_acq_rel) != 1; + } + + // Return whether the reference count is one. If the reference count is used + // in the conventional way, a refrerence count of 1 implies that the current + // thread owns the reference and no other thread shares it. This call + // performs the test for a reference count of one, and performs the memory + // barrier needed for the owning thread to act on the object, knowing that it + // has exclusive access to the object. + bool IsOne() const { return ref_count_.load(std::memory_order_acquire) == 1; } + + // Return whether the reference count is zero. With conventional object + // referencing counting, the object will be destroyed, so the reference count + // should never be zero. Hence this is generally used for a debug check. + bool IsZero() const { + return ref_count_.load(std::memory_order_acquire) == 0; + } + + // Returns the current reference count (with no barriers). This is subtle, and + // should be used only for debugging. + int SubtleRefCountForDebug() const { + return ref_count_.load(std::memory_order_relaxed); + } + + private: + std::atomic_int ref_count_; +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ diff --git a/Thirdparty/libcef/include/base/cef_auto_reset.h b/Thirdparty/libcef/include/base/cef_auto_reset.h new file mode 100644 index 0000000..ba1f248 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_auto_reset.h @@ -0,0 +1,89 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +// base::AutoReset<> is useful for setting a variable to a new value only within +// a particular scope. An base::AutoReset<> object resets a variable to its +// original value upon destruction, making it an alternative to writing +// "var = false;" or "var = old_val;" at all of a block's exit points. +// +// This should be obvious, but note that an base::AutoReset<> instance should +// have a shorter lifetime than its scoped_variable, to prevent invalid memory +// writes when the base::AutoReset<> object is destroyed. + +#ifndef CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_ +#define CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/auto_reset.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +namespace base { + +template +class AutoReset { + public: + template + AutoReset(T* scoped_variable, U&& new_value) + : scoped_variable_(scoped_variable), + original_value_( + std::exchange(*scoped_variable_, std::forward(new_value))) {} + + AutoReset(AutoReset&& other) + : scoped_variable_(std::exchange(other.scoped_variable_, nullptr)), + original_value_(std::move(other.original_value_)) {} + + AutoReset& operator=(AutoReset&& rhs) { + scoped_variable_ = std::exchange(rhs.scoped_variable_, nullptr); + original_value_ = std::move(rhs.original_value_); + return *this; + } + + ~AutoReset() { + if (scoped_variable_) + *scoped_variable_ = std::move(original_value_); + } + + private: + T* scoped_variable_; + T original_value_; +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_ diff --git a/Thirdparty/libcef/include/base/cef_basictypes.h b/Thirdparty/libcef/include/base/cef_basictypes.h new file mode 100644 index 0000000..4f39e83 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_basictypes.h @@ -0,0 +1,86 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +#ifndef CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ +#define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ +#pragma once + +#include // For UINT_MAX +#include // For size_t + +#include "include/base/cef_build.h" + +// The NSPR system headers define 64-bit as |long| when possible, except on +// Mac OS X. In order to not have typedef mismatches, we do the same on LP64. +// +// On Mac OS X, |long long| is used for 64-bit types for compatibility with +// format macros even in the LP64 model. +#if defined(__LP64__) && !defined(OS_MAC) && !defined(OS_OPENBSD) +typedef long int64; +typedef unsigned long uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _INT32 +#define _INT32 +typedef int int32; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _UINT32 +#define _UINT32 +typedef unsigned int uint32; +#endif + +#ifndef _INT16 +#define _INT16 +typedef short int16; +#endif + +#ifndef _UINT16 +#define _UINT16 +typedef unsigned short uint16; +#endif + +// UTF-16 character type. +#ifndef char16 +#if defined(WCHAR_T_IS_UTF16) +typedef wchar_t char16; +#elif defined(WCHAR_T_IS_UTF32) +typedef unsigned short char16; +#endif +#endif + +#endif // CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ diff --git a/Thirdparty/libcef/include/base/cef_bind.h b/Thirdparty/libcef/include/base/cef_bind.h new file mode 100644 index 0000000..2e6a071 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_bind.h @@ -0,0 +1,352 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +// ----------------------------------------------------------------------------- +// Usage documentation +// ----------------------------------------------------------------------------- +// +// Overview: +// base::BindOnce() and base::BindRepeating() are helpers for creating +// base::OnceCallback and base::RepeatingCallback objects respectively. +// +// For a runnable object of n-arity, the base::Bind*() family allows partial +// application of the first m arguments. The remaining n - m arguments must be +// passed when invoking the callback with Run(). +// +// // The first argument is bound at callback creation; the remaining +// // two must be passed when calling Run() on the callback object. +// base::OnceCallback cb = base::BindOnce( +// [](short x, int y, long z) { return x * y * z; }, 42); +// +// When binding to a method, the receiver object must also be specified at +// callback creation time. When Run() is invoked, the method will be invoked on +// the specified receiver object. +// +// class C : public base::RefCounted { void F(); }; +// auto instance = base::MakeRefCounted(); +// auto cb = base::BindOnce(&C::F, instance); +// std::move(cb).Run(); // Identical to instance->F() +// +// See //docs/callback.md for the full documentation. +// +// ----------------------------------------------------------------------------- +// Implementation notes +// ----------------------------------------------------------------------------- +// +// If you're reading the implementation, before proceeding further, you should +// read the top comment of base/internal/cef_bind_internal.h for a definition of +// common terms and concepts. + +#ifndef CEF_INCLUDE_BASE_CEF_BIND_H_ +#define CEF_INCLUDE_BASE_CEF_BIND_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/bind.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include +#include +#include +#include + +#include "include/base/cef_build.h" +#include "include/base/cef_compiler_specific.h" +#include "include/base/cef_template_util.h" +#include "include/base/internal/cef_bind_internal.h" + +#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc) +#include "include/base/internal/cef_scoped_block_mac.h" +#endif + +namespace base { + +// Bind as OnceCallback. +template +inline OnceCallback> BindOnce( + Functor&& functor, + Args&&... args) { + static_assert(!internal::IsOnceCallback>() || + (std::is_rvalue_reference() && + !std::is_const>()), + "BindOnce requires non-const rvalue for OnceCallback binding." + " I.e.: base::BindOnce(std::move(callback))."); + static_assert( + conjunction< + internal::AssertBindArgIsNotBasePassed>...>::value, + "Use std::move() instead of base::Passed() with base::BindOnce()"); + + return internal::BindImpl(std::forward(functor), + std::forward(args)...); +} + +// Bind as RepeatingCallback. +template +inline RepeatingCallback> +BindRepeating(Functor&& functor, Args&&... args) { + static_assert( + !internal::IsOnceCallback>(), + "BindRepeating cannot bind OnceCallback. Use BindOnce with std::move()."); + + return internal::BindImpl(std::forward(functor), + std::forward(args)...); +} + +// Special cases for binding to a base::Callback without extra bound arguments. +// We CHECK() the validity of callback to guard against null pointers +// accidentally ending up in posted tasks, causing hard-to-debug crashes. +template +OnceCallback BindOnce(OnceCallback callback) { + CHECK(callback); + return callback; +} + +template +OnceCallback BindOnce(RepeatingCallback callback) { + CHECK(callback); + return callback; +} + +template +RepeatingCallback BindRepeating( + RepeatingCallback callback) { + CHECK(callback); + return callback; +} + +// Unretained() allows binding a non-refcounted class, and to disable +// refcounting on arguments that are refcounted objects. +// +// EXAMPLE OF Unretained(): +// +// class Foo { +// public: +// void func() { cout << "Foo:f" << endl; } +// }; +// +// // In some function somewhere. +// Foo foo; +// OnceClosure foo_callback = +// BindOnce(&Foo::func, Unretained(&foo)); +// std::move(foo_callback).Run(); // Prints "Foo:f". +// +// Without the Unretained() wrapper on |&foo|, the above call would fail +// to compile because Foo does not support the AddRef() and Release() methods. +template +inline internal::UnretainedWrapper Unretained(T* o) { + return internal::UnretainedWrapper(o); +} + +// RetainedRef() accepts a ref counted object and retains a reference to it. +// When the callback is called, the object is passed as a raw pointer. +// +// EXAMPLE OF RetainedRef(): +// +// void foo(RefCountedBytes* bytes) {} +// +// scoped_refptr bytes = ...; +// OnceClosure callback = BindOnce(&foo, base::RetainedRef(bytes)); +// std::move(callback).Run(); +// +// Without RetainedRef, the scoped_refptr would try to implicitly convert to +// a raw pointer and fail compilation: +// +// OnceClosure callback = BindOnce(&foo, bytes); // ERROR! +template +inline internal::RetainedRefWrapper RetainedRef(T* o) { + return internal::RetainedRefWrapper(o); +} +template +inline internal::RetainedRefWrapper RetainedRef(scoped_refptr o) { + return internal::RetainedRefWrapper(std::move(o)); +} + +// Owned() transfers ownership of an object to the callback resulting from +// bind; the object will be deleted when the callback is deleted. +// +// EXAMPLE OF Owned(): +// +// void foo(int* arg) { cout << *arg << endl } +// +// int* pn = new int(1); +// RepeatingClosure foo_callback = BindRepeating(&foo, Owned(pn)); +// +// foo_callback.Run(); // Prints "1" +// foo_callback.Run(); // Prints "1" +// *pn = 2; +// foo_callback.Run(); // Prints "2" +// +// foo_callback.Reset(); // |pn| is deleted. Also will happen when +// // |foo_callback| goes out of scope. +// +// Without Owned(), someone would have to know to delete |pn| when the last +// reference to the callback is deleted. +template +inline internal::OwnedWrapper Owned(T* o) { + return internal::OwnedWrapper(o); +} + +template +inline internal::OwnedWrapper Owned( + std::unique_ptr&& ptr) { + return internal::OwnedWrapper(std::move(ptr)); +} + +// OwnedRef() stores an object in the callback resulting from +// bind and passes a reference to the object to the bound function. +// +// EXAMPLE OF OwnedRef(): +// +// void foo(int& arg) { cout << ++arg << endl } +// +// int counter = 0; +// RepeatingClosure foo_callback = BindRepeating(&foo, OwnedRef(counter)); +// +// foo_callback.Run(); // Prints "1" +// foo_callback.Run(); // Prints "2" +// foo_callback.Run(); // Prints "3" +// +// cout << counter; // Prints "0", OwnedRef creates a copy of counter. +// +// Supports OnceCallbacks as well, useful to pass placeholder arguments: +// +// void bar(int& ignore, const std::string& s) { cout << s << endl } +// +// OnceClosure bar_callback = BindOnce(&bar, OwnedRef(0), "Hello"); +// +// std::move(bar_callback).Run(); // Prints "Hello" +// +// Without OwnedRef() it would not be possible to pass a mutable reference to an +// object owned by the callback. +template +internal::OwnedRefWrapper> OwnedRef(T&& t) { + return internal::OwnedRefWrapper>(std::forward(t)); +} + +// Passed() is for transferring movable-but-not-copyable types (eg. unique_ptr) +// through a RepeatingCallback. Logically, this signifies a destructive transfer +// of the state of the argument into the target function. Invoking +// RepeatingCallback::Run() twice on a callback that was created with a Passed() +// argument will CHECK() because the first invocation would have already +// transferred ownership to the target function. +// +// Note that Passed() is not necessary with BindOnce(), as std::move() does the +// same thing. Avoid Passed() in favor of std::move() with BindOnce(). +// +// EXAMPLE OF Passed(): +// +// void TakesOwnership(std::unique_ptr arg) { } +// std::unique_ptr CreateFoo() { return std::make_unique(); +// } +// +// auto f = std::make_unique(); +// +// // |cb| is given ownership of Foo(). |f| is now NULL. +// // You can use std::move(f) in place of &f, but it's more verbose. +// RepeatingClosure cb = BindRepeating(&TakesOwnership, Passed(&f)); +// +// // Run was never called so |cb| still owns Foo() and deletes +// // it on Reset(). +// cb.Reset(); +// +// // |cb| is given a new Foo created by CreateFoo(). +// cb = BindRepeating(&TakesOwnership, Passed(CreateFoo())); +// +// // |arg| in TakesOwnership() is given ownership of Foo(). |cb| +// // no longer owns Foo() and, if reset, would not delete Foo(). +// cb.Run(); // Foo() is now transferred to |arg| and deleted. +// cb.Run(); // This CHECK()s since Foo() already been used once. +// +// We offer 2 syntaxes for calling Passed(). The first takes an rvalue and is +// best suited for use with the return value of a function or other temporary +// rvalues. The second takes a pointer to the scoper and is just syntactic sugar +// to avoid having to write Passed(std::move(scoper)). +// +// Both versions of Passed() prevent T from being an lvalue reference. The first +// via use of enable_if, and the second takes a T* which will not bind to T&. +template ::value>* = nullptr> +inline internal::PassedWrapper Passed(T&& scoper) { + return internal::PassedWrapper(std::move(scoper)); +} +template +inline internal::PassedWrapper Passed(T* scoper) { + return internal::PassedWrapper(std::move(*scoper)); +} + +// IgnoreResult() is used to adapt a function or callback with a return type to +// one with a void return. This is most useful if you have a function with, +// say, a pesky ignorable bool return that you want to use with PostTask or +// something else that expect a callback with a void return. +// +// EXAMPLE OF IgnoreResult(): +// +// int DoSomething(int arg) { cout << arg << endl; } +// +// // Assign to a callback with a void return type. +// OnceCallback cb = BindOnce(IgnoreResult(&DoSomething)); +// std::move(cb).Run(1); // Prints "1". +// +// // Prints "2" on |ml|. +// ml->PostTask(FROM_HERE, BindOnce(IgnoreResult(&DoSomething), 2); +template +inline internal::IgnoreResultHelper IgnoreResult(T data) { + return internal::IgnoreResultHelper(std::move(data)); +} + +#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc) + +// RetainBlock() is used to adapt an Objective-C block when Automated Reference +// Counting (ARC) is disabled. This is unnecessary when ARC is enabled, as the +// BindOnce and BindRepeating already support blocks then. +// +// EXAMPLE OF RetainBlock(): +// +// // Wrap the block and bind it to a callback. +// OnceCallback cb = +// BindOnce(RetainBlock(^(int n) { NSLog(@"%d", n); })); +// std::move(cb).Run(1); // Logs "1". +template +base::mac::ScopedBlock RetainBlock(R (^block)(Args...)) { + return base::mac::ScopedBlock(block, + base::scoped_policy::RETAIN); +} + +#endif // defined(OS_APPLE) && !HAS_FEATURE(objc_arc) + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_BIND_H_ diff --git a/Thirdparty/libcef/include/base/cef_build.h b/Thirdparty/libcef/include/base/cef_build.h new file mode 100644 index 0000000..576056c --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_build.h @@ -0,0 +1,259 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. 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 name Chromium Embedded +// Framework 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. + +// This file adds defines about the platform we're currently building on. +// +// Operating System: +// OS_AIX / OS_ANDROID / OS_ASMJS / OS_FREEBSD / OS_FUCHSIA / OS_IOS / +// OS_LINUX / OS_MAC / OS_NACL (SFI or NONSFI) / OS_NETBSD / OS_OPENBSD / +// OS_QNX / OS_SOLARIS / OS_WIN +// Operating System family: +// OS_APPLE: IOS or MAC +// OS_BSD: FREEBSD or NETBSD or OPENBSD +// OS_POSIX: AIX or ANDROID or ASMJS or CHROMEOS or FREEBSD or IOS or LINUX +// or MAC or NACL or NETBSD or OPENBSD or QNX or SOLARIS +// +// /!\ Note: OS_CHROMEOS is set by the build system, not this file +// +// Compiler: +// COMPILER_MSVC / COMPILER_GCC +// +// Processor: +// ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 / +// ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 / +// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64 +// Processor family: +// ARCH_CPU_ARM_FAMILY: ARMEL or ARM64 +// ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS +// ARCH_CPU_PPC64_FAMILY: PPC64 +// ARCH_CPU_S390_FAMILY: S390 or S390X +// ARCH_CPU_X86_FAMILY: X86 or X86_64 +// Processor features: +// ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS +// ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN + +#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_ +#define CEF_INCLUDE_BASE_CEF_BUILD_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "build/build_config.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +// A set of macros to use for platform detection. +#if defined(ANDROID) +#define OS_ANDROID 1 +#elif defined(__APPLE__) +// Only include TargetConditionals after testing ANDROID as some Android builds +// on the Mac have this header available and it's not needed unless the target +// is really an Apple platform. +#include +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#define OS_IOS 1 +#else +#define OS_MAC 1 +// For backwards compatibility. +#define OS_MACOSX 1 +#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#elif defined(__linux__) +#if !defined(OS_CHROMEOS) +// Do not define OS_LINUX on Chrome OS build. +// The OS_CHROMEOS macro is defined in GN. +#define OS_LINUX 1 +#endif // !defined(OS_CHROMEOS) +// Include a system header to pull in features.h for glibc/uclibc macros. +#include +#if defined(__GLIBC__) && !defined(__UCLIBC__) +// We really are using glibc, not uClibc pretending to be glibc. +#define LIBC_GLIBC 1 +#endif +#elif defined(_WIN32) +#define OS_WIN 1 +#elif defined(__Fuchsia__) +#define OS_FUCHSIA 1 +#elif defined(__FreeBSD__) +#define OS_FREEBSD 1 +#elif defined(__NetBSD__) +#define OS_NETBSD 1 +#elif defined(__OpenBSD__) +#define OS_OPENBSD 1 +#elif defined(__sun) +#define OS_SOLARIS 1 +#elif defined(__QNXNTO__) +#define OS_QNX 1 +#elif defined(_AIX) +#define OS_AIX 1 +#elif defined(__asmjs__) || defined(__wasm__) +#define OS_ASMJS 1 +#else +#error Please add support for your platform in include/base/cef_build.h +#endif +// NOTE: Adding a new port? Please follow +// https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md + +#if defined(OS_MAC) || defined(OS_IOS) +#define OS_APPLE 1 +#endif + +// For access to standard BSD features, use OS_BSD instead of a +// more specific macro. +#if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD) +#define OS_BSD 1 +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \ + defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) || \ + defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_NACL) || \ + defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \ + defined(OS_SOLARIS) +#define OS_POSIX 1 +#endif + +// Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on +// Windows. +#if defined(__GNUC__) +#define COMPILER_GCC 1 +#elif defined(_MSC_VER) +#define COMPILER_MSVC 1 +#else +#error Please add support for your compiler in build/build_config.h +#endif + +// Processor architecture detection. For more info on what's defined, see: +// http://msdn.microsoft.com/en-us/library/b0084kay.aspx +// http://www.agner.org/optimize/calling_conventions.pdf +// or with gcc, run: "echo | gcc -E -dM -" +#if defined(_M_X64) || defined(__x86_64__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86_64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(_M_IX86) || defined(__i386__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__s390x__) +#define ARCH_CPU_S390_FAMILY 1 +#define ARCH_CPU_S390X 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_BIG_ENDIAN 1 +#elif defined(__s390__) +#define ARCH_CPU_S390_FAMILY 1 +#define ARCH_CPU_S390 1 +#define ARCH_CPU_31_BITS 1 +#define ARCH_CPU_BIG_ENDIAN 1 +#elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__) +#define ARCH_CPU_PPC64_FAMILY 1 +#define ARCH_CPU_PPC64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_BIG_ENDIAN 1 +#elif defined(__PPC64__) +#define ARCH_CPU_PPC64_FAMILY 1 +#define ARCH_CPU_PPC64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__ARMEL__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARMEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__aarch64__) || defined(_M_ARM64) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARM64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__) +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__MIPSEL__) +#if defined(__LP64__) +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPS64EL 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#else +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPSEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#endif +#elif defined(__MIPSEB__) +#if defined(__LP64__) +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPS64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_BIG_ENDIAN 1 +#else +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPS 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_BIG_ENDIAN 1 +#endif +#else +#error Please add support for your architecture in include/base/cef_build.h +#endif + +// Type detection for wchar_t. +#if defined(OS_WIN) +#define WCHAR_T_IS_UTF16 +#elif defined(OS_FUCHSIA) +#define WCHAR_T_IS_UTF32 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) +#define WCHAR_T_IS_UTF32 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) +// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to +// compile in this mode (in particular, Chrome doesn't). This is intended for +// other projects using base who manage their own dependencies and make sure +// short wchar works for them. +#define WCHAR_T_IS_UTF16 +#else +#error Please add support for your compiler in include/base/cef_build.h +#endif + +#if defined(OS_ANDROID) +// The compiler thinks std::string::const_iterator and "const char*" are +// equivalent types. +#define STD_STRING_ITERATOR_IS_CHAR_POINTER +// The compiler thinks std::u16string::const_iterator and "char16*" are +// equivalent types. +#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER +#endif + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_ diff --git a/Thirdparty/libcef/include/base/cef_callback.h b/Thirdparty/libcef/include/base/cef_callback.h new file mode 100644 index 0000000..4df8562 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_callback.h @@ -0,0 +1,251 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +// ----------------------------------------------------------------------------- +// Usage documentation +// ----------------------------------------------------------------------------- +// +// Overview: +// A callback is similar in concept to a function pointer: it wraps a runnable +// object such as a function, method, lambda, or even another callback, allowing +// the runnable object to be invoked later via the callback object. +// +// Unlike function pointers, callbacks are created with base::BindOnce() or +// base::BindRepeating() and support partial function application. +// +// A base::OnceCallback may be Run() at most once; a base::RepeatingCallback may +// be Run() any number of times. |is_null()| is guaranteed to return true for a +// moved-from callback. +// +// // The lambda takes two arguments, but the first argument |x| is bound at +// // callback creation. +// base::OnceCallback cb = base::BindOnce([] (int x, int y) { +// return x + y; +// }, 1); +// // Run() only needs the remaining unbound argument |y|. +// printf("1 + 2 = %d\n", std::move(cb).Run(2)); // Prints 3 +// printf("cb is null? %s\n", +// cb.is_null() ? "true" : "false"); // Prints true +// std::move(cb).Run(2); // Crashes since |cb| has already run. +// +// Callbacks also support cancellation. A common use is binding the receiver +// object as a WeakPtr. If that weak pointer is invalidated, calling Run() +// will be a no-op. Note that |IsCancelled()| and |is_null()| are distinct: +// simply cancelling a callback will not also make it null. +// +// See https://chromium.googlesource.com/chromium/src/+/HEAD/docs/callback.md +// for the full documentation. + +#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_bind.h" +#include "include/base/cef_callback_forward.h" +#include "include/base/cef_logging.h" +#include "include/base/internal/cef_callback_internal.h" + +namespace base { + +template +class OnceCallback : public internal::CallbackBase { + public: + using ResultType = R; + using RunType = R(Args...); + using PolymorphicInvoke = R (*)(internal::BindStateBase*, + internal::PassingType...); + + constexpr OnceCallback() = default; + OnceCallback(std::nullptr_t) = delete; + + explicit OnceCallback(internal::BindStateBase* bind_state) + : internal::CallbackBase(bind_state) {} + + OnceCallback(const OnceCallback&) = delete; + OnceCallback& operator=(const OnceCallback&) = delete; + + OnceCallback(OnceCallback&&) noexcept = default; + OnceCallback& operator=(OnceCallback&&) noexcept = default; + + OnceCallback(RepeatingCallback other) + : internal::CallbackBase(std::move(other)) {} + + OnceCallback& operator=(RepeatingCallback other) { + static_cast(*this) = std::move(other); + return *this; + } + + R Run(Args... args) const& { + static_assert(!sizeof(*this), + "OnceCallback::Run() may only be invoked on a non-const " + "rvalue, i.e. std::move(callback).Run()."); + NOTREACHED(); + } + + R Run(Args... args) && { + // Move the callback instance into a local variable before the invocation, + // that ensures the internal state is cleared after the invocation. + // It's not safe to touch |this| after the invocation, since running the + // bound function may destroy |this|. + OnceCallback cb = std::move(*this); + PolymorphicInvoke f = + reinterpret_cast(cb.polymorphic_invoke()); + return f(cb.bind_state_.get(), std::forward(args)...); + } + + // Then() returns a new OnceCallback that receives the same arguments as + // |this|, and with the return type of |then|. The returned callback will: + // 1) Run the functor currently bound to |this| callback. + // 2) Run the |then| callback with the result from step 1 as its single + // argument. + // 3) Return the value from running the |then| callback. + // + // Since this method generates a callback that is a replacement for `this`, + // `this` will be consumed and reset to a null callback to ensure the + // originally-bound functor can be run at most once. + template + OnceCallback Then(OnceCallback then) && { + CHECK(then); + return BindOnce( + internal::ThenHelper< + OnceCallback, OnceCallback>::CreateTrampoline(), + std::move(*this), std::move(then)); + } + + // This overload is required; even though RepeatingCallback is implicitly + // convertible to OnceCallback, that conversion will not used when matching + // for template argument deduction. + template + OnceCallback Then( + RepeatingCallback then) && { + CHECK(then); + return BindOnce( + internal::ThenHelper< + OnceCallback, + RepeatingCallback>::CreateTrampoline(), + std::move(*this), std::move(then)); + } +}; + +template +class RepeatingCallback : public internal::CallbackBaseCopyable { + public: + using ResultType = R; + using RunType = R(Args...); + using PolymorphicInvoke = R (*)(internal::BindStateBase*, + internal::PassingType...); + + constexpr RepeatingCallback() = default; + RepeatingCallback(std::nullptr_t) = delete; + + explicit RepeatingCallback(internal::BindStateBase* bind_state) + : internal::CallbackBaseCopyable(bind_state) {} + + // Copyable and movable. + RepeatingCallback(const RepeatingCallback&) = default; + RepeatingCallback& operator=(const RepeatingCallback&) = default; + RepeatingCallback(RepeatingCallback&&) noexcept = default; + RepeatingCallback& operator=(RepeatingCallback&&) noexcept = default; + + bool operator==(const RepeatingCallback& other) const { + return EqualsInternal(other); + } + + bool operator!=(const RepeatingCallback& other) const { + return !operator==(other); + } + + R Run(Args... args) const& { + PolymorphicInvoke f = + reinterpret_cast(this->polymorphic_invoke()); + return f(this->bind_state_.get(), std::forward(args)...); + } + + R Run(Args... args) && { + // Move the callback instance into a local variable before the invocation, + // that ensures the internal state is cleared after the invocation. + // It's not safe to touch |this| after the invocation, since running the + // bound function may destroy |this|. + RepeatingCallback cb = std::move(*this); + PolymorphicInvoke f = + reinterpret_cast(cb.polymorphic_invoke()); + return f(std::move(cb).bind_state_.get(), std::forward(args)...); + } + + // Then() returns a new RepeatingCallback that receives the same arguments as + // |this|, and with the return type of |then|. The + // returned callback will: + // 1) Run the functor currently bound to |this| callback. + // 2) Run the |then| callback with the result from step 1 as its single + // argument. + // 3) Return the value from running the |then| callback. + // + // If called on an rvalue (e.g. std::move(cb).Then(...)), this method + // generates a callback that is a replacement for `this`. Therefore, `this` + // will be consumed and reset to a null callback to ensure the + // originally-bound functor will be run at most once. + template + RepeatingCallback Then( + RepeatingCallback then) const& { + CHECK(then); + return BindRepeating( + internal::ThenHelper< + RepeatingCallback, + RepeatingCallback>::CreateTrampoline(), + *this, std::move(then)); + } + + template + RepeatingCallback Then( + RepeatingCallback then) && { + CHECK(then); + return BindRepeating( + internal::ThenHelper< + RepeatingCallback, + RepeatingCallback>::CreateTrampoline(), + std::move(*this), std::move(then)); + } +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_H_ diff --git a/Thirdparty/libcef/include/base/cef_callback_forward.h b/Thirdparty/libcef/include/base/cef_callback_forward.h new file mode 100644 index 0000000..3587fa4 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_callback_forward.h @@ -0,0 +1,61 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +#ifndef INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ +#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_forward.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +namespace base { + +template +class OnceCallback; + +template +class RepeatingCallback; + +// Syntactic sugar to make OnceClosure and RepeatingClosure +// easier to declare since they will be used in a lot of APIs with delayed +// execution. +using OnceClosure = OnceCallback; +using RepeatingClosure = RepeatingCallback; + +} // namespace base + +#endif // !!USING_CHROMIUM_INCLUDES + +#endif // INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ diff --git a/Thirdparty/libcef/include/base/cef_callback_helpers.h b/Thirdparty/libcef/include/base/cef_callback_helpers.h new file mode 100644 index 0000000..0d04e16 --- /dev/null +++ b/Thirdparty/libcef/include/base/cef_callback_helpers.h @@ -0,0 +1,241 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. 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 name Chromium Embedded +// Framework 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. + +// This defines helpful methods for dealing with Callbacks. Because Callbacks +// are implemented using templates, with a class per callback signature, adding +// methods to Callback<> itself is unattractive (lots of extra code gets +// generated). Instead, consider adding methods here. + +#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_helpers.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include +#include +#include +#include + +#include "include/base/cef_bind.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_compiler_specific.h" +#include "include/base/cef_logging.h" + +namespace base { + +namespace internal { + +template +struct IsBaseCallbackImpl : std::false_type {}; + +template +struct IsBaseCallbackImpl> : std::true_type {}; + +template +struct IsBaseCallbackImpl> : std::true_type {}; + +template +struct IsOnceCallbackImpl : std::false_type {}; + +template +struct IsOnceCallbackImpl> : std::true_type {}; + +} // namespace internal + +// IsBaseCallback::value is true when T is any of the Closure or Callback +// family of types. +template +using IsBaseCallback = internal::IsBaseCallbackImpl>; + +// IsOnceCallback::value is true when T is a OnceClosure or OnceCallback +// type. +template +using IsOnceCallback = internal::IsOnceCallbackImpl>; + +// SFINAE friendly enabler allowing to overload methods for both Repeating and +// OnceCallbacks. +// +// Usage: +// template