add cef library
This commit is contained in:
parent
5d96f91a26
commit
14aa6ffe31
11
README.md
11
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
|
BIN
Thirdparty/libcef/Resources/chrome_100_percent.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/chrome_100_percent.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/chrome_200_percent.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/chrome_200_percent.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/icudtl.dat
vendored
Normal file
BIN
Thirdparty/libcef/Resources/icudtl.dat
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/af.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/af.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/am.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/am.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ar.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ar.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/bg.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/bg.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/bn.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/bn.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ca.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ca.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/cs.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/cs.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/da.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/da.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/de.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/de.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/el.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/el.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/en-GB.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/en-GB.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/en-US.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/en-US.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/es-419.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/es-419.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/es.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/es.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/et.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/et.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/fa.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/fa.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/fi.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/fi.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/fil.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/fil.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/fr.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/fr.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/gu.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/gu.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/he.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/he.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/hi.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/hi.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/hr.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/hr.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/hu.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/hu.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/id.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/id.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/it.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/it.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ja.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ja.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/kn.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/kn.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ko.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ko.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/lt.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/lt.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/lv.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/lv.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ml.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ml.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/mr.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/mr.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ms.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ms.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/nb.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/nb.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/nl.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/nl.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/pl.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/pl.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/pt-BR.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/pt-BR.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/pt-PT.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/pt-PT.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ro.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ro.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ru.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ru.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/sk.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/sk.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/sl.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/sl.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/sr.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/sr.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/sv.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/sv.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/sw.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/sw.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ta.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ta.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/te.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/te.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/th.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/th.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/tr.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/tr.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/uk.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/uk.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/ur.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/ur.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/vi.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/vi.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/zh-CN.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/zh-CN.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/locales/zh-TW.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/locales/zh-TW.pak
vendored
Normal file
Binary file not shown.
BIN
Thirdparty/libcef/Resources/resources.pak
vendored
Normal file
BIN
Thirdparty/libcef/Resources/resources.pak
vendored
Normal file
Binary file not shown.
88
Thirdparty/libcef/include/base/cef_atomic_flag.h
vendored
Normal file
88
Thirdparty/libcef/include/base/cef_atomic_flag.h
vendored
Normal file
@ -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 <stdint.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#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<uint_fast8_t> flag_{0};
|
||||
base::ThreadChecker set_thread_checker_;
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
111
Thirdparty/libcef/include/base/cef_atomic_ref_count.h
vendored
Normal file
111
Thirdparty/libcef/include/base/cef_atomic_ref_count.h
vendored
Normal file
@ -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 <atomic>
|
||||
|
||||
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_
|
89
Thirdparty/libcef/include/base/cef_auto_reset.h
vendored
Normal file
89
Thirdparty/libcef/include/base/cef_auto_reset.h
vendored
Normal file
@ -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 <utility>
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename T>
|
||||
class AutoReset {
|
||||
public:
|
||||
template <typename U>
|
||||
AutoReset(T* scoped_variable, U&& new_value)
|
||||
: scoped_variable_(scoped_variable),
|
||||
original_value_(
|
||||
std::exchange(*scoped_variable_, std::forward<U>(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_
|
86
Thirdparty/libcef/include/base/cef_basictypes.h
vendored
Normal file
86
Thirdparty/libcef/include/base/cef_basictypes.h
vendored
Normal file
@ -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 <limits.h> // For UINT_MAX
|
||||
#include <stddef.h> // 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
|
||||
// <inttypes.h> 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_
|
352
Thirdparty/libcef/include/base/cef_bind.h
vendored
Normal file
352
Thirdparty/libcef/include/base/cef_bind.h
vendored
Normal file
@ -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<long(int, long)> 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<C> { void F(); };
|
||||
// auto instance = base::MakeRefCounted<C>();
|
||||
// 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 <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#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 <typename Functor, typename... Args>
|
||||
inline OnceCallback<internal::MakeUnboundRunType<Functor, Args...>> BindOnce(
|
||||
Functor&& functor,
|
||||
Args&&... args) {
|
||||
static_assert(!internal::IsOnceCallback<std::decay_t<Functor>>() ||
|
||||
(std::is_rvalue_reference<Functor&&>() &&
|
||||
!std::is_const<std::remove_reference_t<Functor>>()),
|
||||
"BindOnce requires non-const rvalue for OnceCallback binding."
|
||||
" I.e.: base::BindOnce(std::move(callback)).");
|
||||
static_assert(
|
||||
conjunction<
|
||||
internal::AssertBindArgIsNotBasePassed<std::decay_t<Args>>...>::value,
|
||||
"Use std::move() instead of base::Passed() with base::BindOnce()");
|
||||
|
||||
return internal::BindImpl<OnceCallback>(std::forward<Functor>(functor),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Bind as RepeatingCallback.
|
||||
template <typename Functor, typename... Args>
|
||||
inline RepeatingCallback<internal::MakeUnboundRunType<Functor, Args...>>
|
||||
BindRepeating(Functor&& functor, Args&&... args) {
|
||||
static_assert(
|
||||
!internal::IsOnceCallback<std::decay_t<Functor>>(),
|
||||
"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move().");
|
||||
|
||||
return internal::BindImpl<RepeatingCallback>(std::forward<Functor>(functor),
|
||||
std::forward<Args>(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 <typename Signature>
|
||||
OnceCallback<Signature> BindOnce(OnceCallback<Signature> callback) {
|
||||
CHECK(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
OnceCallback<Signature> BindOnce(RepeatingCallback<Signature> callback) {
|
||||
CHECK(callback);
|
||||
return callback;
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
RepeatingCallback<Signature> BindRepeating(
|
||||
RepeatingCallback<Signature> 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 <typename T>
|
||||
inline internal::UnretainedWrapper<T> Unretained(T* o) {
|
||||
return internal::UnretainedWrapper<T>(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<RefCountedBytes> 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 <typename T>
|
||||
inline internal::RetainedRefWrapper<T> RetainedRef(T* o) {
|
||||
return internal::RetainedRefWrapper<T>(o);
|
||||
}
|
||||
template <typename T>
|
||||
inline internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) {
|
||||
return internal::RetainedRefWrapper<T>(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 <typename T>
|
||||
inline internal::OwnedWrapper<T> Owned(T* o) {
|
||||
return internal::OwnedWrapper<T>(o);
|
||||
}
|
||||
|
||||
template <typename T, typename Deleter>
|
||||
inline internal::OwnedWrapper<T, Deleter> Owned(
|
||||
std::unique_ptr<T, Deleter>&& ptr) {
|
||||
return internal::OwnedWrapper<T, Deleter>(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 <typename T>
|
||||
internal::OwnedRefWrapper<std::decay_t<T>> OwnedRef(T&& t) {
|
||||
return internal::OwnedRefWrapper<std::decay_t<T>>(std::forward<T>(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<Foo> arg) { }
|
||||
// std::unique_ptr<Foo> CreateFoo() { return std::make_unique<Foo>();
|
||||
// }
|
||||
//
|
||||
// auto f = std::make_unique<Foo>();
|
||||
//
|
||||
// // |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 <typename T,
|
||||
std::enable_if_t<!std::is_lvalue_reference<T>::value>* = nullptr>
|
||||
inline internal::PassedWrapper<T> Passed(T&& scoper) {
|
||||
return internal::PassedWrapper<T>(std::move(scoper));
|
||||
}
|
||||
template <typename T>
|
||||
inline internal::PassedWrapper<T> Passed(T* scoper) {
|
||||
return internal::PassedWrapper<T>(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<void(int)> cb = BindOnce(IgnoreResult(&DoSomething));
|
||||
// std::move(cb).Run(1); // Prints "1".
|
||||
//
|
||||
// // Prints "2" on |ml|.
|
||||
// ml->PostTask(FROM_HERE, BindOnce(IgnoreResult(&DoSomething), 2);
|
||||
template <typename T>
|
||||
inline internal::IgnoreResultHelper<T> IgnoreResult(T data) {
|
||||
return internal::IgnoreResultHelper<T>(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<void(int)> cb =
|
||||
// BindOnce(RetainBlock(^(int n) { NSLog(@"%d", n); }));
|
||||
// std::move(cb).Run(1); // Logs "1".
|
||||
template <typename R, typename... Args>
|
||||
base::mac::ScopedBlock<R (^)(Args...)> RetainBlock(R (^block)(Args...)) {
|
||||
return base::mac::ScopedBlock<R (^)(Args...)>(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_
|
259
Thirdparty/libcef/include/base/cef_build.h
vendored
Normal file
259
Thirdparty/libcef/include/base/cef_build.h
vendored
Normal file
@ -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 <TargetConditionals.h>
|
||||
#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 <unistd.h>
|
||||
#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_
|
251
Thirdparty/libcef/include/base/cef_callback.h
vendored
Normal file
251
Thirdparty/libcef/include/base/cef_callback.h
vendored
Normal file
@ -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<int(int)> 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<T>. 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 <stddef.h>
|
||||
|
||||
#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 <typename R, typename... Args>
|
||||
class OnceCallback<R(Args...)> : public internal::CallbackBase {
|
||||
public:
|
||||
using ResultType = R;
|
||||
using RunType = R(Args...);
|
||||
using PolymorphicInvoke = R (*)(internal::BindStateBase*,
|
||||
internal::PassingType<Args>...);
|
||||
|
||||
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<RunType> other)
|
||||
: internal::CallbackBase(std::move(other)) {}
|
||||
|
||||
OnceCallback& operator=(RepeatingCallback<RunType> other) {
|
||||
static_cast<internal::CallbackBase&>(*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<PolymorphicInvoke>(cb.polymorphic_invoke());
|
||||
return f(cb.bind_state_.get(), std::forward<Args>(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 <typename ThenR, typename... ThenArgs>
|
||||
OnceCallback<ThenR(Args...)> Then(OnceCallback<ThenR(ThenArgs...)> then) && {
|
||||
CHECK(then);
|
||||
return BindOnce(
|
||||
internal::ThenHelper<
|
||||
OnceCallback, OnceCallback<ThenR(ThenArgs...)>>::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 <typename ThenR, typename... ThenArgs>
|
||||
OnceCallback<ThenR(Args...)> Then(
|
||||
RepeatingCallback<ThenR(ThenArgs...)> then) && {
|
||||
CHECK(then);
|
||||
return BindOnce(
|
||||
internal::ThenHelper<
|
||||
OnceCallback,
|
||||
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
std::move(*this), std::move(then));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable {
|
||||
public:
|
||||
using ResultType = R;
|
||||
using RunType = R(Args...);
|
||||
using PolymorphicInvoke = R (*)(internal::BindStateBase*,
|
||||
internal::PassingType<Args>...);
|
||||
|
||||
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<PolymorphicInvoke>(this->polymorphic_invoke());
|
||||
return f(this->bind_state_.get(), std::forward<Args>(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<PolymorphicInvoke>(cb.polymorphic_invoke());
|
||||
return f(std::move(cb).bind_state_.get(), std::forward<Args>(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 <typename ThenR, typename... ThenArgs>
|
||||
RepeatingCallback<ThenR(Args...)> Then(
|
||||
RepeatingCallback<ThenR(ThenArgs...)> then) const& {
|
||||
CHECK(then);
|
||||
return BindRepeating(
|
||||
internal::ThenHelper<
|
||||
RepeatingCallback,
|
||||
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
*this, std::move(then));
|
||||
}
|
||||
|
||||
template <typename ThenR, typename... ThenArgs>
|
||||
RepeatingCallback<ThenR(Args...)> Then(
|
||||
RepeatingCallback<ThenR(ThenArgs...)> then) && {
|
||||
CHECK(then);
|
||||
return BindRepeating(
|
||||
internal::ThenHelper<
|
||||
RepeatingCallback,
|
||||
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||
std::move(*this), std::move(then));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
61
Thirdparty/libcef/include/base/cef_callback_forward.h
vendored
Normal file
61
Thirdparty/libcef/include/base/cef_callback_forward.h
vendored
Normal file
@ -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 <typename Signature>
|
||||
class OnceCallback;
|
||||
|
||||
template <typename Signature>
|
||||
class RepeatingCallback;
|
||||
|
||||
// Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()>
|
||||
// easier to declare since they will be used in a lot of APIs with delayed
|
||||
// execution.
|
||||
using OnceClosure = OnceCallback<void()>;
|
||||
using RepeatingClosure = RepeatingCallback<void()>;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !!USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
241
Thirdparty/libcef/include/base/cef_callback_helpers.h
vendored
Normal file
241
Thirdparty/libcef/include/base/cef_callback_helpers.h
vendored
Normal file
@ -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 <atomic>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#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 <typename T>
|
||||
struct IsBaseCallbackImpl : std::false_type {};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct IsBaseCallbackImpl<OnceCallback<R(Args...)>> : std::true_type {};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct IsBaseCallbackImpl<RepeatingCallback<R(Args...)>> : std::true_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsOnceCallbackImpl : std::false_type {};
|
||||
|
||||
template <typename R, typename... Args>
|
||||
struct IsOnceCallbackImpl<OnceCallback<R(Args...)>> : std::true_type {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// IsBaseCallback<T>::value is true when T is any of the Closure or Callback
|
||||
// family of types.
|
||||
template <typename T>
|
||||
using IsBaseCallback = internal::IsBaseCallbackImpl<std::decay_t<T>>;
|
||||
|
||||
// IsOnceCallback<T>::value is true when T is a OnceClosure or OnceCallback
|
||||
// type.
|
||||
template <typename T>
|
||||
using IsOnceCallback = internal::IsOnceCallbackImpl<std::decay_t<T>>;
|
||||
|
||||
// SFINAE friendly enabler allowing to overload methods for both Repeating and
|
||||
// OnceCallbacks.
|
||||
//
|
||||
// Usage:
|
||||
// template <template <typename> class CallbackType,
|
||||
// ... other template args ...,
|
||||
// typename = EnableIfIsBaseCallback<CallbackType>>
|
||||
// void DoStuff(CallbackType<...> cb, ...);
|
||||
template <template <typename> class CallbackType>
|
||||
using EnableIfIsBaseCallback =
|
||||
std::enable_if_t<IsBaseCallback<CallbackType<void()>>::value>;
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename... Args>
|
||||
class OnceCallbackHolder final {
|
||||
public:
|
||||
OnceCallbackHolder(OnceCallback<void(Args...)> callback,
|
||||
bool ignore_extra_runs)
|
||||
: callback_(std::move(callback)), ignore_extra_runs_(ignore_extra_runs) {
|
||||
DCHECK(callback_);
|
||||
}
|
||||
OnceCallbackHolder(const OnceCallbackHolder&) = delete;
|
||||
OnceCallbackHolder& operator=(const OnceCallbackHolder&) = delete;
|
||||
|
||||
void Run(Args... args) {
|
||||
if (has_run_.exchange(true)) {
|
||||
CHECK(ignore_extra_runs_) << "Both OnceCallbacks returned by "
|
||||
"base::SplitOnceCallback() were run. "
|
||||
"At most one of the pair should be run.";
|
||||
return;
|
||||
}
|
||||
DCHECK(callback_);
|
||||
std::move(callback_).Run(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
private:
|
||||
volatile std::atomic_bool has_run_{false};
|
||||
base::OnceCallback<void(Args...)> callback_;
|
||||
const bool ignore_extra_runs_;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Wraps the given OnceCallback into a RepeatingCallback that relays its
|
||||
// invocation to the original OnceCallback on the first invocation. The
|
||||
// following invocations are just ignored.
|
||||
//
|
||||
// Note that this deliberately subverts the Once/Repeating paradigm of Callbacks
|
||||
// but helps ease the migration from old-style Callbacks. Avoid if possible; use
|
||||
// if necessary for migration. TODO(tzik): Remove it. https://crbug.com/730593
|
||||
template <typename... Args>
|
||||
RepeatingCallback<void(Args...)> AdaptCallbackForRepeating(
|
||||
OnceCallback<void(Args...)> callback) {
|
||||
using Helper = internal::OnceCallbackHolder<Args...>;
|
||||
return base::BindRepeating(
|
||||
&Helper::Run, std::make_unique<Helper>(std::move(callback),
|
||||
/*ignore_extra_runs=*/true));
|
||||
}
|
||||
|
||||
// Wraps the given OnceCallback and returns two OnceCallbacks with an identical
|
||||
// signature. On first invokation of either returned callbacks, the original
|
||||
// callback is invoked. Invoking the remaining callback results in a crash.
|
||||
template <typename... Args>
|
||||
std::pair<OnceCallback<void(Args...)>, OnceCallback<void(Args...)>>
|
||||
SplitOnceCallback(OnceCallback<void(Args...)> callback) {
|
||||
using Helper = internal::OnceCallbackHolder<Args...>;
|
||||
auto wrapped_once = base::BindRepeating(
|
||||
&Helper::Run, std::make_unique<Helper>(std::move(callback),
|
||||
/*ignore_extra_runs=*/false));
|
||||
return std::make_pair(wrapped_once, wrapped_once);
|
||||
}
|
||||
|
||||
// ScopedClosureRunner is akin to std::unique_ptr<> for Closures. It ensures
|
||||
// that the Closure is executed no matter how the current scope exits.
|
||||
// If you are looking for "ScopedCallback", "CallbackRunner", or
|
||||
// "CallbackScoper" this is the class you want.
|
||||
class ScopedClosureRunner {
|
||||
public:
|
||||
ScopedClosureRunner();
|
||||
explicit ScopedClosureRunner(OnceClosure closure);
|
||||
ScopedClosureRunner(ScopedClosureRunner&& other);
|
||||
// Runs the current closure if it's set, then replaces it with the closure
|
||||
// from |other|. This is akin to how unique_ptr frees the contained pointer in
|
||||
// its move assignment operator. If you need to explicitly avoid running any
|
||||
// current closure, use ReplaceClosure().
|
||||
ScopedClosureRunner& operator=(ScopedClosureRunner&& other);
|
||||
~ScopedClosureRunner();
|
||||
|
||||
explicit operator bool() const { return !!closure_; }
|
||||
|
||||
// Calls the current closure and resets it, so it wont be called again.
|
||||
void RunAndReset();
|
||||
|
||||
// Replaces closure with the new one releasing the old one without calling it.
|
||||
void ReplaceClosure(OnceClosure closure);
|
||||
|
||||
// Releases the Closure without calling.
|
||||
OnceClosure Release() WARN_UNUSED_RESULT;
|
||||
|
||||
private:
|
||||
OnceClosure closure_;
|
||||
};
|
||||
|
||||
// Creates a null callback.
|
||||
class NullCallback {
|
||||
public:
|
||||
template <typename R, typename... Args>
|
||||
operator RepeatingCallback<R(Args...)>() const {
|
||||
return RepeatingCallback<R(Args...)>();
|
||||
}
|
||||
template <typename R, typename... Args>
|
||||
operator OnceCallback<R(Args...)>() const {
|
||||
return OnceCallback<R(Args...)>();
|
||||
}
|
||||
};
|
||||
|
||||
// Creates a callback that does nothing when called.
|
||||
class DoNothing {
|
||||
public:
|
||||
template <typename... Args>
|
||||
operator RepeatingCallback<void(Args...)>() const {
|
||||
return Repeatedly<Args...>();
|
||||
}
|
||||
template <typename... Args>
|
||||
operator OnceCallback<void(Args...)>() const {
|
||||
return Once<Args...>();
|
||||
}
|
||||
// Explicit way of specifying a specific callback type when the compiler can't
|
||||
// deduce it.
|
||||
template <typename... Args>
|
||||
static RepeatingCallback<void(Args...)> Repeatedly() {
|
||||
return BindRepeating([](Args... args) {});
|
||||
}
|
||||
template <typename... Args>
|
||||
static OnceCallback<void(Args...)> Once() {
|
||||
return BindOnce([](Args... args) {});
|
||||
}
|
||||
};
|
||||
|
||||
// Useful for creating a Closure that will delete a pointer when invoked. Only
|
||||
// use this when necessary. In most cases MessageLoop::DeleteSoon() is a better
|
||||
// fit.
|
||||
template <typename T>
|
||||
void DeletePointer(T* obj) {
|
||||
delete obj;
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
395
Thirdparty/libcef/include/base/cef_callback_list.h
vendored
Normal file
395
Thirdparty/libcef/include/base/cef_callback_list.h
vendored
Normal file
@ -0,0 +1,395 @@
|
||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013
|
||||
// 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.
|
||||
|
||||
// OVERVIEW:
|
||||
//
|
||||
// A container for a list of callbacks. Provides callers the ability to manually
|
||||
// or automatically unregister callbacks at any time, including during callback
|
||||
// notification.
|
||||
//
|
||||
// TYPICAL USAGE:
|
||||
//
|
||||
// class MyWidget {
|
||||
// public:
|
||||
// using CallbackList = base::RepeatingCallbackList<void(const Foo&)>;
|
||||
//
|
||||
// // Registers |cb| to be called whenever NotifyFoo() is executed.
|
||||
// CallbackListSubscription RegisterCallback(CallbackList::CallbackType cb) {
|
||||
// return callback_list_.Add(std::move(cb));
|
||||
// }
|
||||
//
|
||||
// private:
|
||||
// // Calls all registered callbacks, with |foo| as the supplied arg.
|
||||
// void NotifyFoo(const Foo& foo) {
|
||||
// callback_list_.Notify(foo);
|
||||
// }
|
||||
//
|
||||
// CallbackList callback_list_;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// class MyWidgetListener {
|
||||
// private:
|
||||
// void OnFoo(const Foo& foo) {
|
||||
// // Called whenever MyWidget::NotifyFoo() is executed, unless
|
||||
// // |foo_subscription_| has been destroyed.
|
||||
// }
|
||||
//
|
||||
// // Automatically deregisters the callback when deleted (e.g. in
|
||||
// // ~MyWidgetListener()). Unretained(this) is safe here since the
|
||||
// // ScopedClosureRunner does not outlive |this|.
|
||||
// CallbackListSubscription foo_subscription_ =
|
||||
// MyWidget::Get()->RegisterCallback(
|
||||
// base::BindRepeating(&MyWidgetListener::OnFoo,
|
||||
// base::Unretained(this)));
|
||||
// };
|
||||
//
|
||||
// UNSUPPORTED:
|
||||
//
|
||||
// * Destroying the CallbackList during callback notification.
|
||||
//
|
||||
// This is possible to support, but not currently necessary.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/callback_list.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 <algorithm>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_auto_reset.h"
|
||||
#include "include/base/cef_bind.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_callback_helpers.h"
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_weak_ptr.h"
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
template <typename CallbackListImpl>
|
||||
class CallbackListBase;
|
||||
} // namespace internal
|
||||
|
||||
template <typename Signature>
|
||||
class OnceCallbackList;
|
||||
|
||||
template <typename Signature>
|
||||
class RepeatingCallbackList;
|
||||
|
||||
// A trimmed-down version of ScopedClosureRunner that can be used to guarantee a
|
||||
// closure is run on destruction. This is designed to be used by
|
||||
// CallbackListBase to run CancelCallback() when this subscription dies;
|
||||
// consumers can avoid callbacks on dead objects by ensuring the subscription
|
||||
// returned by CallbackListBase::Add() does not outlive the bound object in the
|
||||
// callback. A typical way to do this is to bind a callback to a member function
|
||||
// on `this` and store the returned subscription as a member variable.
|
||||
class CallbackListSubscription {
|
||||
public:
|
||||
CallbackListSubscription();
|
||||
CallbackListSubscription(CallbackListSubscription&& subscription);
|
||||
CallbackListSubscription& operator=(CallbackListSubscription&& subscription);
|
||||
~CallbackListSubscription();
|
||||
|
||||
explicit operator bool() const { return !!closure_; }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
friend class internal::CallbackListBase;
|
||||
|
||||
explicit CallbackListSubscription(base::OnceClosure closure);
|
||||
|
||||
void Run();
|
||||
|
||||
OnceClosure closure_;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// From base/stl_util.h.
|
||||
template <class T, class Allocator, class Predicate>
|
||||
size_t EraseIf(std::list<T, Allocator>& container, Predicate pred) {
|
||||
size_t old_size = container.size();
|
||||
container.remove_if(pred);
|
||||
return old_size - container.size();
|
||||
}
|
||||
|
||||
// A traits class to break circular type dependencies between CallbackListBase
|
||||
// and its subclasses.
|
||||
template <typename CallbackList>
|
||||
struct CallbackListTraits;
|
||||
|
||||
// NOTE: It's important that Callbacks provide iterator stability when items are
|
||||
// added to the end, so e.g. a std::vector<> is not suitable here.
|
||||
template <typename Signature>
|
||||
struct CallbackListTraits<OnceCallbackList<Signature>> {
|
||||
using CallbackType = OnceCallback<Signature>;
|
||||
using Callbacks = std::list<CallbackType>;
|
||||
};
|
||||
template <typename Signature>
|
||||
struct CallbackListTraits<RepeatingCallbackList<Signature>> {
|
||||
using CallbackType = RepeatingCallback<Signature>;
|
||||
using Callbacks = std::list<CallbackType>;
|
||||
};
|
||||
|
||||
template <typename CallbackListImpl>
|
||||
class CallbackListBase {
|
||||
public:
|
||||
using CallbackType =
|
||||
typename CallbackListTraits<CallbackListImpl>::CallbackType;
|
||||
static_assert(IsBaseCallback<CallbackType>::value, "");
|
||||
|
||||
// TODO(crbug.com/1103086): Update references to use this directly and by
|
||||
// value, then remove.
|
||||
using Subscription = CallbackListSubscription;
|
||||
|
||||
CallbackListBase() = default;
|
||||
CallbackListBase(const CallbackListBase&) = delete;
|
||||
CallbackListBase& operator=(const CallbackListBase&) = delete;
|
||||
|
||||
~CallbackListBase() {
|
||||
// Destroying the list during iteration is unsupported and will cause a UAF.
|
||||
CHECK(!iterating_);
|
||||
}
|
||||
|
||||
// Registers |cb| for future notifications. Returns a CallbackListSubscription
|
||||
// whose destruction will cancel |cb|.
|
||||
CallbackListSubscription Add(CallbackType cb) WARN_UNUSED_RESULT {
|
||||
DCHECK(!cb.is_null());
|
||||
return CallbackListSubscription(base::BindOnce(
|
||||
&CallbackListBase::CancelCallback, weak_ptr_factory_.GetWeakPtr(),
|
||||
callbacks_.insert(callbacks_.end(), std::move(cb))));
|
||||
}
|
||||
|
||||
// Registers |cb| for future notifications. Provides no way for the caller to
|
||||
// cancel, so this is only safe for cases where the callback is guaranteed to
|
||||
// live at least as long as this list (e.g. if it's bound on the same object
|
||||
// that owns the list).
|
||||
// TODO(pkasting): Attempt to use Add() instead and see if callers can relax
|
||||
// other lifetime/ordering mechanisms as a result.
|
||||
void AddUnsafe(CallbackType cb) {
|
||||
DCHECK(!cb.is_null());
|
||||
callbacks_.push_back(std::move(cb));
|
||||
}
|
||||
|
||||
// Registers |removal_callback| to be run after elements are removed from the
|
||||
// list of registered callbacks.
|
||||
void set_removal_callback(const RepeatingClosure& removal_callback) {
|
||||
removal_callback_ = removal_callback;
|
||||
}
|
||||
|
||||
// Returns whether the list of registered callbacks is empty (from an external
|
||||
// perspective -- meaning no remaining callbacks are live).
|
||||
bool empty() const {
|
||||
return std::all_of(callbacks_.cbegin(), callbacks_.cend(),
|
||||
[](const auto& callback) { return callback.is_null(); });
|
||||
}
|
||||
|
||||
// Calls all registered callbacks that are not canceled beforehand. If any
|
||||
// callbacks are unregistered, notifies any registered removal callback at the
|
||||
// end.
|
||||
//
|
||||
// Arguments must be copyable, since they must be supplied to all callbacks.
|
||||
// Move-only types would be destructively modified by passing them to the
|
||||
// first callback and not reach subsequent callbacks as intended.
|
||||
//
|
||||
// Notify() may be called re-entrantly, in which case the nested call
|
||||
// completes before the outer one continues. Callbacks are only ever added at
|
||||
// the end and canceled callbacks are not pruned from the list until the
|
||||
// outermost iteration completes, so existing iterators should never be
|
||||
// invalidated. However, this does mean that a callback added during a nested
|
||||
// call can be notified by outer calls -- meaning it will be notified about
|
||||
// things that happened before it was added -- if its subscription outlives
|
||||
// the reentrant Notify() call.
|
||||
template <typename... RunArgs>
|
||||
void Notify(RunArgs&&... args) {
|
||||
if (empty())
|
||||
return; // Nothing to do.
|
||||
|
||||
{
|
||||
AutoReset<bool> iterating(&iterating_, true);
|
||||
|
||||
// Skip any callbacks that are canceled during iteration.
|
||||
// NOTE: Since RunCallback() may call Add(), it's not safe to cache the
|
||||
// value of callbacks_.end() across loop iterations.
|
||||
const auto next_valid = [this](const auto it) {
|
||||
return std::find_if_not(it, callbacks_.end(), [](const auto& callback) {
|
||||
return callback.is_null();
|
||||
});
|
||||
};
|
||||
for (auto it = next_valid(callbacks_.begin()); it != callbacks_.end();
|
||||
it = next_valid(it))
|
||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...,
|
||||
// since that would allow move-only arguments.
|
||||
static_cast<CallbackListImpl*>(this)->RunCallback(it++, args...);
|
||||
}
|
||||
|
||||
// Re-entrant invocations shouldn't prune anything from the list. This can
|
||||
// invalidate iterators from underneath higher call frames. It's safe to
|
||||
// simply do nothing, since the outermost frame will continue through here
|
||||
// and prune all null callbacks below.
|
||||
if (iterating_)
|
||||
return;
|
||||
|
||||
// Any null callbacks remaining in the list were canceled due to
|
||||
// Subscription destruction during iteration, and can safely be erased now.
|
||||
const size_t erased_callbacks =
|
||||
EraseIf(callbacks_, [](const auto& cb) { return cb.is_null(); });
|
||||
|
||||
// Run |removal_callback_| if any callbacks were canceled. Note that we
|
||||
// cannot simply compare list sizes before and after iterating, since
|
||||
// notification may result in Add()ing new callbacks as well as canceling
|
||||
// them. Also note that if this is a OnceCallbackList, the OnceCallbacks
|
||||
// that were executed above have all been removed regardless of whether
|
||||
// they're counted in |erased_callbacks_|.
|
||||
if (removal_callback_ &&
|
||||
(erased_callbacks || IsOnceCallback<CallbackType>::value))
|
||||
removal_callback_.Run(); // May delete |this|!
|
||||
}
|
||||
|
||||
protected:
|
||||
using Callbacks = typename CallbackListTraits<CallbackListImpl>::Callbacks;
|
||||
|
||||
// Holds non-null callbacks, which will be called during Notify().
|
||||
Callbacks callbacks_;
|
||||
|
||||
private:
|
||||
// Cancels the callback pointed to by |it|, which is guaranteed to be valid.
|
||||
void CancelCallback(const typename Callbacks::iterator& it) {
|
||||
if (static_cast<CallbackListImpl*>(this)->CancelNullCallback(it))
|
||||
return;
|
||||
|
||||
if (iterating_) {
|
||||
// Calling erase() here is unsafe, since the loop in Notify() may be
|
||||
// referencing this same iterator, e.g. if adjacent callbacks'
|
||||
// Subscriptions are both destroyed when the first one is Run(). Just
|
||||
// reset the callback and let Notify() clean it up at the end.
|
||||
it->Reset();
|
||||
} else {
|
||||
callbacks_.erase(it);
|
||||
if (removal_callback_)
|
||||
removal_callback_.Run(); // May delete |this|!
|
||||
}
|
||||
}
|
||||
|
||||
// Set while Notify() is traversing |callbacks_|. Used primarily to avoid
|
||||
// invalidating iterators that may be in use.
|
||||
bool iterating_ = false;
|
||||
|
||||
// Called after elements are removed from |callbacks_|.
|
||||
RepeatingClosure removal_callback_;
|
||||
|
||||
WeakPtrFactory<CallbackListBase> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename Signature>
|
||||
class OnceCallbackList
|
||||
: public internal::CallbackListBase<OnceCallbackList<Signature>> {
|
||||
private:
|
||||
friend internal::CallbackListBase<OnceCallbackList>;
|
||||
using Traits = internal::CallbackListTraits<OnceCallbackList>;
|
||||
|
||||
// Runs the current callback, which may cancel it or any other callbacks.
|
||||
template <typename... RunArgs>
|
||||
void RunCallback(typename Traits::Callbacks::iterator it, RunArgs&&... args) {
|
||||
// OnceCallbacks still have Subscriptions with outstanding iterators;
|
||||
// splice() removes them from |callbacks_| without invalidating those.
|
||||
null_callbacks_.splice(null_callbacks_.end(), this->callbacks_, it);
|
||||
|
||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...; see
|
||||
// comments in Notify().
|
||||
std::move(*it).Run(args...);
|
||||
}
|
||||
|
||||
// If |it| refers to an already-canceled callback, does any necessary cleanup
|
||||
// and returns true. Otherwise returns false.
|
||||
bool CancelNullCallback(const typename Traits::Callbacks::iterator& it) {
|
||||
if (it->is_null()) {
|
||||
null_callbacks_.erase(it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Holds null callbacks whose Subscriptions are still alive, so the
|
||||
// Subscriptions will still contain valid iterators. Only needed for
|
||||
// OnceCallbacks, since RepeatingCallbacks are not canceled except by
|
||||
// Subscription destruction.
|
||||
typename Traits::Callbacks null_callbacks_;
|
||||
};
|
||||
|
||||
template <typename Signature>
|
||||
class RepeatingCallbackList
|
||||
: public internal::CallbackListBase<RepeatingCallbackList<Signature>> {
|
||||
private:
|
||||
friend internal::CallbackListBase<RepeatingCallbackList>;
|
||||
using Traits = internal::CallbackListTraits<RepeatingCallbackList>;
|
||||
// Runs the current callback, which may cancel it or any other callbacks.
|
||||
template <typename... RunArgs>
|
||||
void RunCallback(typename Traits::Callbacks::iterator it, RunArgs&&... args) {
|
||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...; see
|
||||
// comments in Notify().
|
||||
it->Run(args...);
|
||||
}
|
||||
|
||||
// If |it| refers to an already-canceled callback, does any necessary cleanup
|
||||
// and returns true. Otherwise returns false.
|
||||
bool CancelNullCallback(const typename Traits::Callbacks::iterator& it) {
|
||||
// Because at most one Subscription can point to a given callback, and
|
||||
// RepeatingCallbacks are only reset by CancelCallback(), no one should be
|
||||
// able to request cancellation of a canceled RepeatingCallback.
|
||||
DCHECK(!it->is_null());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Syntactic sugar to parallel that used for Callbacks.
|
||||
// ClosureList explicitly not provided since it is not used, and CallbackList
|
||||
// is deprecated. {Once,Repeating}ClosureList should instead be used.
|
||||
using OnceClosureList = OnceCallbackList<void()>;
|
||||
using RepeatingClosureList = RepeatingCallbackList<void()>;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
185
Thirdparty/libcef/include/base/cef_cancelable_callback.h
vendored
Normal file
185
Thirdparty/libcef/include/base/cef_cancelable_callback.h
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
// 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.
|
||||
|
||||
// CancelableCallback is a wrapper around base::Callback that allows
|
||||
// cancellation of a callback. CancelableCallback takes a reference on the
|
||||
// wrapped callback until this object is destroyed or Reset()/Cancel() are
|
||||
// called.
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
// Calling CancelableCallback::Cancel() brings the object back to its natural,
|
||||
// default-constructed state, i.e., CancelableCallback::callback() will return
|
||||
// a null callback.
|
||||
//
|
||||
// THREAD-SAFETY:
|
||||
//
|
||||
// CancelableCallback objects must be created on, posted to, cancelled on, and
|
||||
// destroyed on the same thread.
|
||||
//
|
||||
//
|
||||
// EXAMPLE USAGE:
|
||||
//
|
||||
// In the following example, the test is verifying that RunIntensiveTest()
|
||||
// Quit()s the message loop within 4 seconds. The cancelable callback is posted
|
||||
// to the message loop, the intensive test runs, the message loop is run,
|
||||
// then the callback is cancelled.
|
||||
//
|
||||
// RunLoop run_loop;
|
||||
//
|
||||
// void TimeoutCallback(const std::string& timeout_message) {
|
||||
// FAIL() << timeout_message;
|
||||
// run_loop.QuitWhenIdle();
|
||||
// }
|
||||
//
|
||||
// CancelableOnceClosure timeout(
|
||||
// base::BindOnce(&TimeoutCallback, "Test timed out."));
|
||||
// ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, timeout.callback(),
|
||||
// TimeDelta::FromSeconds(4));
|
||||
// RunIntensiveTest();
|
||||
// run_loop.Run();
|
||||
// timeout.Cancel(); // Hopefully this is hit before the timeout callback runs.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/cancelable_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 <utility>
|
||||
|
||||
#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"
|
||||
#include "include/base/cef_weak_ptr.h"
|
||||
#include "include/base/internal/cef_callback_internal.h"
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
|
||||
template <typename CallbackType>
|
||||
class CancelableCallbackImpl {
|
||||
public:
|
||||
CancelableCallbackImpl() = default;
|
||||
CancelableCallbackImpl(const CancelableCallbackImpl&) = delete;
|
||||
CancelableCallbackImpl& operator=(const CancelableCallbackImpl&) = delete;
|
||||
|
||||
// |callback| must not be null.
|
||||
explicit CancelableCallbackImpl(CallbackType callback)
|
||||
: callback_(std::move(callback)) {
|
||||
DCHECK(callback_);
|
||||
}
|
||||
|
||||
~CancelableCallbackImpl() = default;
|
||||
|
||||
// Cancels and drops the reference to the wrapped callback.
|
||||
void Cancel() {
|
||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||
callback_.Reset();
|
||||
}
|
||||
|
||||
// Returns true if the wrapped callback has been cancelled.
|
||||
bool IsCancelled() const { return callback_.is_null(); }
|
||||
|
||||
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
||||
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
||||
void Reset(CallbackType callback) {
|
||||
DCHECK(callback);
|
||||
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
||||
Cancel();
|
||||
callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
// Returns a callback that can be disabled by calling Cancel().
|
||||
CallbackType callback() const {
|
||||
if (!callback_)
|
||||
return CallbackType();
|
||||
CallbackType forwarder;
|
||||
MakeForwarder(&forwarder);
|
||||
return forwarder;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename... Args>
|
||||
void MakeForwarder(RepeatingCallback<void(Args...)>* out) const {
|
||||
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
||||
ForwarderType forwarder = &CancelableCallbackImpl::ForwardRepeating;
|
||||
*out = BindRepeating(forwarder, weak_ptr_factory_.GetWeakPtr());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void MakeForwarder(OnceCallback<void(Args...)>* out) const {
|
||||
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
||||
ForwarderType forwarder = &CancelableCallbackImpl::ForwardOnce;
|
||||
*out = BindOnce(forwarder, weak_ptr_factory_.GetWeakPtr());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void ForwardRepeating(Args... args) {
|
||||
callback_.Run(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void ForwardOnce(Args... args) {
|
||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||
std::move(callback_).Run(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// The stored closure that may be cancelled.
|
||||
CallbackType callback_;
|
||||
mutable base::WeakPtrFactory<CancelableCallbackImpl> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Consider using base::WeakPtr directly instead of base::CancelableCallback for
|
||||
// the task cancellation.
|
||||
template <typename Signature>
|
||||
using CancelableOnceCallback =
|
||||
internal::CancelableCallbackImpl<OnceCallback<Signature>>;
|
||||
using CancelableOnceClosure = CancelableOnceCallback<void()>;
|
||||
|
||||
template <typename Signature>
|
||||
using CancelableRepeatingCallback =
|
||||
internal::CancelableCallbackImpl<RepeatingCallback<Signature>>;
|
||||
using CancelableRepeatingClosure = CancelableRepeatingCallback<void()>;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
411
Thirdparty/libcef/include/base/cef_compiler_specific.h
vendored
Normal file
411
Thirdparty/libcef/include/base/cef_compiler_specific.h
vendored
Normal file
@ -0,0 +1,411 @@
|
||||
// Copyright (c) 2021 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_COMPILER_SPECIFIC_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/compiler_specific.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/base/cef_build.h"
|
||||
|
||||
// This is a wrapper around `__has_cpp_attribute`, which can be used to test for
|
||||
// the presence of an attribute. In case the compiler does not support this
|
||||
// macro it will simply evaluate to 0.
|
||||
//
|
||||
// References:
|
||||
// https://wg21.link/sd6#testing-for-the-presence-of-an-attribute-__has_cpp_attribute
|
||||
// https://wg21.link/cpp.cond#:__has_cpp_attribute
|
||||
#if defined(__has_cpp_attribute)
|
||||
#define HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||
#else
|
||||
#define HAS_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
// A wrapper around `__has_builtin`, similar to HAS_CPP_ATTRIBUTE.
|
||||
#if defined(__has_builtin)
|
||||
#define HAS_BUILTIN(x) __has_builtin(x)
|
||||
#else
|
||||
#define HAS_BUILTIN(x) 0
|
||||
#endif
|
||||
|
||||
// __has_feature and __has_attribute don't exist for MSVC.
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif // !defined(__has_feature)
|
||||
|
||||
#if !defined(__has_attribute)
|
||||
#define __has_attribute(x) 0
|
||||
#endif // !defined(__has_attribute)
|
||||
|
||||
// Annotate a function indicating it should not be inlined.
|
||||
// Use like:
|
||||
// NOINLINE void DoStuff() { ... }
|
||||
#if defined(COMPILER_GCC)
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#elif defined(COMPILER_MSVC)
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define NOINLINE
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC) && defined(NDEBUG)
|
||||
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
|
||||
#elif defined(COMPILER_MSVC) && defined(NDEBUG)
|
||||
#define ALWAYS_INLINE __forceinline
|
||||
#else
|
||||
#define ALWAYS_INLINE inline
|
||||
#endif
|
||||
|
||||
// Annotate a function indicating it should never be tail called. Useful to make
|
||||
// sure callers of the annotated function are never omitted from call-stacks.
|
||||
// To provide the complementary behavior (prevent the annotated function from
|
||||
// being omitted) look at NOINLINE. Also note that this doesn't prevent code
|
||||
// folding of multiple identical caller functions into a single signature. To
|
||||
// prevent code folding, see NO_CODE_FOLDING() in base/debug/alias.h.
|
||||
// Use like:
|
||||
// void NOT_TAIL_CALLED FooBar();
|
||||
#if defined(__clang__) && __has_attribute(not_tail_called)
|
||||
#define NOT_TAIL_CALLED __attribute__((not_tail_called))
|
||||
#else
|
||||
#define NOT_TAIL_CALLED
|
||||
#endif
|
||||
|
||||
// Specify memory alignment for structs, classes, etc.
|
||||
// Use like:
|
||||
// class ALIGNAS(16) MyClass { ... }
|
||||
// ALIGNAS(16) int array[4];
|
||||
//
|
||||
// In most places you can use the C++11 keyword "alignas", which is preferred.
|
||||
//
|
||||
// But compilers have trouble mixing __attribute__((...)) syntax with
|
||||
// alignas(...) syntax.
|
||||
//
|
||||
// Doesn't work in clang or gcc:
|
||||
// struct alignas(16) __attribute__((packed)) S { char c; };
|
||||
// Works in clang but not gcc:
|
||||
// struct __attribute__((packed)) alignas(16) S2 { char c; };
|
||||
// Works in clang and gcc:
|
||||
// struct alignas(16) S3 { char c; } __attribute__((packed));
|
||||
//
|
||||
// There are also some attributes that must be specified *before* a class
|
||||
// definition: visibility (used for exporting functions/classes) is one of
|
||||
// these attributes. This means that it is not possible to use alignas() with a
|
||||
// class that is marked as exported.
|
||||
#if defined(COMPILER_MSVC)
|
||||
#define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
|
||||
#elif defined(COMPILER_GCC)
|
||||
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
||||
#endif
|
||||
|
||||
// In case the compiler supports it NO_UNIQUE_ADDRESS evaluates to the C++20
|
||||
// attribute [[no_unique_address]]. This allows annotating data members so that
|
||||
// they need not have an address distinct from all other non-static data members
|
||||
// of its class.
|
||||
//
|
||||
// References:
|
||||
// * https://en.cppreference.com/w/cpp/language/attributes/no_unique_address
|
||||
// * https://wg21.link/dcl.attr.nouniqueaddr
|
||||
#if HAS_CPP_ATTRIBUTE(no_unique_address)
|
||||
#define NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||
#else
|
||||
#define NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
|
||||
// Tell the compiler a function is using a printf-style format string.
|
||||
// |format_param| is the one-based index of the format string parameter;
|
||||
// |dots_param| is the one-based index of the "..." parameter.
|
||||
// For v*printf functions (which take a va_list), pass 0 for dots_param.
|
||||
// (This is undocumented but matches what the system C headers do.)
|
||||
// For member functions, the implicit this parameter counts as index 1.
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define PRINTF_FORMAT(format_param, dots_param) \
|
||||
__attribute__((format(printf, format_param, dots_param)))
|
||||
#else
|
||||
#define PRINTF_FORMAT(format_param, dots_param)
|
||||
#endif
|
||||
|
||||
// WPRINTF_FORMAT is the same, but for wide format strings.
|
||||
// This doesn't appear to yet be implemented in any compiler.
|
||||
// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 .
|
||||
#define WPRINTF_FORMAT(format_param, dots_param)
|
||||
// If available, it would look like:
|
||||
// __attribute__((format(wprintf, format_param, dots_param)))
|
||||
|
||||
// Sanitizers annotations.
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(NO_SANITIZE)
|
||||
#define NO_SANITIZE(what)
|
||||
#endif
|
||||
|
||||
// MemorySanitizer annotations.
|
||||
#if defined(MEMORY_SANITIZER) && !defined(OS_NACL)
|
||||
#include <sanitizer/msan_interface.h>
|
||||
|
||||
// Mark a memory region fully initialized.
|
||||
// Use this to annotate code that deliberately reads uninitialized data, for
|
||||
// example a GC scavenging root set pointers from the stack.
|
||||
#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size)
|
||||
|
||||
// Check a memory region for initializedness, as if it was being used here.
|
||||
// If any bits are uninitialized, crash with an MSan report.
|
||||
// Use this to sanitize data which MSan won't be able to track, e.g. before
|
||||
// passing data to another process via shared memory.
|
||||
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \
|
||||
__msan_check_mem_is_initialized(p, size)
|
||||
#else // MEMORY_SANITIZER
|
||||
#define MSAN_UNPOISON(p, size)
|
||||
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size)
|
||||
#endif // MEMORY_SANITIZER
|
||||
|
||||
// DISABLE_CFI_PERF -- Disable Control Flow Integrity for perf reasons.
|
||||
#if !defined(DISABLE_CFI_PERF)
|
||||
#if defined(__clang__) && defined(OFFICIAL_BUILD)
|
||||
#define DISABLE_CFI_PERF __attribute__((no_sanitize("cfi")))
|
||||
#else
|
||||
#define DISABLE_CFI_PERF
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// DISABLE_CFI_ICALL -- Disable Control Flow Integrity indirect call checks.
|
||||
#if !defined(DISABLE_CFI_ICALL)
|
||||
#if defined(OS_WIN)
|
||||
// Windows also needs __declspec(guard(nocf)).
|
||||
#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") __declspec(guard(nocf))
|
||||
#else
|
||||
#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall")
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(DISABLE_CFI_ICALL)
|
||||
#define DISABLE_CFI_ICALL
|
||||
#endif
|
||||
|
||||
// Macro useful for writing cross-platform function pointers.
|
||||
#if !defined(CDECL)
|
||||
#if defined(OS_WIN)
|
||||
#define CDECL __cdecl
|
||||
#else // defined(OS_WIN)
|
||||
#define CDECL
|
||||
#endif // defined(OS_WIN)
|
||||
#endif // !defined(CDECL)
|
||||
|
||||
// Macro for hinting that an expression is likely to be false.
|
||||
#if !defined(UNLIKELY)
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define UNLIKELY(x) (x)
|
||||
#endif // defined(COMPILER_GCC)
|
||||
#endif // !defined(UNLIKELY)
|
||||
|
||||
#if !defined(LIKELY)
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#else
|
||||
#define LIKELY(x) (x)
|
||||
#endif // defined(COMPILER_GCC)
|
||||
#endif // !defined(LIKELY)
|
||||
|
||||
// Compiler feature-detection.
|
||||
// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
|
||||
#if defined(__has_feature)
|
||||
#define HAS_FEATURE(FEATURE) __has_feature(FEATURE)
|
||||
#else
|
||||
#define HAS_FEATURE(FEATURE) 0
|
||||
#endif
|
||||
|
||||
// Macro for telling -Wimplicit-fallthrough that a fallthrough is intentional.
|
||||
#if defined(__clang__)
|
||||
#define FALLTHROUGH [[clang::fallthrough]]
|
||||
#else
|
||||
#define FALLTHROUGH
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC)
|
||||
#define PRETTY_FUNCTION __PRETTY_FUNCTION__
|
||||
#elif defined(COMPILER_MSVC)
|
||||
#define PRETTY_FUNCTION __FUNCSIG__
|
||||
#else
|
||||
// See https://en.cppreference.com/w/c/language/function_definition#func
|
||||
#define PRETTY_FUNCTION __func__
|
||||
#endif
|
||||
|
||||
#if !defined(CPU_ARM_NEON)
|
||||
#if defined(__arm__)
|
||||
#if !defined(__ARMEB__) && !defined(__ARM_EABI__) && !defined(__EABI__) && \
|
||||
!defined(__VFP_FP__) && !defined(_WIN32_WCE) && !defined(ANDROID)
|
||||
#error Chromium does not support middle endian architecture
|
||||
#endif
|
||||
#if defined(__ARM_NEON__)
|
||||
#define CPU_ARM_NEON 1
|
||||
#endif
|
||||
#endif // defined(__arm__)
|
||||
#endif // !defined(CPU_ARM_NEON)
|
||||
|
||||
#if !defined(HAVE_MIPS_MSA_INTRINSICS)
|
||||
#if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5)
|
||||
#define HAVE_MIPS_MSA_INTRINSICS 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && __has_attribute(uninitialized)
|
||||
// Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for
|
||||
// the specified variable.
|
||||
// Library-wide alternative is
|
||||
// 'configs -= [ "//build/config/compiler:default_init_stack_vars" ]' in .gn
|
||||
// file.
|
||||
//
|
||||
// See "init_stack_vars" in build/config/compiler/BUILD.gn and
|
||||
// http://crbug.com/977230
|
||||
// "init_stack_vars" is enabled for non-official builds and we hope to enable it
|
||||
// in official build in 2020 as well. The flag writes fixed pattern into
|
||||
// uninitialized parts of all local variables. In rare cases such initialization
|
||||
// is undesirable and attribute can be used:
|
||||
// 1. Degraded performance
|
||||
// In most cases compiler is able to remove additional stores. E.g. if memory is
|
||||
// never accessed or properly initialized later. Preserved stores mostly will
|
||||
// not affect program performance. However if compiler failed on some
|
||||
// performance critical code we can get a visible regression in a benchmark.
|
||||
// 2. memset, memcpy calls
|
||||
// Compiler may replaces some memory writes with memset or memcpy calls. This is
|
||||
// not -ftrivial-auto-var-init specific, but it can happen more likely with the
|
||||
// flag. It can be a problem if code is not linked with C run-time library.
|
||||
//
|
||||
// Note: The flag is security risk mitigation feature. So in future the
|
||||
// attribute uses should be avoided when possible. However to enable this
|
||||
// mitigation on the most of the code we need to be less strict now and minimize
|
||||
// number of exceptions later. So if in doubt feel free to use attribute, but
|
||||
// please document the problem for someone who is going to cleanup it later.
|
||||
// E.g. platform, bot, benchmark or test name in patch description or next to
|
||||
// the attribute.
|
||||
#define STACK_UNINITIALIZED __attribute__((uninitialized))
|
||||
#else
|
||||
#define STACK_UNINITIALIZED
|
||||
#endif
|
||||
|
||||
// The ANALYZER_ASSUME_TRUE(bool arg) macro adds compiler-specific hints
|
||||
// to Clang which control what code paths are statically analyzed,
|
||||
// and is meant to be used in conjunction with assert & assert-like functions.
|
||||
// The expression is passed straight through if analysis isn't enabled.
|
||||
//
|
||||
// ANALYZER_SKIP_THIS_PATH() suppresses static analysis for the current
|
||||
// codepath and any other branching codepaths that might follow.
|
||||
#if defined(__clang_analyzer__)
|
||||
|
||||
inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline constexpr bool AnalyzerAssumeTrue(bool arg) {
|
||||
// AnalyzerNoReturn() is invoked and analysis is terminated if |arg| is
|
||||
// false.
|
||||
return arg || AnalyzerNoReturn();
|
||||
}
|
||||
|
||||
#define ANALYZER_ASSUME_TRUE(arg) ::AnalyzerAssumeTrue(!!(arg))
|
||||
#define ANALYZER_SKIP_THIS_PATH() static_cast<void>(::AnalyzerNoReturn())
|
||||
#define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
|
||||
|
||||
#else // !defined(__clang_analyzer__)
|
||||
|
||||
#define ANALYZER_ASSUME_TRUE(arg) (arg)
|
||||
#define ANALYZER_SKIP_THIS_PATH()
|
||||
#define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
|
||||
|
||||
#endif // defined(__clang_analyzer__)
|
||||
|
||||
// Use nomerge attribute to disable optimization of merging multiple same calls.
|
||||
#if defined(__clang__) && __has_attribute(nomerge)
|
||||
#define NOMERGE [[clang::nomerge]]
|
||||
#else
|
||||
#define NOMERGE
|
||||
#endif
|
||||
|
||||
// Marks a type as being eligible for the "trivial" ABI despite having a
|
||||
// non-trivial destructor or copy/move constructor. Such types can be relocated
|
||||
// after construction by simply copying their memory, which makes them eligible
|
||||
// to be passed in registers. The canonical example is std::unique_ptr.
|
||||
//
|
||||
// Use with caution; this has some subtle effects on constructor/destructor
|
||||
// ordering and will be very incorrect if the type relies on its address
|
||||
// remaining constant. When used as a function argument (by value), the value
|
||||
// may be constructed in the caller's stack frame, passed in a register, and
|
||||
// then used and destructed in the callee's stack frame. A similar thing can
|
||||
// occur when values are returned.
|
||||
//
|
||||
// TRIVIAL_ABI is not needed for types which have a trivial destructor and
|
||||
// copy/move constructors, such as base::TimeTicks and other POD.
|
||||
//
|
||||
// It is also not likely to be effective on types too large to be passed in one
|
||||
// or two registers on typical target ABIs.
|
||||
//
|
||||
// See also:
|
||||
// https://clang.llvm.org/docs/AttributeReference.html#trivial-abi
|
||||
// https://libcxx.llvm.org/docs/DesignDocs/UniquePtrTrivialAbi.html
|
||||
#if defined(__clang__) && __has_attribute(trivial_abi)
|
||||
#define TRIVIAL_ABI [[clang::trivial_abi]]
|
||||
#else
|
||||
#define TRIVIAL_ABI
|
||||
#endif
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
// Annotate a function indicating the caller must examine the return value.
|
||||
// Use like:
|
||||
// int foo() WARN_UNUSED_RESULT;
|
||||
// To explicitly ignore a result, use std::ignore from <tuple>.
|
||||
// Alternately use `[[nodiscard]]` with code that supports C++17.
|
||||
#undef WARN_UNUSED_RESULT
|
||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
#define WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
// Annotate a variable indicating it's ok if the variable is not used.
|
||||
// (Typically used to silence a compiler warning when the assignment
|
||||
// is important for some other reason.)
|
||||
// Use like:
|
||||
// int x = ...;
|
||||
// ALLOW_UNUSED_LOCAL(x);
|
||||
// Alternately use `[[maybe_unused]]` with code that supports C++17.
|
||||
#define ALLOW_UNUSED_LOCAL(x) (void)x
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
60
Thirdparty/libcef/include/base/cef_cxx17_backports.h
vendored
Normal file
60
Thirdparty/libcef/include/base/cef_cxx17_backports.h
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2021
|
||||
// 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_CXX17_BACKPORTS_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CXX17_BACKPORTS_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/cxx17_backports.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following was removed from Chromium in https://crrev.com/78734f77be.
|
||||
|
||||
namespace base {
|
||||
|
||||
// C++14 implementation of C++17's std::size():
|
||||
// http://en.cppreference.com/w/cpp/iterator/size
|
||||
template <typename Container>
|
||||
constexpr auto size(const Container& c) -> decltype(c.size()) {
|
||||
return c.size();
|
||||
}
|
||||
|
||||
template <typename T, size_t N>
|
||||
constexpr size_t size(const T (&array)[N]) noexcept {
|
||||
return N;
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CXX17_BACKPORTS_H_
|
174
Thirdparty/libcef/include/base/cef_lock.h
vendored
Normal file
174
Thirdparty/libcef/include/base/cef_lock.h
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
// 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_LOCK_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_LOCK_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/synchronization/lock.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/base/cef_logging.h"
|
||||
#include "include/base/cef_platform_thread.h"
|
||||
#include "include/base/internal/cef_lock_impl.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
// A convenient wrapper for an OS specific critical section. The only real
|
||||
// intelligence in this class is in debug mode for the support for the
|
||||
// AssertAcquired() method.
|
||||
class Lock {
|
||||
public:
|
||||
#if !DCHECK_IS_ON() // Optimized wrapper implementation
|
||||
Lock() : lock_() {}
|
||||
|
||||
Lock(const Lock&) = delete;
|
||||
Lock& operator=(const Lock&) = delete;
|
||||
|
||||
~Lock() {}
|
||||
void Acquire() { lock_.Lock(); }
|
||||
void Release() { lock_.Unlock(); }
|
||||
|
||||
// If the lock is not held, take it and return true. If the lock is already
|
||||
// held by another thread, immediately return false. This must not be called
|
||||
// by a thread already holding the lock (what happens is undefined and an
|
||||
// assertion may fail).
|
||||
bool Try() { return lock_.Try(); }
|
||||
|
||||
// Null implementation if not debug.
|
||||
void AssertAcquired() const {}
|
||||
#else
|
||||
Lock();
|
||||
~Lock();
|
||||
|
||||
// NOTE: Although windows critical sections support recursive locks, we do not
|
||||
// allow this, and we will commonly fire a DCHECK() if a thread attempts to
|
||||
// acquire the lock a second time (while already holding it).
|
||||
void Acquire() {
|
||||
lock_.Lock();
|
||||
CheckUnheldAndMark();
|
||||
}
|
||||
void Release() {
|
||||
CheckHeldAndUnmark();
|
||||
lock_.Unlock();
|
||||
}
|
||||
|
||||
bool Try() {
|
||||
bool rv = lock_.Try();
|
||||
if (rv) {
|
||||
CheckUnheldAndMark();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void AssertAcquired() const;
|
||||
#endif // !DCHECK_IS_ON()
|
||||
|
||||
private:
|
||||
#if DCHECK_IS_ON()
|
||||
// Members and routines taking care of locks assertions.
|
||||
// Note that this checks for recursive locks and allows them
|
||||
// if the variable is set. This is allowed by the underlying implementation
|
||||
// on windows but not on Posix, so we're doing unneeded checks on Posix.
|
||||
// It's worth it to share the code.
|
||||
void CheckHeldAndUnmark();
|
||||
void CheckUnheldAndMark();
|
||||
|
||||
// All private data is implicitly protected by lock_.
|
||||
// Be VERY careful to only access members under that lock.
|
||||
base::PlatformThreadRef owning_thread_ref_;
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
// Platform specific underlying lock implementation.
|
||||
LockImpl lock_;
|
||||
};
|
||||
|
||||
// A helper class that acquires the given Lock while the AutoLock is in scope.
|
||||
class AutoLock {
|
||||
public:
|
||||
struct AlreadyAcquired {};
|
||||
|
||||
explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); }
|
||||
|
||||
AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) {
|
||||
lock_.AssertAcquired();
|
||||
}
|
||||
|
||||
AutoLock(const AutoLock&) = delete;
|
||||
AutoLock& operator=(const AutoLock&) = delete;
|
||||
|
||||
~AutoLock() {
|
||||
lock_.AssertAcquired();
|
||||
lock_.Release();
|
||||
}
|
||||
|
||||
private:
|
||||
Lock& lock_;
|
||||
};
|
||||
|
||||
// AutoUnlock is a helper that will Release() the |lock| argument in the
|
||||
// constructor, and re-Acquire() it in the destructor.
|
||||
class AutoUnlock {
|
||||
public:
|
||||
explicit AutoUnlock(Lock& lock) : lock_(lock) {
|
||||
// We require our caller to have the lock.
|
||||
lock_.AssertAcquired();
|
||||
lock_.Release();
|
||||
}
|
||||
|
||||
AutoUnlock(const AutoUnlock&) = delete;
|
||||
AutoUnlock& operator=(const AutoUnlock&) = delete;
|
||||
|
||||
~AutoUnlock() { lock_.Acquire(); }
|
||||
|
||||
private:
|
||||
Lock& lock_;
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
// Implement classes in the cef_internal namespace and then expose them to the
|
||||
// base namespace. This avoids conflicts with the base.lib implementation when
|
||||
// linking sandbox support on Windows.
|
||||
using cef_internal::AutoLock;
|
||||
using cef_internal::AutoUnlock;
|
||||
using cef_internal::Lock;
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_LOCK_H_
|
758
Thirdparty/libcef/include/base/cef_logging.h
vendored
Normal file
758
Thirdparty/libcef/include/base/cef_logging.h
vendored
Normal file
@ -0,0 +1,758 @@
|
||||
// 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.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file are only available to applications that link
|
||||
// against the libcef_dll_wrapper target.
|
||||
//
|
||||
// WARNING: Logging macros should not be used in the main/browser process before
|
||||
// calling CefInitialize or in sub-processes before calling CefExecuteProcess.
|
||||
//
|
||||
// Instructions
|
||||
// ------------
|
||||
//
|
||||
// Make a bunch of macros for logging. The way to log things is to stream
|
||||
// things to LOG(<a particular severity level>). E.g.,
|
||||
//
|
||||
// LOG(INFO) << "Found " << num_cookies << " cookies";
|
||||
//
|
||||
// You can also do conditional logging:
|
||||
//
|
||||
// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||
//
|
||||
// The CHECK(condition) macro is active in both debug and release builds and
|
||||
// effectively performs a LOG(FATAL) which terminates the process and
|
||||
// generates a crashdump unless a debugger is attached.
|
||||
//
|
||||
// There are also "debug mode" logging macros like the ones above:
|
||||
//
|
||||
// DLOG(INFO) << "Found cookies";
|
||||
//
|
||||
// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||
//
|
||||
// All "debug mode" logging is compiled away to nothing for non-debug mode
|
||||
// compiles. LOG_IF and development flags also work well together
|
||||
// because the code can be compiled away sometimes.
|
||||
//
|
||||
// We also have
|
||||
//
|
||||
// LOG_ASSERT(assertion);
|
||||
// DLOG_ASSERT(assertion);
|
||||
//
|
||||
// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
|
||||
//
|
||||
// There are "verbose level" logging macros. They look like
|
||||
//
|
||||
// VLOG(1) << "I'm printed when you run the program with --v=1 or more";
|
||||
// VLOG(2) << "I'm printed when you run the program with --v=2 or more";
|
||||
//
|
||||
// These always log at the INFO log level (when they log at all).
|
||||
// The verbose logging can also be turned on module-by-module. For instance,
|
||||
// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0
|
||||
// will cause:
|
||||
// a. VLOG(2) and lower messages to be printed from profile.{h,cc}
|
||||
// b. VLOG(1) and lower messages to be printed from icon_loader.{h,cc}
|
||||
// c. VLOG(3) and lower messages to be printed from files prefixed with
|
||||
// "browser"
|
||||
// d. VLOG(4) and lower messages to be printed from files under a
|
||||
// "chromeos" directory.
|
||||
// e. VLOG(0) and lower messages to be printed from elsewhere
|
||||
//
|
||||
// The wildcarding functionality shown by (c) supports both '*' (match
|
||||
// 0 or more characters) and '?' (match any single character)
|
||||
// wildcards. Any pattern containing a forward or backward slash will
|
||||
// be tested against the whole pathname and not just the module.
|
||||
// E.g., "*/foo/bar/*=2" would change the logging level for all code
|
||||
// in source files under a "foo/bar" directory.
|
||||
//
|
||||
// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
|
||||
//
|
||||
// if (VLOG_IS_ON(2)) {
|
||||
// // do some logging preparation and logging
|
||||
// // that can't be accomplished with just VLOG(2) << ...;
|
||||
// }
|
||||
//
|
||||
// There is also a VLOG_IF "verbose level" condition macro for sample
|
||||
// cases, when some extra computation and preparation for logs is not
|
||||
// needed.
|
||||
//
|
||||
// VLOG_IF(1, (size > 1024))
|
||||
// << "I'm printed when size is more than 1024 and when you run the "
|
||||
// "program with --v=1 or more";
|
||||
//
|
||||
// We also override the standard 'assert' to use 'DLOG_ASSERT'.
|
||||
//
|
||||
// Lastly, there is:
|
||||
//
|
||||
// PLOG(ERROR) << "Couldn't do foo";
|
||||
// DPLOG(ERROR) << "Couldn't do foo";
|
||||
// PLOG_IF(ERROR, cond) << "Couldn't do foo";
|
||||
// DPLOG_IF(ERROR, cond) << "Couldn't do foo";
|
||||
// PCHECK(condition) << "Couldn't do foo";
|
||||
// DPCHECK(condition) << "Couldn't do foo";
|
||||
//
|
||||
// which append the last system error to the message in string form (taken from
|
||||
// GetLastError() on Windows and errno on POSIX).
|
||||
//
|
||||
// The supported severity levels for macros that allow you to specify one
|
||||
// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
|
||||
//
|
||||
// Very important: logging a message at the FATAL severity level causes
|
||||
// the program to terminate (after the message is logged).
|
||||
//
|
||||
// There is the special severity of DFATAL, which logs FATAL in debug mode,
|
||||
// ERROR in normal mode.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/logging.h"
|
||||
#include "base/notreached.h"
|
||||
#elif defined(DCHECK)
|
||||
// Do nothing if the macros provided by this header already exist.
|
||||
// This can happen in cases where Chromium code is used directly by the
|
||||
// client application. When using Chromium code directly always include
|
||||
// the Chromium header first to avoid type conflicts.
|
||||
|
||||
// Always define the DCHECK_IS_ON macro which is used from other CEF headers.
|
||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||
#define DCHECK_IS_ON() false
|
||||
#else
|
||||
#define DCHECK_IS_ON() true
|
||||
#endif
|
||||
|
||||
#else // !defined(DCHECK)
|
||||
// The following is substantially similar to the Chromium implementation.
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// updated to match.
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/internal/cef_logging_internal.h"
|
||||
|
||||
namespace cef {
|
||||
namespace logging {
|
||||
|
||||
// Gets the current log level.
|
||||
inline int GetMinLogLevel() {
|
||||
return cef_get_min_log_level();
|
||||
}
|
||||
|
||||
// Gets the current vlog level for the given file (usually taken from
|
||||
// __FILE__). Note that |N| is the size *with* the null terminator.
|
||||
template <size_t N>
|
||||
int GetVlogLevel(const char (&file)[N]) {
|
||||
return cef_get_vlog_level(file, N);
|
||||
}
|
||||
|
||||
typedef int LogSeverity;
|
||||
const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity
|
||||
// Note: the log severities are used to index into the array of names,
|
||||
// see log_severity_names.
|
||||
const LogSeverity LOG_INFO = 0;
|
||||
const LogSeverity LOG_WARNING = 1;
|
||||
const LogSeverity LOG_ERROR = 2;
|
||||
const LogSeverity LOG_FATAL = 3;
|
||||
const 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
|
||||
|
||||
// A few definitions of macros that don't generate much code. These are used
|
||||
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
||||
// better to have compact code for these operations.
|
||||
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_INFO, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_WARNING, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_ERROR, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_FATAL, \
|
||||
##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
|
||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_DFATAL, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage)
|
||||
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
||||
// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
|
||||
// to keep using this syntax, we define this macro to do the same thing
|
||||
// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that
|
||||
// the Windows SDK does for consistency.
|
||||
#define ERROR 0
|
||||
#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \
|
||||
COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
|
||||
// Needed for LOG_IS_ON(ERROR).
|
||||
const LogSeverity LOG_0 = LOG_ERROR;
|
||||
#endif
|
||||
|
||||
// As special cases, we can assume that LOG_IS_ON(FATAL) always holds. Also,
|
||||
// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will
|
||||
// always fire if they fail.
|
||||
#define LOG_IS_ON(severity) \
|
||||
((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel())
|
||||
|
||||
// We can't do any caching tricks with VLOG_IS_ON() like the
|
||||
// google-glog version since it requires GCC extensions. This means
|
||||
// that using the v-logging functions in conjunction with --vmodule
|
||||
// may be slow.
|
||||
#define VLOG_IS_ON(verboselevel) \
|
||||
((verboselevel) <= ::cef::logging::GetVlogLevel(__FILE__))
|
||||
|
||||
// Helper macro which avoids evaluating the arguments to a stream if
|
||||
// the condition doesn't hold.
|
||||
#define LAZY_STREAM(stream, condition) \
|
||||
!(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream)
|
||||
|
||||
// We use the preprocessor's merging operator, "##", so that, e.g.,
|
||||
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
|
||||
// subtle difference between ostream member streaming functions (e.g.,
|
||||
// ostream::operator<<(int) and ostream non-member streaming functions
|
||||
// (e.g., ::operator<<(ostream&, string&): it turns out that it's
|
||||
// impossible to stream something like a string directly to an unnamed
|
||||
// ostream. We employ a neat hack by calling the stream() member
|
||||
// function of LogMessage which seems to avoid the problem.
|
||||
#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream()
|
||||
|
||||
#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity))
|
||||
#define LOG_IF(severity, condition) \
|
||||
LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
|
||||
|
||||
#define SYSLOG(severity) LOG(severity)
|
||||
#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition)
|
||||
|
||||
// The VLOG macros log with negative verbosities.
|
||||
#define VLOG_STREAM(verbose_level) \
|
||||
cef::logging::LogMessage(__FILE__, __LINE__, -verbose_level).stream()
|
||||
|
||||
#define VLOG(verbose_level) \
|
||||
LAZY_STREAM(VLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level))
|
||||
|
||||
#define VLOG_IF(verbose_level, condition) \
|
||||
LAZY_STREAM(VLOG_STREAM(verbose_level), \
|
||||
VLOG_IS_ON(verbose_level) && (condition))
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define VPLOG_STREAM(verbose_level) \
|
||||
cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#elif defined(OS_POSIX)
|
||||
#define VPLOG_STREAM(verbose_level) \
|
||||
cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#endif
|
||||
|
||||
#define VPLOG(verbose_level) \
|
||||
LAZY_STREAM(VPLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level))
|
||||
|
||||
#define VPLOG_IF(verbose_level, condition) \
|
||||
LAZY_STREAM(VPLOG_STREAM(verbose_level), \
|
||||
VLOG_IS_ON(verbose_level) && (condition))
|
||||
|
||||
// TODO(akalin): Add more VLOG variants, e.g. VPLOG.
|
||||
|
||||
#define LOG_ASSERT(condition) \
|
||||
LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
|
||||
#define SYSLOG_ASSERT(condition) \
|
||||
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define PLOG_STREAM(severity) \
|
||||
COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#elif defined(OS_POSIX)
|
||||
#define PLOG_STREAM(severity) \
|
||||
COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \
|
||||
::cef::logging::GetLastSystemErrorCode()) \
|
||||
.stream()
|
||||
#endif
|
||||
|
||||
#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
|
||||
|
||||
#define PLOG_IF(severity, condition) \
|
||||
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
|
||||
|
||||
// The actual stream used isn't important.
|
||||
#define EAT_STREAM_PARAMETERS \
|
||||
true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
|
||||
|
||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG, so the check will be executed regardless of
|
||||
// compilation mode.
|
||||
//
|
||||
// We make sure CHECK et al. always evaluates their arguments, as
|
||||
// doing CHECK(FunctionWithSideEffect()) is a common idiom.
|
||||
|
||||
#define CHECK(condition) \
|
||||
LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
#define PCHECK(condition) \
|
||||
LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
// Helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use CHECK_EQ et al below.
|
||||
//
|
||||
// TODO(akalin): Rewrite this so that constructs like if (...)
|
||||
// CHECK_EQ(...) else { ... } work properly.
|
||||
#define CHECK_OP(name, op, val1, val2) \
|
||||
if (std::string* _result = cef::logging::Check##name##Impl( \
|
||||
(val1), (val2), #val1 " " #op " " #val2)) \
|
||||
cef::logging::LogMessage(__FILE__, __LINE__, _result).stream()
|
||||
|
||||
// Build the error message string. This is separate from the "Impl"
|
||||
// function template because it is not performance critical and so can
|
||||
// be out of line, while the "Impl" code should be inline. Caller
|
||||
// takes ownership of the returned string.
|
||||
template <class t1, class t2>
|
||||
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
|
||||
std::ostringstream ss;
|
||||
ss << names << " (" << v1 << " vs. " << v2 << ")";
|
||||
std::string* msg = new std::string(ss.str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
// MSVC doesn't like complex extern templates and DLLs.
|
||||
#if !defined(COMPILER_MSVC)
|
||||
// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
|
||||
// in logging.cc.
|
||||
extern template std::string* MakeCheckOpString<int, int>(const int&,
|
||||
const int&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<unsigned long, unsigned long>(
|
||||
const unsigned long&,
|
||||
const unsigned long&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<unsigned long, unsigned int>(
|
||||
const unsigned long&,
|
||||
const unsigned int&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<unsigned int, unsigned long>(
|
||||
const unsigned int&,
|
||||
const unsigned long&,
|
||||
const char* names);
|
||||
extern template std::string* MakeCheckOpString<std::string, std::string>(
|
||||
const std::string&,
|
||||
const std::string&,
|
||||
const char* name);
|
||||
#endif
|
||||
|
||||
// Helper functions for CHECK_OP macro.
|
||||
// The (int, int) specialization works around the issue that the compiler
|
||||
// will not instantiate the template version of the function on values of
|
||||
// unnamed enum type - see comment below.
|
||||
#define DEFINE_CHECK_OP_IMPL(name, op) \
|
||||
template <class t1, class t2> \
|
||||
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
|
||||
const char* names) { \
|
||||
if (v1 op v2) \
|
||||
return NULL; \
|
||||
else \
|
||||
return MakeCheckOpString(v1, v2, names); \
|
||||
} \
|
||||
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
|
||||
if (v1 op v2) \
|
||||
return NULL; \
|
||||
else \
|
||||
return MakeCheckOpString(v1, v2, names); \
|
||||
}
|
||||
DEFINE_CHECK_OP_IMPL(EQ, ==)
|
||||
DEFINE_CHECK_OP_IMPL(NE, !=)
|
||||
DEFINE_CHECK_OP_IMPL(LE, <=)
|
||||
DEFINE_CHECK_OP_IMPL(LT, <)
|
||||
DEFINE_CHECK_OP_IMPL(GE, >=)
|
||||
DEFINE_CHECK_OP_IMPL(GT, >)
|
||||
#undef DEFINE_CHECK_OP_IMPL
|
||||
|
||||
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
|
||||
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
|
||||
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
|
||||
#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2)
|
||||
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
|
||||
#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2)
|
||||
|
||||
#if defined(NDEBUG)
|
||||
#define ENABLE_DLOG 0
|
||||
#else
|
||||
#define ENABLE_DLOG 1
|
||||
#endif
|
||||
|
||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||
#define DCHECK_IS_ON() 0
|
||||
#else
|
||||
#define DCHECK_IS_ON() 1
|
||||
#endif
|
||||
|
||||
// Definitions for DLOG et al.
|
||||
|
||||
#if ENABLE_DLOG
|
||||
|
||||
#define DLOG_IS_ON(severity) LOG_IS_ON(severity)
|
||||
#define DLOG_IF(severity, condition) LOG_IF(severity, condition)
|
||||
#define DLOG_ASSERT(condition) LOG_ASSERT(condition)
|
||||
#define DPLOG_IF(severity, condition) PLOG_IF(severity, condition)
|
||||
#define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition)
|
||||
#define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition)
|
||||
|
||||
#else // ENABLE_DLOG
|
||||
|
||||
// If ENABLE_DLOG is off, we want to avoid emitting any references to
|
||||
// |condition| (which may reference a variable defined only if NDEBUG
|
||||
// is not defined). Contrast this with DCHECK et al., which has
|
||||
// different behavior.
|
||||
|
||||
#define DLOG_IS_ON(severity) false
|
||||
#define DLOG_IF(severity, condition) EAT_STREAM_PARAMETERS
|
||||
#define DLOG_ASSERT(condition) EAT_STREAM_PARAMETERS
|
||||
#define DPLOG_IF(severity, condition) EAT_STREAM_PARAMETERS
|
||||
#define DVLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS
|
||||
#define DVPLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS
|
||||
|
||||
#endif // ENABLE_DLOG
|
||||
|
||||
// DEBUG_MODE is for uses like
|
||||
// if (DEBUG_MODE) foo.CheckThatFoo();
|
||||
// instead of
|
||||
// #ifndef NDEBUG
|
||||
// foo.CheckThatFoo();
|
||||
// #endif
|
||||
//
|
||||
// We tie its state to ENABLE_DLOG.
|
||||
enum { DEBUG_MODE = ENABLE_DLOG };
|
||||
|
||||
#undef ENABLE_DLOG
|
||||
|
||||
#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
|
||||
|
||||
#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
|
||||
|
||||
#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
|
||||
|
||||
#define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
|
||||
|
||||
// Definitions for DCHECK et al.
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
|
||||
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
||||
COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
|
||||
const LogSeverity LOG_DCHECK = LOG_FATAL;
|
||||
|
||||
#else // DCHECK_IS_ON()
|
||||
|
||||
// These are just dummy values.
|
||||
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
||||
COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__)
|
||||
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
|
||||
const LogSeverity LOG_DCHECK = LOG_INFO;
|
||||
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
// DCHECK et al. make sure to reference |condition| regardless of
|
||||
// whether DCHECKs are enabled; this is so that we don't get unused
|
||||
// variable warnings if the only use of a variable is in a DCHECK.
|
||||
// This behavior is different from DLOG_IF et al.
|
||||
|
||||
#define DCHECK(condition) \
|
||||
LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
#define DPCHECK(condition) \
|
||||
LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
|
||||
<< "Check failed: " #condition ". "
|
||||
|
||||
// Helper macro for binary operators.
|
||||
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
|
||||
#define DCHECK_OP(name, op, val1, val2) \
|
||||
if (DCHECK_IS_ON()) \
|
||||
if (std::string* _result = cef::logging::Check##name##Impl( \
|
||||
(val1), (val2), #val1 " " #op " " #val2)) \
|
||||
cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \
|
||||
_result) \
|
||||
.stream()
|
||||
|
||||
// Equality/Inequality checks - compare two values, and log a
|
||||
// LOG_DCHECK message including the two values when the result is not
|
||||
// as expected. The values must have operator<<(ostream, ...)
|
||||
// defined.
|
||||
//
|
||||
// You may append to the error message like so:
|
||||
// DCHECK_NE(1, 2) << ": The world must be ending!";
|
||||
//
|
||||
// We are very careful to ensure that each argument is evaluated exactly
|
||||
// once, and that anything which is legal to pass as a function argument is
|
||||
// legal here. In particular, the arguments may be temporary expressions
|
||||
// which will end up being destroyed at the end of the apparent statement,
|
||||
// for example:
|
||||
// DCHECK_EQ(string("abc")[1], 'b');
|
||||
//
|
||||
// WARNING: These may not compile correctly if one of the arguments is a pointer
|
||||
// and the other is NULL. To work around this, simply static_cast NULL to the
|
||||
// type of the desired pointer.
|
||||
|
||||
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
|
||||
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
|
||||
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
|
||||
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2)
|
||||
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
||||
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
|
||||
|
||||
#define NOTREACHED() DCHECK(false)
|
||||
|
||||
// Redefine the standard assert to use our nice log files
|
||||
#undef assert
|
||||
#define assert(x) DLOG_ASSERT(x)
|
||||
|
||||
// This class more or less represents a particular log message. You
|
||||
// create an instance of LogMessage and then stream stuff to it.
|
||||
// When you finish streaming to it, ~LogMessage is called and the
|
||||
// full message gets streamed to the appropriate destination.
|
||||
//
|
||||
// You shouldn't actually use LogMessage's constructor to log things,
|
||||
// though. You should use the LOG() macro (and variants thereof)
|
||||
// above.
|
||||
class LogMessage {
|
||||
public:
|
||||
// Used for LOG(severity).
|
||||
LogMessage(const char* file, int line, LogSeverity severity);
|
||||
|
||||
// Used for CHECK_EQ(), etc. Takes ownership of the given string.
|
||||
// Implied severity = LOG_FATAL.
|
||||
LogMessage(const char* file, int line, std::string* result);
|
||||
|
||||
// Used for DCHECK_EQ(), etc. Takes ownership of the given string.
|
||||
LogMessage(const char* file,
|
||||
int line,
|
||||
LogSeverity severity,
|
||||
std::string* result);
|
||||
|
||||
LogMessage(const LogMessage&) = delete;
|
||||
LogMessage& operator=(const LogMessage&) = delete;
|
||||
|
||||
~LogMessage();
|
||||
|
||||
std::ostream& stream() { return stream_; }
|
||||
|
||||
private:
|
||||
LogSeverity severity_;
|
||||
std::ostringstream stream_;
|
||||
|
||||
// The file and line information passed in to the constructor.
|
||||
const char* file_;
|
||||
const int line_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Stores the current value of GetLastError in the constructor and restores
|
||||
// it in the destructor by calling SetLastError.
|
||||
// This is useful since the LogMessage class uses a lot of Win32 calls
|
||||
// that will lose the value of GLE and the code that called the log function
|
||||
// will have lost the thread error value when the log call returns.
|
||||
class SaveLastError {
|
||||
public:
|
||||
SaveLastError();
|
||||
~SaveLastError();
|
||||
|
||||
unsigned long get_error() const { return last_error_; }
|
||||
|
||||
protected:
|
||||
unsigned long last_error_;
|
||||
};
|
||||
|
||||
SaveLastError last_error_;
|
||||
#endif
|
||||
};
|
||||
|
||||
// A non-macro interface to the log facility; (useful
|
||||
// when the logging level is not a compile-time constant).
|
||||
inline void LogAtLevel(int const log_level, std::string const& msg) {
|
||||
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
|
||||
}
|
||||
|
||||
// This class is used to explicitly ignore values in the conditional
|
||||
// logging macros. This avoids compiler warnings like "value computed
|
||||
// is not used" and "statement has no effect".
|
||||
class LogMessageVoidify {
|
||||
public:
|
||||
LogMessageVoidify() {}
|
||||
// This has to be an operator with a precedence lower than << but
|
||||
// higher than ?:
|
||||
void operator&(std::ostream&) {}
|
||||
};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
typedef unsigned long SystemErrorCode;
|
||||
#elif defined(OS_POSIX)
|
||||
typedef int SystemErrorCode;
|
||||
#endif
|
||||
|
||||
// Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to
|
||||
// pull in windows.h just for GetLastError() and DWORD.
|
||||
SystemErrorCode GetLastSystemErrorCode();
|
||||
std::string SystemErrorCodeToString(SystemErrorCode error_code);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Appends a formatted system message of the GetLastError() type.
|
||||
class Win32ErrorLogMessage {
|
||||
public:
|
||||
Win32ErrorLogMessage(const char* file,
|
||||
int line,
|
||||
LogSeverity severity,
|
||||
SystemErrorCode err);
|
||||
|
||||
Win32ErrorLogMessage(const Win32ErrorLogMessage&) = delete;
|
||||
Win32ErrorLogMessage& operator=(const Win32ErrorLogMessage&) = delete;
|
||||
|
||||
// Appends the error message before destructing the encapsulated class.
|
||||
~Win32ErrorLogMessage();
|
||||
|
||||
std::ostream& stream() { return log_message_.stream(); }
|
||||
|
||||
private:
|
||||
SystemErrorCode err_;
|
||||
LogMessage log_message_;
|
||||
};
|
||||
#elif defined(OS_POSIX)
|
||||
// Appends a formatted system message of the errno type
|
||||
class ErrnoLogMessage {
|
||||
public:
|
||||
ErrnoLogMessage(const char* file,
|
||||
int line,
|
||||
LogSeverity severity,
|
||||
SystemErrorCode err);
|
||||
|
||||
ErrnoLogMessage(const ErrnoLogMessage&) = delete;
|
||||
ErrnoLogMessage& operator=(const ErrnoLogMessage&) = delete;
|
||||
|
||||
// Appends the error message before destructing the encapsulated class.
|
||||
~ErrnoLogMessage();
|
||||
|
||||
std::ostream& stream() { return log_message_.stream(); }
|
||||
|
||||
private:
|
||||
SystemErrorCode err_;
|
||||
LogMessage log_message_;
|
||||
};
|
||||
#endif // OS_WIN
|
||||
|
||||
} // namespace logging
|
||||
} // namespace cef
|
||||
|
||||
// These functions are provided as a convenience for logging, which is where we
|
||||
// use streams (it is against Google style to use streams in other places). It
|
||||
// is designed to allow you to emit non-ASCII Unicode strings to the log file,
|
||||
// which is normally ASCII. It is relatively slow, so try not to use it for
|
||||
// common cases. Non-ASCII characters will be converted to UTF-8 by these
|
||||
// operators.
|
||||
std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
|
||||
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
|
||||
return out << wstr.c_str();
|
||||
}
|
||||
|
||||
// The NOTIMPLEMENTED() macro annotates codepaths which have
|
||||
// not been implemented yet.
|
||||
//
|
||||
// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY:
|
||||
// 0 -- Do nothing (stripped by compiler)
|
||||
// 1 -- Warn at compile time
|
||||
// 2 -- Fail at compile time
|
||||
// 3 -- Fail at runtime (DCHECK)
|
||||
// 4 -- [default] LOG(ERROR) at runtime
|
||||
// 5 -- LOG(ERROR) at runtime, only once per call-site
|
||||
|
||||
#ifndef NOTIMPLEMENTED_POLICY
|
||||
#if defined(OS_ANDROID) && defined(OFFICIAL_BUILD)
|
||||
#define NOTIMPLEMENTED_POLICY 0
|
||||
#else
|
||||
// Select default policy: LOG(ERROR)
|
||||
#define NOTIMPLEMENTED_POLICY 4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(COMPILER_GCC)
|
||||
// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name
|
||||
// of the current function in the NOTIMPLEMENTED message.
|
||||
#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__
|
||||
#else
|
||||
#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED"
|
||||
#endif
|
||||
|
||||
#if NOTIMPLEMENTED_POLICY == 0
|
||||
#define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS
|
||||
#elif NOTIMPLEMENTED_POLICY == 1
|
||||
// TODO, figure out how to generate a warning
|
||||
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
|
||||
#elif NOTIMPLEMENTED_POLICY == 2
|
||||
#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED)
|
||||
#elif NOTIMPLEMENTED_POLICY == 3
|
||||
#define NOTIMPLEMENTED() NOTREACHED()
|
||||
#elif NOTIMPLEMENTED_POLICY == 4
|
||||
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
|
||||
#elif NOTIMPLEMENTED_POLICY == 5
|
||||
#define NOTIMPLEMENTED() \
|
||||
do { \
|
||||
static bool logged_once = false; \
|
||||
LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \
|
||||
logged_once = true; \
|
||||
} while (0); \
|
||||
EAT_STREAM_PARAMETERS
|
||||
#endif
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
63
Thirdparty/libcef/include/base/cef_macros.h
vendored
Normal file
63
Thirdparty/libcef/include/base/cef_macros.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
// 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_MACROS_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(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.
|
||||
|
||||
// ALL DISALLOW_xxx MACROS ARE DEPRECATED; DO NOT USE IN NEW CODE.
|
||||
// Use explicit deletions instead. See the section on copyability/movability in
|
||||
// //styleguide/c++/c++-dos-and-donts.md for more information.
|
||||
|
||||
// DEPRECATED: See above. Makes a class uncopyable.
|
||||
#define DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete
|
||||
|
||||
// DEPRECATED: See above. Makes a class unassignable.
|
||||
#define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
|
||||
|
||||
// DEPRECATED: See above. Makes a class uncopyable and unassignable.
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
DISALLOW_COPY(TypeName); \
|
||||
DISALLOW_ASSIGN(TypeName)
|
||||
|
||||
// DEPRECATED: See above. Disallow all implicit constructors, namely the
|
||||
// default constructor, copy constructor and operator= functions.
|
||||
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
||||
TypeName() = delete; \
|
||||
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_
|
101
Thirdparty/libcef/include/base/cef_platform_thread.h
vendored
Normal file
101
Thirdparty/libcef/include/base/cef_platform_thread.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
// 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.
|
||||
|
||||
// WARNING: You should *NOT* be using this class directly. PlatformThread is
|
||||
// the low-level platform-specific abstraction to the OS's threading interface.
|
||||
// You should instead be using a message-loop driven Thread, see thread.h.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||
#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/threading/platform_thread.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/base/cef_basictypes.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/internal/cef_thread_internal.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
// Used for logging. Always an integer value.
|
||||
typedef cef_platform_thread_id_t PlatformThreadId;
|
||||
|
||||
// Used for thread checking and debugging.
|
||||
// Meant to be as fast as possible.
|
||||
// These are produced by PlatformThread::CurrentRef(), and used to later
|
||||
// check if we are on the same thread or not by using ==. These are safe
|
||||
// to copy between threads, but can't be copied to another process as they
|
||||
// have no meaning there. Also, the internal identifier can be re-used
|
||||
// after a thread dies, so a PlatformThreadRef cannot be reliably used
|
||||
// to distinguish a new thread from an old, dead thread.
|
||||
class PlatformThreadRef {
|
||||
public:
|
||||
typedef cef_platform_thread_handle_t RefType;
|
||||
|
||||
PlatformThreadRef() : id_(0) {}
|
||||
|
||||
explicit PlatformThreadRef(RefType id) : id_(id) {}
|
||||
|
||||
bool operator==(PlatformThreadRef other) const { return id_ == other.id_; }
|
||||
|
||||
bool is_null() const { return id_ == 0; }
|
||||
|
||||
private:
|
||||
RefType id_;
|
||||
};
|
||||
|
||||
// A namespace for low-level thread functions.
|
||||
// Chromium uses a class with static methods but CEF uses an actual namespace
|
||||
// to avoid linker problems with the sandbox libaries on Windows.
|
||||
namespace PlatformThread {
|
||||
|
||||
// Gets the current thread id, which may be useful for logging purposes.
|
||||
inline PlatformThreadId CurrentId() {
|
||||
return cef_get_current_platform_thread_id();
|
||||
}
|
||||
|
||||
// Gets the current thread reference, which can be used to check if
|
||||
// we're on the right thread quickly.
|
||||
inline PlatformThreadRef CurrentRef() {
|
||||
return PlatformThreadRef(cef_get_current_platform_thread_handle());
|
||||
}
|
||||
|
||||
} // namespace PlatformThread
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
58
Thirdparty/libcef/include/base/cef_ptr_util.h
vendored
Normal file
58
Thirdparty/libcef/include/base/cef_ptr_util.h
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2015
|
||||
// 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_PTR_UTIL_H_
|
||||
#define INCLUDE_BASE_CEF_PTR_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/ptr_util.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 <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace base {
|
||||
|
||||
// Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.
|
||||
// Note that std::unique_ptr<T> has very different semantics from
|
||||
// std::unique_ptr<T[]>: do not use this helper for array allocations.
|
||||
template <typename T>
|
||||
std::unique_ptr<T> WrapUnique(T* ptr) {
|
||||
return std::unique_ptr<T>(ptr);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // INCLUDE_BASE_CEF_PTR_UTIL_H_
|
496
Thirdparty/libcef/include/base/cef_ref_counted.h
vendored
Normal file
496
Thirdparty/libcef/include/base/cef_ref_counted.h
vendored
Normal file
@ -0,0 +1,496 @@
|
||||
// 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_REF_COUNTED_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/ref_counted.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 <stddef.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_atomic_ref_count.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_scoped_refptr.h"
|
||||
#include "include/base/cef_template_util.h"
|
||||
#include "include/base/cef_thread_checker.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_subtle {
|
||||
|
||||
class RefCountedBase {
|
||||
public:
|
||||
bool HasOneRef() const { return ref_count_ == 1; }
|
||||
bool HasAtLeastOneRef() const { return ref_count_ >= 1; }
|
||||
|
||||
protected:
|
||||
explicit RefCountedBase(StartRefCountFromZeroTag) {
|
||||
#if DCHECK_IS_ON()
|
||||
thread_checker_.DetachFromThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
explicit RefCountedBase(StartRefCountFromOneTag) : ref_count_(1) {
|
||||
#if DCHECK_IS_ON()
|
||||
needs_adopt_ref_ = true;
|
||||
thread_checker_.DetachFromThread();
|
||||
#endif
|
||||
}
|
||||
|
||||
RefCountedBase(const RefCountedBase&) = delete;
|
||||
RefCountedBase& operator=(const RefCountedBase&) = delete;
|
||||
|
||||
~RefCountedBase() {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||
#endif
|
||||
}
|
||||
|
||||
void AddRef() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!needs_adopt_ref_)
|
||||
<< "This RefCounted object is created with non-zero reference count."
|
||||
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||
<< " MakeRefCounted.";
|
||||
if (ref_count_ >= 1) {
|
||||
DCHECK(CalledOnValidThread());
|
||||
}
|
||||
#endif
|
||||
|
||||
AddRefImpl();
|
||||
}
|
||||
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release() const {
|
||||
ReleaseImpl();
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
if (ref_count_ == 0)
|
||||
in_dtor_ = true;
|
||||
|
||||
if (ref_count_ >= 1)
|
||||
DCHECK(CalledOnValidThread());
|
||||
if (ref_count_ == 1)
|
||||
thread_checker_.DetachFromThread();
|
||||
#endif
|
||||
|
||||
return ref_count_ == 0;
|
||||
}
|
||||
|
||||
// Returns true if it is safe to read or write the object, from a thread
|
||||
// safety standpoint. Should be DCHECK'd from the methods of RefCounted
|
||||
// classes if there is a danger of objects being shared across threads.
|
||||
//
|
||||
// This produces fewer false positives than adding a separate ThreadChecker
|
||||
// into the subclass, because it automatically detaches from the thread when
|
||||
// the reference count is 1 (and never fails if there is only one reference).
|
||||
//
|
||||
// This means unlike a separate ThreadChecker, it will permit a singly
|
||||
// referenced object to be passed between threads (not holding a reference on
|
||||
// the sending thread), but will trap if the sending thread holds onto a
|
||||
// reference, or if the object is accessed from multiple threads
|
||||
// simultaneously.
|
||||
bool IsOnValidThread() const {
|
||||
#if DCHECK_IS_ON()
|
||||
return ref_count_ <= 1 || CalledOnValidThread();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||
|
||||
void Adopted() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(needs_adopt_ref_);
|
||||
needs_adopt_ref_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ARCH_CPU_64_BITS)
|
||||
void AddRefImpl() const;
|
||||
void ReleaseImpl() const;
|
||||
#else
|
||||
void AddRefImpl() const { ++ref_count_; }
|
||||
void ReleaseImpl() const { --ref_count_; }
|
||||
#endif
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
bool CalledOnValidThread() const;
|
||||
#endif
|
||||
|
||||
mutable uint32_t ref_count_ = 0;
|
||||
static_assert(std::is_unsigned<decltype(ref_count_)>::value,
|
||||
"ref_count_ must be an unsigned type.");
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool needs_adopt_ref_ = false;
|
||||
mutable bool in_dtor_ = false;
|
||||
mutable ThreadChecker thread_checker_;
|
||||
#endif
|
||||
};
|
||||
|
||||
class RefCountedThreadSafeBase {
|
||||
public:
|
||||
bool HasOneRef() const;
|
||||
bool HasAtLeastOneRef() const;
|
||||
|
||||
protected:
|
||||
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromZeroTag) {}
|
||||
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromOneTag)
|
||||
: ref_count_(1) {
|
||||
#if DCHECK_IS_ON()
|
||||
needs_adopt_ref_ = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
RefCountedThreadSafeBase(const RefCountedThreadSafeBase&) = delete;
|
||||
RefCountedThreadSafeBase& operator=(const RefCountedThreadSafeBase&) = delete;
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
~RefCountedThreadSafeBase();
|
||||
#else
|
||||
~RefCountedThreadSafeBase() = default;
|
||||
#endif
|
||||
|
||||
// Release and AddRef are suitable for inlining on X86 because they generate
|
||||
// very small code threads. On other platforms (ARM), it causes a size
|
||||
// regression and is probably not worth it.
|
||||
#if defined(ARCH_CPU_X86_FAMILY)
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release() const { return ReleaseImpl(); }
|
||||
void AddRef() const { AddRefImpl(); }
|
||||
void AddRefWithCheck() const { AddRefWithCheckImpl(); }
|
||||
#else
|
||||
// Returns true if the object should self-delete.
|
||||
bool Release() const;
|
||||
void AddRef() const;
|
||||
void AddRefWithCheck() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||
|
||||
void Adopted() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(needs_adopt_ref_);
|
||||
needs_adopt_ref_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AddRefImpl() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!needs_adopt_ref_)
|
||||
<< "This RefCounted object is created with non-zero reference count."
|
||||
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||
<< " MakeRefCounted.";
|
||||
#endif
|
||||
ref_count_.Increment();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AddRefWithCheckImpl() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!needs_adopt_ref_)
|
||||
<< "This RefCounted object is created with non-zero reference count."
|
||||
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||
<< " MakeRefCounted.";
|
||||
#endif
|
||||
CHECK(ref_count_.Increment() > 0);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool ReleaseImpl() const {
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
DCHECK(!ref_count_.IsZero());
|
||||
#endif
|
||||
if (!ref_count_.Decrement()) {
|
||||
#if DCHECK_IS_ON()
|
||||
in_dtor_ = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
mutable AtomicRefCount ref_count_{0};
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool needs_adopt_ref_ = false;
|
||||
mutable bool in_dtor_ = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
// ScopedAllowCrossThreadRefCountAccess disables the check documented on
|
||||
// RefCounted below for rare pre-existing use cases where thread-safety was
|
||||
// guaranteed through other means (e.g. explicit sequencing of calls across
|
||||
// execution threads when bouncing between threads in order). New callers
|
||||
// should refrain from using this (callsites handling thread-safety through
|
||||
// locks should use RefCountedThreadSafe per the overhead of its atomics being
|
||||
// negligible compared to locks anyways and callsites doing explicit sequencing
|
||||
// should properly std::move() the ref to avoid hitting this check).
|
||||
// TODO(tzik): Cleanup existing use cases and remove
|
||||
// ScopedAllowCrossThreadRefCountAccess.
|
||||
class ScopedAllowCrossThreadRefCountAccess final {
|
||||
public:
|
||||
#if DCHECK_IS_ON()
|
||||
ScopedAllowCrossThreadRefCountAccess();
|
||||
~ScopedAllowCrossThreadRefCountAccess();
|
||||
#else
|
||||
ScopedAllowCrossThreadRefCountAccess() {}
|
||||
~ScopedAllowCrossThreadRefCountAccess() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace cef_subtle
|
||||
|
||||
using ScopedAllowCrossThreadRefCountAccess =
|
||||
cef_subtle::ScopedAllowCrossThreadRefCountAccess;
|
||||
|
||||
//
|
||||
// A base class for reference counted classes. Otherwise, known as a cheap
|
||||
// knock-off of WebKit's RefCounted<T> class. To use this, just extend your
|
||||
// class from it like so:
|
||||
//
|
||||
// class MyFoo : public base::RefCounted<MyFoo> {
|
||||
// ...
|
||||
// private:
|
||||
// friend class base::RefCounted<MyFoo>;
|
||||
// ~MyFoo();
|
||||
// };
|
||||
//
|
||||
// Usage Notes:
|
||||
// 1. You should always make your destructor non-public, to avoid any code
|
||||
// deleting the object accidentally while there are references to it.
|
||||
// 2. You should always make the ref-counted base class a friend of your class,
|
||||
// so that it can access the destructor.
|
||||
//
|
||||
// The ref count manipulation to RefCounted is NOT thread safe and has DCHECKs
|
||||
// to trap unsafe cross thread usage. A subclass instance of RefCounted can be
|
||||
// passed to another execution thread only when its ref count is 1. If the ref
|
||||
// count is more than 1, the RefCounted class verifies the ref updates are made
|
||||
// on the same execution thread as the previous ones. The subclass can also
|
||||
// manually call IsOnValidThread to trap other non-thread-safe accesses; see
|
||||
// the documentation for that method.
|
||||
//
|
||||
//
|
||||
// The reference count starts from zero by default, and we intended to migrate
|
||||
// to start-from-one ref count. Put REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() to
|
||||
// the ref counted class to opt-in.
|
||||
//
|
||||
// If an object has start-from-one ref count, the first scoped_refptr need to be
|
||||
// created by base::AdoptRef() or base::MakeRefCounted(). We can use
|
||||
// base::MakeRefCounted() to create create both type of ref counted object.
|
||||
//
|
||||
// The motivations to use start-from-one ref count are:
|
||||
// - Start-from-one ref count doesn't need the ref count increment for the
|
||||
// first reference.
|
||||
// - It can detect an invalid object acquisition for a being-deleted object
|
||||
// that has zero ref count. That tends to happen on custom deleter that
|
||||
// delays the deletion.
|
||||
// TODO(tzik): Implement invalid acquisition detection.
|
||||
// - Behavior parity to Blink's WTF::RefCounted, whose count starts from one.
|
||||
// And start-from-one ref count is a step to merge WTF::RefCounted into
|
||||
// base::RefCounted.
|
||||
//
|
||||
#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \
|
||||
static constexpr ::base::cef_subtle::StartRefCountFromOneTag \
|
||||
kRefCountPreference = ::base::cef_subtle::kStartRefCountFromOneTag
|
||||
|
||||
template <class T, typename Traits>
|
||||
class RefCounted;
|
||||
|
||||
template <typename T>
|
||||
struct DefaultRefCountedTraits {
|
||||
static void Destruct(const T* x) {
|
||||
RefCounted<T, DefaultRefCountedTraits>::DeleteInternal(x);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, typename Traits = DefaultRefCountedTraits<T>>
|
||||
class RefCounted : public cef_subtle::RefCountedBase {
|
||||
public:
|
||||
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||
cef_subtle::kStartRefCountFromZeroTag;
|
||||
|
||||
RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {}
|
||||
|
||||
RefCounted(const RefCounted&) = delete;
|
||||
RefCounted& operator=(const RefCounted&) = delete;
|
||||
|
||||
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
|
||||
|
||||
void Release() const {
|
||||
if (cef_subtle::RefCountedBase::Release()) {
|
||||
// Prune the code paths which the static analyzer may take to simulate
|
||||
// object destruction. Use-after-free errors aren't possible given the
|
||||
// lifetime guarantees of the refcounting system.
|
||||
ANALYZER_SKIP_THIS_PATH();
|
||||
|
||||
Traits::Destruct(static_cast<const T*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
~RefCounted() = default;
|
||||
|
||||
private:
|
||||
friend struct DefaultRefCountedTraits<T>;
|
||||
template <typename U>
|
||||
static void DeleteInternal(const U* x) {
|
||||
delete x;
|
||||
}
|
||||
};
|
||||
|
||||
// Forward declaration.
|
||||
template <class T, typename Traits>
|
||||
class RefCountedThreadSafe;
|
||||
|
||||
// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
|
||||
// count reaches 0. Overload to delete it on a different thread etc.
|
||||
template <typename T>
|
||||
struct DefaultRefCountedThreadSafeTraits {
|
||||
static void Destruct(const T* x) {
|
||||
// Delete through RefCountedThreadSafe to make child classes only need to be
|
||||
// friend with RefCountedThreadSafe instead of this struct, which is an
|
||||
// implementation detail.
|
||||
RefCountedThreadSafe<T, DefaultRefCountedThreadSafeTraits>::DeleteInternal(
|
||||
x);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// A thread-safe variant of RefCounted<T>
|
||||
//
|
||||
// class MyFoo : public base::RefCountedThreadSafe<MyFoo> {
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
// If you're using the default trait, then you should add compile time
|
||||
// asserts that no one else is deleting your object. i.e.
|
||||
// private:
|
||||
// friend class base::RefCountedThreadSafe<MyFoo>;
|
||||
// ~MyFoo();
|
||||
//
|
||||
// We can use REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() with RefCountedThreadSafe
|
||||
// too. See the comment above the RefCounted definition for details.
|
||||
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
|
||||
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
||||
public:
|
||||
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||
cef_subtle::kStartRefCountFromZeroTag;
|
||||
|
||||
explicit RefCountedThreadSafe()
|
||||
: cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
|
||||
|
||||
RefCountedThreadSafe(const RefCountedThreadSafe&) = delete;
|
||||
RefCountedThreadSafe& operator=(const RefCountedThreadSafe&) = delete;
|
||||
|
||||
void AddRef() const { AddRefImpl(T::kRefCountPreference); }
|
||||
|
||||
void Release() const {
|
||||
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
||||
ANALYZER_SKIP_THIS_PATH();
|
||||
Traits::Destruct(static_cast<const T*>(this));
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
~RefCountedThreadSafe() = default;
|
||||
|
||||
private:
|
||||
friend struct DefaultRefCountedThreadSafeTraits<T>;
|
||||
template <typename U>
|
||||
static void DeleteInternal(const U* x) {
|
||||
delete x;
|
||||
}
|
||||
|
||||
void AddRefImpl(cef_subtle::StartRefCountFromZeroTag) const {
|
||||
cef_subtle::RefCountedThreadSafeBase::AddRef();
|
||||
}
|
||||
|
||||
void AddRefImpl(cef_subtle::StartRefCountFromOneTag) const {
|
||||
cef_subtle::RefCountedThreadSafeBase::AddRefWithCheck();
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// A thread-safe wrapper for some piece of data so we can place other
|
||||
// things in scoped_refptrs<>.
|
||||
//
|
||||
template <typename T>
|
||||
class RefCountedData
|
||||
: public base::RefCountedThreadSafe<base::RefCountedData<T>> {
|
||||
public:
|
||||
RefCountedData() : data() {}
|
||||
RefCountedData(const T& in_value) : data(in_value) {}
|
||||
RefCountedData(T&& in_value) : data(std::move(in_value)) {}
|
||||
template <typename... Args>
|
||||
explicit RefCountedData(in_place_t, Args&&... args)
|
||||
: data(std::forward<Args>(args)...) {}
|
||||
|
||||
T data;
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
|
||||
~RefCountedData() = default;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const RefCountedData<T>& lhs, const RefCountedData<T>& rhs) {
|
||||
return lhs.data == rhs.data;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(const RefCountedData<T>& lhs, const RefCountedData<T>& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
411
Thirdparty/libcef/include/base/cef_scoped_refptr.h
vendored
Normal file
411
Thirdparty/libcef/include/base/cef_scoped_refptr.h
vendored
Normal file
@ -0,0 +1,411 @@
|
||||
// Copyright (c) 2017 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_SCOPED_REFPTR_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/scoped_refptr.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 <stddef.h>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_compiler_specific.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
|
||||
template <class T>
|
||||
class scoped_refptr;
|
||||
|
||||
namespace base {
|
||||
|
||||
template <class, typename>
|
||||
class RefCounted;
|
||||
template <class, typename>
|
||||
class RefCountedThreadSafe;
|
||||
class SequencedTaskRunner;
|
||||
class WrappedPromise;
|
||||
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRef(T* t);
|
||||
|
||||
namespace internal {
|
||||
|
||||
class BasePromise;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
namespace cef_subtle {
|
||||
|
||||
enum AdoptRefTag { kAdoptRefTag };
|
||||
enum StartRefCountFromZeroTag { kStartRefCountFromZeroTag };
|
||||
enum StartRefCountFromOneTag { kStartRefCountFromOneTag };
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
constexpr bool IsRefCountPreferenceOverridden(const T*,
|
||||
const RefCounted<U, V>*) {
|
||||
return !std::is_same<std::decay_t<decltype(T::kRefCountPreference)>,
|
||||
std::decay_t<decltype(U::kRefCountPreference)>>::value;
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename V>
|
||||
constexpr bool IsRefCountPreferenceOverridden(
|
||||
const T*,
|
||||
const RefCountedThreadSafe<U, V>*) {
|
||||
return !std::is_same<std::decay_t<decltype(T::kRefCountPreference)>,
|
||||
std::decay_t<decltype(U::kRefCountPreference)>>::value;
|
||||
}
|
||||
|
||||
constexpr bool IsRefCountPreferenceOverridden(...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cef_subtle
|
||||
|
||||
// Creates a scoped_refptr from a raw pointer without incrementing the reference
|
||||
// count. Use this only for a newly created object whose reference count starts
|
||||
// from 1 instead of 0.
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRef(T* obj) {
|
||||
using Tag = std::decay_t<decltype(T::kRefCountPreference)>;
|
||||
static_assert(std::is_same<cef_subtle::StartRefCountFromOneTag, Tag>::value,
|
||||
"Use AdoptRef only if the reference count starts from one.");
|
||||
|
||||
DCHECK(obj);
|
||||
DCHECK(obj->HasOneRef());
|
||||
obj->Adopted();
|
||||
return scoped_refptr<T>(obj, cef_subtle::kAdoptRefTag);
|
||||
}
|
||||
|
||||
namespace cef_subtle {
|
||||
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromZeroTag) {
|
||||
return scoped_refptr<T>(obj);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromOneTag) {
|
||||
return AdoptRef(obj);
|
||||
}
|
||||
|
||||
} // namespace cef_subtle
|
||||
|
||||
// Constructs an instance of T, which is a ref counted type, and wraps the
|
||||
// object into a scoped_refptr<T>.
|
||||
template <typename T, typename... Args>
|
||||
scoped_refptr<T> MakeRefCounted(Args&&... args) {
|
||||
T* obj = new T(std::forward<Args>(args)...);
|
||||
return cef_subtle::AdoptRefIfNeeded(obj, T::kRefCountPreference);
|
||||
}
|
||||
|
||||
// Takes an instance of T, which is a ref counted type, and wraps the object
|
||||
// into a scoped_refptr<T>.
|
||||
template <typename T>
|
||||
scoped_refptr<T> WrapRefCounted(T* t) {
|
||||
return scoped_refptr<T>(t);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
//
|
||||
// A smart pointer class for reference counted objects. Use this class instead
|
||||
// of calling AddRef and Release manually on a reference counted object to
|
||||
// avoid common memory leaks caused by forgetting to Release an object
|
||||
// reference. Sample usage:
|
||||
//
|
||||
// class MyFoo : public RefCounted<MyFoo> {
|
||||
// ...
|
||||
// private:
|
||||
// friend class RefCounted<MyFoo>; // Allow destruction by RefCounted<>.
|
||||
// ~MyFoo(); // Destructor must be private/protected.
|
||||
// };
|
||||
//
|
||||
// void some_function() {
|
||||
// scoped_refptr<MyFoo> foo = MakeRefCounted<MyFoo>();
|
||||
// foo->Method(param);
|
||||
// // |foo| is released when this function returns
|
||||
// }
|
||||
//
|
||||
// void some_other_function() {
|
||||
// scoped_refptr<MyFoo> foo = MakeRefCounted<MyFoo>();
|
||||
// ...
|
||||
// foo.reset(); // explicitly releases |foo|
|
||||
// ...
|
||||
// if (foo)
|
||||
// foo->Method(param);
|
||||
// }
|
||||
//
|
||||
// The above examples show how scoped_refptr<T> acts like a pointer to T.
|
||||
// Given two scoped_refptr<T> classes, it is also possible to exchange
|
||||
// references between the two objects, like so:
|
||||
//
|
||||
// {
|
||||
// scoped_refptr<MyFoo> a = MakeRefCounted<MyFoo>();
|
||||
// scoped_refptr<MyFoo> b;
|
||||
//
|
||||
// b.swap(a);
|
||||
// // now, |b| references the MyFoo object, and |a| references nullptr.
|
||||
// }
|
||||
//
|
||||
// To make both |a| and |b| in the above example reference the same MyFoo
|
||||
// object, simply use the assignment operator:
|
||||
//
|
||||
// {
|
||||
// scoped_refptr<MyFoo> a = MakeRefCounted<MyFoo>();
|
||||
// scoped_refptr<MyFoo> b;
|
||||
//
|
||||
// b = a;
|
||||
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||
// }
|
||||
//
|
||||
// Also see Chromium's ownership and calling conventions:
|
||||
// https://chromium.googlesource.com/chromium/src/+/lkgr/styleguide/c++/c++.md#object-ownership-and-calling-conventions
|
||||
// Specifically:
|
||||
// If the function (at least sometimes) takes a ref on a refcounted object,
|
||||
// declare the param as scoped_refptr<T>. The caller can decide whether it
|
||||
// wishes to transfer ownership (by calling std::move(t) when passing t) or
|
||||
// retain its ref (by simply passing t directly).
|
||||
// In other words, use scoped_refptr like you would a std::unique_ptr except
|
||||
// in the odd case where it's required to hold on to a ref while handing one
|
||||
// to another component (if a component merely needs to use t on the stack
|
||||
// without keeping a ref: pass t as a raw T*).
|
||||
template <class T>
|
||||
class TRIVIAL_ABI scoped_refptr {
|
||||
public:
|
||||
typedef T element_type;
|
||||
|
||||
constexpr scoped_refptr() = default;
|
||||
|
||||
// Allow implicit construction from nullptr.
|
||||
constexpr scoped_refptr(std::nullptr_t) {}
|
||||
|
||||
// Constructs from a raw pointer. Note that this constructor allows implicit
|
||||
// conversion from T* to scoped_refptr<T> which is strongly discouraged. If
|
||||
// you are creating a new ref-counted object please use
|
||||
// base::MakeRefCounted<T>() or base::WrapRefCounted<T>(). Otherwise you
|
||||
// should move or copy construct from an existing scoped_refptr<T> to the
|
||||
// ref-counted object.
|
||||
scoped_refptr(T* p) : ptr_(p) {
|
||||
if (ptr_)
|
||||
AddRef(ptr_);
|
||||
}
|
||||
|
||||
// Copy constructor. This is required in addition to the copy conversion
|
||||
// constructor below.
|
||||
scoped_refptr(const scoped_refptr& r) : scoped_refptr(r.ptr_) {}
|
||||
|
||||
// Copy conversion constructor.
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<
|
||||
std::is_convertible<U*, T*>::value>::type>
|
||||
scoped_refptr(const scoped_refptr<U>& r) : scoped_refptr(r.ptr_) {}
|
||||
|
||||
// Move constructor. This is required in addition to the move conversion
|
||||
// constructor below.
|
||||
scoped_refptr(scoped_refptr&& r) noexcept : ptr_(r.ptr_) { r.ptr_ = nullptr; }
|
||||
|
||||
// Move conversion constructor.
|
||||
template <typename U,
|
||||
typename = typename std::enable_if<
|
||||
std::is_convertible<U*, T*>::value>::type>
|
||||
scoped_refptr(scoped_refptr<U>&& r) noexcept : ptr_(r.ptr_) {
|
||||
r.ptr_ = nullptr;
|
||||
}
|
||||
|
||||
~scoped_refptr() {
|
||||
static_assert(!base::cef_subtle::IsRefCountPreferenceOverridden(
|
||||
static_cast<T*>(nullptr), static_cast<T*>(nullptr)),
|
||||
"It's unsafe to override the ref count preference."
|
||||
" Please remove REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE"
|
||||
" from subclasses.");
|
||||
if (ptr_)
|
||||
Release(ptr_);
|
||||
}
|
||||
|
||||
T* get() const { return ptr_; }
|
||||
|
||||
T& operator*() const {
|
||||
DCHECK(ptr_);
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
DCHECK(ptr_);
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
scoped_refptr& operator=(std::nullptr_t) {
|
||||
reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
scoped_refptr& operator=(T* p) { return *this = scoped_refptr(p); }
|
||||
|
||||
// Unified assignment operator.
|
||||
scoped_refptr& operator=(scoped_refptr r) noexcept {
|
||||
swap(r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Sets managed object to null and releases reference to the previous managed
|
||||
// object, if it existed.
|
||||
void reset() { scoped_refptr().swap(*this); }
|
||||
|
||||
// Returns the owned pointer (if any), releasing ownership to the caller. The
|
||||
// caller is responsible for managing the lifetime of the reference.
|
||||
T* release() WARN_UNUSED_RESULT;
|
||||
|
||||
void swap(scoped_refptr& r) noexcept { std::swap(ptr_, r.ptr_); }
|
||||
|
||||
explicit operator bool() const { return ptr_ != nullptr; }
|
||||
|
||||
template <typename U>
|
||||
bool operator==(const scoped_refptr<U>& rhs) const {
|
||||
return ptr_ == rhs.get();
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator!=(const scoped_refptr<U>& rhs) const {
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
bool operator<(const scoped_refptr<U>& rhs) const {
|
||||
return ptr_ < rhs.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
T* ptr_ = nullptr;
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||
friend class ::base::SequencedTaskRunner;
|
||||
|
||||
// Friend access so these classes can use the constructor below as part of a
|
||||
// binary size optimization.
|
||||
friend class ::base::internal::BasePromise;
|
||||
friend class ::base::WrappedPromise;
|
||||
|
||||
scoped_refptr(T* p, base::cef_subtle::AdoptRefTag) : ptr_(p) {}
|
||||
|
||||
// Friend required for move constructors that set r.ptr_ to null.
|
||||
template <typename U>
|
||||
friend class scoped_refptr;
|
||||
|
||||
// Non-inline helpers to allow:
|
||||
// class Opaque;
|
||||
// extern template class scoped_refptr<Opaque>;
|
||||
// Otherwise the compiler will complain that Opaque is an incomplete type.
|
||||
static void AddRef(T* ptr);
|
||||
static void Release(T* ptr);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T* scoped_refptr<T>::release() {
|
||||
T* ptr = ptr_;
|
||||
ptr_ = nullptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// static
|
||||
template <typename T>
|
||||
void scoped_refptr<T>::AddRef(T* ptr) {
|
||||
ptr->AddRef();
|
||||
}
|
||||
|
||||
// static
|
||||
template <typename T>
|
||||
void scoped_refptr<T>::Release(T* ptr) {
|
||||
ptr->Release();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const scoped_refptr<T>& lhs, const U* rhs) {
|
||||
return lhs.get() == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const T* lhs, const scoped_refptr<U>& rhs) {
|
||||
return lhs == rhs.get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const scoped_refptr<T>& lhs, std::nullptr_t null) {
|
||||
return !static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator==(std::nullptr_t null, const scoped_refptr<T>& rhs) {
|
||||
return !static_cast<bool>(rhs);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) {
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) {
|
||||
return !operator==(lhs, rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(const scoped_refptr<T>& lhs, std::nullptr_t null) {
|
||||
return !operator==(lhs, null);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) {
|
||||
return !operator==(null, rhs);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) {
|
||||
return out << p.get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void swap(scoped_refptr<T>& lhs, scoped_refptr<T>& rhs) noexcept {
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
414
Thirdparty/libcef/include/base/cef_template_util.h
vendored
Normal file
414
Thirdparty/libcef/include/base/cef_template_util.h
vendored
Normal file
@ -0,0 +1,414 @@
|
||||
// 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_TEMPLATE_UTIL_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/template_util.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 <stddef.h>
|
||||
#include <iosfwd>
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
// Some versions of libstdc++ have partial support for type_traits, but misses
|
||||
// a smaller subset while removing some of the older non-standard stuff. Assume
|
||||
// that all versions below 5.0 fall in this category, along with one 5.0
|
||||
// experimental release. Test for this by consulting compiler major version,
|
||||
// the only reliable option available, so theoretically this could fail should
|
||||
// you attempt to mix an earlier version of libstdc++ with >= GCC5. But
|
||||
// that's unlikely to work out, especially as GCC5 changed ABI.
|
||||
#define CR_GLIBCXX_5_0_0 20150123
|
||||
#if (defined(__GNUC__) && __GNUC__ < 5) || \
|
||||
(defined(__GLIBCXX__) && __GLIBCXX__ == CR_GLIBCXX_5_0_0)
|
||||
#define CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX
|
||||
#endif
|
||||
|
||||
// This hacks around using gcc with libc++ which has some incompatibilies.
|
||||
// - is_trivially_* doesn't work: https://llvm.org/bugs/show_bug.cgi?id=27538
|
||||
// TODO(danakj): Remove this when android builders are all using a newer version
|
||||
// of gcc, or the android ndk is updated to a newer libc++ that works with older
|
||||
// gcc versions.
|
||||
#if !defined(__clang__) && defined(_LIBCPP_VERSION)
|
||||
#define CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
template <class T> struct is_non_const_reference : std::false_type {};
|
||||
template <class T> struct is_non_const_reference<T&> : std::true_type {};
|
||||
template <class T> struct is_non_const_reference<const T&> : std::false_type {};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Implementation detail of base::void_t below.
|
||||
template <typename...>
|
||||
struct make_void {
|
||||
using type = void;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// base::void_t is an implementation of std::void_t from C++17.
|
||||
//
|
||||
// We use |base::internal::make_void| as a helper struct to avoid a C++14
|
||||
// defect:
|
||||
// http://en.cppreference.com/w/cpp/types/void_t
|
||||
// http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558
|
||||
template <typename... Ts>
|
||||
using void_t = typename ::base::internal::make_void<Ts...>::type;
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Uses expression SFINAE to detect whether using operator<< would work.
|
||||
template <typename T, typename = void>
|
||||
struct SupportsOstreamOperator : std::false_type {};
|
||||
template <typename T>
|
||||
struct SupportsOstreamOperator<T,
|
||||
decltype(void(std::declval<std::ostream&>()
|
||||
<< std::declval<T>()))>
|
||||
: std::true_type {};
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct SupportsToString : std::false_type {};
|
||||
template <typename T>
|
||||
struct SupportsToString<T, decltype(void(std::declval<T>().ToString()))>
|
||||
: std::true_type {};
|
||||
|
||||
// Used to detect whether the given type is an iterator. This is normally used
|
||||
// with std::enable_if to provide disambiguation for functions that take
|
||||
// templatzed iterators as input.
|
||||
template <typename T, typename = void>
|
||||
struct is_iterator : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_iterator<T,
|
||||
void_t<typename std::iterator_traits<T>::iterator_category>>
|
||||
: std::true_type {};
|
||||
|
||||
// Helper to express preferences in an overload set. If more than one overload
|
||||
// are available for a given set of parameters the overload with the higher
|
||||
// priority will be chosen.
|
||||
template <size_t I>
|
||||
struct priority_tag : priority_tag<I - 1> {};
|
||||
|
||||
template <>
|
||||
struct priority_tag<0> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// is_trivially_copyable is especially hard to get right.
|
||||
// - Older versions of libstdc++ will fail to have it like they do for other
|
||||
// type traits. This has become a subset of the second point, but used to be
|
||||
// handled independently.
|
||||
// - An experimental release of gcc includes most of type_traits but misses
|
||||
// is_trivially_copyable, so we still have to avoid using libstdc++ in this
|
||||
// case, which is covered by CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX.
|
||||
// - When compiling libc++ from before r239653, with a gcc compiler, the
|
||||
// std::is_trivially_copyable can fail. So we need to work around that by not
|
||||
// using the one in libc++ in this case. This is covered by the
|
||||
// CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX define, and is discussed in
|
||||
// https://llvm.org/bugs/show_bug.cgi?id=27538#c1 where they point out that
|
||||
// in libc++'s commit r239653 this is fixed by libc++ checking for gcc 5.1.
|
||||
// - In both of the above cases we are using the gcc compiler. When defining
|
||||
// this ourselves on compiler intrinsics, the __is_trivially_copyable()
|
||||
// intrinsic is not available on gcc before version 5.1 (see the discussion in
|
||||
// https://llvm.org/bugs/show_bug.cgi?id=27538#c1 again), so we must check for
|
||||
// that version.
|
||||
// - When __is_trivially_copyable() is not available because we are on gcc older
|
||||
// than 5.1, we need to fall back to something, so we use __has_trivial_copy()
|
||||
// instead based on what was done one-off in bit_cast() previously.
|
||||
|
||||
// TODO(crbug.com/554293): Remove this when all platforms have this in the std
|
||||
// namespace and it works with gcc as needed.
|
||||
#if defined(CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX) || \
|
||||
defined(CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX)
|
||||
template <typename T>
|
||||
struct is_trivially_copyable {
|
||||
// TODO(danakj): Remove this when android builders are all using a newer version
|
||||
// of gcc, or the android ndk is updated to a newer libc++ that does this for
|
||||
// us.
|
||||
#if _GNUC_VER >= 501
|
||||
static constexpr bool value = __is_trivially_copyable(T);
|
||||
#else
|
||||
static constexpr bool value =
|
||||
__has_trivial_copy(T) && __has_trivial_destructor(T);
|
||||
#endif
|
||||
};
|
||||
#else
|
||||
template <class T>
|
||||
using is_trivially_copyable = std::is_trivially_copyable<T>;
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 7
|
||||
// Workaround for g++7 and earlier family.
|
||||
// Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80654, without this
|
||||
// Optional<std::vector<T>> where T is non-copyable causes a compile error.
|
||||
// As we know it is not trivially copy constructible, explicitly declare so.
|
||||
template <typename T>
|
||||
struct is_trivially_copy_constructible
|
||||
: std::is_trivially_copy_constructible<T> {};
|
||||
|
||||
template <typename... T>
|
||||
struct is_trivially_copy_constructible<std::vector<T...>> : std::false_type {};
|
||||
#else
|
||||
// Otherwise use std::is_trivially_copy_constructible as is.
|
||||
template <typename T>
|
||||
using is_trivially_copy_constructible = std::is_trivially_copy_constructible<T>;
|
||||
#endif
|
||||
|
||||
// base::in_place_t is an implementation of std::in_place_t from
|
||||
// C++17. A tag type used to request in-place construction in template vararg
|
||||
// constructors.
|
||||
|
||||
// Specification:
|
||||
// https://en.cppreference.com/w/cpp/utility/in_place
|
||||
struct in_place_t {};
|
||||
constexpr in_place_t in_place = {};
|
||||
|
||||
// base::in_place_type_t is an implementation of std::in_place_type_t from
|
||||
// C++17. A tag type used for in-place construction when the type to construct
|
||||
// needs to be specified, such as with base::unique_any, designed to be a
|
||||
// drop-in replacement.
|
||||
|
||||
// Specification:
|
||||
// http://en.cppreference.com/w/cpp/utility/in_place
|
||||
template <typename T>
|
||||
struct in_place_type_t {};
|
||||
|
||||
template <typename T>
|
||||
struct is_in_place_type_t {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
struct is_in_place_type_t<in_place_type_t<Ts...>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
// C++14 implementation of C++17's std::bool_constant.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/integral_constant
|
||||
// Specification: https://wg21.link/meta.type.synop
|
||||
template <bool B>
|
||||
using bool_constant = std::integral_constant<bool, B>;
|
||||
|
||||
// C++14 implementation of C++17's std::conjunction.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/conjunction
|
||||
// Specification: https://wg21.link/meta.logical#1.itemdecl:1
|
||||
template <typename...>
|
||||
struct conjunction : std::true_type {};
|
||||
|
||||
template <typename B1>
|
||||
struct conjunction<B1> : B1 {};
|
||||
|
||||
template <typename B1, typename... Bn>
|
||||
struct conjunction<B1, Bn...>
|
||||
: std::conditional_t<static_cast<bool>(B1::value), conjunction<Bn...>, B1> {
|
||||
};
|
||||
|
||||
// C++14 implementation of C++17's std::disjunction.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/disjunction
|
||||
// Specification: https://wg21.link/meta.logical#itemdecl:2
|
||||
template <typename...>
|
||||
struct disjunction : std::false_type {};
|
||||
|
||||
template <typename B1>
|
||||
struct disjunction<B1> : B1 {};
|
||||
|
||||
template <typename B1, typename... Bn>
|
||||
struct disjunction<B1, Bn...>
|
||||
: std::conditional_t<static_cast<bool>(B1::value), B1, disjunction<Bn...>> {
|
||||
};
|
||||
|
||||
// C++14 implementation of C++17's std::negation.
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/negation
|
||||
// Specification: https://wg21.link/meta.logical#itemdecl:3
|
||||
template <typename B>
|
||||
struct negation : bool_constant<!static_cast<bool>(B::value)> {};
|
||||
|
||||
// Implementation of C++17's invoke_result.
|
||||
//
|
||||
// This implementation adds references to `Functor` and `Args` to work around
|
||||
// some quirks of std::result_of. See the #Notes section of [1] for details.
|
||||
//
|
||||
// References:
|
||||
// [1] https://en.cppreference.com/w/cpp/types/result_of
|
||||
// [2] https://wg21.link/meta.trans.other#lib:invoke_result
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
template <typename Functor, typename... Args>
|
||||
using invoke_result = std::invoke_result<Functor, Args...>;
|
||||
#else
|
||||
template <typename Functor, typename... Args>
|
||||
using invoke_result = std::result_of<Functor && (Args && ...)>;
|
||||
#endif
|
||||
|
||||
// Implementation of C++17's std::invoke_result_t.
|
||||
//
|
||||
// Reference: https://wg21.link/meta.type.synop#lib:invoke_result_t
|
||||
template <typename Functor, typename... Args>
|
||||
using invoke_result_t = typename invoke_result<Functor, Args...>::type;
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Base case, `InvokeResult` does not have a nested type member. This means `F`
|
||||
// could not be invoked with `Args...` and thus is not invocable.
|
||||
template <typename InvokeResult, typename R, typename = void>
|
||||
struct IsInvocableImpl : std::false_type {};
|
||||
|
||||
// Happy case, `InvokeResult` does have a nested type member. Now check whether
|
||||
// `InvokeResult::type` is convertible to `R`. Short circuit in case
|
||||
// `std::is_void<R>`.
|
||||
template <typename InvokeResult, typename R>
|
||||
struct IsInvocableImpl<InvokeResult, R, void_t<typename InvokeResult::type>>
|
||||
: disjunction<std::is_void<R>,
|
||||
std::is_convertible<typename InvokeResult::type, R>> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Implementation of C++17's std::is_invocable_r.
|
||||
//
|
||||
// Returns whether `F` can be invoked with `Args...` and the result is
|
||||
// convertible to `R`.
|
||||
//
|
||||
// Reference: https://wg21.link/meta.rel#lib:is_invocable_r
|
||||
template <typename R, typename F, typename... Args>
|
||||
struct is_invocable_r
|
||||
: internal::IsInvocableImpl<invoke_result<F, Args...>, R> {};
|
||||
|
||||
// Implementation of C++17's std::is_invocable.
|
||||
//
|
||||
// Returns whether `F` can be invoked with `Args...`.
|
||||
//
|
||||
// Reference: https://wg21.link/meta.rel#lib:is_invocable
|
||||
template <typename F, typename... Args>
|
||||
struct is_invocable : is_invocable_r<void, F, Args...> {};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// The indirection with std::is_enum<T> is required, because instantiating
|
||||
// std::underlying_type_t<T> when T is not an enum is UB prior to C++20.
|
||||
template <typename T, bool = std::is_enum<T>::value>
|
||||
struct IsScopedEnumImpl : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsScopedEnumImpl<T, /*std::is_enum<T>::value=*/true>
|
||||
: negation<std::is_convertible<T, std::underlying_type_t<T>>> {};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Implementation of C++23's std::is_scoped_enum
|
||||
//
|
||||
// Reference: https://en.cppreference.com/w/cpp/types/is_scoped_enum
|
||||
template <typename T>
|
||||
struct is_scoped_enum : internal::IsScopedEnumImpl<T> {};
|
||||
|
||||
// Implementation of C++20's std::remove_cvref.
|
||||
//
|
||||
// References:
|
||||
// - https://en.cppreference.com/w/cpp/types/remove_cvref
|
||||
// - https://wg21.link/meta.trans.other#lib:remove_cvref
|
||||
template <typename T>
|
||||
struct remove_cvref {
|
||||
using type = std::remove_cv_t<std::remove_reference_t<T>>;
|
||||
};
|
||||
|
||||
// Implementation of C++20's std::remove_cvref_t.
|
||||
//
|
||||
// References:
|
||||
// - https://en.cppreference.com/w/cpp/types/remove_cvref
|
||||
// - https://wg21.link/meta.type.synop#lib:remove_cvref_t
|
||||
template <typename T>
|
||||
using remove_cvref_t = typename remove_cvref<T>::type;
|
||||
|
||||
// Simplified implementation of C++20's std::iter_value_t.
|
||||
// As opposed to std::iter_value_t, this implementation does not restrict
|
||||
// the type of `Iter` and does not consider specializations of
|
||||
// `indirectly_readable_traits`.
|
||||
//
|
||||
// Reference: https://wg21.link/readable.traits#2
|
||||
template <typename Iter>
|
||||
using iter_value_t =
|
||||
typename std::iterator_traits<remove_cvref_t<Iter>>::value_type;
|
||||
|
||||
// Simplified implementation of C++20's std::iter_reference_t.
|
||||
// As opposed to std::iter_reference_t, this implementation does not restrict
|
||||
// the type of `Iter`.
|
||||
//
|
||||
// Reference: https://wg21.link/iterator.synopsis#:~:text=iter_reference_t
|
||||
template <typename Iter>
|
||||
using iter_reference_t = decltype(*std::declval<Iter&>());
|
||||
|
||||
// Simplified implementation of C++20's std::indirect_result_t. As opposed to
|
||||
// std::indirect_result_t, this implementation does not restrict the type of
|
||||
// `Func` and `Iters`.
|
||||
//
|
||||
// Reference: https://wg21.link/iterator.synopsis#:~:text=indirect_result_t
|
||||
template <typename Func, typename... Iters>
|
||||
using indirect_result_t = invoke_result_t<Func, iter_reference_t<Iters>...>;
|
||||
|
||||
// Simplified implementation of C++20's std::projected. As opposed to
|
||||
// std::projected, this implementation does not explicitly restrict the type of
|
||||
// `Iter` and `Proj`, but rather does so implicitly by requiring
|
||||
// `indirect_result_t<Proj, Iter>` is a valid type. This is required for SFINAE
|
||||
// friendliness.
|
||||
//
|
||||
// Reference: https://wg21.link/projected
|
||||
template <typename Iter,
|
||||
typename Proj,
|
||||
typename IndirectResultT = indirect_result_t<Proj, Iter>>
|
||||
struct projected {
|
||||
using value_type = remove_cvref_t<IndirectResultT>;
|
||||
|
||||
IndirectResultT operator*() const; // not defined
|
||||
};
|
||||
|
||||
} // namespace base
|
||||
|
||||
#undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
|
||||
#undef CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
116
Thirdparty/libcef/include/base/cef_thread_checker.h
vendored
Normal file
116
Thirdparty/libcef/include/base/cef_thread_checker.h
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
// 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_THREAD_CHECKER_H_
|
||||
#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/threading/thread_checker.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/base/cef_logging.h"
|
||||
#include "include/base/internal/cef_thread_checker_impl.h"
|
||||
|
||||
// Apart from debug builds, we also enable the thread checker in
|
||||
// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
|
||||
// with this define will get the same level of thread checking as
|
||||
// debug bots.
|
||||
#if DCHECK_IS_ON()
|
||||
#define ENABLE_THREAD_CHECKER 1
|
||||
#else
|
||||
#define ENABLE_THREAD_CHECKER 0
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
namespace cef_internal {
|
||||
|
||||
// Do nothing implementation, for use in release mode.
|
||||
//
|
||||
// Note: You should almost always use the ThreadChecker class to get the
|
||||
// right version for your build configuration.
|
||||
class ThreadCheckerDoNothing {
|
||||
public:
|
||||
bool CalledOnValidThread() const { return true; }
|
||||
|
||||
void DetachFromThread() {}
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
|
||||
// ThreadChecker is a helper class used to help verify that some methods of a
|
||||
// class are called from the same thread. It provides identical functionality to
|
||||
// base::NonThreadSafe, but it is meant to be held as a member variable, rather
|
||||
// than inherited from base::NonThreadSafe.
|
||||
//
|
||||
// While inheriting from base::NonThreadSafe may give a clear indication about
|
||||
// the thread-safety of a class, it may also lead to violations of the style
|
||||
// guide with regard to multiple inheritance. The choice between having a
|
||||
// ThreadChecker member and inheriting from base::NonThreadSafe should be based
|
||||
// on whether:
|
||||
// - Derived classes need to know the thread they belong to, as opposed to
|
||||
// having that functionality fully encapsulated in the base class.
|
||||
// - Derived classes should be able to reassign the base class to another
|
||||
// thread, via DetachFromThread.
|
||||
//
|
||||
// If neither of these are true, then having a ThreadChecker member and calling
|
||||
// CalledOnValidThread is the preferable solution.
|
||||
//
|
||||
// Example:
|
||||
// class MyClass {
|
||||
// public:
|
||||
// void Foo() {
|
||||
// DCHECK(thread_checker_.CalledOnValidThread());
|
||||
// ... (do stuff) ...
|
||||
// }
|
||||
//
|
||||
// private:
|
||||
// ThreadChecker thread_checker_;
|
||||
// }
|
||||
//
|
||||
// In Release mode, CalledOnValidThread will always return true.
|
||||
#if ENABLE_THREAD_CHECKER
|
||||
class ThreadChecker : public cef_internal::ThreadCheckerImpl {};
|
||||
#else
|
||||
class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {};
|
||||
#endif // ENABLE_THREAD_CHECKER
|
||||
|
||||
#undef ENABLE_THREAD_CHECKER
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
415
Thirdparty/libcef/include/base/cef_trace_event.h
vendored
Normal file
415
Thirdparty/libcef/include/base/cef_trace_event.h
vendored
Normal file
@ -0,0 +1,415 @@
|
||||
// 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.
|
||||
|
||||
///
|
||||
// Trace events are for tracking application performance and resource usage.
|
||||
// Macros are provided to track:
|
||||
// Begin and end of function calls
|
||||
// Counters
|
||||
//
|
||||
// Events are issued against categories. Whereas LOG's categories are statically
|
||||
// defined, TRACE categories are created implicitly with a string. For example:
|
||||
// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
|
||||
//
|
||||
// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
|
||||
// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
|
||||
// doSomethingCostly()
|
||||
// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
|
||||
// Note: Our tools can't always determine the correct BEGIN/END pairs unless
|
||||
// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
|
||||
// need them to be in separate scopes.
|
||||
//
|
||||
// A common use case is to trace entire function scopes. This issues a trace
|
||||
// BEGIN and END automatically:
|
||||
// void doSomethingCostly() {
|
||||
// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// Additional parameters can be associated with an event:
|
||||
// void doSomethingCostly2(int howMuch) {
|
||||
// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
|
||||
// "howMuch", howMuch);
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// The trace system will automatically add to this information the current
|
||||
// process id, thread id, and a timestamp in microseconds.
|
||||
//
|
||||
// To trace an asynchronous procedure such as an IPC send/receive, use
|
||||
// ASYNC_BEGIN and ASYNC_END:
|
||||
// [single threaded sender code]
|
||||
// static int send_count = 0;
|
||||
// ++send_count;
|
||||
// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
|
||||
// Send(new MyMessage(send_count));
|
||||
// [receive code]
|
||||
// void OnMyMessage(send_count) {
|
||||
// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
|
||||
// }
|
||||
// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
|
||||
// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
|
||||
// Pointers can be used for the ID parameter, and they will be mangled
|
||||
// internally so that the same pointer on two different processes will not
|
||||
// match. For example:
|
||||
// class MyTracedClass {
|
||||
// public:
|
||||
// MyTracedClass() {
|
||||
// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
|
||||
// }
|
||||
// ~MyTracedClass() {
|
||||
// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The trace event also supports counters, which is a way to track a quantity
|
||||
// as it varies over time. Counters are created with the following macro:
|
||||
// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
|
||||
//
|
||||
// Counters are process-specific. The macro itself can be issued from any
|
||||
// thread, however.
|
||||
//
|
||||
// Sometimes, you want to track two counters at once. You can do this with two
|
||||
// counter macros:
|
||||
// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
|
||||
// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
|
||||
// Or you can do it with a combined macro:
|
||||
// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
|
||||
// "bytesPinned", g_myCounterValue[0],
|
||||
// "bytesAllocated", g_myCounterValue[1]);
|
||||
// This indicates to the tracing UI that these counters should be displayed
|
||||
// in a single graph, as a summed area chart.
|
||||
//
|
||||
// Since counters are in a global namespace, you may want to disembiguate with a
|
||||
// unique ID, by using the TRACE_COUNTER_ID* variations.
|
||||
//
|
||||
// By default, trace collection is compiled in, but turned off at runtime.
|
||||
// Collecting trace data is the responsibility of the embedding application. In
|
||||
// CEF's case, calling BeginTracing will turn on tracing on all active
|
||||
// processes.
|
||||
//
|
||||
//
|
||||
// Memory scoping note:
|
||||
// Tracing copies the pointers, not the string content, of the strings passed
|
||||
// in for category, name, and arg_names. Thus, the following code will cause
|
||||
// problems:
|
||||
// char* str = strdup("impprtantName");
|
||||
// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD!
|
||||
// free(str); // Trace system now has dangling pointer
|
||||
//
|
||||
// To avoid this issue with the |name| and |arg_name| parameters, use the
|
||||
// TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime
|
||||
// overhead.
|
||||
// Notes: The category must always be in a long-lived char* (i.e. static const).
|
||||
// The |arg_values|, when used, are always deep copied with the _COPY
|
||||
// macros.
|
||||
//
|
||||
//
|
||||
// Thread Safety:
|
||||
// All macros are thread safe and can be used from any process.
|
||||
///
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/trace_event/trace_event.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/internal/cef_trace_event_internal.h"
|
||||
|
||||
// Records a pair of begin and end events called "name" for the current
|
||||
// scope, with 0, 1 or 2 associated arguments. If the category is not
|
||||
// enabled, then this does nothing.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
#define TRACE_EVENT0(category, name) \
|
||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \
|
||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \
|
||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false); \
|
||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||
|
||||
// Implementation detail: trace event macros create temporary variable names.
|
||||
// These macros give each temporary variable a unique name based on the line
|
||||
// number to prevent name collisions.
|
||||
#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b
|
||||
#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) CEF_INTERNAL_TRACE_EVENT_UID3(a, b)
|
||||
#define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \
|
||||
CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
|
||||
|
||||
// Implementation detail: internal macro to end end event when the scope ends.
|
||||
#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \
|
||||
cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \
|
||||
profileScope)(category, name)
|
||||
|
||||
// Records a single event called "name" immediately, with 0, 1 or 2
|
||||
// associated arguments. If the category is not enabled, then this
|
||||
// does nothing.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
#define TRACE_EVENT_INSTANT0(category, name) \
|
||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false)
|
||||
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_INSTANT0(category, name) \
|
||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, true)
|
||||
|
||||
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
|
||||
// associated arguments. If the category is not enabled, then this
|
||||
// does nothing.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
#define TRACE_EVENT_BEGIN0(category, name) \
|
||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false)
|
||||
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_BEGIN0(category, name) \
|
||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, true)
|
||||
|
||||
// Records a single END event for "name" immediately. If the category
|
||||
// is not enabled, then this does nothing.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
#define TRACE_EVENT_END0(category, name) \
|
||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false)
|
||||
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_END0(category, name) \
|
||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val) \
|
||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
||||
arg2_val, true)
|
||||
|
||||
// Records the value of a counter called "name" immediately. Value
|
||||
// must be representable as a 32 bit integer.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
#define TRACE_COUNTER1(category, name, value) \
|
||||
cef_trace_counter(category, name, NULL, value, NULL, 0, false)
|
||||
#define TRACE_COPY_COUNTER1(category, name, value) \
|
||||
cef_trace_counter(category, name, NULL, value, NULL, 0, true)
|
||||
|
||||
// Records the values of a multi-parted counter called "name" immediately.
|
||||
// The UI will treat value1 and value2 as parts of a whole, displaying their
|
||||
// values as a stacked-bar chart.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
|
||||
value2_val) \
|
||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
||||
value2_val, false)
|
||||
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
|
||||
value2_name, value2_val) \
|
||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
||||
value2_val, true)
|
||||
|
||||
// Records the value of a counter called "name" immediately. Value
|
||||
// must be representable as a 32 bit integer.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
// - |id| is used to disambiguate counters with the same name. It must either
|
||||
// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
||||
// bits will be xored with a hash of the process ID so that the same pointer
|
||||
// on two different processes will not collide.
|
||||
#define TRACE_COUNTER_ID1(category, name, id, value) \
|
||||
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false)
|
||||
#define TRACE_COPY_COUNTER_ID1(category, name, id, value) \
|
||||
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true)
|
||||
|
||||
// Records the values of a multi-parted counter called "name" immediately.
|
||||
// The UI will treat value1 and value2 as parts of a whole, displaying their
|
||||
// values as a stacked-bar chart.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
// - |id| is used to disambiguate counters with the same name. It must either
|
||||
// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
||||
// bits will be xored with a hash of the process ID so that the same pointer
|
||||
// on two different processes will not collide.
|
||||
#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val) \
|
||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val, false)
|
||||
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val) \
|
||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||
value2_name, value2_val, true)
|
||||
|
||||
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
|
||||
// associated arguments. If the category is not enabled, then this
|
||||
// does nothing.
|
||||
// - category and name strings must have application lifetime (statics or
|
||||
// literals). They may not include " chars.
|
||||
// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event.
|
||||
// ASYNC events are considered to match if their category, name and id values
|
||||
// all match. |id| must either be a pointer or an integer value up to 64
|
||||
// bits. If it's a pointer, the bits will be xored with a hash of the process
|
||||
// ID sothat the same pointer on two different processes will not collide.
|
||||
// An asynchronous operation can consist of multiple phases. The first phase is
|
||||
// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
|
||||
// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END.
|
||||
// An async operation can span threads and processes, but all events in that
|
||||
// operation must use the same |name| and |id|. Each event can have its own
|
||||
// args.
|
||||
#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
|
||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
||||
0, false)
|
||||
#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \
|
||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
||||
0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, true)
|
||||
|
||||
// Records a single ASYNC_STEP_INTO event for |step| immediately. If the
|
||||
// category is not enabled, then this does nothing. The |name| and |id| must
|
||||
// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
||||
// within the async event. This should be called at the beginning of the next
|
||||
// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
||||
// ASYNC_STEP_PAST events.
|
||||
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
||||
arg1_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
||||
arg1_val, true)
|
||||
|
||||
// Records a single ASYNC_STEP_PAST event for |step| immediately. If the
|
||||
// category is not enabled, then this does nothing. The |name| and |id| must
|
||||
// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
||||
// within the async event. This should be called at the beginning of the next
|
||||
// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
||||
// ASYNC_STEP_INTO events.
|
||||
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
||||
arg1_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
||||
arg1_val) \
|
||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
||||
arg1_val, true)
|
||||
|
||||
// Records a single ASYNC_END event for "name" immediately. If the category
|
||||
// is not enabled, then this does nothing.
|
||||
#define TRACE_EVENT_ASYNC_END0(category, name, id) \
|
||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false)
|
||||
#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
||||
false)
|
||||
#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, false)
|
||||
#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \
|
||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
||||
true)
|
||||
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val) \
|
||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
||||
arg2_name, arg2_val, true)
|
||||
|
||||
namespace cef_trace_event {
|
||||
|
||||
// Used by TRACE_EVENTx macro. Do not use directly.
|
||||
class CefTraceEndOnScopeClose {
|
||||
public:
|
||||
CefTraceEndOnScopeClose(const char* category, const char* name)
|
||||
: category_(category), name_(name) {}
|
||||
~CefTraceEndOnScopeClose() {
|
||||
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false);
|
||||
}
|
||||
|
||||
private:
|
||||
const char* category_;
|
||||
const char* name_;
|
||||
};
|
||||
|
||||
} // cef_trace_event
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
149
Thirdparty/libcef/include/base/cef_tuple.h
vendored
Normal file
149
Thirdparty/libcef/include/base/cef_tuple.h
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
// 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.
|
||||
|
||||
// Use std::tuple as tuple type. This file contains helper functions for
|
||||
// working with std::tuples.
|
||||
// The functions DispatchToMethod and DispatchToFunction take a function pointer
|
||||
// or instance and method pointer, and unpack a tuple into arguments to the
|
||||
// call.
|
||||
//
|
||||
// Example usage:
|
||||
// // These two methods of creating a Tuple are identical.
|
||||
// std::tuple<int, const char*> tuple_a(1, "wee");
|
||||
// std::tuple<int, const char*> tuple_b = std::make_tuple(1, "wee");
|
||||
//
|
||||
// void SomeFunc(int a, const char* b) { }
|
||||
// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee")
|
||||
// DispatchToFunction(
|
||||
// &SomeFunc, std::make_tuple(10, "foo")); // SomeFunc(10, "foo")
|
||||
//
|
||||
// struct { void SomeMeth(int a, int b, int c) { } } foo;
|
||||
// DispatchToMethod(&foo, &Foo::SomeMeth, std::make_tuple(1, 2, 3));
|
||||
// // foo->SomeMeth(1, 2, 3);
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_TUPLE_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_TUPLE_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/tuple.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 <stddef.h>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
// Dispatchers ----------------------------------------------------------------
|
||||
//
|
||||
// Helper functions that call the given method on an object, with the unpacked
|
||||
// tuple arguments. Notice that they all have the same number of arguments,
|
||||
// so you need only write:
|
||||
// DispatchToMethod(object, &Object::method, args);
|
||||
// This is very useful for templated dispatchers, since they don't need to know
|
||||
// what type |args| is.
|
||||
|
||||
// Non-Static Dispatchers with no out params.
|
||||
|
||||
template <typename ObjT, typename Method, typename Tuple, size_t... Ns>
|
||||
inline void DispatchToMethodImpl(const ObjT& obj,
|
||||
Method method,
|
||||
Tuple&& args,
|
||||
std::index_sequence<Ns...>) {
|
||||
(obj->*method)(std::get<Ns>(std::forward<Tuple>(args))...);
|
||||
}
|
||||
|
||||
template <typename ObjT, typename Method, typename Tuple>
|
||||
inline void DispatchToMethod(const ObjT& obj,
|
||||
Method method,
|
||||
Tuple&& args) {
|
||||
constexpr size_t size = std::tuple_size<std::decay_t<Tuple>>::value;
|
||||
DispatchToMethodImpl(obj, method, std::forward<Tuple>(args),
|
||||
std::make_index_sequence<size>());
|
||||
}
|
||||
|
||||
// Static Dispatchers with no out params.
|
||||
|
||||
template <typename Function, typename Tuple, size_t... Ns>
|
||||
inline void DispatchToFunctionImpl(Function function,
|
||||
Tuple&& args,
|
||||
std::index_sequence<Ns...>) {
|
||||
(*function)(std::get<Ns>(std::forward<Tuple>(args))...);
|
||||
}
|
||||
|
||||
template <typename Function, typename Tuple>
|
||||
inline void DispatchToFunction(Function function, Tuple&& args) {
|
||||
constexpr size_t size = std::tuple_size<std::decay_t<Tuple>>::value;
|
||||
DispatchToFunctionImpl(function, std::forward<Tuple>(args),
|
||||
std::make_index_sequence<size>());
|
||||
}
|
||||
|
||||
// Dispatchers with out parameters.
|
||||
|
||||
template <typename ObjT,
|
||||
typename Method,
|
||||
typename InTuple,
|
||||
typename OutTuple,
|
||||
size_t... InNs,
|
||||
size_t... OutNs>
|
||||
inline void DispatchToMethodImpl(const ObjT& obj,
|
||||
Method method,
|
||||
InTuple&& in,
|
||||
OutTuple* out,
|
||||
std::index_sequence<InNs...>,
|
||||
std::index_sequence<OutNs...>) {
|
||||
(obj->*method)(std::get<InNs>(std::forward<InTuple>(in))...,
|
||||
&std::get<OutNs>(*out)...);
|
||||
}
|
||||
|
||||
template <typename ObjT, typename Method, typename InTuple, typename OutTuple>
|
||||
inline void DispatchToMethod(const ObjT& obj,
|
||||
Method method,
|
||||
InTuple&& in,
|
||||
OutTuple* out) {
|
||||
constexpr size_t in_size = std::tuple_size<std::decay_t<InTuple>>::value;
|
||||
constexpr size_t out_size = std::tuple_size<OutTuple>::value;
|
||||
DispatchToMethodImpl(obj, method, std::forward<InTuple>(in), out,
|
||||
std::make_index_sequence<in_size>(),
|
||||
std::make_index_sequence<out_size>());
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_TUPLE_H_
|
438
Thirdparty/libcef/include/base/cef_weak_ptr.h
vendored
Normal file
438
Thirdparty/libcef/include/base/cef_weak_ptr.h
vendored
Normal file
@ -0,0 +1,438 @@
|
||||
// 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.
|
||||
|
||||
// Weak pointers are pointers to an object that do not affect its lifetime,
|
||||
// and which may be invalidated (i.e. reset to nullptr) by the object, or its
|
||||
// owner, at any time, most commonly when the object is about to be deleted.
|
||||
|
||||
// Weak pointers are useful when an object needs to be accessed safely by one
|
||||
// or more objects other than its owner, and those callers can cope with the
|
||||
// object vanishing and e.g. tasks posted to it being silently dropped.
|
||||
// Reference-counting such an object would complicate the ownership graph and
|
||||
// make it harder to reason about the object's lifetime.
|
||||
|
||||
// EXAMPLE:
|
||||
//
|
||||
// class Controller {
|
||||
// public:
|
||||
// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
|
||||
// void WorkComplete(const Result& result) { ... }
|
||||
// private:
|
||||
// // Member variables should appear before the WeakPtrFactory, to ensure
|
||||
// // that any WeakPtrs to Controller are invalidated before its members
|
||||
// // variable's destructors are executed, rendering them invalid.
|
||||
// WeakPtrFactory<Controller> weak_factory_{this};
|
||||
// };
|
||||
//
|
||||
// class Worker {
|
||||
// public:
|
||||
// static void StartNew(WeakPtr<Controller> controller) {
|
||||
// Worker* worker = new Worker(std::move(controller));
|
||||
// // Kick off asynchronous processing...
|
||||
// }
|
||||
// private:
|
||||
// Worker(WeakPtr<Controller> controller)
|
||||
// : controller_(std::move(controller)) {}
|
||||
// void DidCompleteAsynchronousProcessing(const Result& result) {
|
||||
// if (controller_)
|
||||
// controller_->WorkComplete(result);
|
||||
// }
|
||||
// WeakPtr<Controller> controller_;
|
||||
// };
|
||||
//
|
||||
// With this implementation a caller may use SpawnWorker() to dispatch multiple
|
||||
// Workers and subsequently delete the Controller, without waiting for all
|
||||
// Workers to have completed.
|
||||
|
||||
// ------------------------- IMPORTANT: Thread-safety -------------------------
|
||||
|
||||
// Weak pointers may be passed safely between threads, but must always be
|
||||
// dereferenced and invalidated on the same ThreaddTaskRunner otherwise
|
||||
// checking the pointer would be racey.
|
||||
//
|
||||
// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory
|
||||
// is dereferenced, the factory and its WeakPtrs become bound to the calling
|
||||
// thread or current ThreaddWorkerPool token, and cannot be dereferenced or
|
||||
// invalidated on any other task runner. Bound WeakPtrs can still be handed
|
||||
// off to other task runners, e.g. to use to post tasks back to object on the
|
||||
// bound thread.
|
||||
//
|
||||
// If all WeakPtr objects are destroyed or invalidated then the factory is
|
||||
// unbound from the ThreaddTaskRunner/Thread. The WeakPtrFactory may then be
|
||||
// destroyed, or new WeakPtr objects may be used, from a different thread.
|
||||
//
|
||||
// Thus, at least one WeakPtr object must exist and have been dereferenced on
|
||||
// the correct thread to enforce that other WeakPtr objects will enforce they
|
||||
// are used on the desired thread.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/memory/weak_ptr.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 <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include "include/base/cef_atomic_flag.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_ref_counted.h"
|
||||
#include "include/base/cef_thread_checker.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
template <typename T>
|
||||
class SupportsWeakPtr;
|
||||
template <typename T>
|
||||
class WeakPtr;
|
||||
|
||||
namespace internal {
|
||||
// These classes are part of the WeakPtr implementation.
|
||||
// DO NOT USE THESE CLASSES DIRECTLY YOURSELF.
|
||||
|
||||
class WeakReference {
|
||||
public:
|
||||
// Although Flag is bound to a specific ThreaddTaskRunner, it may be
|
||||
// deleted from another via base::WeakPtr::~WeakPtr().
|
||||
class Flag : public RefCountedThreadSafe<Flag> {
|
||||
public:
|
||||
Flag();
|
||||
|
||||
void Invalidate();
|
||||
bool IsValid() const;
|
||||
|
||||
bool MaybeValid() const;
|
||||
|
||||
void DetachFromThread();
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<Flag>;
|
||||
|
||||
~Flag();
|
||||
|
||||
base::ThreadChecker thread_checker_;
|
||||
AtomicFlag invalidated_;
|
||||
};
|
||||
|
||||
WeakReference();
|
||||
explicit WeakReference(const scoped_refptr<Flag>& flag);
|
||||
~WeakReference();
|
||||
|
||||
WeakReference(WeakReference&& other) noexcept;
|
||||
WeakReference(const WeakReference& other);
|
||||
WeakReference& operator=(WeakReference&& other) noexcept = default;
|
||||
WeakReference& operator=(const WeakReference& other) = default;
|
||||
|
||||
bool IsValid() const;
|
||||
bool MaybeValid() const;
|
||||
|
||||
private:
|
||||
scoped_refptr<const Flag> flag_;
|
||||
};
|
||||
|
||||
class WeakReferenceOwner {
|
||||
public:
|
||||
WeakReferenceOwner();
|
||||
~WeakReferenceOwner();
|
||||
|
||||
WeakReference GetRef() const;
|
||||
|
||||
bool HasRefs() const { return !flag_->HasOneRef(); }
|
||||
|
||||
void Invalidate();
|
||||
|
||||
private:
|
||||
scoped_refptr<WeakReference::Flag> flag_;
|
||||
};
|
||||
|
||||
// This class simplifies the implementation of WeakPtr's type conversion
|
||||
// constructor by avoiding the need for a public accessor for ref_. A
|
||||
// WeakPtr<T> cannot access the private members of WeakPtr<U>, so this
|
||||
// base class gives us a way to access ref_ in a protected fashion.
|
||||
class WeakPtrBase {
|
||||
public:
|
||||
WeakPtrBase();
|
||||
~WeakPtrBase();
|
||||
|
||||
WeakPtrBase(const WeakPtrBase& other) = default;
|
||||
WeakPtrBase(WeakPtrBase&& other) noexcept = default;
|
||||
WeakPtrBase& operator=(const WeakPtrBase& other) = default;
|
||||
WeakPtrBase& operator=(WeakPtrBase&& other) noexcept = default;
|
||||
|
||||
void reset() {
|
||||
ref_ = internal::WeakReference();
|
||||
ptr_ = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
WeakPtrBase(const WeakReference& ref, uintptr_t ptr);
|
||||
|
||||
WeakReference ref_;
|
||||
|
||||
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
|
||||
// value is undefined (as opposed to nullptr).
|
||||
uintptr_t ptr_;
|
||||
};
|
||||
|
||||
// This class provides a common implementation of common functions that would
|
||||
// otherwise get instantiated separately for each distinct instantiation of
|
||||
// SupportsWeakPtr<>.
|
||||
class SupportsWeakPtrBase {
|
||||
public:
|
||||
// A safe static downcast of a WeakPtr<Base> to WeakPtr<Derived>. This
|
||||
// conversion will only compile if there is exists a Base which inherits
|
||||
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
|
||||
// function that makes calling this easier.
|
||||
//
|
||||
// Precondition: t != nullptr
|
||||
template <typename Derived>
|
||||
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
|
||||
static_assert(
|
||||
std::is_base_of<internal::SupportsWeakPtrBase, Derived>::value,
|
||||
"AsWeakPtr argument must inherit from SupportsWeakPtr");
|
||||
return AsWeakPtrImpl<Derived>(t);
|
||||
}
|
||||
|
||||
private:
|
||||
// This template function uses type inference to find a Base of Derived
|
||||
// which is an instance of SupportsWeakPtr<Base>. We can then safely
|
||||
// static_cast the Base* to a Derived*.
|
||||
template <typename Derived, typename Base>
|
||||
static WeakPtr<Derived> AsWeakPtrImpl(SupportsWeakPtr<Base>* t) {
|
||||
WeakPtr<Base> ptr = t->AsWeakPtr();
|
||||
return WeakPtr<Derived>(
|
||||
ptr.ref_, static_cast<Derived*>(reinterpret_cast<Base*>(ptr.ptr_)));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename T>
|
||||
class WeakPtrFactory;
|
||||
|
||||
// The WeakPtr class holds a weak reference to |T*|.
|
||||
//
|
||||
// This class is designed to be used like a normal pointer. You should always
|
||||
// null-test an object of this class before using it or invoking a method that
|
||||
// may result in the underlying object being destroyed.
|
||||
//
|
||||
// EXAMPLE:
|
||||
//
|
||||
// class Foo { ... };
|
||||
// WeakPtr<Foo> foo;
|
||||
// if (foo)
|
||||
// foo->method();
|
||||
//
|
||||
template <typename T>
|
||||
class WeakPtr : public internal::WeakPtrBase {
|
||||
public:
|
||||
WeakPtr() = default;
|
||||
WeakPtr(std::nullptr_t) {}
|
||||
|
||||
// Allow conversion from U to T provided U "is a" T. Note that this
|
||||
// is separate from the (implicit) copy and move constructors.
|
||||
template <typename U>
|
||||
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other) {
|
||||
// Need to cast from U* to T* to do pointer adjustment in case of multiple
|
||||
// inheritance. This also enforces the "U is a T" rule.
|
||||
T* t = reinterpret_cast<U*>(other.ptr_);
|
||||
ptr_ = reinterpret_cast<uintptr_t>(t);
|
||||
}
|
||||
template <typename U>
|
||||
WeakPtr(WeakPtr<U>&& other) noexcept : WeakPtrBase(std::move(other)) {
|
||||
// Need to cast from U* to T* to do pointer adjustment in case of multiple
|
||||
// inheritance. This also enforces the "U is a T" rule.
|
||||
T* t = reinterpret_cast<U*>(other.ptr_);
|
||||
ptr_ = reinterpret_cast<uintptr_t>(t);
|
||||
}
|
||||
|
||||
T* get() const {
|
||||
return ref_.IsValid() ? reinterpret_cast<T*>(ptr_) : nullptr;
|
||||
}
|
||||
|
||||
T& operator*() const {
|
||||
CHECK(ref_.IsValid());
|
||||
return *get();
|
||||
}
|
||||
T* operator->() const {
|
||||
CHECK(ref_.IsValid());
|
||||
return get();
|
||||
}
|
||||
|
||||
// Allow conditionals to test validity, e.g. if (weak_ptr) {...};
|
||||
explicit operator bool() const { return get() != nullptr; }
|
||||
|
||||
// Returns false if the WeakPtr is confirmed to be invalid. This call is safe
|
||||
// to make from any thread, e.g. to optimize away unnecessary work, but
|
||||
// operator bool() must always be called, on the correct thread, before
|
||||
// actually using the pointer.
|
||||
//
|
||||
// Warning: as with any object, this call is only thread-safe if the WeakPtr
|
||||
// instance isn't being re-assigned or reset() racily with this call.
|
||||
bool MaybeValid() const { return ref_.MaybeValid(); }
|
||||
|
||||
// Returns whether the object |this| points to has been invalidated. This can
|
||||
// be used to distinguish a WeakPtr to a destroyed object from one that has
|
||||
// been explicitly set to null.
|
||||
bool WasInvalidated() const { return ptr_ && !ref_.IsValid(); }
|
||||
|
||||
private:
|
||||
friend class internal::SupportsWeakPtrBase;
|
||||
template <typename U>
|
||||
friend class WeakPtr;
|
||||
friend class SupportsWeakPtr<T>;
|
||||
friend class WeakPtrFactory<T>;
|
||||
|
||||
WeakPtr(const internal::WeakReference& ref, T* ptr)
|
||||
: WeakPtrBase(ref, reinterpret_cast<uintptr_t>(ptr)) {}
|
||||
};
|
||||
|
||||
// Allow callers to compare WeakPtrs against nullptr to test validity.
|
||||
template <class T>
|
||||
bool operator!=(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
||||
return !(weak_ptr == nullptr);
|
||||
}
|
||||
template <class T>
|
||||
bool operator!=(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
|
||||
return weak_ptr != nullptr;
|
||||
}
|
||||
template <class T>
|
||||
bool operator==(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
||||
return weak_ptr.get() == nullptr;
|
||||
}
|
||||
template <class T>
|
||||
bool operator==(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
|
||||
return weak_ptr == nullptr;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
class WeakPtrFactoryBase {
|
||||
protected:
|
||||
WeakPtrFactoryBase(uintptr_t ptr);
|
||||
~WeakPtrFactoryBase();
|
||||
internal::WeakReferenceOwner weak_reference_owner_;
|
||||
uintptr_t ptr_;
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
// A class may be composed of a WeakPtrFactory and thereby
|
||||
// control how it exposes weak pointers to itself. This is helpful if you only
|
||||
// need weak pointers within the implementation of a class. This class is also
|
||||
// useful when working with primitive types. For example, you could have a
|
||||
// WeakPtrFactory<bool> that is used to pass around a weak reference to a bool.
|
||||
template <class T>
|
||||
class WeakPtrFactory : public internal::WeakPtrFactoryBase {
|
||||
public:
|
||||
WeakPtrFactory() = delete;
|
||||
|
||||
explicit WeakPtrFactory(T* ptr)
|
||||
: WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}
|
||||
|
||||
WeakPtrFactory(const WeakPtrFactory&) = delete;
|
||||
WeakPtrFactory& operator=(const WeakPtrFactory&) = delete;
|
||||
|
||||
~WeakPtrFactory() = default;
|
||||
|
||||
WeakPtr<T> GetWeakPtr() const {
|
||||
return WeakPtr<T>(weak_reference_owner_.GetRef(),
|
||||
reinterpret_cast<T*>(ptr_));
|
||||
}
|
||||
|
||||
// Call this method to invalidate all existing weak pointers.
|
||||
void InvalidateWeakPtrs() {
|
||||
DCHECK(ptr_);
|
||||
weak_reference_owner_.Invalidate();
|
||||
}
|
||||
|
||||
// Call this method to determine if any weak pointers exist.
|
||||
bool HasWeakPtrs() const {
|
||||
DCHECK(ptr_);
|
||||
return weak_reference_owner_.HasRefs();
|
||||
}
|
||||
};
|
||||
|
||||
// A class may extend from SupportsWeakPtr to let others take weak pointers to
|
||||
// it. This avoids the class itself implementing boilerplate to dispense weak
|
||||
// pointers. However, since SupportsWeakPtr's destructor won't invalidate
|
||||
// weak pointers to the class until after the derived class' members have been
|
||||
// destroyed, its use can lead to subtle use-after-destroy issues.
|
||||
template <class T>
|
||||
class SupportsWeakPtr : public internal::SupportsWeakPtrBase {
|
||||
public:
|
||||
SupportsWeakPtr() = default;
|
||||
|
||||
SupportsWeakPtr(const SupportsWeakPtr&) = delete;
|
||||
SupportsWeakPtr& operator=(const SupportsWeakPtr&) = delete;
|
||||
|
||||
WeakPtr<T> AsWeakPtr() {
|
||||
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
|
||||
}
|
||||
|
||||
protected:
|
||||
~SupportsWeakPtr() = default;
|
||||
|
||||
private:
|
||||
internal::WeakReferenceOwner weak_reference_owner_;
|
||||
};
|
||||
|
||||
// Helper function that uses type deduction to safely return a WeakPtr<Derived>
|
||||
// when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it
|
||||
// extends a Base that extends SupportsWeakPtr<Base>.
|
||||
//
|
||||
// EXAMPLE:
|
||||
// class Base : public base::SupportsWeakPtr<Producer> {};
|
||||
// class Derived : public Base {};
|
||||
//
|
||||
// Derived derived;
|
||||
// base::WeakPtr<Derived> ptr = base::AsWeakPtr(&derived);
|
||||
//
|
||||
// Note that the following doesn't work (invalid type conversion) since
|
||||
// Derived::AsWeakPtr() is WeakPtr<Base> SupportsWeakPtr<Base>::AsWeakPtr(),
|
||||
// and there's no way to safely cast WeakPtr<Base> to WeakPtr<Derived> at
|
||||
// the caller.
|
||||
//
|
||||
// base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails.
|
||||
|
||||
template <typename Derived>
|
||||
WeakPtr<Derived> AsWeakPtr(Derived* t) {
|
||||
return internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
6
Thirdparty/libcef/include/base/internal/README-TRANSFER.txt
vendored
Normal file
6
Thirdparty/libcef/include/base/internal/README-TRANSFER.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
Files in this directory have been copied from other locations in the Chromium
|
||||
source tree. They have been modified only to the extent necessary to work in
|
||||
the CEF Binary Distribution directory structure. Below is a listing of the
|
||||
original file locations.
|
||||
|
||||
../net/base/net_error_list.h
|
1408
Thirdparty/libcef/include/base/internal/cef_bind_internal.h
vendored
Normal file
1408
Thirdparty/libcef/include/base/internal/cef_bind_internal.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
275
Thirdparty/libcef/include/base/internal/cef_callback_internal.h
vendored
Normal file
275
Thirdparty/libcef/include/base/internal/cef_callback_internal.h
vendored
Normal file
@ -0,0 +1,275 @@
|
||||
// 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.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_bind.h or
|
||||
// base/cef_callback.h instead.
|
||||
|
||||
// This file contains utility functions and classes that help the
|
||||
// implementation, and management of the Callback objects.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||
|
||||
#include "include/base/cef_callback_forward.h"
|
||||
#include "include/base/cef_ref_counted.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
struct FakeBindState;
|
||||
|
||||
namespace internal {
|
||||
|
||||
class BindStateBase;
|
||||
class FinallyExecutorCommon;
|
||||
class ThenAndCatchExecutorCommon;
|
||||
|
||||
template <typename ReturnType>
|
||||
class PostTaskExecutor;
|
||||
|
||||
template <typename Functor, typename... BoundArgs>
|
||||
struct BindState;
|
||||
|
||||
class CallbackBase;
|
||||
class CallbackBaseCopyable;
|
||||
|
||||
struct BindStateBaseRefCountTraits {
|
||||
static void Destruct(const BindStateBase*);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using PassingType = std::conditional_t<std::is_scalar<T>::value, T, T&&>;
|
||||
|
||||
// BindStateBase is used to provide an opaque handle that the Callback
|
||||
// class can use to represent a function object with bound arguments. It
|
||||
// behaves as an existential type that is used by a corresponding
|
||||
// DoInvoke function to perform the function execution. This allows
|
||||
// us to shield the Callback class from the types of the bound argument via
|
||||
// "type erasure."
|
||||
// At the base level, the only task is to add reference counting data. Avoid
|
||||
// using or inheriting any virtual functions. Creating a vtable for every
|
||||
// BindState template instantiation results in a lot of bloat. Its only task is
|
||||
// to call the destructor which can be done with a function pointer.
|
||||
class BindStateBase
|
||||
: public RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits> {
|
||||
public:
|
||||
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
|
||||
|
||||
enum CancellationQueryMode {
|
||||
IS_CANCELLED,
|
||||
MAYBE_VALID,
|
||||
};
|
||||
|
||||
using InvokeFuncStorage = void (*)();
|
||||
|
||||
BindStateBase(const BindStateBase&) = delete;
|
||||
BindStateBase& operator=(const BindStateBase&) = delete;
|
||||
|
||||
private:
|
||||
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
||||
void (*destructor)(const BindStateBase*));
|
||||
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
||||
void (*destructor)(const BindStateBase*),
|
||||
bool (*query_cancellation_traits)(const BindStateBase*,
|
||||
CancellationQueryMode mode));
|
||||
|
||||
~BindStateBase() = default;
|
||||
|
||||
friend struct BindStateBaseRefCountTraits;
|
||||
friend class RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits>;
|
||||
|
||||
friend class CallbackBase;
|
||||
friend class CallbackBaseCopyable;
|
||||
|
||||
// Allowlist subclasses that access the destructor of BindStateBase.
|
||||
template <typename Functor, typename... BoundArgs>
|
||||
friend struct BindState;
|
||||
friend struct ::base::FakeBindState;
|
||||
|
||||
bool IsCancelled() const {
|
||||
return query_cancellation_traits_(this, IS_CANCELLED);
|
||||
}
|
||||
|
||||
bool MaybeValid() const {
|
||||
return query_cancellation_traits_(this, MAYBE_VALID);
|
||||
}
|
||||
|
||||
// In C++, it is safe to cast function pointers to function pointers of
|
||||
// another type. It is not okay to use void*. We create a InvokeFuncStorage
|
||||
// that that can store our function pointer, and then cast it back to
|
||||
// the original type on usage.
|
||||
InvokeFuncStorage polymorphic_invoke_;
|
||||
|
||||
// Pointer to a function that will properly destroy |this|.
|
||||
void (*destructor_)(const BindStateBase*);
|
||||
bool (*query_cancellation_traits_)(const BindStateBase*,
|
||||
CancellationQueryMode mode);
|
||||
};
|
||||
|
||||
// Holds the Callback methods that don't require specialization to reduce
|
||||
// template bloat.
|
||||
// CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and
|
||||
// CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation.
|
||||
class CallbackBase {
|
||||
public:
|
||||
inline CallbackBase(CallbackBase&& c) noexcept;
|
||||
CallbackBase& operator=(CallbackBase&& c) noexcept;
|
||||
|
||||
explicit CallbackBase(const CallbackBaseCopyable& c);
|
||||
CallbackBase& operator=(const CallbackBaseCopyable& c);
|
||||
|
||||
explicit CallbackBase(CallbackBaseCopyable&& c) noexcept;
|
||||
CallbackBase& operator=(CallbackBaseCopyable&& c) noexcept;
|
||||
|
||||
// Returns true if Callback is null (doesn't refer to anything).
|
||||
bool is_null() const { return !bind_state_; }
|
||||
explicit operator bool() const { return !is_null(); }
|
||||
|
||||
// Returns true if the callback invocation will be nop due to an cancellation.
|
||||
// It's invalid to call this on uninitialized callback.
|
||||
//
|
||||
// Must be called on the Callback's destination sequence.
|
||||
bool IsCancelled() const;
|
||||
|
||||
// If this returns false, the callback invocation will be a nop due to a
|
||||
// cancellation. This may(!) still return true, even on a cancelled callback.
|
||||
//
|
||||
// This function is thread-safe.
|
||||
bool MaybeValid() const;
|
||||
|
||||
// Returns the Callback into an uninitialized state.
|
||||
void Reset();
|
||||
|
||||
protected:
|
||||
friend class FinallyExecutorCommon;
|
||||
friend class ThenAndCatchExecutorCommon;
|
||||
|
||||
template <typename ReturnType>
|
||||
friend class PostTaskExecutor;
|
||||
|
||||
using InvokeFuncStorage = BindStateBase::InvokeFuncStorage;
|
||||
|
||||
// Returns true if this callback equals |other|. |other| may be null.
|
||||
bool EqualsInternal(const CallbackBase& other) const;
|
||||
|
||||
constexpr inline CallbackBase();
|
||||
|
||||
// Allow initializing of |bind_state_| via the constructor to avoid default
|
||||
// initialization of the scoped_refptr.
|
||||
explicit inline CallbackBase(BindStateBase* bind_state);
|
||||
|
||||
InvokeFuncStorage polymorphic_invoke() const {
|
||||
return bind_state_->polymorphic_invoke_;
|
||||
}
|
||||
|
||||
// Force the destructor to be instantiated inside this translation unit so
|
||||
// that our subclasses will not get inlined versions. Avoids more template
|
||||
// bloat.
|
||||
~CallbackBase();
|
||||
|
||||
scoped_refptr<BindStateBase> bind_state_;
|
||||
};
|
||||
|
||||
constexpr CallbackBase::CallbackBase() = default;
|
||||
CallbackBase::CallbackBase(CallbackBase&&) noexcept = default;
|
||||
CallbackBase::CallbackBase(BindStateBase* bind_state)
|
||||
: bind_state_(AdoptRef(bind_state)) {}
|
||||
|
||||
// CallbackBase<Copyable> is a direct base class of Copyable Callbacks.
|
||||
class CallbackBaseCopyable : public CallbackBase {
|
||||
public:
|
||||
CallbackBaseCopyable(const CallbackBaseCopyable& c);
|
||||
CallbackBaseCopyable(CallbackBaseCopyable&& c) noexcept = default;
|
||||
CallbackBaseCopyable& operator=(const CallbackBaseCopyable& c);
|
||||
CallbackBaseCopyable& operator=(CallbackBaseCopyable&& c) noexcept;
|
||||
|
||||
protected:
|
||||
constexpr CallbackBaseCopyable() = default;
|
||||
explicit CallbackBaseCopyable(BindStateBase* bind_state)
|
||||
: CallbackBase(bind_state) {}
|
||||
~CallbackBaseCopyable() = default;
|
||||
};
|
||||
|
||||
// Helpers for the `Then()` implementation.
|
||||
template <typename OriginalCallback, typename ThenCallback>
|
||||
struct ThenHelper;
|
||||
|
||||
// Specialization when original callback returns `void`.
|
||||
template <template <typename> class OriginalCallback,
|
||||
template <typename>
|
||||
class ThenCallback,
|
||||
typename... OriginalArgs,
|
||||
typename ThenR,
|
||||
typename... ThenArgs>
|
||||
struct ThenHelper<OriginalCallback<void(OriginalArgs...)>,
|
||||
ThenCallback<ThenR(ThenArgs...)>> {
|
||||
static_assert(sizeof...(ThenArgs) == 0,
|
||||
"|then| callback cannot accept parameters if |this| has a "
|
||||
"void return type.");
|
||||
|
||||
static auto CreateTrampoline() {
|
||||
return [](OriginalCallback<void(OriginalArgs...)> c1,
|
||||
ThenCallback<ThenR(ThenArgs...)> c2, OriginalArgs... c1_args) {
|
||||
std::move(c1).Run(std::forward<OriginalArgs>(c1_args)...);
|
||||
return std::move(c2).Run();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization when original callback returns a non-void type.
|
||||
template <template <typename> class OriginalCallback,
|
||||
template <typename>
|
||||
class ThenCallback,
|
||||
typename OriginalR,
|
||||
typename... OriginalArgs,
|
||||
typename ThenR,
|
||||
typename... ThenArgs>
|
||||
struct ThenHelper<OriginalCallback<OriginalR(OriginalArgs...)>,
|
||||
ThenCallback<ThenR(ThenArgs...)>> {
|
||||
static_assert(sizeof...(ThenArgs) == 1,
|
||||
"|then| callback must accept exactly one parameter if |this| "
|
||||
"has a non-void return type.");
|
||||
// TODO(dcheng): This should probably check is_convertible as well (same with
|
||||
// `AssertBindArgsValidity`).
|
||||
static_assert(std::is_constructible<ThenArgs..., OriginalR&&>::value,
|
||||
"|then| callback's parameter must be constructible from "
|
||||
"return type of |this|.");
|
||||
|
||||
static auto CreateTrampoline() {
|
||||
return [](OriginalCallback<OriginalR(OriginalArgs...)> c1,
|
||||
ThenCallback<ThenR(ThenArgs...)> c2, OriginalArgs... c1_args) {
|
||||
return std::move(c2).Run(
|
||||
std::move(c1).Run(std::forward<OriginalArgs>(c1_args)...));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
87
Thirdparty/libcef/include/base/internal/cef_lock_impl.h
vendored
Normal file
87
Thirdparty/libcef/include/base/internal/cef_lock_impl.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
// 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.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_lock.h instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
|
||||
|
||||
#include "include/base/cef_build.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#elif defined(OS_POSIX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
// This class implements the underlying platform-specific spin-lock mechanism
|
||||
// used for the Lock class. Most users should not use LockImpl directly, but
|
||||
// should instead use Lock.
|
||||
class LockImpl {
|
||||
public:
|
||||
#if defined(OS_WIN)
|
||||
typedef CRITICAL_SECTION NativeHandle;
|
||||
#elif defined(OS_POSIX)
|
||||
typedef pthread_mutex_t NativeHandle;
|
||||
#endif
|
||||
|
||||
LockImpl();
|
||||
|
||||
LockImpl(const LockImpl&) = delete;
|
||||
LockImpl& operator=(const LockImpl&) = delete;
|
||||
|
||||
~LockImpl();
|
||||
|
||||
// If the lock is not held, take it and return true. If the lock is already
|
||||
// held by something else, immediately return false.
|
||||
bool Try();
|
||||
|
||||
// Take the lock, blocking until it is available if necessary.
|
||||
void Lock();
|
||||
|
||||
// Release the lock. This must only be called by the lock's holder: after
|
||||
// a successful call to Try, or a call to Lock.
|
||||
void Unlock();
|
||||
|
||||
// Return the native underlying lock.
|
||||
// TODO(awalker): refactor lock and condition variables so that this is
|
||||
// unnecessary.
|
||||
NativeHandle* native_handle() { return &native_handle_; }
|
||||
|
||||
private:
|
||||
NativeHandle native_handle_;
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_
|
1020
Thirdparty/libcef/include/base/internal/cef_net_error_list.h
vendored
Normal file
1020
Thirdparty/libcef/include/base/internal/cef_net_error_list.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
75
Thirdparty/libcef/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h
vendored
Normal file
75
Thirdparty/libcef/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
// 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.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_callback.h instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "include/base/cef_template_util.h"
|
||||
|
||||
// It is dangerous to post a task with a T* argument where T is a subtype of
|
||||
// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
|
||||
// object may already have been deleted since it was not held with a
|
||||
// scoped_refptr. Example: http://crbug.com/27191
|
||||
// The following set of traits are designed to generate a compile error
|
||||
// whenever this antipattern is attempted.
|
||||
|
||||
namespace base {
|
||||
|
||||
// This is a base internal implementation file used by task.h and callback.h.
|
||||
// Not for public consumption, so we wrap it in namespace internal.
|
||||
namespace internal {
|
||||
|
||||
template <typename T, typename = void>
|
||||
struct IsRefCountedType : std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsRefCountedType<T,
|
||||
void_t<decltype(std::declval<T*>()->AddRef()),
|
||||
decltype(std::declval<T*>()->Release())>>
|
||||
: std::true_type {};
|
||||
|
||||
// Human readable translation: you needed to be a scoped_refptr if you are a raw
|
||||
// pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) type.
|
||||
template <typename T>
|
||||
struct NeedsScopedRefptrButGetsRawPtr
|
||||
: conjunction<std::is_pointer<T>,
|
||||
IsRefCountedType<std::remove_pointer_t<T>>> {
|
||||
static_assert(!std::is_reference<T>::value,
|
||||
"NeedsScopedRefptrButGetsRawPtr requires non-reference type.");
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
53
Thirdparty/libcef/include/base/internal/cef_scoped_policy.h
vendored
Normal file
53
Thirdparty/libcef/include/base/internal/cef_scoped_policy.h
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
// 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.
|
||||
|
||||
// Do not include this header file directly. Use base/memory/scoped_policy.h
|
||||
// instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||
|
||||
namespace base {
|
||||
namespace scoped_policy {
|
||||
|
||||
// Defines the ownership policy for a scoped object.
|
||||
enum OwnershipPolicy {
|
||||
// The scoped object takes ownership of an object by taking over an existing
|
||||
// ownership claim.
|
||||
ASSUME,
|
||||
|
||||
// The scoped object will retain the object and any initial ownership is
|
||||
// not changed.
|
||||
RETAIN
|
||||
};
|
||||
|
||||
} // namespace scoped_policy
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
72
Thirdparty/libcef/include/base/internal/cef_thread_checker_impl.h
vendored
Normal file
72
Thirdparty/libcef/include/base/internal/cef_thread_checker_impl.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
// 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.
|
||||
|
||||
// Do not include this header file directly. Use base/cef_thread_checker.h
|
||||
// instead.
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_
|
||||
#define CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_
|
||||
|
||||
#include "include/base/cef_lock.h"
|
||||
#include "include/base/cef_platform_thread.h"
|
||||
|
||||
namespace base {
|
||||
namespace cef_internal {
|
||||
|
||||
// Real implementation of ThreadChecker, for use in debug mode, or
|
||||
// for temporary use in release mode (e.g. to CHECK on a threading issue
|
||||
// seen only in the wild).
|
||||
//
|
||||
// Note: You should almost always use the ThreadChecker class to get the
|
||||
// right version for your build configuration.
|
||||
class ThreadCheckerImpl {
|
||||
public:
|
||||
ThreadCheckerImpl();
|
||||
~ThreadCheckerImpl();
|
||||
|
||||
bool CalledOnValidThread() const;
|
||||
|
||||
// Changes the thread that is checked for in CalledOnValidThread. This may
|
||||
// be useful when an object may be created on one thread and then used
|
||||
// exclusively on another thread.
|
||||
void DetachFromThread();
|
||||
|
||||
private:
|
||||
void EnsureThreadIdAssigned() const;
|
||||
|
||||
mutable base::Lock lock_;
|
||||
// This is mutable so that CalledOnValidThread can set it.
|
||||
// It's guarded by |lock_|.
|
||||
mutable PlatformThreadRef valid_thread_id_;
|
||||
};
|
||||
|
||||
} // namespace cef_internal
|
||||
} // namespace base
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_
|
81
Thirdparty/libcef/include/capi/cef_accessibility_handler_capi.h
vendored
Normal file
81
Thirdparty/libcef/include/capi/cef_accessibility_handler_capi.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2022 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 was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=306e44d49ab6198a0fa1bcea50e8a25ee18672be$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// Implement this structure to receive accessibility notification when
|
||||
// accessibility events have been registered. The functions of this structure
|
||||
// will be called on the UI thread.
|
||||
///
|
||||
typedef struct _cef_accessibility_handler_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called after renderer process sends accessibility tree changes to the
|
||||
// browser process.
|
||||
///
|
||||
void(CEF_CALLBACK* on_accessibility_tree_change)(
|
||||
struct _cef_accessibility_handler_t* self,
|
||||
struct _cef_value_t* value);
|
||||
|
||||
///
|
||||
// Called after renderer process sends accessibility location changes to the
|
||||
// browser process.
|
||||
///
|
||||
void(CEF_CALLBACK* on_accessibility_location_change)(
|
||||
struct _cef_accessibility_handler_t* self,
|
||||
struct _cef_value_t* value);
|
||||
} cef_accessibility_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
201
Thirdparty/libcef/include/capi/cef_app_capi.h
vendored
Normal file
201
Thirdparty/libcef/include/capi/cef_app_capi.h
vendored
Normal file
@ -0,0 +1,201 @@
|
||||
// Copyright (c) 2022 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 was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=665709ecf3ebad59e85285d319eae72197b9766f$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_process_handler_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_render_process_handler_capi.h"
|
||||
#include "include/capi/cef_resource_bundle_handler_capi.h"
|
||||
#include "include/capi/cef_scheme_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_app_t;
|
||||
|
||||
///
|
||||
// Implement this structure to provide handler implementations. Methods will be
|
||||
// called by the process and/or thread indicated.
|
||||
///
|
||||
typedef struct _cef_app_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Provides an opportunity to view and/or modify command-line arguments before
|
||||
// processing by CEF and Chromium. The |process_type| value will be NULL for
|
||||
// the browser process. Do not keep a reference to the cef_command_line_t
|
||||
// object passed to this function. The CefSettings.command_line_args_disabled
|
||||
// value can be used to start with an NULL command-line object. Any values
|
||||
// specified in CefSettings that equate to command-line arguments will be set
|
||||
// before this function is called. Be cautious when using this function to
|
||||
// modify command-line arguments for non-browser processes as this may result
|
||||
// in undefined behavior including crashes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_command_line_processing)(
|
||||
struct _cef_app_t* self,
|
||||
const cef_string_t* process_type,
|
||||
struct _cef_command_line_t* command_line);
|
||||
|
||||
///
|
||||
// Provides an opportunity to register custom schemes. Do not keep a reference
|
||||
// to the |registrar| object. This function is called on the main thread for
|
||||
// each process and the registered schemes should be the same across all
|
||||
// processes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_register_custom_schemes)(
|
||||
struct _cef_app_t* self,
|
||||
struct _cef_scheme_registrar_t* registrar);
|
||||
|
||||
///
|
||||
// Return the handler for resource bundle events. If
|
||||
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
|
||||
// If no handler is returned resources will be loaded from pack files. This
|
||||
// function is called by the browser and render processes on multiple threads.
|
||||
///
|
||||
struct _cef_resource_bundle_handler_t*(
|
||||
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
// Return the handler for functionality specific to the browser process. This
|
||||
// function is called on multiple threads in the browser process.
|
||||
///
|
||||
struct _cef_browser_process_handler_t*(
|
||||
CEF_CALLBACK* get_browser_process_handler)(struct _cef_app_t* self);
|
||||
|
||||
///
|
||||
// Return the handler for functionality specific to the render process. This
|
||||
// function is called on the render process main thread.
|
||||
///
|
||||
struct _cef_render_process_handler_t*(
|
||||
CEF_CALLBACK* get_render_process_handler)(struct _cef_app_t* self);
|
||||
} cef_app_t;
|
||||
|
||||
///
|
||||
// This function should be called from the application entry point function to
|
||||
// execute a secondary process. It can be used to run secondary processes from
|
||||
// the browser client executable (default behavior) or from a separate
|
||||
// executable specified by the CefSettings.browser_subprocess_path value. If
|
||||
// called for the browser process (identified by no "type" command-line value)
|
||||
// it will return immediately with a value of -1. If called for a recognized
|
||||
// secondary process it will block until the process should exit and then return
|
||||
// the process exit code. The |application| parameter may be NULL. The
|
||||
// |windows_sandbox_info| parameter is only used on Windows and may be NULL (see
|
||||
// cef_sandbox_win.h for details).
|
||||
///
|
||||
CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
|
||||
cef_app_t* application,
|
||||
void* windows_sandbox_info);
|
||||
|
||||
///
|
||||
// This function should be called on the main application thread to initialize
|
||||
// the CEF browser process. The |application| parameter may be NULL. A return
|
||||
// value of true (1) indicates that it succeeded and false (0) indicates that it
|
||||
// failed. The |windows_sandbox_info| parameter is only used on Windows and may
|
||||
// be NULL (see cef_sandbox_win.h for details).
|
||||
///
|
||||
CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
|
||||
const struct _cef_settings_t* settings,
|
||||
cef_app_t* application,
|
||||
void* windows_sandbox_info);
|
||||
|
||||
///
|
||||
// This function should be called on the main application thread to shut down
|
||||
// the CEF browser process before the application exits.
|
||||
///
|
||||
CEF_EXPORT void cef_shutdown(void);
|
||||
|
||||
///
|
||||
// Perform a single iteration of CEF message loop processing. This function is
|
||||
// provided for cases where the CEF message loop must be integrated into an
|
||||
// existing application message loop. Use of this function is not recommended
|
||||
// for most users; use either the cef_run_message_loop() function or
|
||||
// CefSettings.multi_threaded_message_loop if possible. When using this function
|
||||
// care must be taken to balance performance against excessive CPU usage. It is
|
||||
// recommended to enable the CefSettings.external_message_pump option when using
|
||||
// this function so that
|
||||
// cef_browser_process_handler_t::on_schedule_message_pump_work() callbacks can
|
||||
// facilitate the scheduling process. This function should only be called on the
|
||||
// main application thread and only if cef_initialize() is called with a
|
||||
// CefSettings.multi_threaded_message_loop value of false (0). This function
|
||||
// will not block.
|
||||
///
|
||||
CEF_EXPORT void cef_do_message_loop_work(void);
|
||||
|
||||
///
|
||||
// Run the CEF message loop. Use this function instead of an application-
|
||||
// provided message loop to get the best balance between performance and CPU
|
||||
// usage. This function should only be called on the main application thread and
|
||||
// only if cef_initialize() is called with a
|
||||
// CefSettings.multi_threaded_message_loop value of false (0). This function
|
||||
// will block until a quit message is received by the system.
|
||||
///
|
||||
CEF_EXPORT void cef_run_message_loop(void);
|
||||
|
||||
///
|
||||
// Quit the CEF message loop that was started by calling cef_run_message_loop().
|
||||
// This function should only be called on the main application thread and only
|
||||
// if cef_run_message_loop() was used.
|
||||
///
|
||||
CEF_EXPORT void cef_quit_message_loop(void);
|
||||
|
||||
///
|
||||
// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
|
||||
// modal message loop. Set to false (0) after exiting the modal message loop.
|
||||
///
|
||||
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
|
||||
|
||||
///
|
||||
// Call during process startup to enable High-DPI support on Windows 7 or newer.
|
||||
// Older versions of Windows should be left DPI-unaware because they do not
|
||||
// support DirectWrite and GDI fonts are kerned very badly.
|
||||
///
|
||||
CEF_EXPORT void cef_enable_highdpi_support(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
121
Thirdparty/libcef/include/capi/cef_audio_handler_capi.h
vendored
Normal file
121
Thirdparty/libcef/include/capi/cef_audio_handler_capi.h
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
// Copyright (c) 2022 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 was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=62f58ab826b8a3d436655bf0855848632f2a73b5$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// Implement this structure to handle audio events.
|
||||
///
|
||||
typedef struct _cef_audio_handler_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called on the UI thread to allow configuration of audio stream parameters.
|
||||
// Return true (1) to proceed with audio stream capture, or false (0) to
|
||||
// cancel it. All members of |params| can optionally be configured here, but
|
||||
// they are also pre-filled with some sensible defaults.
|
||||
///
|
||||
int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
cef_audio_parameters_t* params);
|
||||
|
||||
///
|
||||
// Called on a browser audio capture thread when the browser starts streaming
|
||||
// audio. OnAudioStreamStopped will always be called after
|
||||
// OnAudioStreamStarted; both functions may be called multiple times for the
|
||||
// same browser. |params| contains the audio parameters like sample rate and
|
||||
// channel layout. |channels| is the number of channels.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_started)(
|
||||
struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_audio_parameters_t* params,
|
||||
int channels);
|
||||
|
||||
///
|
||||
// Called on the audio stream thread when a PCM packet is received for the
|
||||
// stream. |data| is an array representing the raw PCM data as a floating
|
||||
// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
|
||||
// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
|
||||
// Unix Epoch) and represents the time at which the decompressed packet should
|
||||
// be presented to the user. Based on |frames| and the |channel_layout| value
|
||||
// passed to OnAudioStreamStarted you can calculate the size of the |data|
|
||||
// array in bytes.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const float** data,
|
||||
int frames,
|
||||
int64 pts);
|
||||
|
||||
///
|
||||
// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
|
||||
// will always be called after OnAudioStreamStarted; both functions may be
|
||||
// called multiple times for the same stream.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser);
|
||||
|
||||
///
|
||||
// Called on the UI or audio stream thread when an error occurred. During the
|
||||
// stream creation phase this callback will be called on the UI thread while
|
||||
// in the capturing phase it will be called on the audio stream thread. The
|
||||
// stream will be stopped immediately.
|
||||
///
|
||||
void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self,
|
||||
struct _cef_browser_t* browser,
|
||||
const cef_string_t* message);
|
||||
} cef_audio_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
76
Thirdparty/libcef/include/capi/cef_auth_callback_capi.h
vendored
Normal file
76
Thirdparty/libcef/include/capi/cef_auth_callback_capi.h
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
// Copyright (c) 2022 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 was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=01a33de48ac9780f78d606d8aee2429ddb0c81a2$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// Callback structure used for asynchronous continuation of authentication
|
||||
// requests.
|
||||
///
|
||||
typedef struct _cef_auth_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Continue the authentication request.
|
||||
///
|
||||
void(CEF_CALLBACK* cont)(struct _cef_auth_callback_t* self,
|
||||
const cef_string_t* username,
|
||||
const cef_string_t* password);
|
||||
|
||||
///
|
||||
// Cancel the authentication request.
|
||||
///
|
||||
void(CEF_CALLBACK* cancel)(struct _cef_auth_callback_t* self);
|
||||
} cef_auth_callback_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
107
Thirdparty/libcef/include/capi/cef_base_capi.h
vendored
Normal file
107
Thirdparty/libcef/include/capi/cef_base_capi.h
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
// Copyright (c) 2014 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.
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "include/internal/cef_export.h"
|
||||
#include "include/internal/cef_string.h"
|
||||
#include "include/internal/cef_string_list.h"
|
||||
#include "include/internal/cef_string_map.h"
|
||||
#include "include/internal/cef_string_multimap.h"
|
||||
#include "include/internal/cef_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// All ref-counted framework structures must include this structure first.
|
||||
///
|
||||
typedef struct _cef_base_ref_counted_t {
|
||||
///
|
||||
// Size of the data structure.
|
||||
///
|
||||
size_t size;
|
||||
|
||||
///
|
||||
// Called to increment the reference count for the object. Should be called
|
||||
// for every new copy of a pointer to a given object.
|
||||
///
|
||||
void(CEF_CALLBACK* add_ref)(struct _cef_base_ref_counted_t* self);
|
||||
|
||||
///
|
||||
// Called to decrement the reference count for the object. If the reference
|
||||
// count falls to 0 the object should self-delete. Returns true (1) if the
|
||||
// resulting reference count is 0.
|
||||
///
|
||||
int(CEF_CALLBACK* release)(struct _cef_base_ref_counted_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the current reference count is 1.
|
||||
///
|
||||
int(CEF_CALLBACK* has_one_ref)(struct _cef_base_ref_counted_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the current reference count is at least 1.
|
||||
///
|
||||
int(CEF_CALLBACK* has_at_least_one_ref)(struct _cef_base_ref_counted_t* self);
|
||||
} cef_base_ref_counted_t;
|
||||
|
||||
///
|
||||
// All scoped framework structures must include this structure first.
|
||||
///
|
||||
typedef struct _cef_base_scoped_t {
|
||||
///
|
||||
// Size of the data structure.
|
||||
///
|
||||
size_t size;
|
||||
|
||||
///
|
||||
// Called to delete this object. May be NULL if the object is not owned.
|
||||
///
|
||||
void(CEF_CALLBACK* del)(struct _cef_base_scoped_t* self);
|
||||
|
||||
} cef_base_scoped_t;
|
||||
|
||||
// Check that the structure |s|, which is defined with a size_t member at the
|
||||
// top, is large enough to contain the specified member |f|.
|
||||
#define CEF_MEMBER_EXISTS(s, f) \
|
||||
((intptr_t) & \
|
||||
((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= *reinterpret_cast<size_t*>(s))
|
||||
|
||||
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
949
Thirdparty/libcef/include/capi/cef_browser_capi.h
vendored
Normal file
949
Thirdparty/libcef/include/capi/cef_browser_capi.h
vendored
Normal file
@ -0,0 +1,949 @@
|
||||
// Copyright (c) 2022 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 was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=b1c1e44e6d3842064ef6e5b9823173f7ec1fcccc$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_devtools_message_observer_capi.h"
|
||||
#include "include/capi/cef_drag_data_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
#include "include/capi/cef_image_capi.h"
|
||||
#include "include/capi/cef_navigation_entry_capi.h"
|
||||
#include "include/capi/cef_registration_capi.h"
|
||||
#include "include/capi/cef_request_context_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _cef_browser_host_t;
|
||||
struct _cef_client_t;
|
||||
|
||||
///
|
||||
// Structure used to represent a browser. When used in the browser process the
|
||||
// functions of this structure may be called on any thread unless otherwise
|
||||
// indicated in the comments. When used in the render process the functions of
|
||||
// this structure may only be called on the main thread.
|
||||
///
|
||||
typedef struct _cef_browser_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// True if this object is currently valid. This will return false (0) after
|
||||
// cef_life_span_handler_t::OnBeforeClose is called.
|
||||
///
|
||||
int(CEF_CALLBACK* is_valid)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the browser host object. This function can only be called in the
|
||||
// browser process.
|
||||
///
|
||||
struct _cef_browser_host_t*(CEF_CALLBACK* get_host)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the browser can navigate backwards.
|
||||
///
|
||||
int(CEF_CALLBACK* can_go_back)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Navigate backwards.
|
||||
///
|
||||
void(CEF_CALLBACK* go_back)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the browser can navigate forwards.
|
||||
///
|
||||
int(CEF_CALLBACK* can_go_forward)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Navigate forwards.
|
||||
///
|
||||
void(CEF_CALLBACK* go_forward)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if the browser is currently loading.
|
||||
///
|
||||
int(CEF_CALLBACK* is_loading)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Reload the current page.
|
||||
///
|
||||
void(CEF_CALLBACK* reload)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Reload the current page ignoring any cached data.
|
||||
///
|
||||
void(CEF_CALLBACK* reload_ignore_cache)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Stop loading the page.
|
||||
///
|
||||
void(CEF_CALLBACK* stop_load)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the globally unique identifier for this browser. This value is also
|
||||
// used as the tabId for extension APIs.
|
||||
///
|
||||
int(CEF_CALLBACK* get_identifier)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this object is pointing to the same handle as |that|
|
||||
// object.
|
||||
///
|
||||
int(CEF_CALLBACK* is_same)(struct _cef_browser_t* self,
|
||||
struct _cef_browser_t* that);
|
||||
|
||||
///
|
||||
// Returns true (1) if the browser is a popup.
|
||||
///
|
||||
int(CEF_CALLBACK* is_popup)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if a document has been loaded in the browser.
|
||||
///
|
||||
int(CEF_CALLBACK* has_document)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the main (top-level) frame for the browser. In the browser process
|
||||
// this will return a valid object until after
|
||||
// cef_life_span_handler_t::OnBeforeClose is called. In the renderer process
|
||||
// this will return NULL if the main frame is hosted in a different renderer
|
||||
// process (e.g. for cross-origin sub-frames). The main frame object will
|
||||
// change during cross-origin navigation or re-navigation after renderer
|
||||
// process termination (due to crashes, etc).
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_main_frame)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the focused frame for the browser.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_focused_frame)(
|
||||
struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the frame with the specified identifier, or NULL if not found.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_frame_byident)(
|
||||
struct _cef_browser_t* self,
|
||||
int64 identifier);
|
||||
|
||||
///
|
||||
// Returns the frame with the specified name, or NULL if not found.
|
||||
///
|
||||
struct _cef_frame_t*(CEF_CALLBACK* get_frame)(struct _cef_browser_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
// Returns the number of frames that currently exist.
|
||||
///
|
||||
size_t(CEF_CALLBACK* get_frame_count)(struct _cef_browser_t* self);
|
||||
|
||||
///
|
||||
// Returns the identifiers of all existing frames.
|
||||
///
|
||||
void(CEF_CALLBACK* get_frame_identifiers)(struct _cef_browser_t* self,
|
||||
size_t* identifiersCount,
|
||||
int64* identifiers);
|
||||
|
||||
///
|
||||
// Returns the names of all existing frames.
|
||||
///
|
||||
void(CEF_CALLBACK* get_frame_names)(struct _cef_browser_t* self,
|
||||
cef_string_list_t names);
|
||||
} cef_browser_t;
|
||||
|
||||
///
|
||||
// Callback structure for cef_browser_host_t::RunFileDialog. The functions of
|
||||
// this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_run_file_dialog_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called asynchronously after the file dialog is dismissed. |file_paths| will
|
||||
// be a single value or a list of values depending on the dialog mode. If the
|
||||
// selection was cancelled |file_paths| will be NULL.
|
||||
///
|
||||
void(CEF_CALLBACK* on_file_dialog_dismissed)(
|
||||
struct _cef_run_file_dialog_callback_t* self,
|
||||
cef_string_list_t file_paths);
|
||||
} cef_run_file_dialog_callback_t;
|
||||
|
||||
///
|
||||
// Callback structure for cef_browser_host_t::GetNavigationEntries. The
|
||||
// functions of this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_navigation_entry_visitor_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Method that will be executed. Do not keep a reference to |entry| outside of
|
||||
// this callback. Return true (1) to continue visiting entries or false (0) to
|
||||
// stop. |current| is true (1) if this entry is the currently loaded
|
||||
// navigation entry. |index| is the 0-based index of this entry and |total| is
|
||||
// the total number of entries.
|
||||
///
|
||||
int(CEF_CALLBACK* visit)(struct _cef_navigation_entry_visitor_t* self,
|
||||
struct _cef_navigation_entry_t* entry,
|
||||
int current,
|
||||
int index,
|
||||
int total);
|
||||
} cef_navigation_entry_visitor_t;
|
||||
|
||||
///
|
||||
// Callback structure for cef_browser_host_t::PrintToPDF. The functions of this
|
||||
// structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_pdf_print_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Method that will be executed when the PDF printing has completed. |path| is
|
||||
// the output path. |ok| will be true (1) if the printing completed
|
||||
// successfully or false (0) otherwise.
|
||||
///
|
||||
void(CEF_CALLBACK* on_pdf_print_finished)(
|
||||
struct _cef_pdf_print_callback_t* self,
|
||||
const cef_string_t* path,
|
||||
int ok);
|
||||
} cef_pdf_print_callback_t;
|
||||
|
||||
///
|
||||
// Callback structure for cef_browser_host_t::DownloadImage. The functions of
|
||||
// this structure will be called on the browser process UI thread.
|
||||
///
|
||||
typedef struct _cef_download_image_callback_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Method that will be executed when the image download has completed.
|
||||
// |image_url| is the URL that was downloaded and |http_status_code| is the
|
||||
// resulting HTTP status code. |image| is the resulting image, possibly at
|
||||
// multiple scale factors, or NULL if the download failed.
|
||||
///
|
||||
void(CEF_CALLBACK* on_download_image_finished)(
|
||||
struct _cef_download_image_callback_t* self,
|
||||
const cef_string_t* image_url,
|
||||
int http_status_code,
|
||||
struct _cef_image_t* image);
|
||||
} cef_download_image_callback_t;
|
||||
|
||||
///
|
||||
// Structure used to represent the browser process aspects of a browser. The
|
||||
// functions of this structure can only be called in the browser process. They
|
||||
// may be called on any thread in that process unless otherwise indicated in the
|
||||
// comments.
|
||||
///
|
||||
typedef struct _cef_browser_host_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Returns the hosted browser object.
|
||||
///
|
||||
struct _cef_browser_t*(CEF_CALLBACK* get_browser)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Request that the browser close. The JavaScript 'onbeforeunload' event will
|
||||
// be fired. If |force_close| is false (0) the event handler, if any, will be
|
||||
// allowed to prompt the user and the user can optionally cancel the close. If
|
||||
// |force_close| is true (1) the prompt will not be displayed and the close
|
||||
// will proceed. Results in a call to cef_life_span_handler_t::do_close() if
|
||||
// the event handler allows the close or if |force_close| is true (1). See
|
||||
// cef_life_span_handler_t::do_close() documentation for additional usage
|
||||
// information.
|
||||
///
|
||||
void(CEF_CALLBACK* close_browser)(struct _cef_browser_host_t* self,
|
||||
int force_close);
|
||||
|
||||
///
|
||||
// Helper for closing a browser. Call this function from the top-level window
|
||||
// close handler (if any). Internally this calls CloseBrowser(false (0)) if
|
||||
// the close has not yet been initiated. This function returns false (0) while
|
||||
// the close is pending and true (1) after the close has completed. See
|
||||
// close_browser() and cef_life_span_handler_t::do_close() documentation for
|
||||
// additional usage information. This function must be called on the browser
|
||||
// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* try_close_browser)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Set whether the browser is focused.
|
||||
///
|
||||
void(CEF_CALLBACK* set_focus)(struct _cef_browser_host_t* self, int focus);
|
||||
|
||||
///
|
||||
// Retrieve the window handle (if any) for this browser. If this browser is
|
||||
// wrapped in a cef_browser_view_t this function should be called on the
|
||||
// browser process UI thread and it will return the handle for the top-level
|
||||
// native window.
|
||||
///
|
||||
cef_window_handle_t(CEF_CALLBACK* get_window_handle)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Retrieve the window handle (if any) of the browser that opened this
|
||||
// browser. Will return NULL for non-popup browsers or if this browser is
|
||||
// wrapped in a cef_browser_view_t. This function can be used in combination
|
||||
// with custom handling of modal windows.
|
||||
///
|
||||
cef_window_handle_t(CEF_CALLBACK* get_opener_window_handle)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this browser is wrapped in a cef_browser_view_t.
|
||||
///
|
||||
int(CEF_CALLBACK* has_view)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns the client for this browser.
|
||||
///
|
||||
struct _cef_client_t*(CEF_CALLBACK* get_client)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns the request context for this browser.
|
||||
///
|
||||
struct _cef_request_context_t*(CEF_CALLBACK* get_request_context)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Get the current zoom level. The default zoom level is 0.0. This function
|
||||
// can only be called on the UI thread.
|
||||
///
|
||||
double(CEF_CALLBACK* get_zoom_level)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Change the zoom level to the specified value. Specify 0.0 to reset the zoom
|
||||
// level. If called on the UI thread the change will be applied immediately.
|
||||
// Otherwise, the change will be applied asynchronously on the UI thread.
|
||||
///
|
||||
void(CEF_CALLBACK* set_zoom_level)(struct _cef_browser_host_t* self,
|
||||
double zoomLevel);
|
||||
|
||||
///
|
||||
// Call to run a file chooser dialog. Only a single file chooser dialog may be
|
||||
// pending at any given time. |mode| represents the type of dialog to display.
|
||||
// |title| to the title to be used for the dialog and may be NULL to show the
|
||||
// default title ("Open" or "Save" depending on the mode). |default_file_path|
|
||||
// is the path with optional directory and/or file name component that will be
|
||||
// initially selected in the dialog. |accept_filters| are used to restrict the
|
||||
// selectable file types and may any combination of (a) valid lower-cased MIME
|
||||
// types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g.
|
||||
// ".txt" or ".png"), or (c) combined description and file extension delimited
|
||||
// using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). |callback| will be
|
||||
// executed after the dialog is dismissed or immediately if another dialog is
|
||||
// already pending. The dialog will be initiated asynchronously on the UI
|
||||
// thread.
|
||||
///
|
||||
void(CEF_CALLBACK* run_file_dialog)(
|
||||
struct _cef_browser_host_t* self,
|
||||
cef_file_dialog_mode_t mode,
|
||||
const cef_string_t* title,
|
||||
const cef_string_t* default_file_path,
|
||||
cef_string_list_t accept_filters,
|
||||
struct _cef_run_file_dialog_callback_t* callback);
|
||||
|
||||
///
|
||||
// Download the file at |url| using cef_download_handler_t.
|
||||
///
|
||||
void(CEF_CALLBACK* start_download)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* url);
|
||||
|
||||
///
|
||||
// Download |image_url| and execute |callback| on completion with the images
|
||||
// received from the renderer. If |is_favicon| is true (1) then cookies are
|
||||
// not sent and not accepted during download. Images with density independent
|
||||
// pixel (DIP) sizes larger than |max_image_size| are filtered out from the
|
||||
// image results. Versions of the image at different scale factors may be
|
||||
// downloaded up to the maximum scale factor supported by the system. If there
|
||||
// are no image results <= |max_image_size| then the smallest image is resized
|
||||
// to |max_image_size| and is the only result. A |max_image_size| of 0 means
|
||||
// unlimited. If |bypass_cache| is true (1) then |image_url| is requested from
|
||||
// the server even if it is present in the browser cache.
|
||||
///
|
||||
void(CEF_CALLBACK* download_image)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_string_t* image_url,
|
||||
int is_favicon,
|
||||
uint32 max_image_size,
|
||||
int bypass_cache,
|
||||
struct _cef_download_image_callback_t* callback);
|
||||
|
||||
///
|
||||
// Print the current browser contents.
|
||||
///
|
||||
void(CEF_CALLBACK* print)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Print the current browser contents to the PDF file specified by |path| and
|
||||
// execute |callback| on completion. The caller is responsible for deleting
|
||||
// |path| when done. For PDF printing to work on Linux you must implement the
|
||||
// cef_print_handler_t::GetPdfPaperSize function.
|
||||
///
|
||||
void(CEF_CALLBACK* print_to_pdf)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_string_t* path,
|
||||
const struct _cef_pdf_print_settings_t* settings,
|
||||
struct _cef_pdf_print_callback_t* callback);
|
||||
|
||||
///
|
||||
// Search for |searchText|. |forward| indicates whether to search forward or
|
||||
// backward within the page. |matchCase| indicates whether the search should
|
||||
// be case-sensitive. |findNext| indicates whether this is the first request
|
||||
// or a follow-up. The search will be restarted if |searchText| or |matchCase|
|
||||
// change. The search will be stopped if |searchText| is NULL. The
|
||||
// cef_find_handler_t instance, if any, returned via
|
||||
// cef_client_t::GetFindHandler will be called to report find results.
|
||||
///
|
||||
void(CEF_CALLBACK* find)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* searchText,
|
||||
int forward,
|
||||
int matchCase,
|
||||
int findNext);
|
||||
|
||||
///
|
||||
// Cancel all searches that are currently going on.
|
||||
///
|
||||
void(CEF_CALLBACK* stop_finding)(struct _cef_browser_host_t* self,
|
||||
int clearSelection);
|
||||
|
||||
///
|
||||
// Open developer tools (DevTools) in its own browser. The DevTools browser
|
||||
// will remain associated with this browser. If the DevTools browser is
|
||||
// already open then it will be focused, in which case the |windowInfo|,
|
||||
// |client| and |settings| parameters will be ignored. If |inspect_element_at|
|
||||
// is non-NULL then the element at the specified (x,y) location will be
|
||||
// inspected. The |windowInfo| parameter will be ignored if this browser is
|
||||
// wrapped in a cef_browser_view_t.
|
||||
///
|
||||
void(CEF_CALLBACK* show_dev_tools)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const struct _cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t* client,
|
||||
const struct _cef_browser_settings_t* settings,
|
||||
const cef_point_t* inspect_element_at);
|
||||
|
||||
///
|
||||
// Explicitly close the associated DevTools browser, if any.
|
||||
///
|
||||
void(CEF_CALLBACK* close_dev_tools)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this browser currently has an associated DevTools
|
||||
// browser. Must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_dev_tools)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Send a function call message over the DevTools protocol. |message| must be
|
||||
// a UTF8-encoded JSON dictionary that contains "id" (int), "function"
|
||||
// (string) and "params" (dictionary, optional) values. See the DevTools
|
||||
// protocol documentation at https://chromedevtools.github.io/devtools-
|
||||
// protocol/ for details of supported functions and the expected "params"
|
||||
// dictionary contents. |message| will be copied if necessary. This function
|
||||
// will return true (1) if called on the UI thread and the message was
|
||||
// successfully submitted for validation, otherwise false (0). Validation will
|
||||
// be applied asynchronously and any messages that fail due to formatting
|
||||
// errors or missing parameters may be discarded without notification. Prefer
|
||||
// ExecuteDevToolsMethod if a more structured approach to message formatting
|
||||
// is desired.
|
||||
//
|
||||
// Every valid function call will result in an asynchronous function result or
|
||||
// error message that references the sent message "id". Event messages are
|
||||
// received while notifications are enabled (for example, between function
|
||||
// calls for "Page.enable" and "Page.disable"). All received messages will be
|
||||
// delivered to the observer(s) registered with AddDevToolsMessageObserver.
|
||||
// See cef_dev_tools_message_observer_t::OnDevToolsMessage documentation for
|
||||
// details of received message contents.
|
||||
//
|
||||
// Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and
|
||||
// AddDevToolsMessageObserver functions does not require an active DevTools
|
||||
// front-end or remote-debugging session. Other active DevTools sessions will
|
||||
// continue to function independently. However, any modification of global
|
||||
// browser state by one session may not be reflected in the UI of other
|
||||
// sessions.
|
||||
//
|
||||
// Communication with the DevTools front-end (when displayed) can be logged
|
||||
// for development purposes by passing the `--devtools-protocol-log-
|
||||
// file=<path>` command-line flag.
|
||||
///
|
||||
int(CEF_CALLBACK* send_dev_tools_message)(struct _cef_browser_host_t* self,
|
||||
const void* message,
|
||||
size_t message_size);
|
||||
|
||||
///
|
||||
// Execute a function call over the DevTools protocol. This is a more
|
||||
// structured version of SendDevToolsMessage. |message_id| is an incremental
|
||||
// number that uniquely identifies the message (pass 0 to have the next number
|
||||
// assigned automatically based on previous values). |function| is the
|
||||
// function name. |params| are the function parameters, which may be NULL. See
|
||||
// the DevTools protocol documentation (linked above) for details of supported
|
||||
// functions and the expected |params| dictionary contents. This function will
|
||||
// return the assigned message ID if called on the UI thread and the message
|
||||
// was successfully submitted for validation, otherwise 0. See the
|
||||
// SendDevToolsMessage documentation for additional usage information.
|
||||
///
|
||||
int(CEF_CALLBACK* execute_dev_tools_method)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int message_id,
|
||||
const cef_string_t* method,
|
||||
struct _cef_dictionary_value_t* params);
|
||||
|
||||
///
|
||||
// Add an observer for DevTools protocol messages (function results and
|
||||
// events). The observer will remain registered until the returned
|
||||
// Registration object is destroyed. See the SendDevToolsMessage documentation
|
||||
// for additional usage information.
|
||||
///
|
||||
struct _cef_registration_t*(CEF_CALLBACK* add_dev_tools_message_observer)(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_dev_tools_message_observer_t* observer);
|
||||
|
||||
///
|
||||
// Retrieve a snapshot of current navigation entries as values sent to the
|
||||
// specified visitor. If |current_only| is true (1) only the current
|
||||
// navigation entry will be sent, otherwise all navigation entries will be
|
||||
// sent.
|
||||
///
|
||||
void(CEF_CALLBACK* get_navigation_entries)(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_navigation_entry_visitor_t* visitor,
|
||||
int current_only);
|
||||
|
||||
///
|
||||
// If a misspelled word is currently selected in an editable node calling this
|
||||
// function will replace it with the specified |word|.
|
||||
///
|
||||
void(CEF_CALLBACK* replace_misspelling)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* word);
|
||||
|
||||
///
|
||||
// Add the specified |word| to the spelling dictionary.
|
||||
///
|
||||
void(CEF_CALLBACK* add_word_to_dictionary)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* word);
|
||||
|
||||
///
|
||||
// Returns true (1) if window rendering is disabled.
|
||||
///
|
||||
int(CEF_CALLBACK* is_window_rendering_disabled)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Notify the browser that the widget has been resized. The browser will first
|
||||
// call cef_render_handler_t::GetViewRect to get the new size and then call
|
||||
// cef_render_handler_t::OnPaint asynchronously with the updated regions. This
|
||||
// function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* was_resized)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Notify the browser that it has been hidden or shown. Layouting and
|
||||
// cef_render_handler_t::OnPaint notification will stop when the browser is
|
||||
// hidden. This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* was_hidden)(struct _cef_browser_host_t* self, int hidden);
|
||||
|
||||
///
|
||||
// Send a notification to the browser that the screen info has changed. The
|
||||
// browser will then call cef_render_handler_t::GetScreenInfo to update the
|
||||
// screen information with the new values. This simulates moving the webview
|
||||
// window from one display to another, or changing the properties of the
|
||||
// current display. This function is only used when window rendering is
|
||||
// disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* notify_screen_info_changed)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Invalidate the view. The browser will call cef_render_handler_t::OnPaint
|
||||
// asynchronously. This function is only used when window rendering is
|
||||
// disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* invalidate)(struct _cef_browser_host_t* self,
|
||||
cef_paint_element_type_t type);
|
||||
|
||||
///
|
||||
// Issue a BeginFrame request to Chromium. Only valid when
|
||||
// cef_window_tInfo::external_begin_frame_enabled is set to true (1).
|
||||
///
|
||||
void(CEF_CALLBACK* send_external_begin_frame)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Send a key event to the browser.
|
||||
///
|
||||
void(CEF_CALLBACK* send_key_event)(struct _cef_browser_host_t* self,
|
||||
const struct _cef_key_event_t* event);
|
||||
|
||||
///
|
||||
// Send a mouse click event to the browser. The |x| and |y| coordinates are
|
||||
// relative to the upper-left corner of the view.
|
||||
///
|
||||
void(CEF_CALLBACK* send_mouse_click_event)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const struct _cef_mouse_event_t* event,
|
||||
cef_mouse_button_type_t type,
|
||||
int mouseUp,
|
||||
int clickCount);
|
||||
|
||||
///
|
||||
// Send a mouse move event to the browser. The |x| and |y| coordinates are
|
||||
// relative to the upper-left corner of the view.
|
||||
///
|
||||
void(CEF_CALLBACK* send_mouse_move_event)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const struct _cef_mouse_event_t* event,
|
||||
int mouseLeave);
|
||||
|
||||
///
|
||||
// Send a mouse wheel event to the browser. The |x| and |y| coordinates are
|
||||
// relative to the upper-left corner of the view. The |deltaX| and |deltaY|
|
||||
// values represent the movement delta in the X and Y directions respectively.
|
||||
// In order to scroll inside select popups with window rendering disabled
|
||||
// cef_render_handler_t::GetScreenPoint should be implemented properly.
|
||||
///
|
||||
void(CEF_CALLBACK* send_mouse_wheel_event)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const struct _cef_mouse_event_t* event,
|
||||
int deltaX,
|
||||
int deltaY);
|
||||
|
||||
///
|
||||
// Send a touch event to the browser for a windowless browser.
|
||||
///
|
||||
void(CEF_CALLBACK* send_touch_event)(struct _cef_browser_host_t* self,
|
||||
const struct _cef_touch_event_t* event);
|
||||
|
||||
///
|
||||
// Send a capture lost event to the browser.
|
||||
///
|
||||
void(CEF_CALLBACK* send_capture_lost_event)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Notify the browser that the window hosting it is about to be moved or
|
||||
// resized. This function is only used on Windows and Linux.
|
||||
///
|
||||
void(CEF_CALLBACK* notify_move_or_resize_started)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns the maximum rate in frames per second (fps) that
|
||||
// cef_render_handler_t:: OnPaint will be called for a windowless browser. The
|
||||
// actual fps may be lower if the browser cannot generate frames at the
|
||||
// requested rate. The minimum value is 1 and the maximum value is 60 (default
|
||||
// 30). This function can only be called on the UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* get_windowless_frame_rate)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Set the maximum rate in frames per second (fps) that cef_render_handler_t::
|
||||
// OnPaint will be called for a windowless browser. The actual fps may be
|
||||
// lower if the browser cannot generate frames at the requested rate. The
|
||||
// minimum value is 1 and the maximum value is 60 (default 30). Can also be
|
||||
// set at browser creation via cef_browser_tSettings.windowless_frame_rate.
|
||||
///
|
||||
void(CEF_CALLBACK* set_windowless_frame_rate)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int frame_rate);
|
||||
|
||||
///
|
||||
// Begins a new composition or updates the existing composition. Blink has a
|
||||
// special node (a composition node) that allows the input function to change
|
||||
// text without affecting other DOM nodes. |text| is the optional text that
|
||||
// will be inserted into the composition node. |underlines| is an optional set
|
||||
// of ranges that will be underlined in the resulting text.
|
||||
// |replacement_range| is an optional range of the existing text that will be
|
||||
// replaced. |selection_range| is an optional range of the resulting text that
|
||||
// will be selected after insertion or replacement. The |replacement_range|
|
||||
// value is only used on OS X.
|
||||
//
|
||||
// This function may be called multiple times as the composition changes. When
|
||||
// the client is done making changes the composition should either be canceled
|
||||
// or completed. To cancel the composition call ImeCancelComposition. To
|
||||
// complete the composition call either ImeCommitText or
|
||||
// ImeFinishComposingText. Completion is usually signaled when:
|
||||
// A. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR
|
||||
// flag (on Windows), or;
|
||||
// B. The client receives a "commit" signal of GtkIMContext (on Linux), or;
|
||||
// C. insertText of NSTextInput is called (on Mac).
|
||||
//
|
||||
// This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_set_composition)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const cef_string_t* text,
|
||||
size_t underlinesCount,
|
||||
cef_composition_underline_t const* underlines,
|
||||
const cef_range_t* replacement_range,
|
||||
const cef_range_t* selection_range);
|
||||
|
||||
///
|
||||
// Completes the existing composition by optionally inserting the specified
|
||||
// |text| into the composition node. |replacement_range| is an optional range
|
||||
// of the existing text that will be replaced. |relative_cursor_pos| is where
|
||||
// the cursor will be positioned relative to the current cursor position. See
|
||||
// comments on ImeSetComposition for usage. The |replacement_range| and
|
||||
// |relative_cursor_pos| values are only used on OS X. This function is only
|
||||
// used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_commit_text)(struct _cef_browser_host_t* self,
|
||||
const cef_string_t* text,
|
||||
const cef_range_t* replacement_range,
|
||||
int relative_cursor_pos);
|
||||
|
||||
///
|
||||
// Completes the existing composition by applying the current composition node
|
||||
// contents. If |keep_selection| is false (0) the current selection, if any,
|
||||
// will be discarded. See comments on ImeSetComposition for usage. This
|
||||
// function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_finish_composing_text)(
|
||||
struct _cef_browser_host_t* self,
|
||||
int keep_selection);
|
||||
|
||||
///
|
||||
// Cancels the existing composition and discards the composition node contents
|
||||
// without applying them. See comments on ImeSetComposition for usage. This
|
||||
// function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* ime_cancel_composition)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Call this function when the user drags the mouse into the web view (before
|
||||
// calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data|
|
||||
// should not contain file contents as this type of data is not allowed to be
|
||||
// dragged into the web view. File contents can be removed using
|
||||
// cef_drag_data_t::ResetFileContents (for example, if |drag_data| comes from
|
||||
// cef_render_handler_t::StartDragging). This function is only used when
|
||||
// window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drag_enter)(
|
||||
struct _cef_browser_host_t* self,
|
||||
struct _cef_drag_data_t* drag_data,
|
||||
const struct _cef_mouse_event_t* event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
|
||||
///
|
||||
// Call this function each time the mouse is moved across the web view during
|
||||
// a drag operation (after calling DragTargetDragEnter and before calling
|
||||
// DragTargetDragLeave/DragTargetDrop). This function is only used when window
|
||||
// rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drag_over)(
|
||||
struct _cef_browser_host_t* self,
|
||||
const struct _cef_mouse_event_t* event,
|
||||
cef_drag_operations_mask_t allowed_ops);
|
||||
|
||||
///
|
||||
// Call this function when the user drags the mouse out of the web view (after
|
||||
// calling DragTargetDragEnter). This function is only used when window
|
||||
// rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drag_leave)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Call this function when the user completes the drag operation by dropping
|
||||
// the object onto the web view (after calling DragTargetDragEnter). The
|
||||
// object being dropped is |drag_data|, given as an argument to the previous
|
||||
// DragTargetDragEnter call. This function is only used when window rendering
|
||||
// is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_target_drop)(struct _cef_browser_host_t* self,
|
||||
const struct _cef_mouse_event_t* event);
|
||||
|
||||
///
|
||||
// Call this function when the drag operation started by a
|
||||
// cef_render_handler_t::StartDragging call has ended either in a drop or by
|
||||
// being cancelled. |x| and |y| are mouse coordinates relative to the upper-
|
||||
// left corner of the view. If the web view is both the drag source and the
|
||||
// drag target then all DragTarget* functions should be called before
|
||||
// DragSource* mthods. This function is only used when window rendering is
|
||||
// disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_source_ended_at)(struct _cef_browser_host_t* self,
|
||||
int x,
|
||||
int y,
|
||||
cef_drag_operations_mask_t op);
|
||||
|
||||
///
|
||||
// Call this function when the drag operation started by a
|
||||
// cef_render_handler_t::StartDragging call has completed. This function may
|
||||
// be called immediately without first calling DragSourceEndedAt to cancel a
|
||||
// drag operation. If the web view is both the drag source and the drag target
|
||||
// then all DragTarget* functions should be called before DragSource* mthods.
|
||||
// This function is only used when window rendering is disabled.
|
||||
///
|
||||
void(CEF_CALLBACK* drag_source_system_drag_ended)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns the current visible navigation entry for this browser. This
|
||||
// function can only be called on the UI thread.
|
||||
///
|
||||
struct _cef_navigation_entry_t*(CEF_CALLBACK* get_visible_navigation_entry)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Set accessibility state for all frames. |accessibility_state| may be
|
||||
// default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT
|
||||
// then accessibility will be disabled by default and the state may be further
|
||||
// controlled with the "force-renderer-accessibility" and "disable-renderer-
|
||||
// accessibility" command-line switches. If |accessibility_state| is
|
||||
// STATE_ENABLED then accessibility will be enabled. If |accessibility_state|
|
||||
// is STATE_DISABLED then accessibility will be completely disabled.
|
||||
//
|
||||
// For windowed browsers accessibility will be enabled in Complete mode (which
|
||||
// corresponds to kAccessibilityModeComplete in Chromium). In this mode all
|
||||
// platform accessibility objects will be created and managed by Chromium's
|
||||
// internal implementation. The client needs only to detect the screen reader
|
||||
// and call this function appropriately. For example, on macOS the client can
|
||||
// handle the @"AXEnhancedUserStructure" accessibility attribute to detect
|
||||
// VoiceOver state changes and on Windows the client can handle WM_GETOBJECT
|
||||
// with OBJID_CLIENT to detect accessibility readers.
|
||||
//
|
||||
// For windowless browsers accessibility will be enabled in TreeOnly mode
|
||||
// (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In
|
||||
// this mode renderer accessibility is enabled, the full tree is computed, and
|
||||
// events are passed to CefAccessibiltyHandler, but platform accessibility
|
||||
// objects are not created. The client may implement platform accessibility
|
||||
// objects using CefAccessibiltyHandler callbacks if desired.
|
||||
///
|
||||
void(CEF_CALLBACK* set_accessibility_state)(struct _cef_browser_host_t* self,
|
||||
cef_state_t accessibility_state);
|
||||
|
||||
///
|
||||
// Enable notifications of auto resize via
|
||||
// cef_display_handler_t::OnAutoResize. Notifications are disabled by default.
|
||||
// |min_size| and |max_size| define the range of allowed sizes.
|
||||
///
|
||||
void(CEF_CALLBACK* set_auto_resize_enabled)(struct _cef_browser_host_t* self,
|
||||
int enabled,
|
||||
const cef_size_t* min_size,
|
||||
const cef_size_t* max_size);
|
||||
|
||||
///
|
||||
// Returns the extension hosted in this browser or NULL if no extension is
|
||||
// hosted. See cef_request_context_t::LoadExtension for details.
|
||||
///
|
||||
struct _cef_extension_t*(CEF_CALLBACK* get_extension)(
|
||||
struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Returns true (1) if this browser is hosting an extension background script.
|
||||
// Background hosts do not have a window and are not displayable. See
|
||||
// cef_request_context_t::LoadExtension for details.
|
||||
///
|
||||
int(CEF_CALLBACK* is_background_host)(struct _cef_browser_host_t* self);
|
||||
|
||||
///
|
||||
// Set whether the browser's audio is muted.
|
||||
///
|
||||
void(CEF_CALLBACK* set_audio_muted)(struct _cef_browser_host_t* self,
|
||||
int mute);
|
||||
|
||||
///
|
||||
// Returns true (1) if the browser's audio is muted. This function can only
|
||||
// be called on the UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self);
|
||||
} cef_browser_host_t;
|
||||
|
||||
///
|
||||
// Create a new browser using the window parameters specified by |windowInfo|.
|
||||
// All values will be copied internally and the actual window (if any) will be
|
||||
// created on the UI thread. If |request_context| is NULL the global request
|
||||
// context will be used. This function can be called on any browser process
|
||||
// thread and will not block. The optional |extra_info| parameter provides an
|
||||
// opportunity to specify extra information specific to the created browser that
|
||||
// will be passed to cef_render_process_handler_t::on_browser_created() in the
|
||||
// render process.
|
||||
///
|
||||
CEF_EXPORT int cef_browser_host_create_browser(
|
||||
const cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t* client,
|
||||
const cef_string_t* url,
|
||||
const struct _cef_browser_settings_t* settings,
|
||||
struct _cef_dictionary_value_t* extra_info,
|
||||
struct _cef_request_context_t* request_context);
|
||||
|
||||
///
|
||||
// Create a new browser using the window parameters specified by |windowInfo|.
|
||||
// If |request_context| is NULL the global request context will be used. This
|
||||
// function can only be called on the browser process UI thread. The optional
|
||||
// |extra_info| parameter provides an opportunity to specify extra information
|
||||
// specific to the created browser that will be passed to
|
||||
// cef_render_process_handler_t::on_browser_created() in the render process.
|
||||
///
|
||||
CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
|
||||
const cef_window_info_t* windowInfo,
|
||||
struct _cef_client_t* client,
|
||||
const cef_string_t* url,
|
||||
const struct _cef_browser_settings_t* settings,
|
||||
struct _cef_dictionary_value_t* extra_info,
|
||||
struct _cef_request_context_t* request_context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
113
Thirdparty/libcef/include/capi/cef_browser_process_handler_capi.h
vendored
Normal file
113
Thirdparty/libcef/include/capi/cef_browser_process_handler_capi.h
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
// Copyright (c) 2022 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 was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=ad0a78715daff99c1ec987800b7e5d62196e7100$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_client_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
// Structure used to implement browser process callbacks. The functions of this
|
||||
// structure will be called on the browser process main thread unless otherwise
|
||||
// indicated.
|
||||
///
|
||||
typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
// Called on the browser process UI thread immediately after the CEF context
|
||||
// has been initialized.
|
||||
///
|
||||
void(CEF_CALLBACK* on_context_initialized)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
|
||||
///
|
||||
// Called before a child process is launched. Will be called on the browser
|
||||
// process UI thread when launching a render process and on the browser
|
||||
// process IO thread when launching a GPU process. Provides an opportunity to
|
||||
// modify the child process command line. Do not keep a reference to
|
||||
// |command_line| outside of this function.
|
||||
///
|
||||
void(CEF_CALLBACK* on_before_child_process_launch)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
struct _cef_command_line_t* command_line);
|
||||
|
||||
///
|
||||
// Called from any thread when work has been scheduled for the browser process
|
||||
// main (UI) thread. This callback is used in combination with CefSettings.
|
||||
// external_message_pump and cef_do_message_loop_work() in cases where the CEF
|
||||
// message loop must be integrated into an existing application message loop
|
||||
// (see additional comments and warnings on CefDoMessageLoopWork). This
|
||||
// callback should schedule a cef_do_message_loop_work() call to happen on the
|
||||
// main (UI) thread. |delay_ms| is the requested delay in milliseconds. If
|
||||
// |delay_ms| is <= 0 then the call should happen reasonably soon. If
|
||||
// |delay_ms| is > 0 then the call should be scheduled to happen after the
|
||||
// specified delay and any currently pending scheduled call should be
|
||||
// cancelled.
|
||||
///
|
||||
void(CEF_CALLBACK* on_schedule_message_pump_work)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
int64 delay_ms);
|
||||
|
||||
///
|
||||
// Return the default client for use with a newly created browser window. If
|
||||
// null is returned the browser will be unmanaged (no callbacks will be
|
||||
// executed for that browser) and application shutdown will be blocked until
|
||||
// the browser window is closed manually. This function is currently only used
|
||||
// with the chrome runtime.
|
||||
///
|
||||
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
|
||||
struct _cef_browser_process_handler_t* self);
|
||||
} cef_browser_process_handler_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user