mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c4ba9f2d8 | ||
|
|
2b5c3a7185 | ||
|
|
37a29e36b3 | ||
|
|
150a22a49c | ||
|
|
16e49fb8af | ||
|
|
c3a7e2cdec | ||
|
|
162e9a9190 | ||
|
|
15d09c7592 | ||
|
|
aab55437e2 | ||
|
|
58b5209269 | ||
|
|
dfdcf403a8 | ||
|
|
aead0852b3 | ||
|
|
4a88e6738a | ||
|
|
c7e062b773 | ||
|
|
14084aaf41 | ||
|
|
d811450a32 | ||
|
|
71d9d35fc3 | ||
|
|
3e763188b5 | ||
|
|
cb3e183d78 | ||
|
|
8949b13120 | ||
|
|
80e473edf2 | ||
|
|
87ce1497b9 | ||
|
|
e33dd88cd4 | ||
|
|
67bb846748 | ||
|
|
1dac96f3e2 | ||
|
|
0974f72478 | ||
|
|
1e15b76262 | ||
|
|
9f1bd36e74 | ||
|
|
a9f5c8bfb2 | ||
|
|
d538cf683e | ||
|
|
a99ebd38a0 | ||
|
|
39b9b98b5c | ||
|
|
3bd9c18309 | ||
|
|
e0a22fe9fa | ||
|
|
cc24f60779 | ||
|
|
5edb3bf62d | ||
|
|
e90b99171b | ||
|
|
4cf33c94e8 | ||
|
|
8a0e29ecf6 | ||
|
|
eac4425c21 | ||
|
|
6b6edcc19c | ||
|
|
06ebf2b0a4 | ||
|
|
6560d03ab0 | ||
|
|
7686007c1a | ||
|
|
da265f6a2d | ||
|
|
39e62853cc | ||
|
|
9bfcca74f2 | ||
|
|
7641240f2e | ||
|
|
2627733710 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -35,7 +35,6 @@
|
|||||||
.metadata
|
.metadata
|
||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
.vscode
|
|
||||||
# Settings directory for eclipse
|
# Settings directory for eclipse
|
||||||
/.settings
|
/.settings
|
||||||
.checkstyle
|
.checkstyle
|
||||||
@@ -43,14 +42,11 @@ cscope.*
|
|||||||
Session.vim
|
Session.vim
|
||||||
tags
|
tags
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
# IDE's
|
|
||||||
.vs/
|
|
||||||
.kdev4/
|
|
||||||
*.kdev4
|
|
||||||
# CEF generated directories
|
# CEF generated directories
|
||||||
/binary_distrib
|
/binary_distrib
|
||||||
/docs
|
/docs
|
||||||
# CEF generated files
|
# CEF generated files
|
||||||
/include/cef_config.h
|
/include/cef_pack_resources.h
|
||||||
|
/include/cef_pack_strings.h
|
||||||
/include/cef_version.h
|
/include/cef_version.h
|
||||||
.ccls-cache/
|
/patch/patch_state.h
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
# Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights
|
|
||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
|
||||||
# can be found in the LICENSE file
|
|
||||||
|
|
||||||
# Configuration settings for tools/fix_style.py
|
|
||||||
{
|
|
||||||
# Directories containing these path components will be ignored.
|
|
||||||
'ignore_directories': ['yapf'],
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
[style]
|
|
||||||
based_on_style = chromium
|
|
||||||
10
AUTHORS.txt
10
AUTHORS.txt
@@ -1,8 +1,6 @@
|
|||||||
# This file is an addendum to the Chromium AUTHORS file. It lists authors
|
# This file is an addendum to the Chromium AUTHORS file.
|
||||||
# through March 16, 2015 when Git was introduced for source code management.
|
# Names should be added to this file like so:
|
||||||
# A list of additional authors added after that date can be found by executing
|
# Name or Organization <email address>
|
||||||
# this command on a local Git checkout:
|
|
||||||
# git log --all --format="%aN <%aE>" | sort -u
|
|
||||||
|
|
||||||
Marshall Greenblatt <magreenblatt@gmail.com>
|
Marshall Greenblatt <magreenblatt@gmail.com>
|
||||||
Jamie Kirkpatrick <jkp@spotify.com>
|
Jamie Kirkpatrick <jkp@spotify.com>
|
||||||
@@ -31,5 +29,3 @@ Felix Bruns <felixbruns@spotify.com>
|
|||||||
YuTeh Shen <shenyute@gmail.com>
|
YuTeh Shen <shenyute@gmail.com>
|
||||||
Andrei Kurushin <ajax16384@gmail.com>
|
Andrei Kurushin <ajax16384@gmail.com>
|
||||||
Gonzo Berman <gberman@factset.com>
|
Gonzo Berman <gberman@factset.com>
|
||||||
Jakub Trzebiatowski <kuba.trzebiatowski@gmail.com>
|
|
||||||
Nishant Kaushik <nishantk@adobe.com>
|
|
||||||
|
|||||||
@@ -7,6 +7,5 @@
|
|||||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||||
|
|
||||||
{
|
{
|
||||||
'chromium_checkout': 'refs/tags/95.0.4638.69',
|
'chromium_checkout': 'refs/tags/53.0.2785.116',
|
||||||
'depot_tools_checkout': 'eff810e93d'
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
# The Chromium Embedded Framework (CEF) project is built on top of the Chromium
|
|
||||||
# project source tree. When updating Chromium to a new version certain files and
|
|
||||||
# patterns should be observed for changes. If changes are detected then the CEF
|
|
||||||
# source code or patch files will likely need to be updated.
|
|
||||||
#
|
|
||||||
# Add `--log-chromium-changes` to the automate-git.py command-line to output
|
|
||||||
# the following files in the <download-dir>:
|
|
||||||
#
|
|
||||||
# * chromium_update_changes.diff
|
|
||||||
# Files in the chromium/src directory that have changed. See the 'files'
|
|
||||||
# section below.
|
|
||||||
#
|
|
||||||
# * chromium_update_patterns.txt
|
|
||||||
# Files in the chromium/src directory that contain invalid/unexpected
|
|
||||||
# patterns. See the 'patterns' section below. Failure of this step is
|
|
||||||
# considered a fatal error during update.
|
|
||||||
#
|
|
||||||
# * chromium_update_patches.txt
|
|
||||||
# Output from attempting to update existing Chromium patch files using the
|
|
||||||
# patch_updater.py tool. Failure of this step is considered a fatal error
|
|
||||||
# during update.
|
|
||||||
#
|
|
||||||
# For complete update instructions see:
|
|
||||||
# https://bitbucket.org/chromiumembedded/cef/wiki/ChromiumUpdate.md
|
|
||||||
|
|
||||||
{
|
|
||||||
# Files in the chromium/src directory that should be evaluated for changes.
|
|
||||||
# Similar changes may need to be applied to the CEF source code.
|
|
||||||
'files': [
|
|
||||||
'chrome/browser/browser_process.h',
|
|
||||||
'chrome/browser/extensions/api/tabs/tabs_api.*',
|
|
||||||
'chrome/browser/extensions/chrome_component_extension_resource_manager.*',
|
|
||||||
'chrome/browser/extensions/chrome_extension_web_contents_observer.*',
|
|
||||||
'chrome/browser/extensions/component_loader.*',
|
|
||||||
'chrome/browser/extensions/extension_service.*',
|
|
||||||
'chrome/browser/printing/print_view_manager*',
|
|
||||||
'chrome/browser/printing/printing_message_filter*',
|
|
||||||
'chrome/browser/profiles/profile.h',
|
|
||||||
'chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.*',
|
|
||||||
'chrome/common/extensions/api/*_features.json',
|
|
||||||
'chrome/renderer/chrome_content_renderer_client.*',
|
|
||||||
'chrome/renderer/extensions/chrome_extensions_renderer_client.*',
|
|
||||||
'content/browser/renderer_host/render_widget_host_view_base.*',
|
|
||||||
'content/public/browser/content_browser_client.*',
|
|
||||||
'content/public/browser/render_widget_host_view.h',
|
|
||||||
'content/public/browser/storage_partition.h',
|
|
||||||
'content/public/browser/web_contents_delegate.h',
|
|
||||||
'content/public/common/content_features.cc',
|
|
||||||
'content/shell/BUILD.gn',
|
|
||||||
'content/shell/app/*',
|
|
||||||
'content/shell/browser/shell_*',
|
|
||||||
'content/shell/browser/renderer_host/shell_*',
|
|
||||||
'content/shell/common/shell_*',
|
|
||||||
'content/shell/gpu/shell_*',
|
|
||||||
'content/shell/renderer/shell_*',
|
|
||||||
'content/shell/utility/shell_*',
|
|
||||||
'extensions/shell/*',
|
|
||||||
'net/base/features.cc',
|
|
||||||
'net/cookies/cookie_store.h',
|
|
||||||
'services/network/public/cpp/features.cc',
|
|
||||||
'ui/base/ui_base_features.cc',
|
|
||||||
],
|
|
||||||
# Patterns that should not be found in the chromium/src directory after
|
|
||||||
# applying patch files.
|
|
||||||
'patterns': [],
|
|
||||||
}
|
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
# CMake-generated project formats that have been tested with this CEF binary
|
# CMake-generated project formats that have been tested with this CEF binary
|
||||||
# distribution include:
|
# distribution include:
|
||||||
#
|
#
|
||||||
# Linux: Ninja, GCC 7.5.0+, Unix Makefiles
|
# Linux: Ninja, Unix Makefiles
|
||||||
# MacOS: Ninja, Xcode 12.2 to 13.0
|
# Mac OS X: Ninja, Xcode 5+
|
||||||
# Windows: Ninja, Visual Studio 2019+
|
# Windows: Ninja, Visual Studio 2010+
|
||||||
#
|
#
|
||||||
# Ninja is a cross-platform open-source tool for running fast builds using
|
# Ninja is a cross-platform open-source tool for running fast builds using
|
||||||
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
|
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
|
||||||
@@ -27,7 +27,8 @@
|
|||||||
# CMakeLists.txt Bootstrap that sets up the CMake environment.
|
# CMakeLists.txt Bootstrap that sets up the CMake environment.
|
||||||
# cmake/*.cmake CEF configuration files shared by all targets.
|
# cmake/*.cmake CEF configuration files shared by all targets.
|
||||||
# libcef_dll/CMakeLists.txt Defines the libcef_dll_wrapper target.
|
# libcef_dll/CMakeLists.txt Defines the libcef_dll_wrapper target.
|
||||||
# tests/*/CMakeLists.txt Defines the test application target.
|
# cefclient/CMakeLists.txt Defines the cefclient target.
|
||||||
|
# cefsimple/CMakeLists.txt Defines the cefsimple target.
|
||||||
#
|
#
|
||||||
# See the "TODO:" comments below for guidance on how to integrate this CEF
|
# See the "TODO:" comments below for guidance on how to integrate this CEF
|
||||||
# binary distribution into a new or existing CMake project.
|
# binary distribution into a new or existing CMake project.
|
||||||
@@ -36,27 +37,25 @@
|
|||||||
#
|
#
|
||||||
# The below requirements must be met to build this CEF binary distribution.
|
# The below requirements must be met to build this CEF binary distribution.
|
||||||
#
|
#
|
||||||
# - CMake version 3.19 or newer.
|
# - CMake version 2.8.12.1 or newer.
|
||||||
#
|
#
|
||||||
# - Linux requirements:
|
# - Linux requirements:
|
||||||
# Currently supported distributions include Debian 10 (Buster), Ubuntu 18
|
# Currently supported distributions include Debian Wheezy, Ubuntu Precise, and
|
||||||
# (Bionic Beaver), and related. Ubuntu 18.04 64-bit with GCC 7.5.0+ is
|
# related. Ubuntu 14.04 64-bit is recommended. Newer versions will likely also
|
||||||
# recommended. Newer versions will likely also work but may not have been
|
# work but may not have been tested.
|
||||||
# tested.
|
|
||||||
# Required packages include:
|
# Required packages include:
|
||||||
# build-essential
|
# build-essential
|
||||||
# libgtk3.0-dev (required by the cefclient target only)
|
# libgtk2.0-dev (required by the cefclient target only)
|
||||||
|
# libgtkglext1-dev (required by the cefclient target only)
|
||||||
#
|
#
|
||||||
# - MacOS requirements:
|
# - Mac OS X requirements:
|
||||||
# Xcode 12.2 to 13.0 building on MacOS 10.15.4 (Catalina) or newer. Only
|
# Xcode 5 or newer building on Mac OS X 10.9 (Mavericks) or newer. Xcode 7.2
|
||||||
# 64-bit builds are supported. The Xcode command-line tools must also be
|
# and OS X 10.11 are recommended. The Xcode command-line tools must also be
|
||||||
# installed. Newer Xcode versions may not have been been tested and are not
|
# installed. Only 64-bit builds are supported on OS X.
|
||||||
# recommended.
|
|
||||||
#
|
#
|
||||||
# - Windows requirements:
|
# - Windows requirements:
|
||||||
# Visual Studio 2019 or newer building on Windows 7 or newer. Windows 10
|
# Visual Studio 2010 or newer building on Windows 7 or newer. Visual Studio
|
||||||
# 64-bit is recommended. Newer versions will likely also work but may not have
|
# 2015 Update 2 and Windows 10 64-bit are recommended.
|
||||||
# been tested.
|
|
||||||
#
|
#
|
||||||
# BUILD EXAMPLES
|
# BUILD EXAMPLES
|
||||||
#
|
#
|
||||||
@@ -77,7 +76,7 @@
|
|||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
#
|
||||||
# To perform a MacOS build using a 64-bit CEF binary distribution:
|
# To perform a Mac OS X build using a 64-bit CEF binary distribution:
|
||||||
# Using the Xcode IDE:
|
# Using the Xcode IDE:
|
||||||
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
|
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
|
||||||
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
||||||
@@ -86,54 +85,33 @@
|
|||||||
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
#
|
||||||
# To perform a MacOS build using an ARM64 CEF binary distribution:
|
|
||||||
# Using the Xcode IDE:
|
|
||||||
# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" ..
|
|
||||||
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
|
||||||
#
|
|
||||||
# Using Ninja:
|
|
||||||
# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug ..
|
|
||||||
# > ninja cefclient cefsimple
|
|
||||||
#
|
|
||||||
# To perform a Windows build using a 32-bit CEF binary distribution:
|
# To perform a Windows build using a 32-bit CEF binary distribution:
|
||||||
# Using the Visual Studio 2019 IDE:
|
# Using the Visual Studio 2015 IDE:
|
||||||
# > cmake -G "Visual Studio 16" -A Win32 ..
|
# > cmake -G "Visual Studio 14" ..
|
||||||
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
||||||
#
|
#
|
||||||
# Using Ninja with Visual Studio 2019 command-line tools:
|
# Using Ninja with Visual Studio 2015 command-line tools:
|
||||||
# (this path may be different depending on your Visual Studio installation)
|
# (this path may be different depending on your Visual Studio installation)
|
||||||
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
|
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
|
||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
#
|
||||||
# To perform a Windows build using a 64-bit CEF binary distribution:
|
# To perform a Windows build using a 64-bit CEF binary distribution:
|
||||||
# Using the Visual Studio 2019 IDE:
|
# Using the Visual Studio 2015 IDE:
|
||||||
# > cmake -G "Visual Studio 16" -A x64 ..
|
# > cmake -G "Visual Studio 14 Win64" ..
|
||||||
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
||||||
#
|
#
|
||||||
# Using Ninja with Visual Studio 2019 command-line tools:
|
# Using Ninja with Visual Studio 2015 command-line tools:
|
||||||
# (this path may be different depending on your Visual Studio installation)
|
# (this path may be different depending on your Visual Studio installation)
|
||||||
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
|
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
|
||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
|
||||||
# To perform a Windows build using an ARM64 CEF binary distribution:
|
|
||||||
# Using the Visual Studio 2019 IDE:
|
|
||||||
# > cmake -G "Visual Studio 16" -A arm64 ..
|
|
||||||
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
|
||||||
#
|
|
||||||
# Using Ninja with Visual Studio 2019 command-line tools:
|
|
||||||
# (this path may be different depending on your Visual Studio installation)
|
|
||||||
# > "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsamd64_arm64.bat"
|
|
||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
|
||||||
# > ninja cefsimple
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Global setup.
|
# Global setup.
|
||||||
#
|
#
|
||||||
|
|
||||||
# For VS2019 and Xcode 12+ support.
|
cmake_minimum_required(VERSION 2.8.12.1)
|
||||||
cmake_minimum_required(VERSION 3.19)
|
|
||||||
|
|
||||||
# Only generate Debug and Release configuration types.
|
# Only generate Debug and Release configuration types.
|
||||||
set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
||||||
@@ -222,15 +200,8 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
|
|||||||
# Include application targets.
|
# Include application targets.
|
||||||
# Comes from the <target>/CMakeLists.txt file in the current directory.
|
# Comes from the <target>/CMakeLists.txt file in the current directory.
|
||||||
# TODO: Change these lines to match your project target when you copy this file.
|
# TODO: Change these lines to match your project target when you copy this file.
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
add_subdirectory(cefclient)
|
||||||
add_subdirectory(tests/cefsimple)
|
add_subdirectory(cefsimple)
|
||||||
add_subdirectory(tests/gtest)
|
|
||||||
add_subdirectory(tests/ceftests)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/cefclient")
|
|
||||||
add_subdirectory(tests/cefclient)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Display configuration settings.
|
# Display configuration settings.
|
||||||
PRINT_CEF_CONFIG()
|
PRINT_CEF_CONFIG()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2008-2020 Marshall A. Greenblatt. Portions Copyright (c)
|
// Copyright (c) 2008-2014 Marshall A. Greenblatt. Portions Copyright (c)
|
||||||
// 2006-2009 Google Inc. All rights reserved.
|
// 2006-2009 Google Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -7,11 +7,10 @@ The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromi
|
|||||||
* General Usage - https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage
|
* General Usage - https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage
|
||||||
* Master Build Quick-Start - https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart
|
* Master Build Quick-Start - https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart
|
||||||
* Branches and Building - https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
* Branches and Building - https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||||
* Announcements - https://groups.google.com/forum/#!forum/cef-announce
|
|
||||||
* Support Forum - http://www.magpcss.org/ceforum/
|
* Support Forum - http://www.magpcss.org/ceforum/
|
||||||
* CEF1 C++ API Docs - http://magpcss.org/ceforum/apidocs/
|
* CEF1 C++ API Docs - http://magpcss.org/ceforum/apidocs/
|
||||||
* CEF3 C++ API Docs - http://magpcss.org/ceforum/apidocs3/
|
* CEF3 C++ API Docs - http://magpcss.org/ceforum/apidocs3/
|
||||||
* Downloads - https://cef-builds.spotifycdn.com/index.html
|
* Downloads - http://www.magpcss.net/cef_downloads/ and http://cefbuilds.com
|
||||||
* Donations - http://www.magpcss.org/ceforum/donate.php
|
* Donations - http://www.magpcss.org/ceforum/donate.php
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
@@ -33,7 +32,7 @@ Users new to CEF development should start by reading the [Tutorial](https://bitb
|
|||||||
|
|
||||||
# Binary Distributions
|
# Binary Distributions
|
||||||
|
|
||||||
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](https://cef-builds.spotifycdn.com/index.html) page. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
|
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](http://www.magpcss.net/cef_downloads/) page and http://cefbuilds.com. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
|
||||||
|
|
||||||
# Source Distributions
|
# Source Distributions
|
||||||
|
|
||||||
@@ -43,14 +42,12 @@ The CEF project is an extension of the Chromium project. CEF maintains developme
|
|||||||
|
|
||||||
The base CEF framework includes support for the C and C++ programming languages. Thanks to the hard work of external maintainers CEF can integrate with a number of other programming languages and frameworks. These external projects are not maintained by CEF so please contact the respective project maintainer if you have any questions or issues.
|
The base CEF framework includes support for the C and C++ programming languages. Thanks to the hard work of external maintainers CEF can integrate with a number of other programming languages and frameworks. These external projects are not maintained by CEF so please contact the respective project maintainer if you have any questions or issues.
|
||||||
|
|
||||||
* .Net (CEF3) - https://github.com/cefsharp/CefSharp
|
* .Net - https://github.com/chillitom/CefSharp
|
||||||
* .Net (CEF1) - https://bitbucket.org/fddima/cefglue
|
* .Net (CEF1) - https://bitbucket.org/fddima/cefglue
|
||||||
* .Net/Mono (CEF3) - https://bitbucket.org/xilium/xilium.cefglue
|
* .Net/Mono (CEF3) - https://bitbucket.org/xilium/xilium.cefglue
|
||||||
* .Net (CEF3) - https://bitbucket.org/chromiumfx/chromiumfx
|
* .Net (CEF3) - https://bitbucket.org/chromiumfx/chromiumfx
|
||||||
* Delphi (CEF1) - http://code.google.com/p/delphichromiumembedded/
|
* Delphi (CEF1) - http://code.google.com/p/delphichromiumembedded/
|
||||||
* Delphi (CEF3) - https://github.com/hgourvest/dcef3
|
* Delphi (CEF3) - http://code.google.com/p/dcef3/
|
||||||
* Delphi (CEF3) - https://github.com/salvadordf/CEF4Delphi
|
|
||||||
* Go - https://github.com/richardwilkes/cef
|
|
||||||
* Go - https://github.com/CzarekTomczak/cef2go
|
* Go - https://github.com/CzarekTomczak/cef2go
|
||||||
* Java - https://bitbucket.org/chromiumembedded/java-cef
|
* Java - https://bitbucket.org/chromiumembedded/java-cef
|
||||||
* Java - http://code.google.com/p/javacef/
|
* Java - http://code.google.com/p/javacef/
|
||||||
|
|||||||
34
cef.gypi
Normal file
34
cef.gypi
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
{
|
||||||
|
'variables': {
|
||||||
|
# Don't use the chrome style plugin with CEF.
|
||||||
|
'clang_use_chrome_plugins': 0,
|
||||||
|
# Set ENABLE_PRINTING=1 ENABLE_BASIC_PRINTING=1.
|
||||||
|
'enable_basic_printing': 1,
|
||||||
|
'enable_print_preview': 0,
|
||||||
|
# Enable support for Widevine CDM.
|
||||||
|
'enable_widevine': 1,
|
||||||
|
# Disable support for plugin installation.
|
||||||
|
'enable_plugin_installation': 0,
|
||||||
|
'conditions': [
|
||||||
|
# Directory for CEF source files.
|
||||||
|
[ 'OS=="win"', {
|
||||||
|
'cef_directory' : '<!(echo %CEF_DIRECTORY%)',
|
||||||
|
}, { # OS!="win"
|
||||||
|
'cef_directory' : '<!(echo $CEF_DIRECTORY)',
|
||||||
|
}],
|
||||||
|
[ 'OS=="mac"', {
|
||||||
|
# Strip symbols and create dSYM files for the Release target.
|
||||||
|
'mac_strip_release': 1,
|
||||||
|
}],
|
||||||
|
['os_posix==1 and OS!="mac" and OS!="android"', {
|
||||||
|
# Disable theme support on Linux so we don't need to implement
|
||||||
|
# ThemeService[Factory] classes.
|
||||||
|
'enable_themes': 0,
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
254
cef_paths.gypi
254
cef_paths.gypi
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2021 The Chromium Embedded Framework Authors. All rights
|
# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
@@ -8,15 +8,11 @@
|
|||||||
# by hand. See the translator.README.txt file in the tools directory for
|
# by hand. See the translator.README.txt file in the tools directory for
|
||||||
# more information.
|
# more information.
|
||||||
#
|
#
|
||||||
# $hash=42b9ae0a0ee20489699d69dcdbcbf8ad3265f821$
|
|
||||||
#
|
|
||||||
|
|
||||||
{
|
{
|
||||||
'variables': {
|
'variables': {
|
||||||
'autogen_cpp_includes': [
|
'autogen_cpp_includes': [
|
||||||
'include/cef_accessibility_handler.h',
|
|
||||||
'include/cef_app.h',
|
'include/cef_app.h',
|
||||||
'include/cef_audio_handler.h',
|
|
||||||
'include/cef_auth_callback.h',
|
'include/cef_auth_callback.h',
|
||||||
'include/cef_browser.h',
|
'include/cef_browser.h',
|
||||||
'include/cef_browser_process_handler.h',
|
'include/cef_browser_process_handler.h',
|
||||||
@@ -25,8 +21,6 @@
|
|||||||
'include/cef_command_line.h',
|
'include/cef_command_line.h',
|
||||||
'include/cef_context_menu_handler.h',
|
'include/cef_context_menu_handler.h',
|
||||||
'include/cef_cookie.h',
|
'include/cef_cookie.h',
|
||||||
'include/cef_crash_util.h',
|
|
||||||
'include/cef_devtools_message_observer.h',
|
|
||||||
'include/cef_dialog_handler.h',
|
'include/cef_dialog_handler.h',
|
||||||
'include/cef_display_handler.h',
|
'include/cef_display_handler.h',
|
||||||
'include/cef_dom.h',
|
'include/cef_dom.h',
|
||||||
@@ -34,20 +28,16 @@
|
|||||||
'include/cef_download_item.h',
|
'include/cef_download_item.h',
|
||||||
'include/cef_drag_data.h',
|
'include/cef_drag_data.h',
|
||||||
'include/cef_drag_handler.h',
|
'include/cef_drag_handler.h',
|
||||||
'include/cef_extension.h',
|
|
||||||
'include/cef_extension_handler.h',
|
|
||||||
'include/cef_file_util.h',
|
|
||||||
'include/cef_find_handler.h',
|
'include/cef_find_handler.h',
|
||||||
'include/cef_focus_handler.h',
|
'include/cef_focus_handler.h',
|
||||||
'include/cef_frame.h',
|
'include/cef_frame.h',
|
||||||
'include/cef_frame_handler.h',
|
'include/cef_geolocation.h',
|
||||||
'include/cef_i18n_util.h',
|
'include/cef_geolocation_handler.h',
|
||||||
'include/cef_image.h',
|
'include/cef_image.h',
|
||||||
'include/cef_jsdialog_handler.h',
|
'include/cef_jsdialog_handler.h',
|
||||||
'include/cef_keyboard_handler.h',
|
'include/cef_keyboard_handler.h',
|
||||||
'include/cef_life_span_handler.h',
|
'include/cef_life_span_handler.h',
|
||||||
'include/cef_load_handler.h',
|
'include/cef_load_handler.h',
|
||||||
'include/cef_media_router.h',
|
|
||||||
'include/cef_menu_model.h',
|
'include/cef_menu_model.h',
|
||||||
'include/cef_menu_model_delegate.h',
|
'include/cef_menu_model_delegate.h',
|
||||||
'include/cef_navigation_entry.h',
|
'include/cef_navigation_entry.h',
|
||||||
@@ -58,7 +48,6 @@
|
|||||||
'include/cef_print_settings.h',
|
'include/cef_print_settings.h',
|
||||||
'include/cef_process_message.h',
|
'include/cef_process_message.h',
|
||||||
'include/cef_process_util.h',
|
'include/cef_process_util.h',
|
||||||
'include/cef_registration.h',
|
|
||||||
'include/cef_render_handler.h',
|
'include/cef_render_handler.h',
|
||||||
'include/cef_render_process_handler.h',
|
'include/cef_render_process_handler.h',
|
||||||
'include/cef_request.h',
|
'include/cef_request.h',
|
||||||
@@ -68,27 +57,20 @@
|
|||||||
'include/cef_resource_bundle.h',
|
'include/cef_resource_bundle.h',
|
||||||
'include/cef_resource_bundle_handler.h',
|
'include/cef_resource_bundle_handler.h',
|
||||||
'include/cef_resource_handler.h',
|
'include/cef_resource_handler.h',
|
||||||
'include/cef_resource_request_handler.h',
|
|
||||||
'include/cef_response.h',
|
'include/cef_response.h',
|
||||||
'include/cef_response_filter.h',
|
'include/cef_response_filter.h',
|
||||||
'include/cef_scheme.h',
|
'include/cef_scheme.h',
|
||||||
'include/cef_server.h',
|
|
||||||
'include/cef_ssl_info.h',
|
'include/cef_ssl_info.h',
|
||||||
'include/cef_ssl_status.h',
|
|
||||||
'include/cef_stream.h',
|
'include/cef_stream.h',
|
||||||
'include/cef_string_visitor.h',
|
'include/cef_string_visitor.h',
|
||||||
'include/cef_task.h',
|
'include/cef_task.h',
|
||||||
'include/cef_thread.h',
|
|
||||||
'include/cef_trace.h',
|
'include/cef_trace.h',
|
||||||
'include/cef_urlrequest.h',
|
'include/cef_urlrequest.h',
|
||||||
'include/cef_v8.h',
|
'include/cef_v8.h',
|
||||||
'include/cef_values.h',
|
'include/cef_values.h',
|
||||||
'include/cef_waitable_event.h',
|
|
||||||
'include/cef_web_plugin.h',
|
'include/cef_web_plugin.h',
|
||||||
'include/cef_x509_certificate.h',
|
|
||||||
'include/cef_xml_reader.h',
|
'include/cef_xml_reader.h',
|
||||||
'include/cef_zip_reader.h',
|
'include/cef_zip_reader.h',
|
||||||
'include/test/cef_test_helpers.h',
|
|
||||||
'include/test/cef_translator_test.h',
|
'include/test/cef_translator_test.h',
|
||||||
'include/views/cef_box_layout.h',
|
'include/views/cef_box_layout.h',
|
||||||
'include/views/cef_browser_view.h',
|
'include/views/cef_browser_view.h',
|
||||||
@@ -101,7 +83,6 @@
|
|||||||
'include/views/cef_layout.h',
|
'include/views/cef_layout.h',
|
||||||
'include/views/cef_menu_button.h',
|
'include/views/cef_menu_button.h',
|
||||||
'include/views/cef_menu_button_delegate.h',
|
'include/views/cef_menu_button_delegate.h',
|
||||||
'include/views/cef_overlay_controller.h',
|
|
||||||
'include/views/cef_panel.h',
|
'include/views/cef_panel.h',
|
||||||
'include/views/cef_panel_delegate.h',
|
'include/views/cef_panel_delegate.h',
|
||||||
'include/views/cef_scroll_view.h',
|
'include/views/cef_scroll_view.h',
|
||||||
@@ -113,9 +94,7 @@
|
|||||||
'include/views/cef_window_delegate.h',
|
'include/views/cef_window_delegate.h',
|
||||||
],
|
],
|
||||||
'autogen_capi_includes': [
|
'autogen_capi_includes': [
|
||||||
'include/capi/cef_accessibility_handler_capi.h',
|
|
||||||
'include/capi/cef_app_capi.h',
|
'include/capi/cef_app_capi.h',
|
||||||
'include/capi/cef_audio_handler_capi.h',
|
|
||||||
'include/capi/cef_auth_callback_capi.h',
|
'include/capi/cef_auth_callback_capi.h',
|
||||||
'include/capi/cef_browser_capi.h',
|
'include/capi/cef_browser_capi.h',
|
||||||
'include/capi/cef_browser_process_handler_capi.h',
|
'include/capi/cef_browser_process_handler_capi.h',
|
||||||
@@ -124,8 +103,6 @@
|
|||||||
'include/capi/cef_command_line_capi.h',
|
'include/capi/cef_command_line_capi.h',
|
||||||
'include/capi/cef_context_menu_handler_capi.h',
|
'include/capi/cef_context_menu_handler_capi.h',
|
||||||
'include/capi/cef_cookie_capi.h',
|
'include/capi/cef_cookie_capi.h',
|
||||||
'include/capi/cef_crash_util_capi.h',
|
|
||||||
'include/capi/cef_devtools_message_observer_capi.h',
|
|
||||||
'include/capi/cef_dialog_handler_capi.h',
|
'include/capi/cef_dialog_handler_capi.h',
|
||||||
'include/capi/cef_display_handler_capi.h',
|
'include/capi/cef_display_handler_capi.h',
|
||||||
'include/capi/cef_dom_capi.h',
|
'include/capi/cef_dom_capi.h',
|
||||||
@@ -133,20 +110,16 @@
|
|||||||
'include/capi/cef_download_item_capi.h',
|
'include/capi/cef_download_item_capi.h',
|
||||||
'include/capi/cef_drag_data_capi.h',
|
'include/capi/cef_drag_data_capi.h',
|
||||||
'include/capi/cef_drag_handler_capi.h',
|
'include/capi/cef_drag_handler_capi.h',
|
||||||
'include/capi/cef_extension_capi.h',
|
|
||||||
'include/capi/cef_extension_handler_capi.h',
|
|
||||||
'include/capi/cef_file_util_capi.h',
|
|
||||||
'include/capi/cef_find_handler_capi.h',
|
'include/capi/cef_find_handler_capi.h',
|
||||||
'include/capi/cef_focus_handler_capi.h',
|
'include/capi/cef_focus_handler_capi.h',
|
||||||
'include/capi/cef_frame_capi.h',
|
'include/capi/cef_frame_capi.h',
|
||||||
'include/capi/cef_frame_handler_capi.h',
|
'include/capi/cef_geolocation_capi.h',
|
||||||
'include/capi/cef_i18n_util_capi.h',
|
'include/capi/cef_geolocation_handler_capi.h',
|
||||||
'include/capi/cef_image_capi.h',
|
'include/capi/cef_image_capi.h',
|
||||||
'include/capi/cef_jsdialog_handler_capi.h',
|
'include/capi/cef_jsdialog_handler_capi.h',
|
||||||
'include/capi/cef_keyboard_handler_capi.h',
|
'include/capi/cef_keyboard_handler_capi.h',
|
||||||
'include/capi/cef_life_span_handler_capi.h',
|
'include/capi/cef_life_span_handler_capi.h',
|
||||||
'include/capi/cef_load_handler_capi.h',
|
'include/capi/cef_load_handler_capi.h',
|
||||||
'include/capi/cef_media_router_capi.h',
|
|
||||||
'include/capi/cef_menu_model_capi.h',
|
'include/capi/cef_menu_model_capi.h',
|
||||||
'include/capi/cef_menu_model_delegate_capi.h',
|
'include/capi/cef_menu_model_delegate_capi.h',
|
||||||
'include/capi/cef_navigation_entry_capi.h',
|
'include/capi/cef_navigation_entry_capi.h',
|
||||||
@@ -157,7 +130,6 @@
|
|||||||
'include/capi/cef_print_settings_capi.h',
|
'include/capi/cef_print_settings_capi.h',
|
||||||
'include/capi/cef_process_message_capi.h',
|
'include/capi/cef_process_message_capi.h',
|
||||||
'include/capi/cef_process_util_capi.h',
|
'include/capi/cef_process_util_capi.h',
|
||||||
'include/capi/cef_registration_capi.h',
|
|
||||||
'include/capi/cef_render_handler_capi.h',
|
'include/capi/cef_render_handler_capi.h',
|
||||||
'include/capi/cef_render_process_handler_capi.h',
|
'include/capi/cef_render_process_handler_capi.h',
|
||||||
'include/capi/cef_request_capi.h',
|
'include/capi/cef_request_capi.h',
|
||||||
@@ -167,27 +139,20 @@
|
|||||||
'include/capi/cef_resource_bundle_capi.h',
|
'include/capi/cef_resource_bundle_capi.h',
|
||||||
'include/capi/cef_resource_bundle_handler_capi.h',
|
'include/capi/cef_resource_bundle_handler_capi.h',
|
||||||
'include/capi/cef_resource_handler_capi.h',
|
'include/capi/cef_resource_handler_capi.h',
|
||||||
'include/capi/cef_resource_request_handler_capi.h',
|
|
||||||
'include/capi/cef_response_capi.h',
|
'include/capi/cef_response_capi.h',
|
||||||
'include/capi/cef_response_filter_capi.h',
|
'include/capi/cef_response_filter_capi.h',
|
||||||
'include/capi/cef_scheme_capi.h',
|
'include/capi/cef_scheme_capi.h',
|
||||||
'include/capi/cef_server_capi.h',
|
|
||||||
'include/capi/cef_ssl_info_capi.h',
|
'include/capi/cef_ssl_info_capi.h',
|
||||||
'include/capi/cef_ssl_status_capi.h',
|
|
||||||
'include/capi/cef_stream_capi.h',
|
'include/capi/cef_stream_capi.h',
|
||||||
'include/capi/cef_string_visitor_capi.h',
|
'include/capi/cef_string_visitor_capi.h',
|
||||||
'include/capi/cef_task_capi.h',
|
'include/capi/cef_task_capi.h',
|
||||||
'include/capi/cef_thread_capi.h',
|
|
||||||
'include/capi/cef_trace_capi.h',
|
'include/capi/cef_trace_capi.h',
|
||||||
'include/capi/cef_urlrequest_capi.h',
|
'include/capi/cef_urlrequest_capi.h',
|
||||||
'include/capi/cef_v8_capi.h',
|
'include/capi/cef_v8_capi.h',
|
||||||
'include/capi/cef_values_capi.h',
|
'include/capi/cef_values_capi.h',
|
||||||
'include/capi/cef_waitable_event_capi.h',
|
|
||||||
'include/capi/cef_web_plugin_capi.h',
|
'include/capi/cef_web_plugin_capi.h',
|
||||||
'include/capi/cef_x509_certificate_capi.h',
|
|
||||||
'include/capi/cef_xml_reader_capi.h',
|
'include/capi/cef_xml_reader_capi.h',
|
||||||
'include/capi/cef_zip_reader_capi.h',
|
'include/capi/cef_zip_reader_capi.h',
|
||||||
'include/capi/test/cef_test_helpers_capi.h',
|
|
||||||
'include/capi/test/cef_translator_test_capi.h',
|
'include/capi/test/cef_translator_test_capi.h',
|
||||||
'include/capi/views/cef_box_layout_capi.h',
|
'include/capi/views/cef_box_layout_capi.h',
|
||||||
'include/capi/views/cef_browser_view_capi.h',
|
'include/capi/views/cef_browser_view_capi.h',
|
||||||
@@ -200,7 +165,6 @@
|
|||||||
'include/capi/views/cef_layout_capi.h',
|
'include/capi/views/cef_layout_capi.h',
|
||||||
'include/capi/views/cef_menu_button_capi.h',
|
'include/capi/views/cef_menu_button_capi.h',
|
||||||
'include/capi/views/cef_menu_button_delegate_capi.h',
|
'include/capi/views/cef_menu_button_delegate_capi.h',
|
||||||
'include/capi/views/cef_overlay_controller_capi.h',
|
|
||||||
'include/capi/views/cef_panel_capi.h',
|
'include/capi/views/cef_panel_capi.h',
|
||||||
'include/capi/views/cef_panel_delegate_capi.h',
|
'include/capi/views/cef_panel_delegate_capi.h',
|
||||||
'include/capi/views/cef_scroll_view_capi.h',
|
'include/capi/views/cef_scroll_view_capi.h',
|
||||||
@@ -212,12 +176,8 @@
|
|||||||
'include/capi/views/cef_window_delegate_capi.h',
|
'include/capi/views/cef_window_delegate_capi.h',
|
||||||
],
|
],
|
||||||
'autogen_library_side': [
|
'autogen_library_side': [
|
||||||
'libcef_dll/ctocpp/accessibility_handler_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/accessibility_handler_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/app_ctocpp.cc',
|
'libcef_dll/ctocpp/app_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/app_ctocpp.h',
|
'libcef_dll/ctocpp/app_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/audio_handler_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/audio_handler_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/auth_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/auth_callback_cpptoc.h',
|
'libcef_dll/cpptoc/auth_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/before_download_callback_cpptoc.cc',
|
||||||
@@ -252,8 +212,6 @@
|
|||||||
'libcef_dll/ctocpp/context_menu_handler_ctocpp.h',
|
'libcef_dll/ctocpp/context_menu_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/context_menu_params_cpptoc.cc',
|
'libcef_dll/cpptoc/context_menu_params_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/context_menu_params_cpptoc.h',
|
'libcef_dll/cpptoc/context_menu_params_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/cookie_access_filter_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/cookie_access_filter_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
|
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
|
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
|
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
|
||||||
@@ -266,8 +224,6 @@
|
|||||||
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h',
|
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/dialog_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/dialog_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/dialog_handler_ctocpp.h',
|
'libcef_dll/ctocpp/dialog_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
|
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
|
||||||
@@ -290,10 +246,6 @@
|
|||||||
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
|
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/extension_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/extension_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/extension_handler_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/extension_handler_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
|
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
|
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
|
||||||
@@ -304,10 +256,12 @@
|
|||||||
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
|
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.h',
|
'libcef_dll/cpptoc/frame_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
|
'libcef_dll/cpptoc/geolocation_callback_cpptoc.cc',
|
||||||
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
|
'libcef_dll/cpptoc/geolocation_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
|
'libcef_dll/ctocpp/geolocation_handler_ctocpp.cc',
|
||||||
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
|
'libcef_dll/ctocpp/geolocation_handler_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/get_geolocation_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/image_cpptoc.cc',
|
'libcef_dll/cpptoc/image_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/image_cpptoc.h',
|
'libcef_dll/cpptoc/image_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
|
||||||
@@ -326,26 +280,10 @@
|
|||||||
'libcef_dll/cpptoc/list_value_cpptoc.h',
|
'libcef_dll/cpptoc/list_value_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/load_handler_ctocpp.h',
|
'libcef_dll/ctocpp/load_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/media_observer_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_observer_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/media_route_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_route_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/media_router_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_router_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/media_sink_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_sink_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/media_source_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_source_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
|
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
|
'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h',
|
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/menu_button_pressed_lock_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/views/menu_button_pressed_lock_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/menu_model_cpptoc.cc',
|
'libcef_dll/cpptoc/menu_model_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/menu_model_cpptoc.h',
|
'libcef_dll/cpptoc/menu_model_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/menu_model_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/menu_model_delegate_ctocpp.cc',
|
||||||
@@ -354,8 +292,6 @@
|
|||||||
'libcef_dll/cpptoc/navigation_entry_cpptoc.h',
|
'libcef_dll/cpptoc/navigation_entry_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.cc',
|
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h',
|
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/overlay_controller_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/views/overlay_controller_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/views/panel_cpptoc.cc',
|
'libcef_dll/cpptoc/views/panel_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/panel_cpptoc.h',
|
'libcef_dll/cpptoc/views/panel_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc',
|
||||||
@@ -378,14 +314,16 @@
|
|||||||
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/registration_cpptoc.cc',
|
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc',
|
||||||
'libcef_dll/cpptoc/registration_cpptoc.h',
|
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/render_handler_ctocpp.h',
|
'libcef_dll/ctocpp/render_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/render_process_handler_ctocpp.h',
|
'libcef_dll/ctocpp/render_process_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/request_cpptoc.cc',
|
'libcef_dll/cpptoc/request_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/request_cpptoc.h',
|
'libcef_dll/cpptoc/request_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/request_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/request_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/request_context_cpptoc.cc',
|
'libcef_dll/cpptoc/request_context_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/request_context_cpptoc.h',
|
'libcef_dll/cpptoc/request_context_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/request_context_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/request_context_handler_ctocpp.cc',
|
||||||
@@ -400,12 +338,6 @@
|
|||||||
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
|
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/resource_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/resource_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/resource_handler_ctocpp.h',
|
'libcef_dll/ctocpp/resource_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/resource_read_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/resource_read_callback_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/resource_request_handler_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/resource_request_handler_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/resource_skip_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/resource_skip_callback_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/response_cpptoc.cc',
|
'libcef_dll/cpptoc/response_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/response_cpptoc.h',
|
'libcef_dll/cpptoc/response_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/response_filter_ctocpp.cc',
|
'libcef_dll/ctocpp/response_filter_ctocpp.cc',
|
||||||
@@ -414,22 +346,16 @@
|
|||||||
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h',
|
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
|
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/sslcert_principal_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/sslcert_principal_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
|
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
|
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/sslstatus_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/sslstatus_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc',
|
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h',
|
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/scheme_registrar_cpptoc.cc',
|
'libcef_dll/cpptoc/scheme_registrar_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/scheme_registrar_cpptoc.h',
|
'libcef_dll/cpptoc/scheme_registrar_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/views/scroll_view_cpptoc.cc',
|
'libcef_dll/cpptoc/views/scroll_view_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/scroll_view_cpptoc.h',
|
'libcef_dll/cpptoc/views/scroll_view_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/server_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/server_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/server_handler_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/server_handler_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.h',
|
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
|
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
|
||||||
@@ -446,46 +372,30 @@
|
|||||||
'libcef_dll/cpptoc/views/textfield_cpptoc.h',
|
'libcef_dll/cpptoc/views/textfield_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h',
|
'libcef_dll/ctocpp/views/textfield_delegate_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/thread_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/thread_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_cpptoc.cc',
|
'libcef_dll/cpptoc/test/translator_test_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/test/translator_test_cpptoc.h',
|
'libcef_dll/cpptoc/test/translator_test_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.cc',
|
'libcef_dll/ctocpp/test/translator_test_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_ctocpp.h',
|
'libcef_dll/ctocpp/test/translator_test_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.cc',
|
'libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_client_child_ctocpp.h',
|
'libcef_dll/ctocpp/test/translator_test_handler_child_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.cc',
|
'libcef_dll/cpptoc/test/translator_test_object_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_cpptoc.h',
|
'libcef_dll/cpptoc/test/translator_test_object_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.cc',
|
'libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_cpptoc.h',
|
'libcef_dll/cpptoc/test/translator_test_object_child_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.cc',
|
'libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_library_child_child_cpptoc.h',
|
'libcef_dll/cpptoc/test/translator_test_object_child_child_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_client_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_client_child_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_library_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_library_child_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_library_child_child_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/urlrequest_cpptoc.cc',
|
'libcef_dll/cpptoc/urlrequest_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
|
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
|
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
|
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
|
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/v8accessor_ctocpp.h',
|
'libcef_dll/ctocpp/v8accessor_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/v8context_cpptoc.cc',
|
'libcef_dll/cpptoc/v8context_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/v8context_cpptoc.h',
|
'libcef_dll/cpptoc/v8context_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/v8exception_cpptoc.cc',
|
'libcef_dll/cpptoc/v8exception_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/v8exception_cpptoc.h',
|
'libcef_dll/cpptoc/v8exception_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/v8handler_ctocpp.cc',
|
'libcef_dll/ctocpp/v8handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/v8handler_ctocpp.h',
|
'libcef_dll/ctocpp/v8handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/v8interceptor_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/v8interceptor_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/v8stack_frame_cpptoc.cc',
|
'libcef_dll/cpptoc/v8stack_frame_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/v8stack_frame_cpptoc.h',
|
'libcef_dll/cpptoc/v8stack_frame_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/v8stack_trace_cpptoc.cc',
|
'libcef_dll/cpptoc/v8stack_trace_cpptoc.cc',
|
||||||
@@ -498,8 +408,6 @@
|
|||||||
'libcef_dll/cpptoc/views/view_cpptoc.h',
|
'libcef_dll/cpptoc/views/view_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/view_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/view_delegate_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/view_delegate_ctocpp.h',
|
'libcef_dll/ctocpp/views/view_delegate_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/waitable_event_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/waitable_event_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/web_plugin_info_cpptoc.cc',
|
'libcef_dll/cpptoc/web_plugin_info_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/web_plugin_info_cpptoc.h',
|
'libcef_dll/cpptoc/web_plugin_info_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc',
|
'libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc',
|
||||||
@@ -512,22 +420,14 @@
|
|||||||
'libcef_dll/ctocpp/views/window_delegate_ctocpp.h',
|
'libcef_dll/ctocpp/views/window_delegate_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/write_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/write_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/write_handler_ctocpp.h',
|
'libcef_dll/ctocpp/write_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/x509cert_principal_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/x509cert_principal_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/x509certificate_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/x509certificate_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/xml_reader_cpptoc.cc',
|
'libcef_dll/cpptoc/xml_reader_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/xml_reader_cpptoc.h',
|
'libcef_dll/cpptoc/xml_reader_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/zip_reader_cpptoc.cc',
|
'libcef_dll/cpptoc/zip_reader_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/zip_reader_cpptoc.h',
|
'libcef_dll/cpptoc/zip_reader_cpptoc.h',
|
||||||
],
|
],
|
||||||
'autogen_client_side': [
|
'autogen_client_side': [
|
||||||
'libcef_dll/cpptoc/accessibility_handler_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/accessibility_handler_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/app_cpptoc.cc',
|
'libcef_dll/cpptoc/app_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/app_cpptoc.h',
|
'libcef_dll/cpptoc/app_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/audio_handler_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/audio_handler_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/auth_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/auth_callback_ctocpp.h',
|
'libcef_dll/ctocpp/auth_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/before_download_callback_ctocpp.cc',
|
||||||
@@ -562,8 +462,6 @@
|
|||||||
'libcef_dll/cpptoc/context_menu_handler_cpptoc.h',
|
'libcef_dll/cpptoc/context_menu_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/context_menu_params_ctocpp.cc',
|
'libcef_dll/ctocpp/context_menu_params_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/context_menu_params_ctocpp.h',
|
'libcef_dll/ctocpp/context_menu_params_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/cookie_access_filter_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/cookie_access_filter_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
|
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
|
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
|
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
|
||||||
@@ -576,8 +474,6 @@
|
|||||||
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h',
|
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/dialog_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/dialog_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/dialog_handler_cpptoc.h',
|
'libcef_dll/cpptoc/dialog_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
|
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
|
||||||
@@ -600,10 +496,6 @@
|
|||||||
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
|
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/extension_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/extension_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/extension_handler_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/extension_handler_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
|
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
|
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
|
||||||
@@ -614,10 +506,12 @@
|
|||||||
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
|
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.h',
|
'libcef_dll/ctocpp/frame_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
|
'libcef_dll/ctocpp/geolocation_callback_ctocpp.cc',
|
||||||
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
|
'libcef_dll/ctocpp/geolocation_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
|
'libcef_dll/cpptoc/geolocation_handler_cpptoc.cc',
|
||||||
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
|
'libcef_dll/cpptoc/geolocation_handler_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/get_geolocation_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/image_ctocpp.cc',
|
'libcef_dll/ctocpp/image_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/image_ctocpp.h',
|
'libcef_dll/ctocpp/image_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
|
||||||
@@ -636,26 +530,10 @@
|
|||||||
'libcef_dll/ctocpp/list_value_ctocpp.h',
|
'libcef_dll/ctocpp/list_value_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/load_handler_cpptoc.h',
|
'libcef_dll/cpptoc/load_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/media_observer_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_observer_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/media_route_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_route_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/media_router_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_router_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/media_sink_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_sink_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/media_source_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/media_source_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
|
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
|
'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h',
|
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/menu_button_pressed_lock_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/views/menu_button_pressed_lock_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/menu_model_ctocpp.cc',
|
'libcef_dll/ctocpp/menu_model_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/menu_model_ctocpp.h',
|
'libcef_dll/ctocpp/menu_model_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/menu_model_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/menu_model_delegate_cpptoc.cc',
|
||||||
@@ -664,8 +542,6 @@
|
|||||||
'libcef_dll/ctocpp/navigation_entry_ctocpp.h',
|
'libcef_dll/ctocpp/navigation_entry_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.cc',
|
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h',
|
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/overlay_controller_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/views/overlay_controller_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/views/panel_ctocpp.cc',
|
'libcef_dll/ctocpp/views/panel_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/panel_ctocpp.h',
|
'libcef_dll/ctocpp/views/panel_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc',
|
||||||
@@ -688,14 +564,16 @@
|
|||||||
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/registration_ctocpp.cc',
|
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc',
|
||||||
'libcef_dll/ctocpp/registration_ctocpp.h',
|
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/render_handler_cpptoc.h',
|
'libcef_dll/cpptoc/render_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/render_process_handler_cpptoc.h',
|
'libcef_dll/cpptoc/render_process_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/request_ctocpp.cc',
|
'libcef_dll/ctocpp/request_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/request_ctocpp.h',
|
'libcef_dll/ctocpp/request_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/request_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/request_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/request_context_ctocpp.cc',
|
'libcef_dll/ctocpp/request_context_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/request_context_ctocpp.h',
|
'libcef_dll/ctocpp/request_context_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/request_context_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/request_context_handler_cpptoc.cc',
|
||||||
@@ -710,12 +588,6 @@
|
|||||||
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
|
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/resource_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/resource_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/resource_handler_cpptoc.h',
|
'libcef_dll/cpptoc/resource_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/resource_read_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/resource_read_callback_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/resource_request_handler_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/resource_request_handler_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/resource_skip_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/resource_skip_callback_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/response_ctocpp.cc',
|
'libcef_dll/ctocpp/response_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/response_ctocpp.h',
|
'libcef_dll/ctocpp/response_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/response_filter_cpptoc.cc',
|
'libcef_dll/cpptoc/response_filter_cpptoc.cc',
|
||||||
@@ -724,22 +596,16 @@
|
|||||||
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h',
|
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
|
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/sslcert_principal_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/sslcert_principal_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
|
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
|
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/sslstatus_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/sslstatus_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc',
|
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h',
|
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/scheme_registrar_ctocpp.cc',
|
'libcef_dll/ctocpp/scheme_registrar_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/scheme_registrar_ctocpp.h',
|
'libcef_dll/ctocpp/scheme_registrar_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/views/scroll_view_ctocpp.cc',
|
'libcef_dll/ctocpp/views/scroll_view_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/scroll_view_ctocpp.h',
|
'libcef_dll/ctocpp/views/scroll_view_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/server_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/server_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/server_handler_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/server_handler_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.h',
|
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
|
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
|
||||||
@@ -756,46 +622,30 @@
|
|||||||
'libcef_dll/ctocpp/views/textfield_ctocpp.h',
|
'libcef_dll/ctocpp/views/textfield_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/textfield_delegate_cpptoc.h',
|
'libcef_dll/cpptoc/views/textfield_delegate_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/thread_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/thread_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_ctocpp.cc',
|
'libcef_dll/ctocpp/test/translator_test_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ctocpp.h',
|
'libcef_dll/ctocpp/test/translator_test_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.cc',
|
'libcef_dll/cpptoc/test/translator_test_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_cpptoc.h',
|
'libcef_dll/cpptoc/test/translator_test_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.cc',
|
'libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/test/translator_test_ref_ptr_client_child_cpptoc.h',
|
'libcef_dll/cpptoc/test/translator_test_handler_child_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.cc',
|
'libcef_dll/ctocpp/test/translator_test_object_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_ctocpp.h',
|
'libcef_dll/ctocpp/test/translator_test_object_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.cc',
|
'libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_ctocpp.h',
|
'libcef_dll/ctocpp/test/translator_test_object_child_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.cc',
|
'libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/test/translator_test_ref_ptr_library_child_child_ctocpp.h',
|
'libcef_dll/ctocpp/test/translator_test_object_child_child_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_client_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/test/translator_test_scoped_client_child_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_library_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_library_child_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/test/translator_test_scoped_library_child_child_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/urlrequest_ctocpp.cc',
|
'libcef_dll/ctocpp/urlrequest_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
|
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',
|
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
|
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
|
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/v8accessor_cpptoc.h',
|
'libcef_dll/cpptoc/v8accessor_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/v8context_ctocpp.cc',
|
'libcef_dll/ctocpp/v8context_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/v8context_ctocpp.h',
|
'libcef_dll/ctocpp/v8context_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/v8exception_ctocpp.cc',
|
'libcef_dll/ctocpp/v8exception_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/v8exception_ctocpp.h',
|
'libcef_dll/ctocpp/v8exception_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/v8handler_cpptoc.cc',
|
'libcef_dll/cpptoc/v8handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/v8handler_cpptoc.h',
|
'libcef_dll/cpptoc/v8handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/v8interceptor_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/v8interceptor_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/v8stack_frame_ctocpp.cc',
|
'libcef_dll/ctocpp/v8stack_frame_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/v8stack_frame_ctocpp.h',
|
'libcef_dll/ctocpp/v8stack_frame_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/v8stack_trace_ctocpp.cc',
|
'libcef_dll/ctocpp/v8stack_trace_ctocpp.cc',
|
||||||
@@ -808,8 +658,6 @@
|
|||||||
'libcef_dll/ctocpp/views/view_ctocpp.h',
|
'libcef_dll/ctocpp/views/view_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/view_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/view_delegate_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/view_delegate_cpptoc.h',
|
'libcef_dll/cpptoc/views/view_delegate_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/waitable_event_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/waitable_event_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/web_plugin_info_ctocpp.cc',
|
'libcef_dll/ctocpp/web_plugin_info_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/web_plugin_info_ctocpp.h',
|
'libcef_dll/ctocpp/web_plugin_info_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc',
|
'libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc',
|
||||||
@@ -822,10 +670,6 @@
|
|||||||
'libcef_dll/cpptoc/views/window_delegate_cpptoc.h',
|
'libcef_dll/cpptoc/views/window_delegate_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/write_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/write_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/write_handler_cpptoc.h',
|
'libcef_dll/cpptoc/write_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/x509cert_principal_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/x509cert_principal_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/x509certificate_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/x509certificate_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/xml_reader_ctocpp.cc',
|
'libcef_dll/ctocpp/xml_reader_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/xml_reader_ctocpp.h',
|
'libcef_dll/ctocpp/xml_reader_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/zip_reader_ctocpp.cc',
|
'libcef_dll/ctocpp/zip_reader_ctocpp.cc',
|
||||||
|
|||||||
409
cef_paths2.gypi
409
cef_paths2.gypi
@@ -5,28 +5,28 @@
|
|||||||
{
|
{
|
||||||
'variables': {
|
'variables': {
|
||||||
'includes_common': [
|
'includes_common': [
|
||||||
'include/base/cef_atomic_flag.h',
|
|
||||||
'include/base/cef_atomic_ref_count.h',
|
'include/base/cef_atomic_ref_count.h',
|
||||||
'include/base/cef_auto_reset.h',
|
'include/base/cef_atomicops.h',
|
||||||
'include/base/cef_basictypes.h',
|
'include/base/cef_basictypes.h',
|
||||||
'include/base/cef_bind.h',
|
'include/base/cef_bind.h',
|
||||||
|
'include/base/cef_bind_helpers.h',
|
||||||
'include/base/cef_build.h',
|
'include/base/cef_build.h',
|
||||||
'include/base/cef_callback.h',
|
'include/base/cef_callback.h',
|
||||||
'include/base/cef_callback_forward.h',
|
'include/base/cef_callback_forward.h',
|
||||||
'include/base/cef_callback_helpers.h',
|
'include/base/cef_callback_helpers.h',
|
||||||
'include/base/cef_callback_list.h',
|
'include/base/cef_callback_list.h',
|
||||||
'include/base/cef_cancelable_callback.h',
|
'include/base/cef_cancelable_callback.h',
|
||||||
'include/base/cef_compiler_specific.h',
|
|
||||||
'include/base/cef_cxx17_backports.h',
|
|
||||||
'include/base/cef_lock.h',
|
'include/base/cef_lock.h',
|
||||||
'include/base/cef_logging.h',
|
'include/base/cef_logging.h',
|
||||||
'include/base/cef_macros.h',
|
'include/base/cef_macros.h',
|
||||||
|
'include/base/cef_move.h',
|
||||||
'include/base/cef_platform_thread.h',
|
'include/base/cef_platform_thread.h',
|
||||||
'include/base/cef_ptr_util.h',
|
|
||||||
'include/base/cef_ref_counted.h',
|
'include/base/cef_ref_counted.h',
|
||||||
'include/base/cef_scoped_refptr.h',
|
'include/base/cef_scoped_ptr.h',
|
||||||
|
'include/base/cef_string16.h',
|
||||||
'include/base/cef_template_util.h',
|
'include/base/cef_template_util.h',
|
||||||
'include/base/cef_thread_checker.h',
|
'include/base/cef_thread_checker.h',
|
||||||
|
'include/base/cef_thread_collision_warner.h',
|
||||||
'include/base/cef_trace_event.h',
|
'include/base/cef_trace_event.h',
|
||||||
'include/base/cef_tuple.h',
|
'include/base/cef_tuple.h',
|
||||||
'include/base/cef_weak_ptr.h',
|
'include/base/cef_weak_ptr.h',
|
||||||
@@ -34,29 +34,23 @@
|
|||||||
'include/base/internal/cef_callback_internal.h',
|
'include/base/internal/cef_callback_internal.h',
|
||||||
'include/base/internal/cef_lock_impl.h',
|
'include/base/internal/cef_lock_impl.h',
|
||||||
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
|
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
|
||||||
'include/base/internal/cef_scoped_policy.h',
|
|
||||||
'include/base/internal/cef_thread_checker_impl.h',
|
'include/base/internal/cef_thread_checker_impl.h',
|
||||||
'include/cef_api_hash.h',
|
|
||||||
'include/cef_base.h',
|
'include/cef_base.h',
|
||||||
'include/cef_config.h',
|
|
||||||
'include/cef_version.h',
|
'include/cef_version.h',
|
||||||
'include/internal/cef_export.h',
|
'include/internal/cef_export.h',
|
||||||
'include/internal/cef_ptr.h',
|
|
||||||
'include/internal/cef_string_wrappers.h',
|
|
||||||
'include/internal/cef_types_wrappers.h',
|
|
||||||
],
|
|
||||||
'includes_common_capi': [
|
|
||||||
'include/internal/cef_logging_internal.h',
|
'include/internal/cef_logging_internal.h',
|
||||||
|
'include/internal/cef_ptr.h',
|
||||||
'include/internal/cef_string.h',
|
'include/internal/cef_string.h',
|
||||||
'include/internal/cef_string_list.h',
|
'include/internal/cef_string_list.h',
|
||||||
'include/internal/cef_string_map.h',
|
'include/internal/cef_string_map.h',
|
||||||
'include/internal/cef_string_multimap.h',
|
'include/internal/cef_string_multimap.h',
|
||||||
'include/internal/cef_string_types.h',
|
'include/internal/cef_string_types.h',
|
||||||
|
'include/internal/cef_string_wrappers.h',
|
||||||
'include/internal/cef_thread_internal.h',
|
'include/internal/cef_thread_internal.h',
|
||||||
'include/internal/cef_time.h',
|
'include/internal/cef_time.h',
|
||||||
'include/internal/cef_trace_event_internal.h',
|
'include/internal/cef_trace_event_internal.h',
|
||||||
'include/internal/cef_types.h',
|
'include/internal/cef_types.h',
|
||||||
'include/internal/cef_types_geometry.h',
|
'include/internal/cef_types_wrappers.h',
|
||||||
],
|
],
|
||||||
'includes_capi': [
|
'includes_capi': [
|
||||||
'include/capi/cef_base_capi.h',
|
'include/capi/cef_base_capi.h',
|
||||||
@@ -67,78 +61,61 @@
|
|||||||
'include/wrapper/cef_helpers.h',
|
'include/wrapper/cef_helpers.h',
|
||||||
'include/wrapper/cef_message_router.h',
|
'include/wrapper/cef_message_router.h',
|
||||||
'include/wrapper/cef_resource_manager.h',
|
'include/wrapper/cef_resource_manager.h',
|
||||||
'include/wrapper/cef_scoped_temp_dir.h',
|
|
||||||
'include/wrapper/cef_stream_resource_handler.h',
|
'include/wrapper/cef_stream_resource_handler.h',
|
||||||
'include/wrapper/cef_xml_object.h',
|
'include/wrapper/cef_xml_object.h',
|
||||||
'include/wrapper/cef_zip_archive.h',
|
'include/wrapper/cef_zip_archive.h',
|
||||||
],
|
],
|
||||||
'includes_wrapper_mac': [
|
|
||||||
'include/wrapper/cef_library_loader.h',
|
|
||||||
],
|
|
||||||
'includes_win': [
|
'includes_win': [
|
||||||
|
'include/base/internal/cef_atomicops_x86_msvc.h',
|
||||||
|
'include/base/internal/cef_bind_internal_win.h',
|
||||||
'include/cef_sandbox_win.h',
|
'include/cef_sandbox_win.h',
|
||||||
|
'include/internal/cef_types_win.h',
|
||||||
'include/internal/cef_win.h',
|
'include/internal/cef_win.h',
|
||||||
],
|
],
|
||||||
'includes_win_capi': [
|
|
||||||
'include/internal/cef_types_win.h',
|
|
||||||
],
|
|
||||||
'includes_mac': [
|
'includes_mac': [
|
||||||
'include/base/cef_scoped_typeref_mac.h',
|
'include/base/internal/cef_atomicops_atomicword_compat.h',
|
||||||
'include/base/internal/cef_scoped_block_mac.h',
|
'include/base/internal/cef_atomicops_mac.h',
|
||||||
'include/cef_application_mac.h',
|
'include/cef_application_mac.h',
|
||||||
'include/cef_sandbox_mac.h',
|
|
||||||
'include/internal/cef_mac.h',
|
'include/internal/cef_mac.h',
|
||||||
],
|
|
||||||
'includes_mac_capi': [
|
|
||||||
'include/internal/cef_types_mac.h',
|
'include/internal/cef_types_mac.h',
|
||||||
],
|
],
|
||||||
'includes_linux': [
|
'includes_linux': [
|
||||||
|
'include/base/internal/cef_atomicops_atomicword_compat.h',
|
||||||
|
'include/base/internal/cef_atomicops_x86_gcc.h',
|
||||||
'include/internal/cef_linux.h',
|
'include/internal/cef_linux.h',
|
||||||
],
|
|
||||||
'includes_linux_capi': [
|
|
||||||
'include/internal/cef_types_linux.h',
|
'include/internal/cef_types_linux.h',
|
||||||
],
|
],
|
||||||
'libcef_sources_common': [
|
'libcef_sources_common': [
|
||||||
'libcef_dll/cpptoc/cpptoc_ref_counted.h',
|
'libcef_dll/cpptoc/cpptoc.h',
|
||||||
'libcef_dll/cpptoc/cpptoc_scoped.h',
|
'libcef_dll/ctocpp/base_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/base_ref_counted_ctocpp.cc',
|
'libcef_dll/ctocpp/base_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/base_ref_counted_ctocpp.h',
|
'libcef_dll/ctocpp/ctocpp.h',
|
||||||
'libcef_dll/ctocpp/base_scoped_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/base_scoped_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/ctocpp_ref_counted.h',
|
|
||||||
'libcef_dll/ctocpp/ctocpp_scoped.h',
|
|
||||||
'libcef_dll/libcef_dll.cc',
|
'libcef_dll/libcef_dll.cc',
|
||||||
'libcef_dll/libcef_dll2.cc',
|
'libcef_dll/libcef_dll2.cc',
|
||||||
'libcef_dll/ptr_util.h',
|
|
||||||
'libcef_dll/resource.h',
|
'libcef_dll/resource.h',
|
||||||
'libcef_dll/shutdown_checker.cc',
|
|
||||||
'libcef_dll/shutdown_checker.h',
|
|
||||||
'libcef_dll/transfer_util.cc',
|
'libcef_dll/transfer_util.cc',
|
||||||
'libcef_dll/transfer_util.h',
|
'libcef_dll/transfer_util.h',
|
||||||
'libcef_dll/wrapper_types.h',
|
'libcef_dll/wrapper_types.h',
|
||||||
],
|
],
|
||||||
'libcef_dll_wrapper_sources_base': [
|
'libcef_dll_wrapper_sources_base': [
|
||||||
'libcef_dll/base/cef_atomic_flag.cc',
|
'libcef_dll/base/cef_atomicops_x86_gcc.cc',
|
||||||
|
'libcef_dll/base/cef_bind_helpers.cc',
|
||||||
'libcef_dll/base/cef_callback_helpers.cc',
|
'libcef_dll/base/cef_callback_helpers.cc',
|
||||||
'libcef_dll/base/cef_callback_internal.cc',
|
'libcef_dll/base/cef_callback_internal.cc',
|
||||||
'libcef_dll/base/cef_lock.cc',
|
'libcef_dll/base/cef_lock.cc',
|
||||||
'libcef_dll/base/cef_lock_impl.cc',
|
'libcef_dll/base/cef_lock_impl.cc',
|
||||||
'libcef_dll/base/cef_logging.cc',
|
'libcef_dll/base/cef_logging.cc',
|
||||||
'libcef_dll/base/cef_ref_counted.cc',
|
'libcef_dll/base/cef_ref_counted.cc',
|
||||||
|
'libcef_dll/base/cef_string16.cc',
|
||||||
'libcef_dll/base/cef_thread_checker_impl.cc',
|
'libcef_dll/base/cef_thread_checker_impl.cc',
|
||||||
|
'libcef_dll/base/cef_thread_collision_warner.cc',
|
||||||
'libcef_dll/base/cef_weak_ptr.cc',
|
'libcef_dll/base/cef_weak_ptr.cc',
|
||||||
],
|
],
|
||||||
'libcef_dll_wrapper_sources_common': [
|
'libcef_dll_wrapper_sources_common': [
|
||||||
'libcef_dll/cpptoc/base_ref_counted_cpptoc.cc',
|
'libcef_dll/cpptoc/base_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/base_ref_counted_cpptoc.h',
|
'libcef_dll/cpptoc/base_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/base_scoped_cpptoc.cc',
|
'libcef_dll/cpptoc/cpptoc.h',
|
||||||
'libcef_dll/cpptoc/base_scoped_cpptoc.h',
|
'libcef_dll/ctocpp/ctocpp.h',
|
||||||
'libcef_dll/cpptoc/cpptoc_ref_counted.h',
|
|
||||||
'libcef_dll/cpptoc/cpptoc_scoped.h',
|
|
||||||
'libcef_dll/ctocpp/ctocpp_ref_counted.h',
|
|
||||||
'libcef_dll/ctocpp/ctocpp_scoped.h',
|
|
||||||
'libcef_dll/shutdown_checker.cc',
|
|
||||||
'libcef_dll/shutdown_checker.h',
|
|
||||||
'libcef_dll/transfer_util.cc',
|
'libcef_dll/transfer_util.cc',
|
||||||
'libcef_dll/transfer_util.h',
|
'libcef_dll/transfer_util.h',
|
||||||
'libcef_dll/wrapper_types.h',
|
'libcef_dll/wrapper_types.h',
|
||||||
@@ -147,71 +124,12 @@
|
|||||||
'libcef_dll/wrapper/cef_closure_task.cc',
|
'libcef_dll/wrapper/cef_closure_task.cc',
|
||||||
'libcef_dll/wrapper/cef_message_router.cc',
|
'libcef_dll/wrapper/cef_message_router.cc',
|
||||||
'libcef_dll/wrapper/cef_resource_manager.cc',
|
'libcef_dll/wrapper/cef_resource_manager.cc',
|
||||||
'libcef_dll/wrapper/cef_scoped_temp_dir.cc',
|
|
||||||
'libcef_dll/wrapper/cef_stream_resource_handler.cc',
|
'libcef_dll/wrapper/cef_stream_resource_handler.cc',
|
||||||
'libcef_dll/wrapper/cef_xml_object.cc',
|
'libcef_dll/wrapper/cef_xml_object.cc',
|
||||||
'libcef_dll/wrapper/cef_zip_archive.cc',
|
'libcef_dll/wrapper/cef_zip_archive.cc',
|
||||||
'libcef_dll/wrapper/libcef_dll_wrapper.cc',
|
'libcef_dll/wrapper/libcef_dll_wrapper.cc',
|
||||||
'libcef_dll/wrapper/libcef_dll_wrapper2.cc',
|
'libcef_dll/wrapper/libcef_dll_wrapper2.cc',
|
||||||
],
|
],
|
||||||
'libcef_dll_wrapper_sources_mac': [
|
|
||||||
'libcef_dll/wrapper/cef_library_loader_mac.mm',
|
|
||||||
'libcef_dll/wrapper/libcef_dll_dylib.cc',
|
|
||||||
],
|
|
||||||
'shared_sources_browser': [
|
|
||||||
'tests/shared/browser/client_app_browser.cc',
|
|
||||||
'tests/shared/browser/client_app_browser.h',
|
|
||||||
'tests/shared/browser/extension_util.cc',
|
|
||||||
'tests/shared/browser/extension_util.h',
|
|
||||||
'tests/shared/browser/file_util.cc',
|
|
||||||
'tests/shared/browser/file_util.h',
|
|
||||||
'tests/shared/browser/geometry_util.cc',
|
|
||||||
'tests/shared/browser/geometry_util.h',
|
|
||||||
'tests/shared/browser/main_message_loop.cc',
|
|
||||||
'tests/shared/browser/main_message_loop.h',
|
|
||||||
'tests/shared/browser/main_message_loop_external_pump.cc',
|
|
||||||
'tests/shared/browser/main_message_loop_external_pump.h',
|
|
||||||
'tests/shared/browser/main_message_loop_std.cc',
|
|
||||||
'tests/shared/browser/main_message_loop_std.h',
|
|
||||||
'tests/shared/browser/resource_util.h',
|
|
||||||
],
|
|
||||||
'shared_sources_common': [
|
|
||||||
'tests/shared/common/client_app.cc',
|
|
||||||
'tests/shared/common/client_app.h',
|
|
||||||
'tests/shared/common/client_app_other.cc',
|
|
||||||
'tests/shared/common/client_app_other.h',
|
|
||||||
'tests/shared/common/client_switches.cc',
|
|
||||||
'tests/shared/common/client_switches.h',
|
|
||||||
],
|
|
||||||
'shared_sources_renderer': [
|
|
||||||
'tests/shared/renderer/client_app_renderer.cc',
|
|
||||||
'tests/shared/renderer/client_app_renderer.h',
|
|
||||||
],
|
|
||||||
'shared_sources_resources': [
|
|
||||||
'tests/shared/resources/osr_test.html',
|
|
||||||
'tests/shared/resources/pdf.html',
|
|
||||||
'tests/shared/resources/pdf.pdf',
|
|
||||||
'tests/shared/resources/window_icon.1x.png',
|
|
||||||
'tests/shared/resources/window_icon.2x.png',
|
|
||||||
],
|
|
||||||
'shared_sources_linux': [
|
|
||||||
'tests/shared/browser/main_message_loop_external_pump_linux.cc',
|
|
||||||
'tests/shared/browser/resource_util_posix.cc',
|
|
||||||
],
|
|
||||||
'shared_sources_mac': [
|
|
||||||
'tests/shared/browser/main_message_loop_external_pump_mac.mm',
|
|
||||||
'tests/shared/browser/resource_util_mac.mm',
|
|
||||||
'tests/shared/browser/resource_util_posix.cc',
|
|
||||||
],
|
|
||||||
'shared_sources_mac_helper': [
|
|
||||||
'tests/shared/process_helper_mac.cc',
|
|
||||||
],
|
|
||||||
'shared_sources_win': [
|
|
||||||
'tests/shared/browser/main_message_loop_external_pump_win.cc',
|
|
||||||
'tests/shared/browser/resource_util_win.cc',
|
|
||||||
'tests/shared/browser/util_win.cc',
|
|
||||||
'tests/shared/browser/util_win.h',
|
|
||||||
],
|
|
||||||
'cefclient_sources_browser': [
|
'cefclient_sources_browser': [
|
||||||
'tests/cefclient/browser/binding_test.cc',
|
'tests/cefclient/browser/binding_test.cc',
|
||||||
'tests/cefclient/browser/binding_test.h',
|
'tests/cefclient/browser/binding_test.h',
|
||||||
@@ -219,9 +137,9 @@
|
|||||||
'tests/cefclient/browser/browser_window.h',
|
'tests/cefclient/browser/browser_window.h',
|
||||||
'tests/cefclient/browser/bytes_write_handler.cc',
|
'tests/cefclient/browser/bytes_write_handler.cc',
|
||||||
'tests/cefclient/browser/bytes_write_handler.h',
|
'tests/cefclient/browser/bytes_write_handler.h',
|
||||||
|
'tests/cefclient/browser/client_app_browser.cc',
|
||||||
|
'tests/cefclient/browser/client_app_browser.h',
|
||||||
'tests/cefclient/browser/client_app_delegates_browser.cc',
|
'tests/cefclient/browser/client_app_delegates_browser.cc',
|
||||||
'tests/cefclient/browser/client_browser.cc',
|
|
||||||
'tests/cefclient/browser/client_browser.h',
|
|
||||||
'tests/cefclient/browser/client_handler.cc',
|
'tests/cefclient/browser/client_handler.cc',
|
||||||
'tests/cefclient/browser/client_handler.h',
|
'tests/cefclient/browser/client_handler.h',
|
||||||
'tests/cefclient/browser/client_handler_osr.cc',
|
'tests/cefclient/browser/client_handler_osr.cc',
|
||||||
@@ -231,21 +149,28 @@
|
|||||||
'tests/cefclient/browser/client_types.h',
|
'tests/cefclient/browser/client_types.h',
|
||||||
'tests/cefclient/browser/dialog_test.cc',
|
'tests/cefclient/browser/dialog_test.cc',
|
||||||
'tests/cefclient/browser/dialog_test.h',
|
'tests/cefclient/browser/dialog_test.h',
|
||||||
'tests/cefclient/browser/image_cache.cc',
|
'tests/cefclient/browser/drm_test.cc',
|
||||||
'tests/cefclient/browser/image_cache.h',
|
'tests/cefclient/browser/drm_test.h',
|
||||||
|
'tests/cefclient/browser/geometry_util.cc',
|
||||||
|
'tests/cefclient/browser/geometry_util.h',
|
||||||
'tests/cefclient/browser/main_context.cc',
|
'tests/cefclient/browser/main_context.cc',
|
||||||
'tests/cefclient/browser/main_context.h',
|
'tests/cefclient/browser/main_context.h',
|
||||||
'tests/cefclient/browser/main_context_impl.cc',
|
'tests/cefclient/browser/main_context_impl.cc',
|
||||||
'tests/cefclient/browser/main_context_impl.h',
|
'tests/cefclient/browser/main_context_impl.h',
|
||||||
'tests/cefclient/browser/media_router_test.cc',
|
'tests/cefclient/browser/main_message_loop.h',
|
||||||
'tests/cefclient/browser/media_router_test.h',
|
'tests/cefclient/browser/main_message_loop.cc',
|
||||||
|
'tests/cefclient/browser/main_message_loop_external_pump.cc',
|
||||||
|
'tests/cefclient/browser/main_message_loop_external_pump.h',
|
||||||
|
'tests/cefclient/browser/main_message_loop_std.h',
|
||||||
|
'tests/cefclient/browser/main_message_loop_std.cc',
|
||||||
'tests/cefclient/browser/osr_dragdrop_events.h',
|
'tests/cefclient/browser/osr_dragdrop_events.h',
|
||||||
'tests/cefclient/browser/osr_renderer.h',
|
'tests/cefclient/browser/osr_renderer.h',
|
||||||
'tests/cefclient/browser/osr_renderer.cc',
|
'tests/cefclient/browser/osr_renderer.cc',
|
||||||
'tests/cefclient/browser/osr_renderer_settings.h',
|
|
||||||
'tests/cefclient/browser/preferences_test.cc',
|
'tests/cefclient/browser/preferences_test.cc',
|
||||||
'tests/cefclient/browser/preferences_test.h',
|
'tests/cefclient/browser/preferences_test.h',
|
||||||
'tests/cefclient/browser/resource.h',
|
'tests/cefclient/browser/resource.h',
|
||||||
|
'tests/cefclient/browser/resource_util.cc',
|
||||||
|
'tests/cefclient/browser/resource_util.h',
|
||||||
'tests/cefclient/browser/response_filter_test.cc',
|
'tests/cefclient/browser/response_filter_test.cc',
|
||||||
'tests/cefclient/browser/response_filter_test.h',
|
'tests/cefclient/browser/response_filter_test.h',
|
||||||
'tests/cefclient/browser/root_window.cc',
|
'tests/cefclient/browser/root_window.cc',
|
||||||
@@ -253,39 +178,33 @@
|
|||||||
'tests/cefclient/browser/root_window_create.cc',
|
'tests/cefclient/browser/root_window_create.cc',
|
||||||
'tests/cefclient/browser/root_window_manager.cc',
|
'tests/cefclient/browser/root_window_manager.cc',
|
||||||
'tests/cefclient/browser/root_window_manager.h',
|
'tests/cefclient/browser/root_window_manager.h',
|
||||||
'tests/cefclient/browser/root_window_views.cc',
|
|
||||||
'tests/cefclient/browser/root_window_views.h',
|
|
||||||
'tests/cefclient/browser/scheme_test.cc',
|
'tests/cefclient/browser/scheme_test.cc',
|
||||||
'tests/cefclient/browser/scheme_test.h',
|
'tests/cefclient/browser/scheme_test.h',
|
||||||
'tests/cefclient/browser/server_test.cc',
|
|
||||||
'tests/cefclient/browser/server_test.h',
|
|
||||||
'tests/cefclient/browser/temp_window.h',
|
'tests/cefclient/browser/temp_window.h',
|
||||||
'tests/cefclient/browser/test_runner.cc',
|
'tests/cefclient/browser/test_runner.cc',
|
||||||
'tests/cefclient/browser/test_runner.h',
|
'tests/cefclient/browser/test_runner.h',
|
||||||
'tests/cefclient/browser/urlrequest_test.cc',
|
'tests/cefclient/browser/urlrequest_test.cc',
|
||||||
'tests/cefclient/browser/urlrequest_test.h',
|
'tests/cefclient/browser/urlrequest_test.h',
|
||||||
'tests/cefclient/browser/views_menu_bar.cc',
|
|
||||||
'tests/cefclient/browser/views_menu_bar.h',
|
|
||||||
'tests/cefclient/browser/views_overlay_controls.cc',
|
|
||||||
'tests/cefclient/browser/views_overlay_controls.h',
|
|
||||||
'tests/cefclient/browser/views_style.cc',
|
|
||||||
'tests/cefclient/browser/views_style.h',
|
|
||||||
'tests/cefclient/browser/views_window.cc',
|
|
||||||
'tests/cefclient/browser/views_window.h',
|
|
||||||
'tests/cefclient/browser/window_test.cc',
|
'tests/cefclient/browser/window_test.cc',
|
||||||
'tests/cefclient/browser/window_test.h',
|
'tests/cefclient/browser/window_test.h',
|
||||||
'tests/cefclient/browser/window_test_runner.cc',
|
'tests/cefclient/browser/window_test_runner.cc',
|
||||||
'tests/cefclient/browser/window_test_runner.h',
|
'tests/cefclient/browser/window_test_runner.h',
|
||||||
'tests/cefclient/browser/window_test_runner_views.cc',
|
|
||||||
'tests/cefclient/browser/window_test_runner_views.h',
|
|
||||||
],
|
],
|
||||||
'cefclient_sources_common': [
|
'cefclient_sources_common': [
|
||||||
|
'tests/cefclient/common/client_app.cc',
|
||||||
|
'tests/cefclient/common/client_app.h',
|
||||||
'tests/cefclient/common/client_app_delegates_common.cc',
|
'tests/cefclient/common/client_app_delegates_common.cc',
|
||||||
|
'tests/cefclient/common/client_app_other.cc',
|
||||||
|
'tests/cefclient/common/client_app_other.h',
|
||||||
|
'tests/cefclient/common/client_switches.cc',
|
||||||
|
'tests/cefclient/common/client_switches.h',
|
||||||
'tests/cefclient/common/scheme_test_common.cc',
|
'tests/cefclient/common/scheme_test_common.cc',
|
||||||
'tests/cefclient/common/scheme_test_common.h',
|
'tests/cefclient/common/scheme_test_common.h',
|
||||||
],
|
],
|
||||||
'cefclient_sources_renderer': [
|
'cefclient_sources_renderer': [
|
||||||
'tests/cefclient/renderer/client_app_delegates_renderer.cc',
|
'tests/cefclient/renderer/client_app_delegates_renderer.cc',
|
||||||
|
'tests/cefclient/renderer/client_app_renderer.cc',
|
||||||
|
'tests/cefclient/renderer/client_app_renderer.h',
|
||||||
'tests/cefclient/renderer/client_renderer.cc',
|
'tests/cefclient/renderer/client_renderer.cc',
|
||||||
'tests/cefclient/renderer/client_renderer.h',
|
'tests/cefclient/renderer/client_renderer.h',
|
||||||
'tests/cefclient/renderer/performance_test.cc',
|
'tests/cefclient/renderer/performance_test.cc',
|
||||||
@@ -297,70 +216,58 @@
|
|||||||
'tests/cefclient/resources/binding.html',
|
'tests/cefclient/resources/binding.html',
|
||||||
'tests/cefclient/resources/dialogs.html',
|
'tests/cefclient/resources/dialogs.html',
|
||||||
'tests/cefclient/resources/draggable.html',
|
'tests/cefclient/resources/draggable.html',
|
||||||
|
'tests/cefclient/resources/drm.html',
|
||||||
'tests/cefclient/resources/localstorage.html',
|
'tests/cefclient/resources/localstorage.html',
|
||||||
'tests/cefclient/resources/logo.png',
|
'tests/cefclient/resources/logo.png',
|
||||||
'tests/cefclient/resources/media_router.html',
|
|
||||||
'tests/cefclient/resources/menu_icon.1x.png',
|
'tests/cefclient/resources/menu_icon.1x.png',
|
||||||
'tests/cefclient/resources/menu_icon.2x.png',
|
'tests/cefclient/resources/menu_icon.2x.png',
|
||||||
|
'tests/cefclient/resources/osr_test.html',
|
||||||
'tests/cefclient/resources/other_tests.html',
|
'tests/cefclient/resources/other_tests.html',
|
||||||
|
'tests/cefclient/resources/pdf.html',
|
||||||
|
'tests/cefclient/resources/pdf.pdf',
|
||||||
'tests/cefclient/resources/performance.html',
|
'tests/cefclient/resources/performance.html',
|
||||||
'tests/cefclient/resources/performance2.html',
|
'tests/cefclient/resources/performance2.html',
|
||||||
'tests/cefclient/resources/preferences.html',
|
'tests/cefclient/resources/preferences.html',
|
||||||
'tests/cefclient/resources/response_filter.html',
|
'tests/cefclient/resources/response_filter.html',
|
||||||
'tests/cefclient/resources/server.html',
|
|
||||||
'tests/cefclient/resources/transparency.html',
|
'tests/cefclient/resources/transparency.html',
|
||||||
'tests/cefclient/resources/urlrequest.html',
|
'tests/cefclient/resources/urlrequest.html',
|
||||||
'tests/cefclient/resources/websocket.html',
|
|
||||||
'tests/cefclient/resources/window.html',
|
'tests/cefclient/resources/window.html',
|
||||||
|
'tests/cefclient/resources/window_icon.1x.png',
|
||||||
|
'tests/cefclient/resources/window_icon.2x.png',
|
||||||
'tests/cefclient/resources/xmlhttprequest.html',
|
'tests/cefclient/resources/xmlhttprequest.html',
|
||||||
],
|
],
|
||||||
'cefclient_sources_resources_extensions_set_page_color': [
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/icon.png',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/manifest.json',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/popup.html',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/popup.js',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/README.md',
|
|
||||||
],
|
|
||||||
'cefclient_sources_win': [
|
'cefclient_sources_win': [
|
||||||
'tests/cefclient/browser/browser_window_osr_win.cc',
|
'tests/cefclient/browser/browser_window_osr_win.cc',
|
||||||
'tests/cefclient/browser/browser_window_osr_win.h',
|
'tests/cefclient/browser/browser_window_osr_win.h',
|
||||||
'tests/cefclient/browser/browser_window_std_win.cc',
|
'tests/cefclient/browser/browser_window_std_win.cc',
|
||||||
'tests/cefclient/browser/browser_window_std_win.h',
|
'tests/cefclient/browser/browser_window_std_win.h',
|
||||||
'tests/cefclient/browser/main_context_impl_win.cc',
|
'tests/cefclient/browser/main_context_impl_win.cc',
|
||||||
|
'tests/cefclient/browser/main_message_loop_external_pump_win.cc',
|
||||||
'tests/cefclient/browser/main_message_loop_multithreaded_win.cc',
|
'tests/cefclient/browser/main_message_loop_multithreaded_win.cc',
|
||||||
'tests/cefclient/browser/main_message_loop_multithreaded_win.h',
|
'tests/cefclient/browser/main_message_loop_multithreaded_win.h',
|
||||||
'tests/cefclient/browser/osr_accessibility_helper.cc',
|
|
||||||
'tests/cefclient/browser/osr_accessibility_helper.h',
|
|
||||||
'tests/cefclient/browser/osr_accessibility_node.cc',
|
|
||||||
'tests/cefclient/browser/osr_accessibility_node.h',
|
|
||||||
'tests/cefclient/browser/osr_accessibility_node_win.cc',
|
|
||||||
'tests/cefclient/browser/osr_dragdrop_win.cc',
|
'tests/cefclient/browser/osr_dragdrop_win.cc',
|
||||||
'tests/cefclient/browser/osr_dragdrop_win.h',
|
'tests/cefclient/browser/osr_dragdrop_win.h',
|
||||||
'tests/cefclient/browser/osr_ime_handler_win.cc',
|
|
||||||
'tests/cefclient/browser/osr_ime_handler_win.h',
|
|
||||||
'tests/cefclient/browser/osr_d3d11_win.cc',
|
|
||||||
'tests/cefclient/browser/osr_d3d11_win.h',
|
|
||||||
'tests/cefclient/browser/osr_render_handler_win.cc',
|
|
||||||
'tests/cefclient/browser/osr_render_handler_win.h',
|
|
||||||
'tests/cefclient/browser/osr_render_handler_win_d3d11.cc',
|
|
||||||
'tests/cefclient/browser/osr_render_handler_win_d3d11.h',
|
|
||||||
'tests/cefclient/browser/osr_render_handler_win_gl.cc',
|
|
||||||
'tests/cefclient/browser/osr_render_handler_win_gl.h',
|
|
||||||
'tests/cefclient/browser/osr_window_win.cc',
|
'tests/cefclient/browser/osr_window_win.cc',
|
||||||
'tests/cefclient/browser/osr_window_win.h',
|
'tests/cefclient/browser/osr_window_win.h',
|
||||||
'tests/cefclient/browser/resource_util_win_idmap.cc',
|
'tests/cefclient/browser/resource_util_win.cc',
|
||||||
|
'tests/cefclient/browser/root_window_views.cc',
|
||||||
|
'tests/cefclient/browser/root_window_views.h',
|
||||||
'tests/cefclient/browser/root_window_win.cc',
|
'tests/cefclient/browser/root_window_win.cc',
|
||||||
'tests/cefclient/browser/root_window_win.h',
|
'tests/cefclient/browser/root_window_win.h',
|
||||||
'tests/cefclient/browser/temp_window_win.cc',
|
'tests/cefclient/browser/temp_window_win.cc',
|
||||||
'tests/cefclient/browser/temp_window_win.h',
|
'tests/cefclient/browser/temp_window_win.h',
|
||||||
|
'tests/cefclient/browser/util_win.cc',
|
||||||
|
'tests/cefclient/browser/util_win.h',
|
||||||
|
'tests/cefclient/browser/views_window.cc',
|
||||||
|
'tests/cefclient/browser/views_window.h',
|
||||||
|
'tests/cefclient/browser/window_test_runner_views.cc',
|
||||||
|
'tests/cefclient/browser/window_test_runner_views.h',
|
||||||
'tests/cefclient/browser/window_test_runner_win.cc',
|
'tests/cefclient/browser/window_test_runner_win.cc',
|
||||||
'tests/cefclient/browser/window_test_runner_win.h',
|
'tests/cefclient/browser/window_test_runner_win.h',
|
||||||
'tests/cefclient/cefclient_win.cc',
|
'tests/cefclient/cefclient_win.cc',
|
||||||
'tests/cefclient/resources/win/cefclient.rc',
|
|
||||||
],
|
|
||||||
'cefclient_sources_resources_win': [
|
|
||||||
'tests/cefclient/resources/win/cefclient.exe.manifest',
|
'tests/cefclient/resources/win/cefclient.exe.manifest',
|
||||||
'tests/cefclient/resources/win/cefclient.ico',
|
'tests/cefclient/resources/win/cefclient.ico',
|
||||||
|
'tests/cefclient/resources/win/cefclient.rc',
|
||||||
'tests/cefclient/resources/win/small.ico',
|
'tests/cefclient/resources/win/small.ico',
|
||||||
],
|
],
|
||||||
'cefclient_sources_mac': [
|
'cefclient_sources_mac': [
|
||||||
@@ -369,20 +276,19 @@
|
|||||||
'tests/cefclient/browser/browser_window_std_mac.h',
|
'tests/cefclient/browser/browser_window_std_mac.h',
|
||||||
'tests/cefclient/browser/browser_window_std_mac.mm',
|
'tests/cefclient/browser/browser_window_std_mac.mm',
|
||||||
'tests/cefclient/browser/main_context_impl_posix.cc',
|
'tests/cefclient/browser/main_context_impl_posix.cc',
|
||||||
'tests/cefclient/browser/osr_accessibility_helper.cc',
|
'tests/cefclient/browser/main_message_loop_external_pump_mac.mm',
|
||||||
'tests/cefclient/browser/osr_accessibility_helper.h',
|
'tests/cefclient/browser/resource_util_mac.mm',
|
||||||
'tests/cefclient/browser/osr_accessibility_node.cc',
|
'tests/cefclient/browser/resource_util_posix.cc',
|
||||||
'tests/cefclient/browser/osr_accessibility_node.h',
|
|
||||||
'tests/cefclient/browser/osr_accessibility_node_mac.mm',
|
|
||||||
'tests/cefclient/browser/root_window_mac.h',
|
'tests/cefclient/browser/root_window_mac.h',
|
||||||
'tests/cefclient/browser/root_window_mac.mm',
|
'tests/cefclient/browser/root_window_mac.mm',
|
||||||
'tests/cefclient/browser/temp_window_mac.h',
|
'tests/cefclient/browser/temp_window_mac.h',
|
||||||
'tests/cefclient/browser/temp_window_mac.mm',
|
'tests/cefclient/browser/temp_window_mac.mm',
|
||||||
'tests/cefclient/browser/text_input_client_osr_mac.h',
|
|
||||||
'tests/cefclient/browser/text_input_client_osr_mac.mm',
|
|
||||||
'tests/cefclient/browser/window_test_runner_mac.h',
|
'tests/cefclient/browser/window_test_runner_mac.h',
|
||||||
'tests/cefclient/browser/window_test_runner_mac.mm',
|
'tests/cefclient/browser/window_test_runner_mac.mm',
|
||||||
'tests/cefclient/cefclient_mac.mm',
|
'tests/cefclient/cefclient_mac.mm',
|
||||||
|
],
|
||||||
|
'cefclient_sources_mac_helper': [
|
||||||
|
'tests/cefclient/process_helper_mac.cc',
|
||||||
],
|
],
|
||||||
'cefclient_bundle_resources_mac': [
|
'cefclient_bundle_resources_mac': [
|
||||||
'tests/cefclient/resources/mac/cefclient.icns',
|
'tests/cefclient/resources/mac/cefclient.icns',
|
||||||
@@ -398,19 +304,23 @@
|
|||||||
'tests/cefclient/browser/dialog_handler_gtk.cc',
|
'tests/cefclient/browser/dialog_handler_gtk.cc',
|
||||||
'tests/cefclient/browser/dialog_handler_gtk.h',
|
'tests/cefclient/browser/dialog_handler_gtk.h',
|
||||||
'tests/cefclient/browser/main_context_impl_posix.cc',
|
'tests/cefclient/browser/main_context_impl_posix.cc',
|
||||||
'tests/cefclient/browser/main_message_loop_multithreaded_gtk.cc',
|
'tests/cefclient/browser/main_message_loop_external_pump_linux.cc',
|
||||||
'tests/cefclient/browser/main_message_loop_multithreaded_gtk.h',
|
|
||||||
'tests/cefclient/browser/print_handler_gtk.cc',
|
'tests/cefclient/browser/print_handler_gtk.cc',
|
||||||
'tests/cefclient/browser/print_handler_gtk.h',
|
'tests/cefclient/browser/print_handler_gtk.h',
|
||||||
'tests/cefclient/browser/resource_util_linux.cc',
|
'tests/cefclient/browser/resource_util_linux.cc',
|
||||||
|
'tests/cefclient/browser/resource_util_posix.cc',
|
||||||
'tests/cefclient/browser/root_window_gtk.cc',
|
'tests/cefclient/browser/root_window_gtk.cc',
|
||||||
'tests/cefclient/browser/root_window_gtk.h',
|
'tests/cefclient/browser/root_window_gtk.h',
|
||||||
|
'tests/cefclient/browser/root_window_views.cc',
|
||||||
|
'tests/cefclient/browser/root_window_views.h',
|
||||||
'tests/cefclient/browser/temp_window_x11.cc',
|
'tests/cefclient/browser/temp_window_x11.cc',
|
||||||
'tests/cefclient/browser/temp_window_x11.h',
|
'tests/cefclient/browser/temp_window_x11.h',
|
||||||
'tests/cefclient/browser/util_gtk.cc',
|
'tests/cefclient/browser/views_window.cc',
|
||||||
'tests/cefclient/browser/util_gtk.h',
|
'tests/cefclient/browser/views_window.h',
|
||||||
'tests/cefclient/browser/window_test_runner_gtk.cc',
|
'tests/cefclient/browser/window_test_runner_gtk.cc',
|
||||||
'tests/cefclient/browser/window_test_runner_gtk.h',
|
'tests/cefclient/browser/window_test_runner_gtk.h',
|
||||||
|
'tests/cefclient/browser/window_test_runner_views.cc',
|
||||||
|
'tests/cefclient/browser/window_test_runner_views.h',
|
||||||
'tests/cefclient/cefclient_gtk.cc',
|
'tests/cefclient/cefclient_gtk.cc',
|
||||||
],
|
],
|
||||||
'cefsimple_sources_common': [
|
'cefsimple_sources_common': [
|
||||||
@@ -420,13 +330,11 @@
|
|||||||
'tests/cefsimple/simple_handler.h',
|
'tests/cefsimple/simple_handler.h',
|
||||||
],
|
],
|
||||||
'cefsimple_sources_win': [
|
'cefsimple_sources_win': [
|
||||||
|
'tests/cefsimple/cefsimple.exe.manifest',
|
||||||
'tests/cefsimple/cefsimple.rc',
|
'tests/cefsimple/cefsimple.rc',
|
||||||
'tests/cefsimple/cefsimple_win.cc',
|
'tests/cefsimple/cefsimple_win.cc',
|
||||||
'tests/cefsimple/simple_handler_win.cc',
|
'tests/cefsimple/simple_handler_win.cc',
|
||||||
'tests/cefsimple/resource.h',
|
'tests/cefsimple/resource.h',
|
||||||
],
|
|
||||||
'cefsimple_sources_resources_win': [
|
|
||||||
'tests/cefsimple/cefsimple.exe.manifest',
|
|
||||||
'tests/cefsimple/res/cefsimple.ico',
|
'tests/cefsimple/res/cefsimple.ico',
|
||||||
'tests/cefsimple/res/small.ico',
|
'tests/cefsimple/res/small.ico',
|
||||||
],
|
],
|
||||||
@@ -447,158 +355,5 @@
|
|||||||
'tests/cefsimple/cefsimple_linux.cc',
|
'tests/cefsimple/cefsimple_linux.cc',
|
||||||
'tests/cefsimple/simple_handler_linux.cc',
|
'tests/cefsimple/simple_handler_linux.cc',
|
||||||
],
|
],
|
||||||
'ceftests_sources_common': [
|
|
||||||
'tests/ceftests/audio_output_unittest.cc',
|
|
||||||
'tests/ceftests/browser_info_map_unittest.cc',
|
|
||||||
'tests/ceftests/command_line_unittest.cc',
|
|
||||||
'tests/ceftests/cookie_unittest.cc',
|
|
||||||
'tests/ceftests/cors_unittest.cc',
|
|
||||||
'tests/ceftests/devtools_message_unittest.cc',
|
|
||||||
'tests/ceftests/dialog_unittest.cc',
|
|
||||||
'tests/ceftests/display_unittest.cc',
|
|
||||||
'tests/ceftests/dom_unittest.cc',
|
|
||||||
'tests/ceftests/download_unittest.cc',
|
|
||||||
'tests/ceftests/draggable_regions_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/background_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/chrome_alarms_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/chrome_storage_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/chrome_tabs_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/extension_test_handler.cc',
|
|
||||||
'tests/ceftests/extensions/extension_test_handler.h',
|
|
||||||
'tests/ceftests/extensions/view_unittest.cc',
|
|
||||||
'tests/ceftests/file_util_unittest.cc',
|
|
||||||
'tests/ceftests/frame_handler_unittest.cc',
|
|
||||||
'tests/ceftests/frame_unittest.cc',
|
|
||||||
'tests/ceftests/image_unittest.cc',
|
|
||||||
'tests/ceftests/image_util.cc',
|
|
||||||
'tests/ceftests/image_util.h',
|
|
||||||
'tests/ceftests/jsdialog_unittest.cc',
|
|
||||||
'tests/ceftests/life_span_unittest.cc',
|
|
||||||
'tests/ceftests/message_router_unittest.cc',
|
|
||||||
'tests/ceftests/navigation_unittest.cc',
|
|
||||||
'tests/ceftests/os_rendering_unittest.cc',
|
|
||||||
'tests/ceftests/osr_accessibility_unittest.cc',
|
|
||||||
'tests/ceftests/osr_display_unittest.cc',
|
|
||||||
'tests/ceftests/parser_unittest.cc',
|
|
||||||
'tests/ceftests/plugin_unittest.cc',
|
|
||||||
'tests/ceftests/preference_unittest.cc',
|
|
||||||
'tests/ceftests/print_unittest.cc',
|
|
||||||
'tests/ceftests/process_message_unittest.cc',
|
|
||||||
'tests/ceftests/request_context_unittest.cc',
|
|
||||||
'tests/ceftests/request_handler_unittest.cc',
|
|
||||||
'tests/ceftests/request_unittest.cc',
|
|
||||||
'tests/ceftests/response_unittest.cc',
|
|
||||||
'tests/ceftests/resource.h',
|
|
||||||
'tests/ceftests/resource_manager_unittest.cc',
|
|
||||||
'tests/ceftests/resource_request_handler_unittest.cc',
|
|
||||||
'tests/ceftests/routing_test_handler.cc',
|
|
||||||
'tests/ceftests/routing_test_handler.h',
|
|
||||||
'tests/ceftests/run_all_unittests.cc',
|
|
||||||
'tests/ceftests/scheme_handler_unittest.cc',
|
|
||||||
'tests/ceftests/scoped_temp_dir_unittest.cc',
|
|
||||||
'tests/ceftests/server_unittest.cc',
|
|
||||||
'tests/ceftests/stream_unittest.cc',
|
|
||||||
'tests/ceftests/stream_resource_handler_unittest.cc',
|
|
||||||
'tests/ceftests/string_unittest.cc',
|
|
||||||
'tests/ceftests/client_app_delegates.cc',
|
|
||||||
'tests/ceftests/task_unittest.cc',
|
|
||||||
'tests/ceftests/test_handler.cc',
|
|
||||||
'tests/ceftests/test_handler.h',
|
|
||||||
'tests/ceftests/test_request.cc',
|
|
||||||
'tests/ceftests/test_request.h',
|
|
||||||
'tests/ceftests/test_server.cc',
|
|
||||||
'tests/ceftests/test_server.h',
|
|
||||||
'tests/ceftests/test_server_unittest.cc',
|
|
||||||
'tests/ceftests/test_suite.cc',
|
|
||||||
'tests/ceftests/test_suite.h',
|
|
||||||
'tests/ceftests/test_util.cc',
|
|
||||||
'tests/ceftests/test_util.h',
|
|
||||||
'tests/ceftests/thread_helper.cc',
|
|
||||||
'tests/ceftests/thread_helper.h',
|
|
||||||
'tests/ceftests/thread_unittest.cc',
|
|
||||||
'tests/ceftests/tracing_unittest.cc',
|
|
||||||
'tests/ceftests/track_callback.h',
|
|
||||||
'tests/ceftests/translator_unittest.cc',
|
|
||||||
'tests/ceftests/urlrequest_unittest.cc',
|
|
||||||
'tests/ceftests/v8_unittest.cc',
|
|
||||||
'tests/ceftests/values_unittest.cc',
|
|
||||||
'tests/ceftests/version_unittest.cc',
|
|
||||||
'tests/ceftests/views/button_unittest.cc',
|
|
||||||
'tests/ceftests/views/panel_unittest.cc',
|
|
||||||
'tests/ceftests/views/scroll_view_unittest.cc',
|
|
||||||
'tests/ceftests/views/test_window_delegate.cc',
|
|
||||||
'tests/ceftests/views/test_window_delegate.h',
|
|
||||||
'tests/ceftests/views/textfield_unittest.cc',
|
|
||||||
'tests/ceftests/views/window_unittest.cc',
|
|
||||||
'tests/ceftests/waitable_event_unittest.cc',
|
|
||||||
'tests/ceftests/webui_unittest.cc',
|
|
||||||
'tests/ceftests/xml_reader_unittest.cc',
|
|
||||||
'tests/ceftests/zip_reader_unittest.cc',
|
|
||||||
],
|
|
||||||
'ceftests_sources_win': [
|
|
||||||
'tests/ceftests/resource_util_win_idmap.cc',
|
|
||||||
'tests/ceftests/resources/win/ceftests.rc',
|
|
||||||
],
|
|
||||||
'ceftests_sources_resources_win': [
|
|
||||||
'tests/ceftests/resources/win/ceftests.exe.manifest',
|
|
||||||
'tests/ceftests/resources/win/ceftests.ico',
|
|
||||||
'tests/ceftests/resources/win/small.ico',
|
|
||||||
],
|
|
||||||
'ceftests_sources_mac': [
|
|
||||||
'tests/ceftests/os_rendering_unittest_mac.h',
|
|
||||||
'tests/ceftests/os_rendering_unittest_mac.mm',
|
|
||||||
'tests/ceftests/run_all_unittests_mac.mm',
|
|
||||||
],
|
|
||||||
'ceftests_sources_mac_helper': [
|
|
||||||
'tests/shared/browser/file_util.cc',
|
|
||||||
'tests/shared/browser/file_util.h',
|
|
||||||
'tests/shared/browser/resource_util.h',
|
|
||||||
'tests/shared/browser/resource_util_mac.mm',
|
|
||||||
'tests/shared/browser/resource_util_posix.cc',
|
|
||||||
'tests/ceftests/audio_output_unittest.cc',
|
|
||||||
'tests/ceftests/client_app_delegates.cc',
|
|
||||||
'tests/ceftests/cookie_unittest.cc',
|
|
||||||
'tests/ceftests/cors_unittest.cc',
|
|
||||||
'tests/ceftests/dom_unittest.cc',
|
|
||||||
'tests/ceftests/frame_unittest.cc',
|
|
||||||
'tests/ceftests/message_router_unittest.cc',
|
|
||||||
'tests/ceftests/navigation_unittest.cc',
|
|
||||||
'tests/ceftests/plugin_unittest.cc',
|
|
||||||
'tests/ceftests/preference_unittest.cc',
|
|
||||||
'tests/ceftests/process_message_unittest.cc',
|
|
||||||
'tests/ceftests/request_handler_unittest.cc',
|
|
||||||
'tests/ceftests/request_unittest.cc',
|
|
||||||
'tests/ceftests/response_unittest.cc',
|
|
||||||
'tests/ceftests/resource_request_handler_unittest.cc',
|
|
||||||
'tests/ceftests/routing_test_handler.cc',
|
|
||||||
'tests/ceftests/routing_test_handler.h',
|
|
||||||
'tests/ceftests/scheme_handler_unittest.cc',
|
|
||||||
'tests/ceftests/urlrequest_unittest.cc',
|
|
||||||
'tests/ceftests/test_handler.cc',
|
|
||||||
'tests/ceftests/test_handler.h',
|
|
||||||
'tests/ceftests/test_request.cc',
|
|
||||||
'tests/ceftests/test_request.h',
|
|
||||||
'tests/ceftests/test_server.cc',
|
|
||||||
'tests/ceftests/test_server.h',
|
|
||||||
'tests/ceftests/test_suite.cc',
|
|
||||||
'tests/ceftests/test_suite.h',
|
|
||||||
'tests/ceftests/test_util.cc',
|
|
||||||
'tests/ceftests/test_util.h',
|
|
||||||
'tests/ceftests/track_callback.h',
|
|
||||||
'tests/ceftests/thread_helper.cc',
|
|
||||||
'tests/ceftests/thread_helper.h',
|
|
||||||
'tests/ceftests/thread_unittest.cc',
|
|
||||||
'tests/ceftests/tracing_unittest.cc',
|
|
||||||
'tests/ceftests/v8_unittest.cc',
|
|
||||||
],
|
|
||||||
'ceftests_bundle_resources_mac': [
|
|
||||||
'tests/ceftests/resources/mac/ceftests.icns',
|
|
||||||
'tests/ceftests/resources/mac/English.lproj/InfoPlist.strings',
|
|
||||||
'tests/ceftests/resources/mac/English.lproj/MainMenu.xib',
|
|
||||||
'tests/ceftests/resources/mac/Info.plist',
|
|
||||||
],
|
|
||||||
'ceftests_sources_linux': [
|
|
||||||
'tests/ceftests/resource_util_linux.cc',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
123
cef_repack_locales.gni
Normal file
123
cef_repack_locales.gni
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
|
||||||
|
# 2014 the Chromium Authors. All rights reserved. Use of this source code is
|
||||||
|
# governed by a BSD-style license that can be found in the LICENSE file.
|
||||||
|
#
|
||||||
|
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
|
||||||
|
# modifications to meet CEF's requirements.
|
||||||
|
|
||||||
|
import("//build/config/chrome_build.gni")
|
||||||
|
import("//build/config/features.gni")
|
||||||
|
import("//build/config/ui.gni")
|
||||||
|
import("//tools/grit/repack.gni")
|
||||||
|
|
||||||
|
# Arguments:
|
||||||
|
#
|
||||||
|
# locale
|
||||||
|
# Internal name of locale. e.g. "pt-BR"
|
||||||
|
#
|
||||||
|
# output
|
||||||
|
# Output file name.
|
||||||
|
#
|
||||||
|
# visibility
|
||||||
|
# Normal meaning.
|
||||||
|
template("_repack_one_locale") {
|
||||||
|
locale = invoker.locale
|
||||||
|
|
||||||
|
repack(target_name) {
|
||||||
|
visibility = invoker.visibility
|
||||||
|
|
||||||
|
# Each input pak file should also have a deps line for completeness.
|
||||||
|
sources = [
|
||||||
|
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
|
||||||
|
"${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Use public_deps so that generated grit headers are discoverable from
|
||||||
|
# the libcef_static target. Grit deps that generate .cc files must be
|
||||||
|
# listed both here and in the libcef_static target.
|
||||||
|
public_deps = [
|
||||||
|
":cef_strings",
|
||||||
|
"//chrome/app/resources:platform_locale_settings",
|
||||||
|
"//components/strings:components_locale_settings",
|
||||||
|
"//components/strings:components_strings",
|
||||||
|
"//content/app/strings",
|
||||||
|
"//extensions/strings",
|
||||||
|
"//ui/strings:app_locale_settings",
|
||||||
|
"//ui/strings:ui_strings",
|
||||||
|
]
|
||||||
|
|
||||||
|
output = invoker.output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Creates an action to call the repack_locales script.
|
||||||
|
#
|
||||||
|
# The GYP version generates the locales in the "gen" directory and then copies
|
||||||
|
# it to the root build directory. This isn't easy to express in a GN copy
|
||||||
|
# rule since the files on Mac have a complex structure. So we generate the
|
||||||
|
# files into the final place and skip the "gen" directory.
|
||||||
|
#
|
||||||
|
# This template uses GN's looping constructs to avoid the complex call to
|
||||||
|
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
|
||||||
|
# GYP build.
|
||||||
|
#
|
||||||
|
# Arguments
|
||||||
|
#
|
||||||
|
# input_locales
|
||||||
|
# List of locale names to use as inputs.
|
||||||
|
#
|
||||||
|
# output_locales
|
||||||
|
# A list containing the corresponding output names for each of the
|
||||||
|
# input names. Mac uses different names in some cases.
|
||||||
|
#
|
||||||
|
# visibility
|
||||||
|
template("cef_repack_locales") {
|
||||||
|
# This is the name of the group below that will collect all the invidual
|
||||||
|
# locale targets. External targets will depend on this.
|
||||||
|
group_target_name = target_name
|
||||||
|
|
||||||
|
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
|
||||||
|
# to make a copy and do output_locales[foo].
|
||||||
|
output_locales = invoker.output_locales
|
||||||
|
|
||||||
|
# Collects all targets the loop generates.
|
||||||
|
locale_targets = []
|
||||||
|
|
||||||
|
# This loop iterates over the input locales and also keeps a counter so it
|
||||||
|
# can simultaneously iterate over the output locales (using GN's very
|
||||||
|
# limited looping capabilities).
|
||||||
|
current_index = 0
|
||||||
|
foreach(input_locale, invoker.input_locales) {
|
||||||
|
output_locale = output_locales[current_index]
|
||||||
|
|
||||||
|
# Compute the name of the target for the current file. Save it for the deps.
|
||||||
|
current_name = "${target_name}_${input_locale}"
|
||||||
|
locale_targets += [ ":$current_name" ]
|
||||||
|
|
||||||
|
_repack_one_locale(current_name) {
|
||||||
|
visibility = [ ":$group_target_name" ]
|
||||||
|
locale = input_locale
|
||||||
|
|
||||||
|
# Compute the output name. Mac uses a different location.
|
||||||
|
if (is_mac || is_ios) {
|
||||||
|
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
|
||||||
|
} else {
|
||||||
|
output = "${root_out_dir}/locales/${output_locale}.pak"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
current_index = current_index + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# The group that external targets depend on which collects all deps.
|
||||||
|
group(group_target_name) {
|
||||||
|
forward_variables_from(invoker, [ "visibility" ])
|
||||||
|
public_deps = locale_targets
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,23 +19,22 @@ macro(PRINT_CEF_CONFIG)
|
|||||||
message(STATUS "Platform: ${CMAKE_SYSTEM_NAME}")
|
message(STATUS "Platform: ${CMAKE_SYSTEM_NAME}")
|
||||||
message(STATUS "Project architecture: ${PROJECT_ARCH}")
|
message(STATUS "Project architecture: ${PROJECT_ARCH}")
|
||||||
|
|
||||||
if(GEN_NINJA OR GEN_MAKEFILES)
|
if(${CMAKE_GENERATOR} STREQUAL "Ninja" OR ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
||||||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
|
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
|
||||||
|
|
||||||
if(OS_MAC)
|
if(OS_MACOSX)
|
||||||
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
|
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
|
||||||
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
|
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OS_WINDOWS)
|
if(OS_WINDOWS)
|
||||||
|
message(STATUS "CEF Windows sandbox: ${USE_SANDBOX}")
|
||||||
message(STATUS "Visual Studio ATL support: ${USE_ATL}")
|
message(STATUS "Visual Studio ATL support: ${USE_ATL}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "CEF sandbox: ${USE_SANDBOX}")
|
|
||||||
|
|
||||||
set(_libraries ${CEF_STANDARD_LIBS})
|
set(_libraries ${CEF_STANDARD_LIBS})
|
||||||
if(OS_WINDOWS AND USE_SANDBOX)
|
if(OS_WINDOWS AND USE_SANDBOX)
|
||||||
list(APPEND _libraries ${CEF_SANDBOX_STANDARD_LIBS})
|
list(APPEND _libraries ${CEF_SANDBOX_STANDARD_LIBS})
|
||||||
@@ -75,14 +74,15 @@ macro(APPEND_PLATFORM_SOURCES name_of_list)
|
|||||||
if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
|
if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
|
||||||
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
|
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
|
||||||
endif()
|
endif()
|
||||||
if(OS_MAC AND ${name_of_list}_MAC)
|
if(OS_MACOSX AND ${name_of_list}_MACOSX)
|
||||||
list(APPEND ${name_of_list} ${${name_of_list}_MAC})
|
list(APPEND ${name_of_list} ${${name_of_list}_MACOSX})
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Determine the target output directory based on platform and generator.
|
# Determine the target output directory based on platform and generator.
|
||||||
macro(SET_CEF_TARGET_OUT_DIR)
|
macro(SET_CEF_TARGET_OUT_DIR)
|
||||||
if(GEN_NINJA OR GEN_MAKEFILES)
|
if(${CMAKE_GENERATOR} STREQUAL "Ninja" OR
|
||||||
|
${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
||||||
# By default Ninja and Make builds don't create a subdirectory named after
|
# By default Ninja and Make builds don't create a subdirectory named after
|
||||||
# the configuration.
|
# the configuration.
|
||||||
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
|
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
|
||||||
@@ -96,25 +96,11 @@ macro(SET_CEF_TARGET_OUT_DIR)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Copy a list of files from one directory to another. Relative files paths are maintained.
|
# Copy a list of files from one directory to another. Relative files paths are maintained.
|
||||||
# The path component of the source |file_list| will be removed.
|
|
||||||
macro(COPY_FILES target file_list source_dir target_dir)
|
macro(COPY_FILES target file_list source_dir target_dir)
|
||||||
foreach(FILENAME ${file_list})
|
foreach(FILENAME ${file_list})
|
||||||
set(source_file ${source_dir}/${FILENAME})
|
set(source_file ${source_dir}/${FILENAME})
|
||||||
get_filename_component(target_name ${FILENAME} NAME)
|
set(target_file ${target_dir}/${FILENAME})
|
||||||
set(target_file ${target_dir}/${target_name})
|
if(IS_DIRECTORY ${source_file})
|
||||||
|
|
||||||
string(FIND ${source_file} "$<CONFIGURATION>" _pos)
|
|
||||||
if(NOT ${_pos} EQUAL -1)
|
|
||||||
# Must test with an actual configuration directory.
|
|
||||||
string(REPLACE "$<CONFIGURATION>" "Release" existing_source_file ${source_file})
|
|
||||||
if(NOT EXISTS ${existing_source_file})
|
|
||||||
string(REPLACE "$<CONFIGURATION>" "Debug" existing_source_file ${source_file})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(existing_source_file ${source_file})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(IS_DIRECTORY ${existing_source_file})
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${target}
|
TARGET ${target}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
@@ -132,6 +118,19 @@ macro(COPY_FILES target file_list source_dir target_dir)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
# Rename a directory replacing the target if it already exists.
|
||||||
|
macro(RENAME_DIRECTORY target source_dir target_dir)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${target}
|
||||||
|
POST_BUILD
|
||||||
|
# Remove the target directory if it already exists.
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E remove_directory "${target_dir}"
|
||||||
|
# Rename the source directory to target directory.
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E rename "${source_dir}" "${target_dir}"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Linux macros.
|
# Linux macros.
|
||||||
@@ -184,10 +183,26 @@ endif(OS_LINUX)
|
|||||||
# Mac OS X macros.
|
# Mac OS X macros.
|
||||||
#
|
#
|
||||||
|
|
||||||
if(OS_MAC)
|
if(OS_MACOSX)
|
||||||
|
|
||||||
|
# Fix the framework rpath in the helper executable.
|
||||||
|
macro(FIX_MACOSX_HELPER_FRAMEWORK_RPATH target)
|
||||||
|
# The helper is in $app_name.app/Contents/Frameworks/$app_name Helper.app/Contents/MacOS/
|
||||||
|
# so set rpath up to Contents/ so that the loader can find Frameworks/.
|
||||||
|
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@executable_path/../../../..")
|
||||||
|
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# Fix the framework rpath in the main executable.
|
||||||
|
macro(FIX_MACOSX_MAIN_FRAMEWORK_RPATH target)
|
||||||
|
# The main app is at $app_name.app/Contents/MacOS/$app_name
|
||||||
|
# so set rpath up to Contents/ so that the loader can find Frameworks/.
|
||||||
|
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@executable_path/..")
|
||||||
|
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
# Manually process and copy over resource files.
|
# Manually process and copy over resource files.
|
||||||
macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
|
macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path)
|
||||||
foreach(FILENAME ${resource_list})
|
foreach(FILENAME ${resource_list})
|
||||||
# Remove one or more prefixes from the source paths.
|
# Remove one or more prefixes from the source paths.
|
||||||
set(TARGET_FILENAME "${FILENAME}")
|
set(TARGET_FILENAME "${FILENAME}")
|
||||||
@@ -229,7 +244,7 @@ macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
endif(OS_MAC)
|
endif(OS_MACOSX)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -272,17 +287,17 @@ endmacro()
|
|||||||
# SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly.
|
# SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly.
|
||||||
macro(SET_COMMON_TARGET_PROPERTIES target)
|
macro(SET_COMMON_TARGET_PROPERTIES target)
|
||||||
# Compile flags.
|
# Compile flags.
|
||||||
target_compile_options(${target} PRIVATE ${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS})
|
target_compile_options(${target} PUBLIC ${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS})
|
||||||
target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
|
target_compile_options(${target} PUBLIC $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
|
||||||
target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
|
target_compile_options(${target} PUBLIC $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
|
||||||
|
|
||||||
# Compile definitions.
|
# Compile definitions.
|
||||||
target_compile_definitions(${target} PRIVATE ${CEF_COMPILER_DEFINES})
|
target_compile_definitions(${target} PUBLIC ${CEF_COMPILER_DEFINES})
|
||||||
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_DEFINES_DEBUG}>)
|
target_compile_definitions(${target} PUBLIC $<$<CONFIG:Debug>:${CEF_COMPILER_DEFINES_DEBUG}>)
|
||||||
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_DEFINES_RELEASE}>)
|
target_compile_definitions(${target} PUBLIC $<$<CONFIG:Release>:${CEF_COMPILER_DEFINES_RELEASE}>)
|
||||||
|
|
||||||
# Include directories.
|
# Include directories.
|
||||||
target_include_directories(${target} PRIVATE ${CEF_INCLUDE_PATH})
|
target_include_directories(${target} PUBLIC ${CEF_INCLUDE_PATH})
|
||||||
|
|
||||||
# Linker flags.
|
# Linker flags.
|
||||||
if(CEF_LINKER_FLAGS)
|
if(CEF_LINKER_FLAGS)
|
||||||
@@ -298,7 +313,7 @@ macro(SET_COMMON_TARGET_PROPERTIES target)
|
|||||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OS_MAC)
|
if(OS_MACOSX)
|
||||||
# Set Xcode target properties.
|
# Set Xcode target properties.
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO
|
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ endif()
|
|||||||
|
|
||||||
# Determine the platform.
|
# Determine the platform.
|
||||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||||
set(OS_MAC 1)
|
set(OS_MACOSX 1)
|
||||||
set(OS_MACOSX 1) # For backwards compatibility.
|
|
||||||
set(OS_POSIX 1)
|
set(OS_POSIX 1)
|
||||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
set(OS_LINUX 1)
|
set(OS_LINUX 1)
|
||||||
@@ -26,28 +25,21 @@ endif()
|
|||||||
|
|
||||||
# Determine the project architecture.
|
# Determine the project architecture.
|
||||||
if(NOT DEFINED PROJECT_ARCH)
|
if(NOT DEFINED PROJECT_ARCH)
|
||||||
if(OS_WINDOWS AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "arm64")
|
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||||
set(PROJECT_ARCH "arm64")
|
|
||||||
elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
|
||||||
set(PROJECT_ARCH "x86_64")
|
set(PROJECT_ARCH "x86_64")
|
||||||
else()
|
else()
|
||||||
set(PROJECT_ARCH "x86")
|
set(PROJECT_ARCH "x86")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OS_MAC)
|
if(OS_MACOSX)
|
||||||
# PROJECT_ARCH should be specified on Mac OS X.
|
# PROJECT_ARCH should be specified on Mac OS X.
|
||||||
message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}")
|
message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
|
||||||
set(GEN_NINJA 1)
|
|
||||||
elseif(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
|
||||||
set(GEN_MAKEFILES 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Determine the build type.
|
# Determine the build type.
|
||||||
if(NOT CMAKE_BUILD_TYPE AND (GEN_NINJA OR GEN_MAKEFILES))
|
if(NOT CMAKE_BUILD_TYPE AND
|
||||||
|
(${CMAKE_GENERATOR} STREQUAL "Ninja" OR ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles"))
|
||||||
# CMAKE_BUILD_TYPE should be specified when using Ninja or Unix Makefiles.
|
# CMAKE_BUILD_TYPE should be specified when using Ninja or Unix Makefiles.
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
message(WARNING "No CMAKE_BUILD_TYPE value selected, using ${CMAKE_BUILD_TYPE}")
|
message(WARNING "No CMAKE_BUILD_TYPE value selected, using ${CMAKE_BUILD_TYPE}")
|
||||||
@@ -69,10 +61,6 @@ list(APPEND CEF_COMPILER_DEFINES
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Configure use of the sandbox.
|
|
||||||
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Linux configuration.
|
# Linux configuration.
|
||||||
#
|
#
|
||||||
@@ -93,9 +81,6 @@ if(OS_LINUX)
|
|||||||
-Werror # Treat warnings as errors
|
-Werror # Treat warnings as errors
|
||||||
-Wno-missing-field-initializers # Don't warn about missing field initializers
|
-Wno-missing-field-initializers # Don't warn about missing field initializers
|
||||||
-Wno-unused-parameter # Don't warn about unused parameters
|
-Wno-unused-parameter # Don't warn about unused parameters
|
||||||
-Wno-error=comment # Don't warn about code in comments
|
|
||||||
-Wno-comment # Don't warn about code in comments
|
|
||||||
-Wno-deprecated-declarations # Don't warn about using deprecated methods
|
|
||||||
)
|
)
|
||||||
list(APPEND CEF_C_COMPILER_FLAGS
|
list(APPEND CEF_C_COMPILER_FLAGS
|
||||||
-std=c99 # Use the C99 language standard
|
-std=c99 # Use the C99 language standard
|
||||||
@@ -105,7 +90,7 @@ if(OS_LINUX)
|
|||||||
-fno-rtti # Disable real-time type information
|
-fno-rtti # Disable real-time type information
|
||||||
-fno-threadsafe-statics # Don't generate thread-safe statics
|
-fno-threadsafe-statics # Don't generate thread-safe statics
|
||||||
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
||||||
-std=c++14 # Use the C++14 language standard
|
-std=gnu++11 # Use the C++11 language standard including GNU extensions
|
||||||
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
||||||
)
|
)
|
||||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||||
@@ -145,13 +130,6 @@ if(OS_LINUX)
|
|||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
|
||||||
if(COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
|
||||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
|
||||||
-Wno-undefined-var-template # Don't warn about potentially uninstantiated static members
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
CHECK_C_COMPILER_FLAG(-Wno-unused-local-typedefs COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
CHECK_C_COMPILER_FLAG(-Wno-unused-local-typedefs COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
||||||
if(COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
if(COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
||||||
list(APPEND CEF_C_COMPILER_FLAGS
|
list(APPEND CEF_C_COMPILER_FLAGS
|
||||||
@@ -173,12 +151,6 @@ if(OS_LINUX)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
||||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
|
||||||
-Wno-attributes # The cfi-icall attribute is not supported by the GNU C++ compiler
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PROJECT_ARCH STREQUAL "x86_64")
|
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||||
# 64-bit architecture.
|
# 64-bit architecture.
|
||||||
list(APPEND CEF_COMPILER_FLAGS
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
@@ -220,30 +192,20 @@ if(OS_LINUX)
|
|||||||
set(CEF_BINARY_FILES
|
set(CEF_BINARY_FILES
|
||||||
chrome-sandbox
|
chrome-sandbox
|
||||||
libcef.so
|
libcef.so
|
||||||
libEGL.so
|
natives_blob.bin
|
||||||
libGLESv2.so
|
|
||||||
libvk_swiftshader.so
|
|
||||||
libvulkan.so.1
|
|
||||||
snapshot_blob.bin
|
snapshot_blob.bin
|
||||||
v8_context_snapshot.bin
|
|
||||||
vk_swiftshader_icd.json
|
|
||||||
swiftshader
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# List of CEF resource files.
|
# List of CEF resource files.
|
||||||
set(CEF_RESOURCE_FILES
|
set(CEF_RESOURCE_FILES
|
||||||
chrome_100_percent.pak
|
cef.pak
|
||||||
chrome_200_percent.pak
|
cef_100_percent.pak
|
||||||
resources.pak
|
cef_200_percent.pak
|
||||||
|
cef_extensions.pak
|
||||||
|
devtools_resources.pak
|
||||||
icudtl.dat
|
icudtl.dat
|
||||||
locales
|
locales
|
||||||
)
|
)
|
||||||
|
|
||||||
if(USE_SANDBOX)
|
|
||||||
list(APPEND CEF_COMPILER_DEFINES
|
|
||||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@@ -251,9 +213,9 @@ endif()
|
|||||||
# Mac OS X configuration.
|
# Mac OS X configuration.
|
||||||
#
|
#
|
||||||
|
|
||||||
if(OS_MAC)
|
if(OS_MACOSX)
|
||||||
# Platform-specific compiler/linker flags.
|
# Platform-specific compiler/linker flags.
|
||||||
# See also Xcode target properties in cef_macros.cmake.
|
# See also Xcode target properties in macros.cmake.
|
||||||
set(CEF_LIBTYPE SHARED)
|
set(CEF_LIBTYPE SHARED)
|
||||||
list(APPEND CEF_COMPILER_FLAGS
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
-fno-strict-aliasing # Avoid assumptions regarding non-aliasing of objects of different types
|
-fno-strict-aliasing # Avoid assumptions regarding non-aliasing of objects of different types
|
||||||
@@ -277,7 +239,7 @@ if(OS_MAC)
|
|||||||
-fno-threadsafe-statics # Don't generate thread-safe statics
|
-fno-threadsafe-statics # Don't generate thread-safe statics
|
||||||
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
|
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
|
||||||
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
||||||
-std=c++14 # Use the C++14 language standard
|
-std=gnu++11 # Use the C++11 language standard including GNU extensions
|
||||||
-Wno-narrowing # Don't warn about type narrowing
|
-Wno-narrowing # Don't warn about type narrowing
|
||||||
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
||||||
)
|
)
|
||||||
@@ -297,15 +259,6 @@ if(OS_MAC)
|
|||||||
-Wl,-dead_strip # Strip dead code
|
-Wl,-dead_strip # Strip dead code
|
||||||
)
|
)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
|
|
||||||
CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
|
||||||
if(COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
|
||||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
|
||||||
-Wno-undefined-var-template # Don't warn about potentially uninstantiated static members
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Standard libraries.
|
# Standard libraries.
|
||||||
set(CEF_STANDARD_LIBS
|
set(CEF_STANDARD_LIBS
|
||||||
-lpthread
|
-lpthread
|
||||||
@@ -315,7 +268,7 @@ if(OS_MAC)
|
|||||||
|
|
||||||
# Find the newest available base SDK.
|
# Find the newest available base SDK.
|
||||||
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
foreach(OS_VERSION 10.15 10.14 10.13 10.12 10.11)
|
foreach(OS_VERSION 10.10 10.9 10.8 10.7)
|
||||||
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
|
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
|
||||||
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
|
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
|
||||||
set(CMAKE_OSX_SYSROOT ${SDK})
|
set(CMAKE_OSX_SYSROOT ${SDK})
|
||||||
@@ -323,7 +276,7 @@ if(OS_MAC)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Target SDK.
|
# Target SDK.
|
||||||
set(CEF_TARGET_SDK "10.11")
|
set(CEF_TARGET_SDK "10.7")
|
||||||
list(APPEND CEF_COMPILER_FLAGS
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
-mmacosx-version-min=${CEF_TARGET_SDK}
|
-mmacosx-version-min=${CEF_TARGET_SDK}
|
||||||
)
|
)
|
||||||
@@ -332,38 +285,18 @@ if(OS_MAC)
|
|||||||
# Target architecture.
|
# Target architecture.
|
||||||
if(PROJECT_ARCH STREQUAL "x86_64")
|
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||||
elseif(PROJECT_ARCH STREQUAL "arm64")
|
|
||||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
|
||||||
else()
|
else()
|
||||||
set(CMAKE_OSX_ARCHITECTURES "i386")
|
set(CMAKE_OSX_ARCHITECTURES "i386")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Prevent Xcode 11 from doing automatic codesigning.
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
|
|
||||||
|
|
||||||
# CEF directory paths.
|
# CEF directory paths.
|
||||||
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
|
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
|
||||||
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
||||||
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/Release")
|
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/Release")
|
||||||
|
|
||||||
if(USE_SANDBOX)
|
# CEF library paths.
|
||||||
list(APPEND CEF_COMPILER_DEFINES
|
set(CEF_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/Chromium Embedded Framework.framework/Chromium Embedded Framework")
|
||||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
set(CEF_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/Chromium Embedded Framework.framework/Chromium Embedded Framework")
|
||||||
)
|
|
||||||
|
|
||||||
# CEF sandbox library paths.
|
|
||||||
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.a")
|
|
||||||
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.a")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# CEF Helper app suffixes.
|
|
||||||
# Format is "<name suffix>:<target suffix>:<plist suffix>".
|
|
||||||
set(CEF_HELPER_APP_SUFFIXES
|
|
||||||
"::"
|
|
||||||
" (GPU):_gpu:.gpu"
|
|
||||||
" (Plugin):_plugin:.plugin"
|
|
||||||
" (Renderer):_renderer:.renderer"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@@ -372,33 +305,27 @@ endif()
|
|||||||
#
|
#
|
||||||
|
|
||||||
if(OS_WINDOWS)
|
if(OS_WINDOWS)
|
||||||
if (GEN_NINJA)
|
# Configure use of the sandbox.
|
||||||
# When using the Ninja generator clear the CMake defaults to avoid excessive
|
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
|
||||||
# console warnings (see issue #2120).
|
if(USE_SANDBOX AND NOT MSVC_VERSION EQUAL 1900)
|
||||||
set(CMAKE_CXX_FLAGS "")
|
# The cef_sandbox.lib static library is currently built with VS2015. It will
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "")
|
# not link successfully with other VS versions.
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_SANDBOX)
|
|
||||||
# Check if the current MSVC version is compatible with the cef_sandbox.lib
|
|
||||||
# static library. We require VS2015 or newer.
|
|
||||||
if(MSVC_VERSION LESS 1900)
|
|
||||||
message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})")
|
|
||||||
set(USE_SANDBOX OFF)
|
set(USE_SANDBOX OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Configure use of official build compiler settings.
|
||||||
|
# When using an official build the "Debug" build is actually a Release build
|
||||||
|
# with DCHECKs enabled. In order to link the sandbox the Debug build must
|
||||||
|
# be configured with some Release-related compiler settings.
|
||||||
|
option(USE_OFFICIAL_BUILD_SANDBOX "Enable or disable use of an official build sandbox." ON)
|
||||||
|
if(NOT USE_SANDBOX)
|
||||||
|
# Don't need official build settings when the sandbox is off.
|
||||||
|
set(USE_OFFICIAL_BUILD_SANDBOX OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
|
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
|
||||||
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
|
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
|
||||||
|
|
||||||
# Consumers using different runtime types may want to pass different flags
|
|
||||||
set(CEF_RUNTIME_LIBRARY_FLAG "/MT" CACHE STRING "Optional flag specifying which runtime to use")
|
|
||||||
if (CEF_RUNTIME_LIBRARY_FLAG)
|
|
||||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG ${CEF_RUNTIME_LIBRARY_FLAG}d)
|
|
||||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE ${CEF_RUNTIME_LIBRARY_FLAG})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Platform-specific compiler/linker flags.
|
# Platform-specific compiler/linker flags.
|
||||||
set(CEF_LIBTYPE STATIC)
|
set(CEF_LIBTYPE STATIC)
|
||||||
list(APPEND CEF_COMPILER_FLAGS
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
@@ -410,7 +337,6 @@ if(OS_WINDOWS)
|
|||||||
/wd4100 # Ignore "unreferenced formal parameter" warning
|
/wd4100 # Ignore "unreferenced formal parameter" warning
|
||||||
/wd4127 # Ignore "conditional expression is constant" warning
|
/wd4127 # Ignore "conditional expression is constant" warning
|
||||||
/wd4244 # Ignore "conversion possible loss of data" warning
|
/wd4244 # Ignore "conversion possible loss of data" warning
|
||||||
/wd4324 # Ignore "structure was padded due to alignment specifier" warning
|
|
||||||
/wd4481 # Ignore "nonstandard extension used: override" warning
|
/wd4481 # Ignore "nonstandard extension used: override" warning
|
||||||
/wd4512 # Ignore "assignment operator could not be generated" warning
|
/wd4512 # Ignore "assignment operator could not be generated" warning
|
||||||
/wd4701 # Ignore "potentially uninitialized local variable" warning
|
/wd4701 # Ignore "potentially uninitialized local variable" warning
|
||||||
@@ -418,11 +344,24 @@ if(OS_WINDOWS)
|
|||||||
/wd4996 # Ignore "function or variable may be unsafe" warning
|
/wd4996 # Ignore "function or variable may be unsafe" warning
|
||||||
${CEF_DEBUG_INFO_FLAG}
|
${CEF_DEBUG_INFO_FLAG}
|
||||||
)
|
)
|
||||||
|
if(USE_OFFICIAL_BUILD_SANDBOX)
|
||||||
|
# CMake adds /RTC1, /D"_DEBUG" and a few other values by default for Debug
|
||||||
|
# builds. We can't link the sandbox with those values so clear the CMake
|
||||||
|
# defaults here.
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "")
|
||||||
|
|
||||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||||
|
/MT # Multithreaded release runtime
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||||
|
/MTd # Multithreaded debug runtime
|
||||||
/RTC1 # Disable optimizations
|
/RTC1 # Disable optimizations
|
||||||
/Od # Enable basic run-time checks
|
/Od # Enable basic run-time checks
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
||||||
|
/MT # Multithreaded release runtime
|
||||||
/O2 # Optimize for maximum speed
|
/O2 # Optimize for maximum speed
|
||||||
/Ob2 # Inline any suitable function
|
/Ob2 # Inline any suitable function
|
||||||
/GF # Enable string pooling
|
/GF # Enable string pooling
|
||||||
@@ -437,11 +376,17 @@ if(OS_WINDOWS)
|
|||||||
list(APPEND CEF_COMPILER_DEFINES
|
list(APPEND CEF_COMPILER_DEFINES
|
||||||
WIN32 _WIN32 _WINDOWS # Windows platform
|
WIN32 _WIN32 _WINDOWS # Windows platform
|
||||||
UNICODE _UNICODE # Unicode build
|
UNICODE _UNICODE # Unicode build
|
||||||
WINVER=0x0601 _WIN32_WINNT=0x601 # Targeting Windows 7
|
WINVER=0x0602 _WIN32_WINNT=0x602 # Targeting Windows 8
|
||||||
NOMINMAX # Use the standard's templated min/max
|
NOMINMAX # Use the standard's templated min/max
|
||||||
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
|
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
|
||||||
_HAS_EXCEPTIONS=0 # Disable exceptions
|
_HAS_EXCEPTIONS=0 # Disable exceptions
|
||||||
)
|
)
|
||||||
|
if(USE_OFFICIAL_BUILD_SANDBOX)
|
||||||
|
list(APPEND CEF_COMPILER_DEFINES_DEBUG
|
||||||
|
NDEBUG _NDEBUG # Not a debug build
|
||||||
|
DCHECK_ALWAYS_ON=1 # DCHECKs are enabled
|
||||||
|
)
|
||||||
|
endif()
|
||||||
list(APPEND CEF_COMPILER_DEFINES_RELEASE
|
list(APPEND CEF_COMPILER_DEFINES_RELEASE
|
||||||
NDEBUG _NDEBUG # Not a debug build
|
NDEBUG _NDEBUG # Not a debug build
|
||||||
)
|
)
|
||||||
@@ -449,7 +394,6 @@ if(OS_WINDOWS)
|
|||||||
# Standard libraries.
|
# Standard libraries.
|
||||||
set(CEF_STANDARD_LIBS
|
set(CEF_STANDARD_LIBS
|
||||||
comctl32.lib
|
comctl32.lib
|
||||||
gdi32.lib
|
|
||||||
rpcrt4.lib
|
rpcrt4.lib
|
||||||
shlwapi.lib
|
shlwapi.lib
|
||||||
ws2_32.lib
|
ws2_32.lib
|
||||||
@@ -467,29 +411,22 @@ if(OS_WINDOWS)
|
|||||||
|
|
||||||
# List of CEF binary files.
|
# List of CEF binary files.
|
||||||
set(CEF_BINARY_FILES
|
set(CEF_BINARY_FILES
|
||||||
chrome_elf.dll
|
d3dcompiler_43.dll
|
||||||
|
d3dcompiler_47.dll
|
||||||
libcef.dll
|
libcef.dll
|
||||||
libEGL.dll
|
libEGL.dll
|
||||||
libGLESv2.dll
|
libGLESv2.dll
|
||||||
|
natives_blob.bin
|
||||||
snapshot_blob.bin
|
snapshot_blob.bin
|
||||||
v8_context_snapshot.bin
|
|
||||||
vk_swiftshader.dll
|
|
||||||
vk_swiftshader_icd.json
|
|
||||||
vulkan-1.dll
|
|
||||||
swiftshader
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT PROJECT_ARCH STREQUAL "arm64")
|
|
||||||
list(APPEND CEF_BINARY_FILES
|
|
||||||
d3dcompiler_47.dll
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# List of CEF resource files.
|
# List of CEF resource files.
|
||||||
set(CEF_RESOURCE_FILES
|
set(CEF_RESOURCE_FILES
|
||||||
chrome_100_percent.pak
|
cef.pak
|
||||||
chrome_200_percent.pak
|
cef_100_percent.pak
|
||||||
resources.pak
|
cef_200_percent.pak
|
||||||
|
cef_extensions.pak
|
||||||
|
devtools_resources.pak
|
||||||
icudtl.dat
|
icudtl.dat
|
||||||
locales
|
locales
|
||||||
)
|
)
|
||||||
@@ -499,23 +436,12 @@ if(OS_WINDOWS)
|
|||||||
PSAPI_VERSION=1 # Required by cef_sandbox.lib
|
PSAPI_VERSION=1 # Required by cef_sandbox.lib
|
||||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
||||||
)
|
)
|
||||||
list(APPEND CEF_COMPILER_DEFINES_DEBUG
|
|
||||||
_HAS_ITERATOR_DEBUGGING=0 # Disable iterator debugging
|
|
||||||
)
|
|
||||||
|
|
||||||
# Libraries required by cef_sandbox.lib.
|
# Libraries required by cef_sandbox.lib.
|
||||||
set(CEF_SANDBOX_STANDARD_LIBS
|
set(CEF_SANDBOX_STANDARD_LIBS
|
||||||
Advapi32.lib
|
|
||||||
dbghelp.lib
|
dbghelp.lib
|
||||||
Delayimp.lib
|
|
||||||
OleAut32.lib
|
|
||||||
PowrProf.lib
|
|
||||||
Propsys.lib
|
|
||||||
psapi.lib
|
psapi.lib
|
||||||
SetupAPI.lib
|
|
||||||
Shell32.lib
|
|
||||||
version.lib
|
version.lib
|
||||||
wbemuuid.lib
|
|
||||||
winmm.lib
|
winmm.lib
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -527,26 +453,10 @@ if(OS_WINDOWS)
|
|||||||
# Configure use of ATL.
|
# Configure use of ATL.
|
||||||
option(USE_ATL "Enable or disable use of ATL." ON)
|
option(USE_ATL "Enable or disable use of ATL." ON)
|
||||||
if(USE_ATL)
|
if(USE_ATL)
|
||||||
# Locate the atlmfc directory if it exists. It may be at any depth inside
|
|
||||||
# the VC directory. The cl.exe path returned by CMAKE_CXX_COMPILER may also
|
|
||||||
# be at different depths depending on the toolchain version
|
|
||||||
# (e.g. "VC/bin/cl.exe", "VC/bin/amd64_x86/cl.exe",
|
|
||||||
# "VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe", etc).
|
|
||||||
set(HAS_ATLMFC 0)
|
|
||||||
get_filename_component(VC_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
|
|
||||||
get_filename_component(VC_DIR_NAME ${VC_DIR} NAME)
|
|
||||||
while(NOT ${VC_DIR_NAME} STREQUAL "VC")
|
|
||||||
get_filename_component(VC_DIR ${VC_DIR} DIRECTORY)
|
|
||||||
if(IS_DIRECTORY "${VC_DIR}/atlmfc")
|
|
||||||
set(HAS_ATLMFC 1)
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
get_filename_component(VC_DIR_NAME ${VC_DIR} NAME)
|
|
||||||
endwhile()
|
|
||||||
|
|
||||||
# Determine if the Visual Studio install supports ATL.
|
# Determine if the Visual Studio install supports ATL.
|
||||||
if(NOT HAS_ATLMFC)
|
get_filename_component(VC_BIN_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
|
||||||
message(WARNING "ATL is not supported by your VC installation.")
|
get_filename_component(VC_DIR ${VC_BIN_DIR} DIRECTORY)
|
||||||
|
if(NOT IS_DIRECTORY "${VC_DIR}/atlmfc")
|
||||||
set(USE_ATL OFF)
|
set(USE_ATL OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
// 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_macros.h"
|
|
||||||
#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();
|
|
||||||
|
|
||||||
// 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_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomicFlag);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
|
||||||
@@ -39,70 +39,85 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_
|
#define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_ATOMIC_REF_COUNT_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/atomic_ref_count.h"
|
#include "base/atomic_ref_count.h"
|
||||||
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <atomic>
|
#include "include/base/cef_atomicops.h"
|
||||||
|
|
||||||
|
// Annotations are not currently supported.
|
||||||
|
#define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */
|
||||||
|
#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
class AtomicRefCount {
|
typedef subtle::Atomic32 AtomicRefCount;
|
||||||
public:
|
|
||||||
constexpr AtomicRefCount() : ref_count_(0) {}
|
|
||||||
explicit constexpr AtomicRefCount(int initial_value)
|
|
||||||
: ref_count_(initial_value) {}
|
|
||||||
|
|
||||||
// Increment a reference count.
|
// Increment a reference count by "increment", which must exceed 0.
|
||||||
// Returns the previous value of the count.
|
inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr,
|
||||||
int Increment() { return Increment(1); }
|
AtomicRefCount increment) {
|
||||||
|
subtle::NoBarrier_AtomicIncrement(ptr, increment);
|
||||||
|
}
|
||||||
|
|
||||||
// Increment a reference count by "increment", which must exceed 0.
|
// Decrement a reference count by "decrement", which must exceed 0,
|
||||||
// Returns the previous value of the count.
|
// and return whether the result is non-zero.
|
||||||
int Increment(int increment) {
|
// Insert barriers to ensure that state written before the reference count
|
||||||
return ref_count_.fetch_add(increment, std::memory_order_relaxed);
|
// became zero will be visible to a thread that has just made the count zero.
|
||||||
|
inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr,
|
||||||
|
AtomicRefCount decrement) {
|
||||||
|
ANNOTATE_HAPPENS_BEFORE(ptr);
|
||||||
|
bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0);
|
||||||
|
if (!res) {
|
||||||
|
ANNOTATE_HAPPENS_AFTER(ptr);
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// Decrement a reference count, and return whether the result is non-zero.
|
// Increment a reference count by 1.
|
||||||
// Insert barriers to ensure that state written before the reference count
|
inline void AtomicRefCountInc(volatile AtomicRefCount *ptr) {
|
||||||
// became zero will be visible to a thread that has just made the count zero.
|
base::AtomicRefCountIncN(ptr, 1);
|
||||||
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).
|
// Decrement a reference count by 1 and return whether the result is non-zero.
|
||||||
// However, there are toolchain issues that make that not work as well at
|
// Insert barriers to ensure that state written before the reference count
|
||||||
// present (notably TSAN doesn't like it).
|
// became zero will be visible to a thread that has just made the count zero.
|
||||||
return ref_count_.fetch_sub(1, std::memory_order_acq_rel) != 1;
|
inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) {
|
||||||
|
return base::AtomicRefCountDecN(ptr, 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.
|
||||||
|
inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) {
|
||||||
|
bool res = (subtle::Acquire_Load(ptr) == 1);
|
||||||
|
if (res) {
|
||||||
|
ANNOTATE_HAPPENS_AFTER(ptr);
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// Return whether the reference count is one. If the reference count is used
|
// Return whether the reference count is zero. With conventional object
|
||||||
// in the conventional way, a refrerence count of 1 implies that the current
|
// referencing counting, the object will be destroyed, so the reference count
|
||||||
// thread owns the reference and no other thread shares it. This call
|
// should never be zero. Hence this is generally used for a debug check.
|
||||||
// performs the test for a reference count of one, and performs the memory
|
inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) {
|
||||||
// barrier needed for the owning thread to act on the object, knowing that it
|
bool res = (subtle::Acquire_Load(ptr) == 0);
|
||||||
// has exclusive access to the object.
|
if (res) {
|
||||||
bool IsOne() const { return ref_count_.load(std::memory_order_acquire) == 1; }
|
ANNOTATE_HAPPENS_AFTER(ptr);
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
// 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
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
198
include/base/cef_atomicops.h
Normal file
198
include/base/cef_atomicops.h
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// For atomic operations on reference counts, see cef_atomic_ref_count.h.
|
||||||
|
|
||||||
|
// The routines exported by this module are subtle. If you use them, even if
|
||||||
|
// you get the code right, it will depend on careful reasoning about atomicity
|
||||||
|
// and memory ordering; it will be less readable, and harder to maintain. If
|
||||||
|
// you plan to use these routines, you should have a good reason, such as solid
|
||||||
|
// evidence that performance would otherwise suffer, or there being no
|
||||||
|
// alternative. You should assume only properties explicitly guaranteed by the
|
||||||
|
// specifications in this file. You are almost certainly _not_ writing code
|
||||||
|
// just for the x86; if you assume x86 semantics, x86 hardware bugs and
|
||||||
|
// implementations on other archtectures will cause your code to break. If you
|
||||||
|
// do not know what you are doing, avoid these routines, and use a Mutex.
|
||||||
|
//
|
||||||
|
// It is incorrect to make direct assignments to/from an atomic variable.
|
||||||
|
// You should use one of the Load or Store routines. The NoBarrier
|
||||||
|
// versions are provided when no barriers are needed:
|
||||||
|
// NoBarrier_Store()
|
||||||
|
// NoBarrier_Load()
|
||||||
|
// Although there are currently no compiler enforcement, you are encouraged
|
||||||
|
// to use these.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(BASE_ATOMICOPS_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/atomicops.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 "include/base/cef_build.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN) && defined(ARCH_CPU_64_BITS)
|
||||||
|
// windows.h #defines this (only on x64). This causes problems because the
|
||||||
|
// public API also uses MemoryBarrier at the public name for this fence. So, on
|
||||||
|
// X64, undef it, and call its documented
|
||||||
|
// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
|
||||||
|
// implementation directly.
|
||||||
|
#undef MemoryBarrier
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace subtle {
|
||||||
|
|
||||||
|
typedef int32_t Atomic32;
|
||||||
|
#ifdef ARCH_CPU_64_BITS
|
||||||
|
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
|
||||||
|
// means Atomic64 and AtomicWord should be the same type on 64-bit.
|
||||||
|
#if defined(__ILP32__) || defined(OS_NACL)
|
||||||
|
// NaCl's intptr_t is not actually 64-bits on 64-bit!
|
||||||
|
// http://code.google.com/p/nativeclient/issues/detail?id=1162
|
||||||
|
typedef int64_t Atomic64;
|
||||||
|
#else
|
||||||
|
typedef intptr_t Atomic64;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
|
||||||
|
// Atomic64 routines below, depending on your architecture.
|
||||||
|
typedef intptr_t AtomicWord;
|
||||||
|
|
||||||
|
// Atomically execute:
|
||||||
|
// result = *ptr;
|
||||||
|
// if (*ptr == old_value)
|
||||||
|
// *ptr = new_value;
|
||||||
|
// return result;
|
||||||
|
//
|
||||||
|
// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value".
|
||||||
|
// Always return the old value of "*ptr"
|
||||||
|
//
|
||||||
|
// This routine implies no memory barriers.
|
||||||
|
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value);
|
||||||
|
|
||||||
|
// Atomically store new_value into *ptr, returning the previous value held in
|
||||||
|
// *ptr. This routine implies no memory barriers.
|
||||||
|
Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value);
|
||||||
|
|
||||||
|
// Atomically increment *ptr by "increment". Returns the new value of
|
||||||
|
// *ptr with the increment applied. This routine implies no memory barriers.
|
||||||
|
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);
|
||||||
|
|
||||||
|
Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment);
|
||||||
|
|
||||||
|
// These following lower-level operations are typically useful only to people
|
||||||
|
// implementing higher-level synchronization operations like spinlocks,
|
||||||
|
// mutexes, and condition-variables. They combine CompareAndSwap(), a load, or
|
||||||
|
// a store with appropriate memory-ordering instructions. "Acquire" operations
|
||||||
|
// ensure that no later memory access can be reordered ahead of the operation.
|
||||||
|
// "Release" operations ensure that no previous memory access can be reordered
|
||||||
|
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
||||||
|
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
||||||
|
// access.
|
||||||
|
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value);
|
||||||
|
Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value);
|
||||||
|
|
||||||
|
void MemoryBarrier();
|
||||||
|
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||||
|
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||||
|
void Release_Store(volatile Atomic32* ptr, Atomic32 value);
|
||||||
|
|
||||||
|
Atomic32 NoBarrier_Load(volatile const Atomic32* ptr);
|
||||||
|
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
|
||||||
|
Atomic32 Release_Load(volatile const Atomic32* ptr);
|
||||||
|
|
||||||
|
// 64-bit atomic operations (only available on 64-bit processors).
|
||||||
|
#ifdef ARCH_CPU_64_BITS
|
||||||
|
Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value);
|
||||||
|
Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value);
|
||||||
|
Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);
|
||||||
|
Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);
|
||||||
|
|
||||||
|
Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value);
|
||||||
|
Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value);
|
||||||
|
void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value);
|
||||||
|
void Acquire_Store(volatile Atomic64* ptr, Atomic64 value);
|
||||||
|
void Release_Store(volatile Atomic64* ptr, Atomic64 value);
|
||||||
|
Atomic64 NoBarrier_Load(volatile const Atomic64* ptr);
|
||||||
|
Atomic64 Acquire_Load(volatile const Atomic64* ptr);
|
||||||
|
Atomic64 Release_Load(volatile const Atomic64* ptr);
|
||||||
|
#endif // ARCH_CPU_64_BITS
|
||||||
|
|
||||||
|
} // namespace subtle
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
// Include our platform specific implementation.
|
||||||
|
#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
|
||||||
|
#include "include/base/internal/cef_atomicops_x86_msvc.h"
|
||||||
|
#elif defined(OS_MACOSX)
|
||||||
|
#include "include/base/internal/cef_atomicops_mac.h"
|
||||||
|
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
|
||||||
|
#include "include/base/internal/cef_atomicops_x86_gcc.h"
|
||||||
|
#else
|
||||||
|
#error "Atomic operations are not supported on your platform"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// On some platforms we need additional declarations to make
|
||||||
|
// AtomicWord compatible with our other Atomic* types.
|
||||||
|
#if defined(OS_MACOSX) || defined(OS_OPENBSD)
|
||||||
|
#include "include/base/internal/cef_atomicops_atomicword_compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
// 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_
|
|
||||||
@@ -42,12 +42,12 @@
|
|||||||
//
|
//
|
||||||
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
|
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
|
||||||
// <inttypes.h> format macros even in the LP64 model.
|
// <inttypes.h> format macros even in the LP64 model.
|
||||||
#if defined(__LP64__) && !defined(OS_MAC) && !defined(OS_OPENBSD)
|
#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
|
||||||
typedef long int64;
|
typedef long int64; // NOLINT(runtime/int)
|
||||||
typedef unsigned long uint64;
|
typedef unsigned long uint64; // NOLINT(runtime/int)
|
||||||
#else
|
#else
|
||||||
typedef long long int64;
|
typedef long long int64; // NOLINT(runtime/int)
|
||||||
typedef unsigned long long uint64;
|
typedef unsigned long long uint64; // NOLINT(runtime/int)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO: Remove these type guards. These are to avoid conflicts with
|
// TODO: Remove these type guards. These are to avoid conflicts with
|
||||||
@@ -64,17 +64,8 @@ typedef int int32;
|
|||||||
typedef unsigned int uint32;
|
typedef unsigned int uint32;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _INT16
|
|
||||||
#define _INT16
|
|
||||||
typedef short int16;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _UINT16
|
|
||||||
#define _UINT16
|
|
||||||
typedef unsigned short uint16;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UTF-16 character type.
|
// UTF-16 character type.
|
||||||
|
// This should be kept synchronized with base/strings/string16.h
|
||||||
#ifndef char16
|
#ifndef char16
|
||||||
#if defined(WCHAR_T_IS_UTF16)
|
#if defined(WCHAR_T_IS_UTF16)
|
||||||
typedef wchar_t char16;
|
typedef wchar_t char16;
|
||||||
|
|||||||
@@ -28,47 +28,16 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// 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_
|
#ifndef CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_BIND_H_
|
#define CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_BIND_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -76,275 +45,502 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// 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"
|
#include "include/base/internal/cef_bind_internal.h"
|
||||||
|
#include "include/base/internal/cef_callback_internal.h"
|
||||||
|
|
||||||
#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
// -----------------------------------------------------------------------------
|
||||||
#include "include/base/internal/cef_scoped_block_mac.h"
|
// Usage documentation
|
||||||
#endif
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// See base/cef_callback.h for documentation.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Implementation notes
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// If you're reading the implementation, before proceeding further, you should
|
||||||
|
// read the top comment of base/bind_internal.h for a definition of common
|
||||||
|
// terms and concepts.
|
||||||
|
//
|
||||||
|
// RETURN TYPES
|
||||||
|
//
|
||||||
|
// Though Bind()'s result is meant to be stored in a Callback<> type, it
|
||||||
|
// cannot actually return the exact type without requiring a large amount
|
||||||
|
// of extra template specializations. The problem is that in order to
|
||||||
|
// discern the correct specialization of Callback<>, Bind would need to
|
||||||
|
// unwrap the function signature to determine the signature's arity, and
|
||||||
|
// whether or not it is a method.
|
||||||
|
//
|
||||||
|
// Each unique combination of (arity, function_type, num_prebound) where
|
||||||
|
// function_type is one of {function, method, const_method} would require
|
||||||
|
// one specialization. We eventually have to do a similar number of
|
||||||
|
// specializations anyways in the implementation (see the Invoker<>,
|
||||||
|
// classes). However, it is avoidable in Bind if we return the result
|
||||||
|
// via an indirection like we do below.
|
||||||
|
//
|
||||||
|
// TODO(ajwong): We might be able to avoid this now, but need to test.
|
||||||
|
//
|
||||||
|
// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>,
|
||||||
|
// but it feels a little nicer to have the asserts here so people do not
|
||||||
|
// need to crack open bind_internal.h. On the other hand, it makes Bind()
|
||||||
|
// harder to read.
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
// Bind as OnceCallback.
|
template <typename Functor>
|
||||||
template <typename Functor, typename... Args>
|
base::Callback<
|
||||||
inline OnceCallback<internal::MakeUnboundRunType<Functor, Args...>> BindOnce(
|
typename cef_internal::BindState<
|
||||||
Functor&& functor,
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
Args&&... args) {
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
static_assert(!internal::IsOnceCallback<std::decay_t<Functor>>() ||
|
void()>
|
||||||
(std::is_rvalue_reference<Functor&&>() &&
|
::UnboundRunType>
|
||||||
!std::is_const<std::remove_reference_t<Functor>>()),
|
Bind(Functor functor) {
|
||||||
"BindOnce requires non-const rvalue for OnceCallback binding."
|
// Typedefs for how to store and run the functor.
|
||||||
" I.e.: base::BindOnce(std::move(callback)).");
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
static_assert(
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
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),
|
typedef cef_internal::BindState<RunnableType, RunType, void()> BindState;
|
||||||
std::forward<Args>(args)...);
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind as RepeatingCallback.
|
template <typename Functor, typename P1>
|
||||||
template <typename Functor, typename... Args>
|
base::Callback<
|
||||||
inline RepeatingCallback<internal::MakeUnboundRunType<Functor, Args...>>
|
typename cef_internal::BindState<
|
||||||
BindRepeating(Functor&& functor, Args&&... args) {
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
static_assert(
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
!internal::IsOnceCallback<std::decay_t<Functor>>(),
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)>
|
||||||
"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move().");
|
::UnboundRunType>
|
||||||
|
Bind(Functor functor, const P1& p1) {
|
||||||
|
// Typedefs for how to store and run the functor.
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
|
|
||||||
return internal::BindImpl<RepeatingCallback>(std::forward<Functor>(functor),
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
std::forward<Args>(args)...);
|
// checks should below for bound references need to know what the actual
|
||||||
|
// functor is going to interpret the argument as.
|
||||||
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
|
BoundFunctorTraits;
|
||||||
|
|
||||||
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
|
// invoked function will receive a reference to the stored copy of the
|
||||||
|
// argument and not the original.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ),
|
||||||
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
|
|
||||||
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
|
// methods. We also disallow binding of an array as the method's target
|
||||||
|
// object.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!is_array<P1>::value,
|
||||||
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)> BindState;
|
||||||
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor), p1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special cases for binding to a base::Callback without extra bound arguments.
|
template <typename Functor, typename P1, typename P2>
|
||||||
// We CHECK() the validity of callback to guard against null pointers
|
base::Callback<
|
||||||
// accidentally ending up in posted tasks, causing hard-to-debug crashes.
|
typename cef_internal::BindState<
|
||||||
template <typename Signature>
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
OnceCallback<Signature> BindOnce(OnceCallback<Signature> callback) {
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
CHECK(callback);
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
return callback;
|
typename cef_internal::CallbackParamTraits<P2>::StorageType)>
|
||||||
|
::UnboundRunType>
|
||||||
|
Bind(Functor functor, const P1& p1, const P2& p2) {
|
||||||
|
// Typedefs for how to store and run the functor.
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
|
|
||||||
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
|
// checks should below for bound references need to know what the actual
|
||||||
|
// functor is going to interpret the argument as.
|
||||||
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
|
BoundFunctorTraits;
|
||||||
|
|
||||||
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
|
// invoked function will receive a reference to the stored copy of the
|
||||||
|
// argument and not the original.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ),
|
||||||
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
|
|
||||||
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
|
// methods. We also disallow binding of an array as the method's target
|
||||||
|
// object.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!is_array<P1>::value,
|
||||||
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
||||||
|
p2_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType)> BindState;
|
||||||
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor), p1, p2));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Signature>
|
template <typename Functor, typename P1, typename P2, typename P3>
|
||||||
OnceCallback<Signature> BindOnce(RepeatingCallback<Signature> callback) {
|
base::Callback<
|
||||||
CHECK(callback);
|
typename cef_internal::BindState<
|
||||||
return callback;
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P3>::StorageType)>
|
||||||
|
::UnboundRunType>
|
||||||
|
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) {
|
||||||
|
// Typedefs for how to store and run the functor.
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
|
|
||||||
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
|
// checks should below for bound references need to know what the actual
|
||||||
|
// functor is going to interpret the argument as.
|
||||||
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
|
BoundFunctorTraits;
|
||||||
|
|
||||||
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
|
// invoked function will receive a reference to the stored copy of the
|
||||||
|
// argument and not the original.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ),
|
||||||
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
|
|
||||||
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
|
// methods. We also disallow binding of an array as the method's target
|
||||||
|
// object.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!is_array<P1>::value,
|
||||||
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
||||||
|
p2_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
||||||
|
p3_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P3>::StorageType)> BindState;
|
||||||
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Signature>
|
template <typename Functor, typename P1, typename P2, typename P3, typename P4>
|
||||||
RepeatingCallback<Signature> BindRepeating(
|
base::Callback<
|
||||||
RepeatingCallback<Signature> callback) {
|
typename cef_internal::BindState<
|
||||||
CHECK(callback);
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
return callback;
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P4>::StorageType)>
|
||||||
|
::UnboundRunType>
|
||||||
|
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
|
||||||
|
// Typedefs for how to store and run the functor.
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
|
|
||||||
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
|
// checks should below for bound references need to know what the actual
|
||||||
|
// functor is going to interpret the argument as.
|
||||||
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
|
BoundFunctorTraits;
|
||||||
|
|
||||||
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
|
// invoked function will receive a reference to the stored copy of the
|
||||||
|
// argument and not the original.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ),
|
||||||
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
|
|
||||||
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
|
// methods. We also disallow binding of an array as the method's target
|
||||||
|
// object.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!is_array<P1>::value,
|
||||||
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
||||||
|
p2_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
||||||
|
p3_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
||||||
|
p4_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P4>::StorageType)> BindState;
|
||||||
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unretained() allows binding a non-refcounted class, and to disable
|
template <typename Functor, typename P1, typename P2, typename P3, typename P4,
|
||||||
// refcounting on arguments that are refcounted objects.
|
typename P5>
|
||||||
//
|
base::Callback<
|
||||||
// EXAMPLE OF Unretained():
|
typename cef_internal::BindState<
|
||||||
//
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
// class Foo {
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
// public:
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
// void func() { cout << "Foo:f" << endl; }
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
// };
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
//
|
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
||||||
// // In some function somewhere.
|
typename cef_internal::CallbackParamTraits<P5>::StorageType)>
|
||||||
// Foo foo;
|
::UnboundRunType>
|
||||||
// OnceClosure foo_callback =
|
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
|
||||||
// BindOnce(&Foo::func, Unretained(&foo));
|
const P5& p5) {
|
||||||
// std::move(foo_callback).Run(); // Prints "Foo:f".
|
// Typedefs for how to store and run the functor.
|
||||||
//
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
// Without the Unretained() wrapper on |&foo|, the above call would fail
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
// to compile because Foo does not support the AddRef() and Release() methods.
|
|
||||||
template <typename T>
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
inline internal::UnretainedWrapper<T> Unretained(T* o) {
|
// checks should below for bound references need to know what the actual
|
||||||
return internal::UnretainedWrapper<T>(o);
|
// functor is going to interpret the argument as.
|
||||||
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
|
BoundFunctorTraits;
|
||||||
|
|
||||||
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
|
// invoked function will receive a reference to the stored copy of the
|
||||||
|
// argument and not the original.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ),
|
||||||
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
|
|
||||||
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
|
// methods. We also disallow binding of an array as the method's target
|
||||||
|
// object.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!is_array<P1>::value,
|
||||||
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
||||||
|
p2_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
||||||
|
p3_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
||||||
|
p4_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
|
||||||
|
p5_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P5>::StorageType)> BindState;
|
||||||
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5));
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetainedRef() accepts a ref counted object and retains a reference to it.
|
template <typename Functor, typename P1, typename P2, typename P3, typename P4,
|
||||||
// When the callback is called, the object is passed as a raw pointer.
|
typename P5, typename P6>
|
||||||
//
|
base::Callback<
|
||||||
// EXAMPLE OF RetainedRef():
|
typename cef_internal::BindState<
|
||||||
//
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
// void foo(RefCountedBytes* bytes) {}
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
//
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
// scoped_refptr<RefCountedBytes> bytes = ...;
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
// OnceClosure callback = BindOnce(&foo, base::RetainedRef(bytes));
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
// std::move(callback).Run();
|
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
||||||
//
|
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
||||||
// Without RetainedRef, the scoped_refptr would try to implicitly convert to
|
typename cef_internal::CallbackParamTraits<P6>::StorageType)>
|
||||||
// a raw pointer and fail compilation:
|
::UnboundRunType>
|
||||||
//
|
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
|
||||||
// OnceClosure callback = BindOnce(&foo, bytes); // ERROR!
|
const P5& p5, const P6& p6) {
|
||||||
template <typename T>
|
// Typedefs for how to store and run the functor.
|
||||||
inline internal::RetainedRefWrapper<T> RetainedRef(T* o) {
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
return internal::RetainedRefWrapper<T>(o);
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
}
|
|
||||||
template <typename T>
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
inline internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) {
|
// checks should below for bound references need to know what the actual
|
||||||
return internal::RetainedRefWrapper<T>(std::move(o));
|
// functor is going to interpret the argument as.
|
||||||
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
|
BoundFunctorTraits;
|
||||||
|
|
||||||
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
|
// invoked function will receive a reference to the stored copy of the
|
||||||
|
// argument and not the original.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
|
||||||
|
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ),
|
||||||
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
|
|
||||||
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
|
// methods. We also disallow binding of an array as the method's target
|
||||||
|
// object.
|
||||||
|
COMPILE_ASSERT(
|
||||||
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
|
!is_array<P1>::value,
|
||||||
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
||||||
|
p2_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
||||||
|
p3_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
||||||
|
p4_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
|
||||||
|
p5_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
|
||||||
|
p6_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
||||||
|
typename cef_internal::CallbackParamTraits<P6>::StorageType)> BindState;
|
||||||
|
|
||||||
|
|
||||||
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
|
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owned() transfers ownership of an object to the callback resulting from
|
template <typename Functor, typename P1, typename P2, typename P3, typename P4,
|
||||||
// bind; the object will be deleted when the callback is deleted.
|
typename P5, typename P6, typename P7>
|
||||||
//
|
base::Callback<
|
||||||
// EXAMPLE OF Owned():
|
typename cef_internal::BindState<
|
||||||
//
|
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
||||||
// void foo(int* arg) { cout << *arg << endl }
|
typename cef_internal::FunctorTraits<Functor>::RunType,
|
||||||
//
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
// int* pn = new int(1);
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
// RepeatingClosure foo_callback = BindRepeating(&foo, Owned(pn));
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
//
|
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
||||||
// foo_callback.Run(); // Prints "1"
|
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
||||||
// foo_callback.Run(); // Prints "1"
|
typename cef_internal::CallbackParamTraits<P6>::StorageType,
|
||||||
// *pn = 2;
|
typename cef_internal::CallbackParamTraits<P7>::StorageType)>
|
||||||
// foo_callback.Run(); // Prints "2"
|
::UnboundRunType>
|
||||||
//
|
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
|
||||||
// foo_callback.Reset(); // |pn| is deleted. Also will happen when
|
const P5& p5, const P6& p6, const P7& p7) {
|
||||||
// // |foo_callback| goes out of scope.
|
// Typedefs for how to store and run the functor.
|
||||||
//
|
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
||||||
// Without Owned(), someone would have to know to delete |pn| when the last
|
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
||||||
// 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>
|
// Use RunnableType::RunType instead of RunType above because our
|
||||||
inline internal::OwnedWrapper<T, Deleter> Owned(
|
// checks should below for bound references need to know what the actual
|
||||||
std::unique_ptr<T, Deleter>&& ptr) {
|
// functor is going to interpret the argument as.
|
||||||
return internal::OwnedWrapper<T, Deleter>(std::move(ptr));
|
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
||||||
}
|
BoundFunctorTraits;
|
||||||
|
|
||||||
// OwnedRef() stores an object in the callback resulting from
|
// Do not allow binding a non-const reference parameter. Non-const reference
|
||||||
// bind and passes a reference to the object to the bound function.
|
// parameters are disallowed by the Google style guide. Also, binding a
|
||||||
//
|
// non-const reference parameter can make for subtle bugs because the
|
||||||
// EXAMPLE OF OwnedRef():
|
// invoked function will receive a reference to the stored copy of the
|
||||||
//
|
// argument and not the original.
|
||||||
// void foo(int& arg) { cout << ++arg << endl }
|
COMPILE_ASSERT(
|
||||||
//
|
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
||||||
// int counter = 0;
|
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
||||||
// RepeatingClosure foo_callback = BindRepeating(&foo, OwnedRef(counter));
|
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
||||||
//
|
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
|
||||||
// foo_callback.Run(); // Prints "1"
|
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
|
||||||
// foo_callback.Run(); // Prints "2"
|
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ||
|
||||||
// foo_callback.Run(); // Prints "3"
|
is_non_const_reference<typename BoundFunctorTraits::A7Type>::value ),
|
||||||
//
|
do_not_bind_functions_with_nonconst_ref);
|
||||||
// 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)
|
// For methods, we need to be careful for parameter 1. We do not require
|
||||||
// through a RepeatingCallback. Logically, this signifies a destructive transfer
|
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
||||||
// of the state of the argument into the target function. Invoking
|
// methods. We also disallow binding of an array as the method's target
|
||||||
// RepeatingCallback::Run() twice on a callback that was created with a Passed()
|
// object.
|
||||||
// argument will CHECK() because the first invocation would have already
|
COMPILE_ASSERT(
|
||||||
// transferred ownership to the target function.
|
cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
//
|
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
||||||
// Note that Passed() is not necessary with BindOnce(), as std::move() does the
|
p1_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
// same thing. Avoid Passed() in favor of std::move() with BindOnce().
|
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
||||||
//
|
!is_array<P1>::value,
|
||||||
// EXAMPLE OF Passed():
|
first_bound_argument_to_method_cannot_be_array);
|
||||||
//
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
||||||
// void TakesOwnership(std::unique_ptr<Foo> arg) { }
|
p2_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
// std::unique_ptr<Foo> CreateFoo() { return std::make_unique<Foo>();
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
||||||
// }
|
p3_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
//
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
||||||
// auto f = std::make_unique<Foo>();
|
p4_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
//
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
|
||||||
// // |cb| is given ownership of Foo(). |f| is now NULL.
|
p5_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
// // You can use std::move(f) in place of &f, but it's more verbose.
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
|
||||||
// RepeatingClosure cb = BindRepeating(&TakesOwnership, Passed(&f));
|
p6_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
//
|
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P7>::value,
|
||||||
// // Run was never called so |cb| still owns Foo() and deletes
|
p7_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
// // it on Reset().
|
typedef cef_internal::BindState<RunnableType, RunType,
|
||||||
// cb.Reset();
|
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
||||||
//
|
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
||||||
// // |cb| is given a new Foo created by CreateFoo().
|
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
||||||
// cb = BindRepeating(&TakesOwnership, Passed(CreateFoo()));
|
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
||||||
//
|
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
||||||
// // |arg| in TakesOwnership() is given ownership of Foo(). |cb|
|
typename cef_internal::CallbackParamTraits<P6>::StorageType,
|
||||||
// // no longer owns Foo() and, if reset, would not delete Foo().
|
typename cef_internal::CallbackParamTraits<P7>::StorageType)> BindState;
|
||||||
// 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,
|
return Callback<typename BindState::UnboundRunType>(
|
||||||
// say, a pesky ignorable bool return that you want to use with PostTask or
|
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6,
|
||||||
// something else that expect a callback with a void return.
|
p7));
|
||||||
//
|
|
||||||
// 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
|
} // namespace base
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
586
include/base/cef_bind_helpers.h
Normal file
586
include/base/cef_bind_helpers.h
Normal file
@@ -0,0 +1,586 @@
|
|||||||
|
// 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 defines a set of argument wrappers and related factory methods that
|
||||||
|
// can be used specify the refcounting and reference semantics of arguments
|
||||||
|
// that are bound by the Bind() function in base/bind.h.
|
||||||
|
//
|
||||||
|
// It also defines a set of simple functions and utilities that people want
|
||||||
|
// when using Callback<> and Bind().
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ARGUMENT BINDING WRAPPERS
|
||||||
|
//
|
||||||
|
// The wrapper functions are base::Unretained(), base::Owned(), base::Passed(),
|
||||||
|
// base::ConstRef(), and base::IgnoreResult().
|
||||||
|
//
|
||||||
|
// Unretained() allows Bind() to bind a non-refcounted class, and to disable
|
||||||
|
// refcounting on arguments that are refcounted objects.
|
||||||
|
//
|
||||||
|
// Owned() transfers ownership of an object to the Callback resulting from
|
||||||
|
// bind; the object will be deleted when the Callback is deleted.
|
||||||
|
//
|
||||||
|
// Passed() is for transferring movable-but-not-copyable types (eg. scoped_ptr)
|
||||||
|
// through a Callback. Logically, this signifies a destructive transfer of
|
||||||
|
// the state of the argument into the target function. Invoking
|
||||||
|
// Callback::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.
|
||||||
|
//
|
||||||
|
// ConstRef() allows binding a constant reference to an argument rather
|
||||||
|
// than a copy.
|
||||||
|
//
|
||||||
|
// 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 Unretained():
|
||||||
|
//
|
||||||
|
// class Foo {
|
||||||
|
// public:
|
||||||
|
// void func() { cout << "Foo:f" << endl; }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// // In some function somewhere.
|
||||||
|
// Foo foo;
|
||||||
|
// Closure foo_callback =
|
||||||
|
// Bind(&Foo::func, Unretained(&foo));
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// EXAMPLE OF Owned():
|
||||||
|
//
|
||||||
|
// void foo(int* arg) { cout << *arg << endl }
|
||||||
|
//
|
||||||
|
// int* pn = new int(1);
|
||||||
|
// Closure foo_callback = Bind(&foo, Owned(pn));
|
||||||
|
//
|
||||||
|
// foo_callback.Run(); // Prints "1"
|
||||||
|
// foo_callback.Run(); // Prints "1"
|
||||||
|
// *n = 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.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// EXAMPLE OF ConstRef():
|
||||||
|
//
|
||||||
|
// void foo(int arg) { cout << arg << endl }
|
||||||
|
//
|
||||||
|
// int n = 1;
|
||||||
|
// Closure no_ref = Bind(&foo, n);
|
||||||
|
// Closure has_ref = Bind(&foo, ConstRef(n));
|
||||||
|
//
|
||||||
|
// no_ref.Run(); // Prints "1"
|
||||||
|
// has_ref.Run(); // Prints "1"
|
||||||
|
//
|
||||||
|
// n = 2;
|
||||||
|
// no_ref.Run(); // Prints "1"
|
||||||
|
// has_ref.Run(); // Prints "2"
|
||||||
|
//
|
||||||
|
// Note that because ConstRef() takes a reference on |n|, |n| must outlive all
|
||||||
|
// its bound callbacks.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// EXAMPLE OF IgnoreResult():
|
||||||
|
//
|
||||||
|
// int DoSomething(int arg) { cout << arg << endl; }
|
||||||
|
//
|
||||||
|
// // Assign to a Callback with a void return type.
|
||||||
|
// Callback<void(int)> cb = Bind(IgnoreResult(&DoSomething));
|
||||||
|
// cb->Run(1); // Prints "1".
|
||||||
|
//
|
||||||
|
// // Prints "1" on |ml|.
|
||||||
|
// ml->PostTask(FROM_HERE, Bind(IgnoreResult(&DoSomething), 1);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// EXAMPLE OF Passed():
|
||||||
|
//
|
||||||
|
// void TakesOwnership(scoped_ptr<Foo> arg) { }
|
||||||
|
// scoped_ptr<Foo> CreateFoo() { return scoped_ptr<Foo>(new Foo()); }
|
||||||
|
//
|
||||||
|
// scoped_ptr<Foo> f(new Foo());
|
||||||
|
//
|
||||||
|
// // |cb| is given ownership of Foo(). |f| is now NULL.
|
||||||
|
// // You can use f.Pass() in place of &f, but it's more verbose.
|
||||||
|
// Closure cb = Bind(&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 = Bind(&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.
|
||||||
|
//
|
||||||
|
// Passed() is particularly useful with PostTask() when you are transferring
|
||||||
|
// ownership of an argument into a task, but don't necessarily know if the
|
||||||
|
// task will always be executed. This can happen if the task is cancellable
|
||||||
|
// or if it is posted to a MessageLoopProxy.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// SIMPLE FUNCTIONS AND UTILITIES.
|
||||||
|
//
|
||||||
|
// DoNothing() - Useful for creating a Closure that does nothing when called.
|
||||||
|
// DeletePointer<T>() - 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.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(BASE_BIND_HELPERS_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/bind_helpers.h"
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
// The following is substantially similar to the Chromium implementation.
|
||||||
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
|
// updated to match.
|
||||||
|
|
||||||
|
#include "include/base/cef_basictypes.h"
|
||||||
|
#include "include/base/cef_callback.h"
|
||||||
|
#include "include/base/cef_template_util.h"
|
||||||
|
#include "include/base/cef_weak_ptr.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace cef_internal {
|
||||||
|
|
||||||
|
// Use the Substitution Failure Is Not An Error (SFINAE) trick to inspect T
|
||||||
|
// for the existence of AddRef() and Release() functions of the correct
|
||||||
|
// signature.
|
||||||
|
//
|
||||||
|
// http://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error
|
||||||
|
// http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
|
||||||
|
// http://stackoverflow.com/questions/4358584/sfinae-approach-comparison
|
||||||
|
// http://stackoverflow.com/questions/1966362/sfinae-to-check-for-inherited-member-functions
|
||||||
|
//
|
||||||
|
// The last link in particular show the method used below.
|
||||||
|
//
|
||||||
|
// For SFINAE to work with inherited methods, we need to pull some extra tricks
|
||||||
|
// with multiple inheritance. In the more standard formulation, the overloads
|
||||||
|
// of Check would be:
|
||||||
|
//
|
||||||
|
// template <typename C>
|
||||||
|
// Yes NotTheCheckWeWant(Helper<&C::TargetFunc>*);
|
||||||
|
//
|
||||||
|
// template <typename C>
|
||||||
|
// No NotTheCheckWeWant(...);
|
||||||
|
//
|
||||||
|
// static const bool value = sizeof(NotTheCheckWeWant<T>(0)) == sizeof(Yes);
|
||||||
|
//
|
||||||
|
// The problem here is that template resolution will not match
|
||||||
|
// C::TargetFunc if TargetFunc does not exist directly in C. That is, if
|
||||||
|
// TargetFunc in inherited from an ancestor, &C::TargetFunc will not match,
|
||||||
|
// |value| will be false. This formulation only checks for whether or
|
||||||
|
// not TargetFunc exist directly in the class being introspected.
|
||||||
|
//
|
||||||
|
// To get around this, we play a dirty trick with multiple inheritance.
|
||||||
|
// First, We create a class BaseMixin that declares each function that we
|
||||||
|
// want to probe for. Then we create a class Base that inherits from both T
|
||||||
|
// (the class we wish to probe) and BaseMixin. Note that the function
|
||||||
|
// signature in BaseMixin does not need to match the signature of the function
|
||||||
|
// we are probing for; thus it's easiest to just use void(void).
|
||||||
|
//
|
||||||
|
// Now, if TargetFunc exists somewhere in T, then &Base::TargetFunc has an
|
||||||
|
// ambiguous resolution between BaseMixin and T. This lets us write the
|
||||||
|
// following:
|
||||||
|
//
|
||||||
|
// template <typename C>
|
||||||
|
// No GoodCheck(Helper<&C::TargetFunc>*);
|
||||||
|
//
|
||||||
|
// template <typename C>
|
||||||
|
// Yes GoodCheck(...);
|
||||||
|
//
|
||||||
|
// static const bool value = sizeof(GoodCheck<Base>(0)) == sizeof(Yes);
|
||||||
|
//
|
||||||
|
// Notice here that the variadic version of GoodCheck() returns Yes here
|
||||||
|
// instead of No like the previous one. Also notice that we calculate |value|
|
||||||
|
// by specializing GoodCheck() on Base instead of T.
|
||||||
|
//
|
||||||
|
// We've reversed the roles of the variadic, and Helper overloads.
|
||||||
|
// GoodCheck(Helper<&C::TargetFunc>*), when C = Base, fails to be a valid
|
||||||
|
// substitution if T::TargetFunc exists. Thus GoodCheck<Base>(0) will resolve
|
||||||
|
// to the variadic version if T has TargetFunc. If T::TargetFunc does not
|
||||||
|
// exist, then &C::TargetFunc is not ambiguous, and the overload resolution
|
||||||
|
// will prefer GoodCheck(Helper<&C::TargetFunc>*).
|
||||||
|
//
|
||||||
|
// This method of SFINAE will correctly probe for inherited names, but it cannot
|
||||||
|
// typecheck those names. It's still a good enough sanity check though.
|
||||||
|
//
|
||||||
|
// Works on gcc-4.2, gcc-4.4, and Visual Studio 2008.
|
||||||
|
//
|
||||||
|
// TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted
|
||||||
|
// this works well.
|
||||||
|
//
|
||||||
|
// TODO(ajwong): Make this check for Release() as well.
|
||||||
|
// See http://crbug.com/82038.
|
||||||
|
template <typename T>
|
||||||
|
class SupportsAddRefAndRelease {
|
||||||
|
typedef char Yes[1];
|
||||||
|
typedef char No[2];
|
||||||
|
|
||||||
|
struct BaseMixin {
|
||||||
|
void AddRef();
|
||||||
|
};
|
||||||
|
|
||||||
|
// MSVC warns when you try to use Base if T has a private destructor, the
|
||||||
|
// common pattern for refcounted types. It does this even though no attempt to
|
||||||
|
// instantiate Base is made. We disable the warning for this definition.
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4624)
|
||||||
|
#endif
|
||||||
|
struct Base : public T, public BaseMixin {
|
||||||
|
};
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <void(BaseMixin::*)(void)> struct Helper {};
|
||||||
|
|
||||||
|
template <typename C>
|
||||||
|
static No& Check(Helper<&C::AddRef>*);
|
||||||
|
|
||||||
|
template <typename >
|
||||||
|
static Yes& Check(...);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const bool value = sizeof(Check<Base>(0)) == sizeof(Yes);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helpers to assert that arguments of a recounted type are bound with a
|
||||||
|
// scoped_refptr.
|
||||||
|
template <bool IsClasstype, typename T>
|
||||||
|
struct UnsafeBindtoRefCountedArgHelper : false_type {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnsafeBindtoRefCountedArgHelper<true, T>
|
||||||
|
: integral_constant<bool, SupportsAddRefAndRelease<T>::value> {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnsafeBindtoRefCountedArg : false_type {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnsafeBindtoRefCountedArg<T*>
|
||||||
|
: UnsafeBindtoRefCountedArgHelper<is_class<T>::value, T> {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class HasIsMethodTag {
|
||||||
|
typedef char Yes[1];
|
||||||
|
typedef char No[2];
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
static Yes& Check(typename U::IsMethod*);
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
static No& Check(...);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const bool value = sizeof(Check<T>(0)) == sizeof(Yes);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class UnretainedWrapper {
|
||||||
|
public:
|
||||||
|
explicit UnretainedWrapper(T* o) : ptr_(o) {}
|
||||||
|
T* get() const { return ptr_; }
|
||||||
|
private:
|
||||||
|
T* ptr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class ConstRefWrapper {
|
||||||
|
public:
|
||||||
|
explicit ConstRefWrapper(const T& o) : ptr_(&o) {}
|
||||||
|
const T& get() const { return *ptr_; }
|
||||||
|
private:
|
||||||
|
const T* ptr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IgnoreResultHelper {
|
||||||
|
explicit IgnoreResultHelper(T functor) : functor_(functor) {}
|
||||||
|
|
||||||
|
T functor_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IgnoreResultHelper<Callback<T> > {
|
||||||
|
explicit IgnoreResultHelper(const Callback<T>& functor) : functor_(functor) {}
|
||||||
|
|
||||||
|
const Callback<T>& functor_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// An alternate implementation is to avoid the destructive copy, and instead
|
||||||
|
// specialize ParamTraits<> for OwnedWrapper<> to change the StorageType to
|
||||||
|
// a class that is essentially a scoped_ptr<>.
|
||||||
|
//
|
||||||
|
// The current implementation has the benefit though of leaving ParamTraits<>
|
||||||
|
// fully in callback_internal.h as well as avoiding type conversions during
|
||||||
|
// storage.
|
||||||
|
template <typename T>
|
||||||
|
class OwnedWrapper {
|
||||||
|
public:
|
||||||
|
explicit OwnedWrapper(T* o) : ptr_(o) {}
|
||||||
|
~OwnedWrapper() { delete ptr_; }
|
||||||
|
T* get() const { return ptr_; }
|
||||||
|
OwnedWrapper(const OwnedWrapper& other) {
|
||||||
|
ptr_ = other.ptr_;
|
||||||
|
other.ptr_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable T* ptr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// PassedWrapper is a copyable adapter for a scoper that ignores const.
|
||||||
|
//
|
||||||
|
// It is needed to get around the fact that Bind() takes a const reference to
|
||||||
|
// all its arguments. Because Bind() takes a const reference to avoid
|
||||||
|
// unnecessary copies, it is incompatible with movable-but-not-copyable
|
||||||
|
// types; doing a destructive "move" of the type into Bind() would violate
|
||||||
|
// the const correctness.
|
||||||
|
//
|
||||||
|
// This conundrum cannot be solved without either C++11 rvalue references or
|
||||||
|
// a O(2^n) blowup of Bind() templates to handle each combination of regular
|
||||||
|
// types and movable-but-not-copyable types. Thus we introduce a wrapper type
|
||||||
|
// that is copyable to transmit the correct type information down into
|
||||||
|
// BindState<>. Ignoring const in this type makes sense because it is only
|
||||||
|
// created when we are explicitly trying to do a destructive move.
|
||||||
|
//
|
||||||
|
// Two notes:
|
||||||
|
// 1) PassedWrapper supports any type that has a "Pass()" function.
|
||||||
|
// This is intentional. The whitelisting of which specific types we
|
||||||
|
// support is maintained by CallbackParamTraits<>.
|
||||||
|
// 2) is_valid_ is distinct from NULL because it is valid to bind a "NULL"
|
||||||
|
// scoper to a Callback and allow the Callback to execute once.
|
||||||
|
template <typename T>
|
||||||
|
class PassedWrapper {
|
||||||
|
public:
|
||||||
|
explicit PassedWrapper(T scoper) : is_valid_(true), scoper_(scoper.Pass()) {}
|
||||||
|
PassedWrapper(const PassedWrapper& other)
|
||||||
|
: is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {
|
||||||
|
}
|
||||||
|
T Pass() const {
|
||||||
|
CHECK(is_valid_);
|
||||||
|
is_valid_ = false;
|
||||||
|
return scoper_.Pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable bool is_valid_;
|
||||||
|
mutable T scoper_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Unwrap the stored parameters for the wrappers above.
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits {
|
||||||
|
typedef const T& ForwardType;
|
||||||
|
static ForwardType Unwrap(const T& o) { return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits<UnretainedWrapper<T> > {
|
||||||
|
typedef T* ForwardType;
|
||||||
|
static ForwardType Unwrap(UnretainedWrapper<T> unretained) {
|
||||||
|
return unretained.get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits<ConstRefWrapper<T> > {
|
||||||
|
typedef const T& ForwardType;
|
||||||
|
static ForwardType Unwrap(ConstRefWrapper<T> const_ref) {
|
||||||
|
return const_ref.get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits<scoped_refptr<T> > {
|
||||||
|
typedef T* ForwardType;
|
||||||
|
static ForwardType Unwrap(const scoped_refptr<T>& o) { return o.get(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits<WeakPtr<T> > {
|
||||||
|
typedef const WeakPtr<T>& ForwardType;
|
||||||
|
static ForwardType Unwrap(const WeakPtr<T>& o) { return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits<OwnedWrapper<T> > {
|
||||||
|
typedef T* ForwardType;
|
||||||
|
static ForwardType Unwrap(const OwnedWrapper<T>& o) {
|
||||||
|
return o.get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct UnwrapTraits<PassedWrapper<T> > {
|
||||||
|
typedef T ForwardType;
|
||||||
|
static T Unwrap(PassedWrapper<T>& o) {
|
||||||
|
return o.Pass();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Utility for handling different refcounting semantics in the Bind()
|
||||||
|
// function.
|
||||||
|
template <bool is_method, typename T>
|
||||||
|
struct MaybeRefcount;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct MaybeRefcount<false, T> {
|
||||||
|
static void AddRef(const T&) {}
|
||||||
|
static void Release(const T&) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, size_t n>
|
||||||
|
struct MaybeRefcount<false, T[n]> {
|
||||||
|
static void AddRef(const T*) {}
|
||||||
|
static void Release(const T*) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct MaybeRefcount<true, T> {
|
||||||
|
static void AddRef(const T&) {}
|
||||||
|
static void Release(const T&) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct MaybeRefcount<true, T*> {
|
||||||
|
static void AddRef(T* o) { o->AddRef(); }
|
||||||
|
static void Release(T* o) { o->Release(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// No need to additionally AddRef() and Release() since we are storing a
|
||||||
|
// scoped_refptr<> inside the storage object already.
|
||||||
|
template <typename T>
|
||||||
|
struct MaybeRefcount<true, scoped_refptr<T> > {
|
||||||
|
static void AddRef(const scoped_refptr<T>& o) {}
|
||||||
|
static void Release(const scoped_refptr<T>& o) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct MaybeRefcount<true, const T*> {
|
||||||
|
static void AddRef(const T* o) { o->AddRef(); }
|
||||||
|
static void Release(const T* o) { o->Release(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a
|
||||||
|
// method. It is used internally by Bind() to select the correct
|
||||||
|
// InvokeHelper that will no-op itself in the event the WeakPtr<> for
|
||||||
|
// the target object is invalidated.
|
||||||
|
//
|
||||||
|
// P1 should be the type of the object that will be received of the method.
|
||||||
|
template <bool IsMethod, typename P1>
|
||||||
|
struct IsWeakMethod : public false_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IsWeakMethod<true, WeakPtr<T> > : public true_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T> > > : public true_type {};
|
||||||
|
|
||||||
|
} // namespace cef_internal
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::UnretainedWrapper<T> Unretained(T* o) {
|
||||||
|
return cef_internal::UnretainedWrapper<T>(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::ConstRefWrapper<T> ConstRef(const T& o) {
|
||||||
|
return cef_internal::ConstRefWrapper<T>(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::OwnedWrapper<T> Owned(T* o) {
|
||||||
|
return cef_internal::OwnedWrapper<T>(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We offer 2 syntaxes for calling Passed(). The first takes a temporary and
|
||||||
|
// is best suited for use with the return value of a function. The second
|
||||||
|
// takes a pointer to the scoper and is just syntactic sugar to avoid having
|
||||||
|
// to write Passed(scoper.Pass()).
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::PassedWrapper<T> Passed(T scoper) {
|
||||||
|
return cef_internal::PassedWrapper<T>(scoper.Pass());
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::PassedWrapper<T> Passed(T* scoper) {
|
||||||
|
return cef_internal::PassedWrapper<T>(scoper->Pass());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::IgnoreResultHelper<T> IgnoreResult(T data) {
|
||||||
|
return cef_internal::IgnoreResultHelper<T>(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static inline cef_internal::IgnoreResultHelper<Callback<T> >
|
||||||
|
IgnoreResult(const Callback<T>& data) {
|
||||||
|
return cef_internal::IgnoreResultHelper<Callback<T> >(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoNothing();
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void DeletePointer(T* obj) {
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_
|
||||||
@@ -27,36 +27,6 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// 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_
|
#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
|
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||||
@@ -64,91 +34,47 @@
|
|||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "build/build_config.h"
|
#include "base/compiler_specific.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
// A set of macros to use for platform detection.
|
#if defined(_WIN32)
|
||||||
#if defined(ANDROID)
|
#ifndef OS_WIN
|
||||||
#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
|
#define OS_WIN 1
|
||||||
#elif defined(__Fuchsia__)
|
#endif
|
||||||
#define OS_FUCHSIA 1
|
#elif defined(__APPLE__)
|
||||||
#elif defined(__FreeBSD__)
|
#ifndef OS_MACOSX
|
||||||
#define OS_FREEBSD 1
|
#define OS_MACOSX 1
|
||||||
#elif defined(__NetBSD__)
|
#endif
|
||||||
#define OS_NETBSD 1
|
#elif defined(__linux__)
|
||||||
#elif defined(__OpenBSD__)
|
#ifndef OS_LINUX
|
||||||
#define OS_OPENBSD 1
|
#define OS_LINUX 1
|
||||||
#elif defined(__sun)
|
#endif
|
||||||
#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
|
#else
|
||||||
#error Please add support for your platform in include/base/cef_build.h
|
#error Please add support for your platform in 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
|
#endif
|
||||||
|
|
||||||
// For access to standard POSIXish features, use OS_POSIX instead of a
|
// For access to standard POSIXish features, use OS_POSIX instead of a
|
||||||
// more specific macro.
|
// more specific macro.
|
||||||
#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \
|
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||||
defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) || \
|
#ifndef OS_POSIX
|
||||||
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
|
#define OS_POSIX 1
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on
|
// Compiler detection.
|
||||||
// Windows.
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
#ifndef COMPILER_GCC
|
||||||
#define COMPILER_GCC 1
|
#define COMPILER_GCC 1
|
||||||
|
#endif
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
#ifndef COMPILER_MSVC
|
||||||
#define COMPILER_MSVC 1
|
#define COMPILER_MSVC 1
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#error Please add support for your compiler in build/build_config.h
|
#error Please add support for your compiler in cef_build.h
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Processor architecture detection. For more info on what's defined, see:
|
// Processor architecture detection. For more info on what's defined, see:
|
||||||
@@ -165,76 +91,37 @@
|
|||||||
#define ARCH_CPU_X86 1
|
#define ARCH_CPU_X86 1
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 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__)
|
#elif defined(__ARMEL__)
|
||||||
#define ARCH_CPU_ARM_FAMILY 1
|
#define ARCH_CPU_ARM_FAMILY 1
|
||||||
#define ARCH_CPU_ARMEL 1
|
#define ARCH_CPU_ARMEL 1
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
#elif defined(__aarch64__)
|
||||||
#define ARCH_CPU_ARM_FAMILY 1
|
#define ARCH_CPU_ARM_FAMILY 1
|
||||||
#define ARCH_CPU_ARM64 1
|
#define ARCH_CPU_ARM64 1
|
||||||
#define ARCH_CPU_64_BITS 1
|
#define ARCH_CPU_64_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
|
#elif defined(__pnacl__)
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__MIPSEL__)
|
#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_MIPS_FAMILY 1
|
||||||
#define ARCH_CPU_MIPSEL 1
|
#define ARCH_CPU_MIPSEL 1
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 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
|
#else
|
||||||
#define ARCH_CPU_MIPS_FAMILY 1
|
#error Please add support for your architecture in cef_build.h
|
||||||
#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
|
#endif
|
||||||
|
|
||||||
// Type detection for wchar_t.
|
// Type detection for wchar_t.
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define WCHAR_T_IS_UTF16
|
#define WCHAR_T_IS_UTF16
|
||||||
#elif defined(OS_FUCHSIA)
|
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
|
||||||
#define WCHAR_T_IS_UTF32
|
defined(__WCHAR_MAX__) && \
|
||||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
|
||||||
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
||||||
#define WCHAR_T_IS_UTF32
|
#define WCHAR_T_IS_UTF32
|
||||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
|
||||||
|
defined(__WCHAR_MAX__) && \
|
||||||
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
||||||
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
|
// 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
|
// compile in this mode (in particular, Chrome doesn't). This is intended for
|
||||||
@@ -242,18 +129,64 @@
|
|||||||
// short wchar works for them.
|
// short wchar works for them.
|
||||||
#define WCHAR_T_IS_UTF16
|
#define WCHAR_T_IS_UTF16
|
||||||
#else
|
#else
|
||||||
#error Please add support for your compiler in include/base/cef_build.h
|
#error Please add support for your compiler in cef_build.h
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_ANDROID)
|
// Annotate a function indicating the caller must examine the return value.
|
||||||
// The compiler thinks std::string::const_iterator and "const char*" are
|
// Use like:
|
||||||
// equivalent types.
|
// int foo() WARN_UNUSED_RESULT;
|
||||||
#define STD_STRING_ITERATOR_IS_CHAR_POINTER
|
// To explicitly ignore a result, see |ignore_result()| in <base/macros.h>.
|
||||||
// The compiler thinks std::u16string::const_iterator and "char16*" are
|
#ifndef WARN_UNUSED_RESULT
|
||||||
// equivalent types.
|
#if defined(COMPILER_GCC)
|
||||||
#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
|
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||||
|
#else
|
||||||
|
#define WARN_UNUSED_RESULT
|
||||||
|
#endif
|
||||||
|
#endif // WARN_UNUSED_RESULT
|
||||||
|
|
||||||
|
// Annotate a typedef or function indicating it's ok if it's not used.
|
||||||
|
// Use like:
|
||||||
|
// typedef Foo Bar ALLOW_UNUSED_TYPE;
|
||||||
|
#ifndef ALLOW_UNUSED_TYPE
|
||||||
|
#if defined(COMPILER_GCC)
|
||||||
|
#define ALLOW_UNUSED_TYPE __attribute__((unused))
|
||||||
|
#else
|
||||||
|
#define ALLOW_UNUSED_TYPE
|
||||||
|
#endif
|
||||||
|
#endif // ALLOW_UNUSED_TYPE
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
#ifndef ALLOW_UNUSED_LOCAL
|
||||||
|
#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
// Annotate a virtual method indicating it must be overriding a virtual method
|
||||||
|
// in the parent class.
|
||||||
|
// Use like:
|
||||||
|
// void foo() OVERRIDE;
|
||||||
|
// NOTE: This define should only be used in classes exposed to the client since
|
||||||
|
// C++11 support may not be enabled in client applications. CEF internal classes
|
||||||
|
// should use the `override` keyword directly.
|
||||||
|
#ifndef OVERRIDE
|
||||||
|
#if defined(__clang__)
|
||||||
|
#define OVERRIDE override
|
||||||
|
#elif defined(COMPILER_MSVC) && _MSC_VER >= 1600
|
||||||
|
// Visual Studio 2010 and later support override.
|
||||||
|
#define OVERRIDE override
|
||||||
|
#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
|
||||||
|
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
|
||||||
|
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
|
||||||
|
#define OVERRIDE override
|
||||||
|
#else
|
||||||
|
#define OVERRIDE
|
||||||
|
#endif
|
||||||
|
#endif // OVERRIDE
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_
|
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||||
|
|||||||
@@ -28,46 +28,16 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// 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_
|
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_CALLBACK_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -75,175 +45,761 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// 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"
|
#include "include/base/internal/cef_callback_internal.h"
|
||||||
|
#include "include/base/cef_callback_forward.h"
|
||||||
|
#include "include/base/cef_template_util.h"
|
||||||
|
|
||||||
|
// NOTE: Header files that do not require the full definition of Callback or
|
||||||
|
// Closure should #include "base/cef_callback_forward.h" instead of this file.
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Introduction
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// The templated Callback class is a generalized function object. Together
|
||||||
|
// with the Bind() function in bind.h, they provide a type-safe method for
|
||||||
|
// performing partial application of functions.
|
||||||
|
//
|
||||||
|
// Partial application (or "currying") is the process of binding a subset of
|
||||||
|
// a function's arguments to produce another function that takes fewer
|
||||||
|
// arguments. This can be used to pass around a unit of delayed execution,
|
||||||
|
// much like lexical closures are used in other languages. For example, it
|
||||||
|
// is used in Chromium code to schedule tasks on different MessageLoops.
|
||||||
|
//
|
||||||
|
// A callback with no unbound input parameters (base::Callback<void(void)>)
|
||||||
|
// is called a base::Closure. Note that this is NOT the same as what other
|
||||||
|
// languages refer to as a closure -- it does not retain a reference to its
|
||||||
|
// enclosing environment.
|
||||||
|
//
|
||||||
|
// MEMORY MANAGEMENT AND PASSING
|
||||||
|
//
|
||||||
|
// The Callback objects themselves should be passed by const-reference, and
|
||||||
|
// stored by copy. They internally store their state via a refcounted class
|
||||||
|
// and thus do not need to be deleted.
|
||||||
|
//
|
||||||
|
// The reason to pass via a const-reference is to avoid unnecessary
|
||||||
|
// AddRef/Release pairs to the internal state.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Quick reference for basic stuff
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// BINDING A BARE FUNCTION
|
||||||
|
//
|
||||||
|
// int Return5() { return 5; }
|
||||||
|
// base::Callback<int(void)> func_cb = base::Bind(&Return5);
|
||||||
|
// LOG(INFO) << func_cb.Run(); // Prints 5.
|
||||||
|
//
|
||||||
|
// BINDING A CLASS METHOD
|
||||||
|
//
|
||||||
|
// The first argument to bind is the member function to call, the second is
|
||||||
|
// the object on which to call it.
|
||||||
|
//
|
||||||
|
// class Ref : public base::RefCountedThreadSafe<Ref> {
|
||||||
|
// public:
|
||||||
|
// int Foo() { return 3; }
|
||||||
|
// void PrintBye() { LOG(INFO) << "bye."; }
|
||||||
|
// };
|
||||||
|
// scoped_refptr<Ref> ref = new Ref();
|
||||||
|
// base::Callback<void(void)> ref_cb = base::Bind(&Ref::Foo, ref);
|
||||||
|
// LOG(INFO) << ref_cb.Run(); // Prints out 3.
|
||||||
|
//
|
||||||
|
// By default the object must support RefCounted or you will get a compiler
|
||||||
|
// error. If you're passing between threads, be sure it's
|
||||||
|
// RefCountedThreadSafe! See "Advanced binding of member functions" below if
|
||||||
|
// you don't want to use reference counting.
|
||||||
|
//
|
||||||
|
// RUNNING A CALLBACK
|
||||||
|
//
|
||||||
|
// Callbacks can be run with their "Run" method, which has the same
|
||||||
|
// signature as the template argument to the callback.
|
||||||
|
//
|
||||||
|
// void DoSomething(const base::Callback<void(int, std::string)>& callback) {
|
||||||
|
// callback.Run(5, "hello");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Callbacks can be run more than once (they don't get deleted or marked when
|
||||||
|
// run). However, this precludes using base::Passed (see below).
|
||||||
|
//
|
||||||
|
// void DoSomething(const base::Callback<double(double)>& callback) {
|
||||||
|
// double myresult = callback.Run(3.14159);
|
||||||
|
// myresult += callback.Run(2.71828);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// PASSING UNBOUND INPUT PARAMETERS
|
||||||
|
//
|
||||||
|
// Unbound parameters are specified at the time a callback is Run(). They are
|
||||||
|
// specified in the Callback template type:
|
||||||
|
//
|
||||||
|
// void MyFunc(int i, const std::string& str) {}
|
||||||
|
// base::Callback<void(int, const std::string&)> cb = base::Bind(&MyFunc);
|
||||||
|
// cb.Run(23, "hello, world");
|
||||||
|
//
|
||||||
|
// PASSING BOUND INPUT PARAMETERS
|
||||||
|
//
|
||||||
|
// Bound parameters are specified when you create thee callback as arguments
|
||||||
|
// to Bind(). They will be passed to the function and the Run()ner of the
|
||||||
|
// callback doesn't see those values or even know that the function it's
|
||||||
|
// calling.
|
||||||
|
//
|
||||||
|
// void MyFunc(int i, const std::string& str) {}
|
||||||
|
// base::Callback<void(void)> cb = base::Bind(&MyFunc, 23, "hello world");
|
||||||
|
// cb.Run();
|
||||||
|
//
|
||||||
|
// A callback with no unbound input parameters (base::Callback<void(void)>)
|
||||||
|
// is called a base::Closure. So we could have also written:
|
||||||
|
//
|
||||||
|
// base::Closure cb = base::Bind(&MyFunc, 23, "hello world");
|
||||||
|
//
|
||||||
|
// When calling member functions, bound parameters just go after the object
|
||||||
|
// pointer.
|
||||||
|
//
|
||||||
|
// base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world");
|
||||||
|
//
|
||||||
|
// PARTIAL BINDING OF PARAMETERS
|
||||||
|
//
|
||||||
|
// You can specify some parameters when you create the callback, and specify
|
||||||
|
// the rest when you execute the callback.
|
||||||
|
//
|
||||||
|
// void MyFunc(int i, const std::string& str) {}
|
||||||
|
// base::Callback<void(const std::string&)> cb = base::Bind(&MyFunc, 23);
|
||||||
|
// cb.Run("hello world");
|
||||||
|
//
|
||||||
|
// When calling a function bound parameters are first, followed by unbound
|
||||||
|
// parameters.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Quick reference for advanced binding
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// BINDING A CLASS METHOD WITH WEAK POINTERS
|
||||||
|
//
|
||||||
|
// base::Bind(&MyClass::Foo, GetWeakPtr());
|
||||||
|
//
|
||||||
|
// The callback will not be run if the object has already been destroyed.
|
||||||
|
// DANGER: weak pointers are not threadsafe, so don't use this
|
||||||
|
// when passing between threads!
|
||||||
|
//
|
||||||
|
// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT
|
||||||
|
//
|
||||||
|
// base::Bind(&MyClass::Foo, base::Unretained(this));
|
||||||
|
//
|
||||||
|
// This disables all lifetime management on the object. You're responsible
|
||||||
|
// for making sure the object is alive at the time of the call. You break it,
|
||||||
|
// you own it!
|
||||||
|
//
|
||||||
|
// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS
|
||||||
|
//
|
||||||
|
// MyClass* myclass = new MyClass;
|
||||||
|
// base::Bind(&MyClass::Foo, base::Owned(myclass));
|
||||||
|
//
|
||||||
|
// The object will be deleted when the callback is destroyed, even if it's
|
||||||
|
// not run (like if you post a task during shutdown). Potentially useful for
|
||||||
|
// "fire and forget" cases.
|
||||||
|
//
|
||||||
|
// IGNORING RETURN VALUES
|
||||||
|
//
|
||||||
|
// Sometimes you want to call a function that returns a value in a callback
|
||||||
|
// that doesn't expect a return value.
|
||||||
|
//
|
||||||
|
// int DoSomething(int arg) { cout << arg << endl; }
|
||||||
|
// base::Callback<void<int>) cb =
|
||||||
|
// base::Bind(base::IgnoreResult(&DoSomething));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Quick reference for binding parameters to Bind()
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Bound parameters are specified as arguments to Bind() and are passed to the
|
||||||
|
// function. A callback with no parameters or no unbound parameters is called a
|
||||||
|
// Closure (base::Callback<void(void)> and base::Closure are the same thing).
|
||||||
|
//
|
||||||
|
// PASSING PARAMETERS OWNED BY THE CALLBACK
|
||||||
|
//
|
||||||
|
// void Foo(int* arg) { cout << *arg << endl; }
|
||||||
|
// int* pn = new int(1);
|
||||||
|
// base::Closure foo_callback = base::Bind(&foo, base::Owned(pn));
|
||||||
|
//
|
||||||
|
// The parameter will be deleted when the callback is destroyed, even if it's
|
||||||
|
// not run (like if you post a task during shutdown).
|
||||||
|
//
|
||||||
|
// PASSING PARAMETERS AS A scoped_ptr
|
||||||
|
//
|
||||||
|
// void TakesOwnership(scoped_ptr<Foo> arg) {}
|
||||||
|
// scoped_ptr<Foo> f(new Foo);
|
||||||
|
// // f becomes null during the following call.
|
||||||
|
// base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f));
|
||||||
|
//
|
||||||
|
// Ownership of the parameter will be with the callback until the it is run,
|
||||||
|
// when ownership is passed to the callback function. This means the callback
|
||||||
|
// can only be run once. If the callback is never run, it will delete the
|
||||||
|
// object when it's destroyed.
|
||||||
|
//
|
||||||
|
// PASSING PARAMETERS AS A scoped_refptr
|
||||||
|
//
|
||||||
|
// void TakesOneRef(scoped_refptr<Foo> arg) {}
|
||||||
|
// scoped_refptr<Foo> f(new Foo)
|
||||||
|
// base::Closure cb = base::Bind(&TakesOneRef, f);
|
||||||
|
//
|
||||||
|
// This should "just work." The closure will take a reference as long as it
|
||||||
|
// is alive, and another reference will be taken for the called function.
|
||||||
|
//
|
||||||
|
// PASSING PARAMETERS BY REFERENCE
|
||||||
|
//
|
||||||
|
// Const references are *copied* unless ConstRef is used. Example:
|
||||||
|
//
|
||||||
|
// void foo(const int& arg) { printf("%d %p\n", arg, &arg); }
|
||||||
|
// int n = 1;
|
||||||
|
// base::Closure has_copy = base::Bind(&foo, n);
|
||||||
|
// base::Closure has_ref = base::Bind(&foo, base::ConstRef(n));
|
||||||
|
// n = 2;
|
||||||
|
// foo(n); // Prints "2 0xaaaaaaaaaaaa"
|
||||||
|
// has_copy.Run(); // Prints "1 0xbbbbbbbbbbbb"
|
||||||
|
// has_ref.Run(); // Prints "2 0xaaaaaaaaaaaa"
|
||||||
|
//
|
||||||
|
// Normally parameters are copied in the closure. DANGER: ConstRef stores a
|
||||||
|
// const reference instead, referencing the original parameter. This means
|
||||||
|
// that you must ensure the object outlives the callback!
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Implementation notes
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// WHERE IS THIS DESIGN FROM:
|
||||||
|
//
|
||||||
|
// The design Callback and Bind is heavily influenced by C++'s
|
||||||
|
// tr1::function/tr1::bind, and by the "Google Callback" system used inside
|
||||||
|
// Google.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// HOW THE IMPLEMENTATION WORKS:
|
||||||
|
//
|
||||||
|
// There are three main components to the system:
|
||||||
|
// 1) The Callback classes.
|
||||||
|
// 2) The Bind() functions.
|
||||||
|
// 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
|
||||||
|
//
|
||||||
|
// The Callback classes represent a generic function pointer. Internally,
|
||||||
|
// it stores a refcounted piece of state that represents the target function
|
||||||
|
// and all its bound parameters. Each Callback specialization has a templated
|
||||||
|
// constructor that takes an BindState<>*. In the context of the constructor,
|
||||||
|
// the static type of this BindState<> pointer uniquely identifies the
|
||||||
|
// function it is representing, all its bound parameters, and a Run() method
|
||||||
|
// that is capable of invoking the target.
|
||||||
|
//
|
||||||
|
// Callback's constructor takes the BindState<>* that has the full static type
|
||||||
|
// and erases the target function type as well as the types of the bound
|
||||||
|
// parameters. It does this by storing a pointer to the specific Run()
|
||||||
|
// function, and upcasting the state of BindState<>* to a
|
||||||
|
// BindStateBase*. This is safe as long as this BindStateBase pointer
|
||||||
|
// is only used with the stored Run() pointer.
|
||||||
|
//
|
||||||
|
// To BindState<> objects are created inside the Bind() functions.
|
||||||
|
// These functions, along with a set of internal templates, are responsible for
|
||||||
|
//
|
||||||
|
// - Unwrapping the function signature into return type, and parameters
|
||||||
|
// - Determining the number of parameters that are bound
|
||||||
|
// - Creating the BindState storing the bound parameters
|
||||||
|
// - Performing compile-time asserts to avoid error-prone behavior
|
||||||
|
// - Returning an Callback<> with an arity matching the number of unbound
|
||||||
|
// parameters and that knows the correct refcounting semantics for the
|
||||||
|
// target object if we are binding a method.
|
||||||
|
//
|
||||||
|
// The Bind functions do the above using type-inference, and template
|
||||||
|
// specializations.
|
||||||
|
//
|
||||||
|
// By default Bind() will store copies of all bound parameters, and attempt
|
||||||
|
// to refcount a target object if the function being bound is a class method.
|
||||||
|
// These copies are created even if the function takes parameters as const
|
||||||
|
// references. (Binding to non-const references is forbidden, see bind.h.)
|
||||||
|
//
|
||||||
|
// To change this behavior, we introduce a set of argument wrappers
|
||||||
|
// (e.g., Unretained(), and ConstRef()). These are simple container templates
|
||||||
|
// that are passed by value, and wrap a pointer to argument. See the
|
||||||
|
// file-level comment in base/bind_helpers.h for more info.
|
||||||
|
//
|
||||||
|
// These types are passed to the Unwrap() functions, and the MaybeRefcount()
|
||||||
|
// functions respectively to modify the behavior of Bind(). The Unwrap()
|
||||||
|
// and MaybeRefcount() functions change behavior by doing partial
|
||||||
|
// specialization based on whether or not a parameter is a wrapper type.
|
||||||
|
//
|
||||||
|
// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// WHY NOT TR1 FUNCTION/BIND?
|
||||||
|
//
|
||||||
|
// Direct use of tr1::function and tr1::bind was considered, but ultimately
|
||||||
|
// rejected because of the number of copy constructors invocations involved
|
||||||
|
// in the binding of arguments during construction, and the forwarding of
|
||||||
|
// arguments during invocation. These copies will no longer be an issue in
|
||||||
|
// C++0x because C++0x will support rvalue reference allowing for the compiler
|
||||||
|
// to avoid these copies. However, waiting for C++0x is not an option.
|
||||||
|
//
|
||||||
|
// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
|
||||||
|
// tr1::bind call itself will invoke a non-trivial copy constructor three times
|
||||||
|
// for each bound parameter. Also, each when passing a tr1::function, each
|
||||||
|
// bound argument will be copied again.
|
||||||
|
//
|
||||||
|
// In addition to the copies taken at binding and invocation, copying a
|
||||||
|
// tr1::function causes a copy to be made of all the bound parameters and
|
||||||
|
// state.
|
||||||
|
//
|
||||||
|
// Furthermore, in Chromium, it is desirable for the Callback to take a
|
||||||
|
// reference on a target object when representing a class method call. This
|
||||||
|
// is not supported by tr1.
|
||||||
|
//
|
||||||
|
// Lastly, tr1::function and tr1::bind has a more general and flexible API.
|
||||||
|
// This includes things like argument reordering by use of
|
||||||
|
// tr1::bind::placeholder, support for non-const reference parameters, and some
|
||||||
|
// limited amount of subtyping of the tr1::function object (e.g.,
|
||||||
|
// tr1::function<int(int)> is convertible to tr1::function<void(int)>).
|
||||||
|
//
|
||||||
|
// These are not features that are required in Chromium. Some of them, such as
|
||||||
|
// allowing for reference parameters, and subtyping of functions, may actually
|
||||||
|
// become a source of errors. Removing support for these features actually
|
||||||
|
// allows for a simpler implementation, and a terser Currying API.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// WHY NOT GOOGLE CALLBACKS?
|
||||||
|
//
|
||||||
|
// The Google callback system also does not support refcounting. Furthermore,
|
||||||
|
// its implementation has a number of strange edge cases with respect to type
|
||||||
|
// conversion of its arguments. In particular, the argument's constness must
|
||||||
|
// at times match exactly the function signature, or the type-inference might
|
||||||
|
// break. Given the above, writing a custom solution was easier.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// MISSING FUNCTIONALITY
|
||||||
|
// - Invoking the return of Bind. Bind(&foo).Run() does not work;
|
||||||
|
// - Binding arrays to functions that take a non-const pointer.
|
||||||
|
// Example:
|
||||||
|
// void Foo(const char* ptr);
|
||||||
|
// void Bar(char* ptr);
|
||||||
|
// Bind(&Foo, "test");
|
||||||
|
// Bind(&Bar, "test"); // This fails because ptr is not const.
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename R, typename... Args>
|
// First, we forward declare the Callback class template. This informs the
|
||||||
class OnceCallback<R(Args...)> : public internal::CallbackBase {
|
// compiler that the template only has 1 type parameter which is the function
|
||||||
|
// signature that the Callback is representing.
|
||||||
|
//
|
||||||
|
// After this, create template specializations for 0-7 parameters. Note that
|
||||||
|
// even though the template typelist grows, the specialization still
|
||||||
|
// only has one type: the function signature.
|
||||||
|
//
|
||||||
|
// If you are thinking of forward declaring Callback in your own header file,
|
||||||
|
// please include "base/callback_forward.h" instead.
|
||||||
|
template <typename Sig>
|
||||||
|
class Callback;
|
||||||
|
|
||||||
|
namespace cef_internal {
|
||||||
|
template <typename Runnable, typename RunType, typename BoundArgsType>
|
||||||
|
struct BindState;
|
||||||
|
} // namespace cef_internal
|
||||||
|
|
||||||
|
template <typename R>
|
||||||
|
class Callback<R(void)> : public cef_internal::CallbackBase {
|
||||||
public:
|
public:
|
||||||
using ResultType = R;
|
typedef R(RunType)();
|
||||||
using RunType = R(Args...);
|
|
||||||
using PolymorphicInvoke = R (*)(internal::BindStateBase*,
|
|
||||||
internal::PassingType<Args>...);
|
|
||||||
|
|
||||||
constexpr OnceCallback() = default;
|
Callback() : CallbackBase(NULL) { }
|
||||||
OnceCallback(std::nullptr_t) = delete;
|
|
||||||
|
|
||||||
explicit OnceCallback(internal::BindStateBase* bind_state)
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
: internal::CallbackBase(bind_state) {}
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
OnceCallback(const OnceCallback&) = delete;
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
OnceCallback& operator=(const OnceCallback&) = delete;
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
OnceCallback(OnceCallback&&) noexcept = default;
|
PolymorphicInvoke invoke_func =
|
||||||
OnceCallback& operator=(OnceCallback&&) noexcept = default;
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
OnceCallback(RepeatingCallback<RunType> other)
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
: 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& {
|
bool Equals(const Callback& other) const {
|
||||||
static_assert(!sizeof(*this),
|
return CallbackBase::Equals(other);
|
||||||
"OnceCallback::Run() may only be invoked on a non-const "
|
|
||||||
"rvalue, i.e. std::move(callback).Run().");
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
R Run(Args... args) && {
|
R Run() const {
|
||||||
// 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 =
|
PolymorphicInvoke f =
|
||||||
reinterpret_cast<PolymorphicInvoke>(cb.polymorphic_invoke());
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
return f(cb.bind_state_.get(), std::forward<Args>(args)...);
|
|
||||||
|
return f(bind_state_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then() returns a new OnceCallback that receives the same arguments as
|
private:
|
||||||
// |this|, and with the return type of |then|. The returned callback will:
|
typedef R(*PolymorphicInvoke)(
|
||||||
// 1) Run the functor currently bound to |this| callback.
|
cef_internal::BindStateBase*);
|
||||||
// 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>
|
template <typename R, typename A1>
|
||||||
class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable {
|
class Callback<R(A1)> : public cef_internal::CallbackBase {
|
||||||
public:
|
public:
|
||||||
using ResultType = R;
|
typedef R(RunType)(A1);
|
||||||
using RunType = R(Args...);
|
|
||||||
using PolymorphicInvoke = R (*)(internal::BindStateBase*,
|
|
||||||
internal::PassingType<Args>...);
|
|
||||||
|
|
||||||
constexpr RepeatingCallback() = default;
|
Callback() : CallbackBase(NULL) { }
|
||||||
RepeatingCallback(std::nullptr_t) = delete;
|
|
||||||
|
|
||||||
explicit RepeatingCallback(internal::BindStateBase* bind_state)
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
: internal::CallbackBaseCopyable(bind_state) {}
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
// Copyable and movable.
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
RepeatingCallback(const RepeatingCallback&) = default;
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
RepeatingCallback& operator=(const RepeatingCallback&) = default;
|
// the correct type.
|
||||||
RepeatingCallback(RepeatingCallback&&) noexcept = default;
|
PolymorphicInvoke invoke_func =
|
||||||
RepeatingCallback& operator=(RepeatingCallback&&) noexcept = default;
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
bool operator==(const RepeatingCallback& other) const {
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
return EqualsInternal(other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const RepeatingCallback& other) const {
|
bool Equals(const Callback& other) const {
|
||||||
return !operator==(other);
|
return CallbackBase::Equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
R Run(Args... args) const& {
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1) const {
|
||||||
PolymorphicInvoke f =
|
PolymorphicInvoke f =
|
||||||
reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke());
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
return f(this->bind_state_.get(), std::forward<Args>(args)...);
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1));
|
||||||
}
|
}
|
||||||
|
|
||||||
R Run(Args... args) && {
|
private:
|
||||||
// Move the callback instance into a local variable before the invocation,
|
typedef R(*PolymorphicInvoke)(
|
||||||
// that ensures the internal state is cleared after the invocation.
|
cef_internal::BindStateBase*,
|
||||||
// It's not safe to touch |this| after the invocation, since running the
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType);
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename R, typename A1, typename A2>
|
||||||
|
class Callback<R(A1, A2)> : public cef_internal::CallbackBase {
|
||||||
|
public:
|
||||||
|
typedef R(RunType)(A1, A2);
|
||||||
|
|
||||||
|
Callback() : CallbackBase(NULL) { }
|
||||||
|
|
||||||
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
|
PolymorphicInvoke invoke_func =
|
||||||
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Equals(const Callback& other) const {
|
||||||
|
return CallbackBase::Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2) const {
|
||||||
|
PolymorphicInvoke f =
|
||||||
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
||||||
|
cef_internal::CallbackForward(a2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef R(*PolymorphicInvoke)(
|
||||||
|
cef_internal::BindStateBase*,
|
||||||
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R, typename A1, typename A2, typename A3>
|
||||||
|
class Callback<R(A1, A2, A3)> : public cef_internal::CallbackBase {
|
||||||
|
public:
|
||||||
|
typedef R(RunType)(A1, A2, A3);
|
||||||
|
|
||||||
|
Callback() : CallbackBase(NULL) { }
|
||||||
|
|
||||||
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
|
PolymorphicInvoke invoke_func =
|
||||||
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Equals(const Callback& other) const {
|
||||||
|
return CallbackBase::Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3) const {
|
||||||
|
PolymorphicInvoke f =
|
||||||
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
||||||
|
cef_internal::CallbackForward(a2),
|
||||||
|
cef_internal::CallbackForward(a3));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef R(*PolymorphicInvoke)(
|
||||||
|
cef_internal::BindStateBase*,
|
||||||
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
||||||
|
class Callback<R(A1, A2, A3, A4)> : public cef_internal::CallbackBase {
|
||||||
|
public:
|
||||||
|
typedef R(RunType)(A1, A2, A3, A4);
|
||||||
|
|
||||||
|
Callback() : CallbackBase(NULL) { }
|
||||||
|
|
||||||
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
|
PolymorphicInvoke invoke_func =
|
||||||
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Equals(const Callback& other) const {
|
||||||
|
return CallbackBase::Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4) const {
|
||||||
|
PolymorphicInvoke f =
|
||||||
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
||||||
|
cef_internal::CallbackForward(a2),
|
||||||
|
cef_internal::CallbackForward(a3),
|
||||||
|
cef_internal::CallbackForward(a4));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef R(*PolymorphicInvoke)(
|
||||||
|
cef_internal::BindStateBase*,
|
||||||
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5>
|
||||||
|
class Callback<R(A1, A2, A3, A4, A5)> : public cef_internal::CallbackBase {
|
||||||
|
public:
|
||||||
|
typedef R(RunType)(A1, A2, A3, A4, A5);
|
||||||
|
|
||||||
|
Callback() : CallbackBase(NULL) { }
|
||||||
|
|
||||||
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
|
PolymorphicInvoke invoke_func =
|
||||||
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Equals(const Callback& other) const {
|
||||||
|
return CallbackBase::Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5) const {
|
||||||
|
PolymorphicInvoke f =
|
||||||
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
||||||
|
cef_internal::CallbackForward(a2),
|
||||||
|
cef_internal::CallbackForward(a3),
|
||||||
|
cef_internal::CallbackForward(a4),
|
||||||
|
cef_internal::CallbackForward(a5));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef R(*PolymorphicInvoke)(
|
||||||
|
cef_internal::BindStateBase*,
|
||||||
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5, typename A6>
|
||||||
|
class Callback<R(A1, A2, A3, A4, A5, A6)> : public cef_internal::CallbackBase {
|
||||||
|
public:
|
||||||
|
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
|
||||||
|
|
||||||
|
Callback() : CallbackBase(NULL) { }
|
||||||
|
|
||||||
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
|
PolymorphicInvoke invoke_func =
|
||||||
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Equals(const Callback& other) const {
|
||||||
|
return CallbackBase::Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6) const {
|
||||||
|
PolymorphicInvoke f =
|
||||||
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
||||||
|
cef_internal::CallbackForward(a2),
|
||||||
|
cef_internal::CallbackForward(a3),
|
||||||
|
cef_internal::CallbackForward(a4),
|
||||||
|
cef_internal::CallbackForward(a5),
|
||||||
|
cef_internal::CallbackForward(a6));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef R(*PolymorphicInvoke)(
|
||||||
|
cef_internal::BindStateBase*,
|
||||||
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A6>::ForwardType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5, typename A6, typename A7>
|
||||||
|
class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public cef_internal::CallbackBase {
|
||||||
|
public:
|
||||||
|
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
|
||||||
|
|
||||||
|
Callback() : CallbackBase(NULL) { }
|
||||||
|
|
||||||
|
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
||||||
|
// return the exact Callback<> type. See base/bind.h for details.
|
||||||
|
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
||||||
|
Callback(cef_internal::BindState<Runnable, BindRunType,
|
||||||
|
BoundArgsType>* bind_state)
|
||||||
|
: CallbackBase(bind_state) {
|
||||||
|
|
||||||
|
// Force the assignment to a local variable of PolymorphicInvoke
|
||||||
|
// so the compiler will typecheck that the passed in Run() method has
|
||||||
|
// the correct type.
|
||||||
|
PolymorphicInvoke invoke_func =
|
||||||
|
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
|
||||||
|
::InvokerType::Run;
|
||||||
|
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Equals(const Callback& other) const {
|
||||||
|
return CallbackBase::Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6,
|
||||||
|
typename cef_internal::CallbackParamTraits<A7>::ForwardType a7) const {
|
||||||
|
PolymorphicInvoke f =
|
||||||
|
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
||||||
|
|
||||||
|
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
||||||
|
cef_internal::CallbackForward(a2),
|
||||||
|
cef_internal::CallbackForward(a3),
|
||||||
|
cef_internal::CallbackForward(a4),
|
||||||
|
cef_internal::CallbackForward(a5),
|
||||||
|
cef_internal::CallbackForward(a6),
|
||||||
|
cef_internal::CallbackForward(a7));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef R(*PolymorphicInvoke)(
|
||||||
|
cef_internal::BindStateBase*,
|
||||||
|
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A6>::ForwardType,
|
||||||
|
typename cef_internal::CallbackParamTraits<A7>::ForwardType);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Syntactic sugar to make Callbacks<void(void)> easier to declare since it
|
||||||
|
// will be used in a lot of APIs with delayed execution.
|
||||||
|
typedef Callback<void(void)> Closure;
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
@@ -32,7 +32,12 @@
|
|||||||
#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_CALLBACK_FORWARD_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback_forward.h"
|
#include "base/callback_forward.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -42,17 +47,10 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename Signature>
|
template <typename Sig>
|
||||||
class OnceCallback;
|
class Callback;
|
||||||
|
|
||||||
template <typename Signature>
|
typedef Callback<void(void)> Closure;
|
||||||
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
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,21 @@
|
|||||||
// are implemented using templates, with a class per callback signature, adding
|
// are implemented using templates, with a class per callback signature, adding
|
||||||
// methods to Callback<> itself is unattractive (lots of extra code gets
|
// methods to Callback<> itself is unattractive (lots of extra code gets
|
||||||
// generated). Instead, consider adding methods here.
|
// generated). Instead, consider adding methods here.
|
||||||
|
//
|
||||||
|
// ResetAndReturn(&cb) is like cb.Reset() but allows executing a callback (via a
|
||||||
|
// copy) after the original callback is Reset(). This can be handy if Run()
|
||||||
|
// reads/writes the variable holding the Callback.
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_CALLBACK_HELPERS_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback_helpers.h"
|
#include "base/callback_helpers.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -45,195 +54,38 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <atomic>
|
#include "include/base/cef_basictypes.h"
|
||||||
#include <memory>
|
#include "include/base/cef_build.h"
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "include/base/cef_bind.h"
|
|
||||||
#include "include/base/cef_callback.h"
|
#include "include/base/cef_callback.h"
|
||||||
#include "include/base/cef_compiler_specific.h"
|
#include "include/base/cef_macros.h"
|
||||||
#include "include/base/cef_logging.h"
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
namespace internal {
|
template <typename Sig>
|
||||||
|
base::Callback<Sig> ResetAndReturn(base::Callback<Sig>* cb) {
|
||||||
template <typename T>
|
base::Callback<Sig> ret(*cb);
|
||||||
struct IsBaseCallbackImpl : std::false_type {};
|
cb->Reset();
|
||||||
|
return ret;
|
||||||
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
|
// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the
|
||||||
// signature. On first invokation of either returned callbacks, the original
|
// Closure is executed and deleted no matter how the current scope exits.
|
||||||
// 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 {
|
class ScopedClosureRunner {
|
||||||
public:
|
public:
|
||||||
ScopedClosureRunner();
|
ScopedClosureRunner();
|
||||||
explicit ScopedClosureRunner(OnceClosure closure);
|
explicit ScopedClosureRunner(const Closure& 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();
|
~ScopedClosureRunner();
|
||||||
|
|
||||||
explicit operator bool() const { return !!closure_; }
|
void Reset();
|
||||||
|
void Reset(const Closure& closure);
|
||||||
// Calls the current closure and resets it, so it wont be called again.
|
Closure Release() WARN_UNUSED_RESULT;
|
||||||
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:
|
private:
|
||||||
OnceClosure closure_;
|
Closure closure_;
|
||||||
};
|
|
||||||
|
|
||||||
// Creates a null callback.
|
DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner);
|
||||||
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
|
} // namespace base
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
@@ -28,60 +28,16 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// 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_
|
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_CALLBACK_LIST_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback_list.h"
|
#include "base/callback_list.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -89,304 +45,397 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "include/base/cef_auto_reset.h"
|
#include "include/base/cef_basictypes.h"
|
||||||
#include "include/base/cef_bind.h"
|
|
||||||
#include "include/base/cef_callback.h"
|
#include "include/base/cef_callback.h"
|
||||||
#include "include/base/cef_callback_helpers.h"
|
#include "include/base/internal/cef_callback_internal.h"
|
||||||
#include "include/base/cef_compiler_specific.h"
|
#include "include/base/cef_build.h"
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_weak_ptr.h"
|
#include "include/base/cef_macros.h"
|
||||||
|
#include "include/base/cef_scoped_ptr.h"
|
||||||
|
|
||||||
|
// OVERVIEW:
|
||||||
|
//
|
||||||
|
// A container for a list of callbacks. Unlike a normal STL vector or list,
|
||||||
|
// this container can be modified during iteration without invalidating the
|
||||||
|
// iterator. It safely handles the case of a callback removing itself
|
||||||
|
// or another callback from the list while callbacks are being run.
|
||||||
|
//
|
||||||
|
// TYPICAL USAGE:
|
||||||
|
//
|
||||||
|
// class MyWidget {
|
||||||
|
// public:
|
||||||
|
// ...
|
||||||
|
//
|
||||||
|
// typedef base::Callback<void(const Foo&)> OnFooCallback;
|
||||||
|
//
|
||||||
|
// scoped_ptr<base::CallbackList<void(const Foo&)>::Subscription>
|
||||||
|
// RegisterCallback(const OnFooCallback& cb) {
|
||||||
|
// return callback_list_.Add(cb);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private:
|
||||||
|
// void NotifyFoo(const Foo& foo) {
|
||||||
|
// callback_list_.Notify(foo);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// base::CallbackList<void(const Foo&)> callback_list_;
|
||||||
|
//
|
||||||
|
// DISALLOW_COPY_AND_ASSIGN(MyWidget);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// class MyWidgetListener {
|
||||||
|
// public:
|
||||||
|
// MyWidgetListener::MyWidgetListener() {
|
||||||
|
// foo_subscription_ = MyWidget::GetCurrent()->RegisterCallback(
|
||||||
|
// base::Bind(&MyWidgetListener::OnFoo, this)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// MyWidgetListener::~MyWidgetListener() {
|
||||||
|
// // Subscription gets deleted automatically and will deregister
|
||||||
|
// // the callback in the process.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private:
|
||||||
|
// void OnFoo(const Foo& foo) {
|
||||||
|
// // Do something.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// scoped_ptr<base::CallbackList<void(const Foo&)>::Subscription>
|
||||||
|
// foo_subscription_;
|
||||||
|
//
|
||||||
|
// DISALLOW_COPY_AND_ASSIGN(MyWidgetListener);
|
||||||
|
// };
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace internal {
|
|
||||||
template <typename CallbackListImpl>
|
|
||||||
class CallbackListBase;
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
template <typename Signature>
|
namespace cef_internal {
|
||||||
class OnceCallbackList;
|
|
||||||
|
|
||||||
template <typename Signature>
|
template <typename CallbackType>
|
||||||
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 {
|
class CallbackListBase {
|
||||||
public:
|
public:
|
||||||
using CallbackType =
|
class Subscription {
|
||||||
typename CallbackListTraits<CallbackListImpl>::CallbackType;
|
public:
|
||||||
static_assert(IsBaseCallback<CallbackType>::value, "");
|
Subscription(CallbackListBase<CallbackType>* list,
|
||||||
|
typename std::list<CallbackType>::iterator iter)
|
||||||
// TODO(crbug.com/1103086): Update references to use this directly and by
|
: list_(list),
|
||||||
// value, then remove.
|
iter_(iter) {
|
||||||
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
|
~Subscription() {
|
||||||
// whose destruction will cancel |cb|.
|
if (list_->active_iterator_count_) {
|
||||||
CallbackListSubscription Add(CallbackType cb) WARN_UNUSED_RESULT {
|
iter_->Reset();
|
||||||
DCHECK(!cb.is_null());
|
} else {
|
||||||
return CallbackListSubscription(base::BindOnce(
|
list_->callbacks_.erase(iter_);
|
||||||
&CallbackListBase::CancelCallback, weak_ptr_factory_.GetWeakPtr(),
|
if (!list_->removal_callback_.is_null())
|
||||||
callbacks_.insert(callbacks_.end(), std::move(cb))));
|
list_->removal_callback_.Run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers |cb| for future notifications. Provides no way for the caller to
|
private:
|
||||||
// cancel, so this is only safe for cases where the callback is guaranteed to
|
CallbackListBase<CallbackType>* list_;
|
||||||
// live at least as long as this list (e.g. if it's bound on the same object
|
typename std::list<CallbackType>::iterator iter_;
|
||||||
// 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
|
DISALLOW_COPY_AND_ASSIGN(Subscription);
|
||||||
// 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))
|
// Add a callback to the list. The callback will remain registered until the
|
||||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...,
|
// returned Subscription is destroyed, which must occur before the
|
||||||
// since that would allow move-only arguments.
|
// CallbackList is destroyed.
|
||||||
static_cast<CallbackListImpl*>(this)->RunCallback(it++, args...);
|
scoped_ptr<Subscription> Add(const CallbackType& cb) WARN_UNUSED_RESULT {
|
||||||
|
DCHECK(!cb.is_null());
|
||||||
|
return scoped_ptr<Subscription>(
|
||||||
|
new Subscription(this, callbacks_.insert(callbacks_.end(), cb)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-entrant invocations shouldn't prune anything from the list. This can
|
// Sets a callback which will be run when a subscription list is changed.
|
||||||
// invalidate iterators from underneath higher call frames. It's safe to
|
void set_removal_callback(const Closure& callback) {
|
||||||
// simply do nothing, since the outermost frame will continue through here
|
removal_callback_ = callback;
|
||||||
// and prune all null callbacks below.
|
}
|
||||||
if (iterating_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Any null callbacks remaining in the list were canceled due to
|
// Returns true if there are no subscriptions. This is only valid to call when
|
||||||
// Subscription destruction during iteration, and can safely be erased now.
|
// not looping through the list.
|
||||||
const size_t erased_callbacks =
|
bool empty() {
|
||||||
EraseIf(callbacks_, [](const auto& cb) { return cb.is_null(); });
|
DCHECK_EQ(0, active_iterator_count_);
|
||||||
|
return callbacks_.empty();
|
||||||
// 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:
|
protected:
|
||||||
using Callbacks = typename CallbackListTraits<CallbackListImpl>::Callbacks;
|
// An iterator class that can be used to access the list of callbacks.
|
||||||
|
class Iterator {
|
||||||
|
public:
|
||||||
|
explicit Iterator(CallbackListBase<CallbackType>* list)
|
||||||
|
: list_(list),
|
||||||
|
list_iter_(list_->callbacks_.begin()) {
|
||||||
|
++list_->active_iterator_count_;
|
||||||
|
}
|
||||||
|
|
||||||
// Holds non-null callbacks, which will be called during Notify().
|
Iterator(const Iterator& iter)
|
||||||
Callbacks callbacks_;
|
: list_(iter.list_),
|
||||||
|
list_iter_(iter.list_iter_) {
|
||||||
|
++list_->active_iterator_count_;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Iterator() {
|
||||||
|
if (list_ && --list_->active_iterator_count_ == 0) {
|
||||||
|
list_->Compact();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CallbackType* GetNext() {
|
||||||
|
while ((list_iter_ != list_->callbacks_.end()) && list_iter_->is_null())
|
||||||
|
++list_iter_;
|
||||||
|
|
||||||
|
CallbackType* cb = NULL;
|
||||||
|
if (list_iter_ != list_->callbacks_.end()) {
|
||||||
|
cb = &(*list_iter_);
|
||||||
|
++list_iter_;
|
||||||
|
}
|
||||||
|
return cb;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Cancels the callback pointed to by |it|, which is guaranteed to be valid.
|
CallbackListBase<CallbackType>* list_;
|
||||||
void CancelCallback(const typename Callbacks::iterator& it) {
|
typename std::list<CallbackType>::iterator list_iter_;
|
||||||
if (static_cast<CallbackListImpl*>(this)->CancelNullCallback(it))
|
};
|
||||||
return;
|
|
||||||
|
|
||||||
if (iterating_) {
|
CallbackListBase() : active_iterator_count_(0) {}
|
||||||
// Calling erase() here is unsafe, since the loop in Notify() may be
|
|
||||||
// referencing this same iterator, e.g. if adjacent callbacks'
|
~CallbackListBase() {
|
||||||
// Subscriptions are both destroyed when the first one is Run(). Just
|
DCHECK_EQ(0, active_iterator_count_);
|
||||||
// reset the callback and let Notify() clean it up at the end.
|
DCHECK_EQ(0U, callbacks_.size());
|
||||||
it->Reset();
|
}
|
||||||
|
|
||||||
|
// Returns an instance of a CallbackListBase::Iterator which can be used
|
||||||
|
// to run callbacks.
|
||||||
|
Iterator GetIterator() {
|
||||||
|
return Iterator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compact the list: remove any entries which were NULLed out during
|
||||||
|
// iteration.
|
||||||
|
void Compact() {
|
||||||
|
typename std::list<CallbackType>::iterator it = callbacks_.begin();
|
||||||
|
bool updated = false;
|
||||||
|
while (it != callbacks_.end()) {
|
||||||
|
if ((*it).is_null()) {
|
||||||
|
updated = true;
|
||||||
|
it = callbacks_.erase(it);
|
||||||
} else {
|
} else {
|
||||||
callbacks_.erase(it);
|
++it;
|
||||||
if (removal_callback_)
|
}
|
||||||
removal_callback_.Run(); // May delete |this|!
|
|
||||||
|
if (updated && !removal_callback_.is_null())
|
||||||
|
removal_callback_.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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:
|
private:
|
||||||
friend internal::CallbackListBase<OnceCallbackList>;
|
std::list<CallbackType> callbacks_;
|
||||||
using Traits = internal::CallbackListTraits<OnceCallbackList>;
|
int active_iterator_count_;
|
||||||
|
Closure removal_callback_;
|
||||||
|
|
||||||
// Runs the current callback, which may cancel it or any other callbacks.
|
DISALLOW_COPY_AND_ASSIGN(CallbackListBase);
|
||||||
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>
|
} // namespace cef_internal
|
||||||
class RepeatingCallbackList
|
|
||||||
: public internal::CallbackListBase<RepeatingCallbackList<Signature>> {
|
template <typename Sig> class CallbackList;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class CallbackList<void(void)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(void)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(void)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify() {
|
||||||
|
cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend internal::CallbackListBase<RepeatingCallbackList>;
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
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.
|
template <typename A1>
|
||||||
// ClosureList explicitly not provided since it is not used, and CallbackList
|
class CallbackList<void(A1)>
|
||||||
// is deprecated. {Once,Repeating}ClosureList should instead be used.
|
: public cef_internal::CallbackListBase<Callback<void(A1)> > {
|
||||||
using OnceClosureList = OnceCallbackList<void()>;
|
public:
|
||||||
using RepeatingClosureList = RepeatingCallbackList<void()>;
|
typedef Callback<void(A1)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2>
|
||||||
|
class CallbackList<void(A1, A2)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(A1, A2)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(A1, A2)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1, a2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2, typename A3>
|
||||||
|
class CallbackList<void(A1, A2, A3)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(A1, A2, A3)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1, a2, a3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2, typename A3, typename A4>
|
||||||
|
class CallbackList<void(A1, A2, A3, A4)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(A1, A2, A3, A4)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1, a2, a3, a4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||||
|
class CallbackList<void(A1, A2, A3, A4, A5)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(A1, A2, A3, A4, A5)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1, a2, a3, a4, a5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||||
|
typename A6>
|
||||||
|
class CallbackList<void(A1, A2, A3, A4, A5, A6)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5,
|
||||||
|
A6)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(A1, A2, A3, A4, A5, A6)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1, a2, a3, a4, a5, a6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2, typename A3, typename A4, typename A5,
|
||||||
|
typename A6, typename A7>
|
||||||
|
class CallbackList<void(A1, A2, A3, A4, A5, A6, A7)>
|
||||||
|
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5, A6,
|
||||||
|
A7)> > {
|
||||||
|
public:
|
||||||
|
typedef Callback<void(A1, A2, A3, A4, A5, A6, A7)> CallbackType;
|
||||||
|
|
||||||
|
CallbackList() {}
|
||||||
|
|
||||||
|
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6,
|
||||||
|
typename cef_internal::CallbackParamTraits<A7>::ForwardType a7) {
|
||||||
|
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
||||||
|
this->GetIterator();
|
||||||
|
CallbackType* cb;
|
||||||
|
while ((cb = it.GetNext()) != NULL) {
|
||||||
|
cb->Run(a1, a2, a3, a4, a5, a6, a7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
// CancelableCallback is a wrapper around base::Callback that allows
|
// CancelableCallback is a wrapper around base::Callback that allows
|
||||||
// cancellation of a callback. CancelableCallback takes a reference on the
|
// cancellation of a callback. CancelableCallback takes a reference on the
|
||||||
// wrapped callback until this object is destroyed or Reset()/Cancel() are
|
// wrapped callback until this object is destroyed or Reset()/Cancel() are
|
||||||
@@ -52,26 +52,29 @@
|
|||||||
// to the message loop, the intensive test runs, the message loop is run,
|
// to the message loop, the intensive test runs, the message loop is run,
|
||||||
// then the callback is cancelled.
|
// then the callback is cancelled.
|
||||||
//
|
//
|
||||||
// RunLoop run_loop;
|
|
||||||
//
|
|
||||||
// void TimeoutCallback(const std::string& timeout_message) {
|
// void TimeoutCallback(const std::string& timeout_message) {
|
||||||
// FAIL() << timeout_message;
|
// FAIL() << timeout_message;
|
||||||
// run_loop.QuitWhenIdle();
|
// MessageLoop::current()->QuitWhenIdle();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// CancelableOnceClosure timeout(
|
// CancelableClosure timeout(base::Bind(&TimeoutCallback, "Test timed out."));
|
||||||
// base::BindOnce(&TimeoutCallback, "Test timed out."));
|
// MessageLoop::current()->PostDelayedTask(FROM_HERE, timeout.callback(),
|
||||||
// ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, timeout.callback(),
|
// 4000) // 4 seconds to run.
|
||||||
// TimeDelta::FromSeconds(4));
|
|
||||||
// RunIntensiveTest();
|
// RunIntensiveTest();
|
||||||
// run_loop.Run();
|
// MessageLoop::current()->Run();
|
||||||
// timeout.Cancel(); // Hopefully this is hit before the timeout callback runs.
|
// timeout.Cancel(); // Hopefully this is hit before the timeout callback runs.
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_CANCELABLE_CALLBACK_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/cancelable_callback.h"
|
#include "base/cancelable_callback.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -79,104 +82,230 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "include/base/cef_bind.h"
|
#include "include/base/cef_bind.h"
|
||||||
#include "include/base/cef_callback.h"
|
#include "include/base/cef_callback.h"
|
||||||
#include "include/base/cef_compiler_specific.h"
|
#include "include/base/cef_build.h"
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
#include "include/base/cef_weak_ptr.h"
|
#include "include/base/cef_weak_ptr.h"
|
||||||
#include "include/base/internal/cef_callback_internal.h"
|
#include "include/base/internal/cef_callback_internal.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template <typename CallbackType>
|
template <typename Sig>
|
||||||
class CancelableCallbackImpl {
|
class CancelableCallback;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class CancelableCallback<void(void)> {
|
||||||
public:
|
public:
|
||||||
CancelableCallbackImpl() = default;
|
CancelableCallback() : weak_factory_(this) {}
|
||||||
CancelableCallbackImpl(const CancelableCallbackImpl&) = delete;
|
|
||||||
CancelableCallbackImpl& operator=(const CancelableCallbackImpl&) = delete;
|
|
||||||
|
|
||||||
// |callback| must not be null.
|
// |callback| must not be null.
|
||||||
explicit CancelableCallbackImpl(CallbackType callback)
|
explicit CancelableCallback(const base::Callback<void(void)>& callback)
|
||||||
: callback_(std::move(callback)) {
|
: weak_factory_(this),
|
||||||
DCHECK(callback_);
|
callback_(callback) {
|
||||||
|
DCHECK(!callback.is_null());
|
||||||
|
InitializeForwarder();
|
||||||
}
|
}
|
||||||
|
|
||||||
~CancelableCallbackImpl() = default;
|
~CancelableCallback() {}
|
||||||
|
|
||||||
// Cancels and drops the reference to the wrapped callback.
|
// Cancels and drops the reference to the wrapped callback.
|
||||||
void Cancel() {
|
void Cancel() {
|
||||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
weak_factory_.InvalidateWeakPtrs();
|
||||||
|
forwarder_.Reset();
|
||||||
callback_.Reset();
|
callback_.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the wrapped callback has been cancelled.
|
// Returns true if the wrapped callback has been cancelled.
|
||||||
bool IsCancelled() const { return callback_.is_null(); }
|
bool IsCancelled() const {
|
||||||
|
return callback_.is_null();
|
||||||
|
}
|
||||||
|
|
||||||
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
||||||
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
||||||
void Reset(CallbackType callback) {
|
void Reset(const base::Callback<void(void)>& callback) {
|
||||||
DCHECK(callback);
|
DCHECK(!callback.is_null());
|
||||||
|
|
||||||
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
||||||
Cancel();
|
Cancel();
|
||||||
callback_ = std::move(callback);
|
|
||||||
|
// |forwarder_| is no longer valid after Cancel(), so re-bind.
|
||||||
|
InitializeForwarder();
|
||||||
|
|
||||||
|
callback_ = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a callback that can be disabled by calling Cancel().
|
// Returns a callback that can be disabled by calling Cancel().
|
||||||
CallbackType callback() const {
|
const base::Callback<void(void)>& callback() const {
|
||||||
if (!callback_)
|
return forwarder_;
|
||||||
return CallbackType();
|
|
||||||
CallbackType forwarder;
|
|
||||||
MakeForwarder(&forwarder);
|
|
||||||
return forwarder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename... Args>
|
void Forward() {
|
||||||
void MakeForwarder(RepeatingCallback<void(Args...)>* out) const {
|
callback_.Run();
|
||||||
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
|
||||||
ForwarderType forwarder = &CancelableCallbackImpl::ForwardRepeating;
|
|
||||||
*out = BindRepeating(forwarder, weak_ptr_factory_.GetWeakPtr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
// Helper method to bind |forwarder_| using a weak pointer from
|
||||||
void MakeForwarder(OnceCallback<void(Args...)>* out) const {
|
// |weak_factory_|.
|
||||||
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
void InitializeForwarder() {
|
||||||
ForwarderType forwarder = &CancelableCallbackImpl::ForwardOnce;
|
forwarder_ = base::Bind(&CancelableCallback<void(void)>::Forward,
|
||||||
*out = BindOnce(forwarder, weak_ptr_factory_.GetWeakPtr());
|
weak_factory_.GetWeakPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
// Used to ensure Forward() is not run when this object is destroyed.
|
||||||
void ForwardRepeating(Args... args) {
|
base::WeakPtrFactory<CancelableCallback<void(void)> > weak_factory_;
|
||||||
callback_.Run(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
// The wrapper closure.
|
||||||
void ForwardOnce(Args... args) {
|
base::Callback<void(void)> forwarder_;
|
||||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
|
||||||
std::move(callback_).Run(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The stored closure that may be cancelled.
|
// The stored closure that may be cancelled.
|
||||||
CallbackType callback_;
|
base::Callback<void(void)> callback_;
|
||||||
mutable base::WeakPtrFactory<CancelableCallbackImpl> weak_ptr_factory_{this};
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CancelableCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
template <typename A1>
|
||||||
|
class CancelableCallback<void(A1)> {
|
||||||
|
public:
|
||||||
|
CancelableCallback() : weak_factory_(this) {}
|
||||||
|
|
||||||
// Consider using base::WeakPtr directly instead of base::CancelableCallback for
|
// |callback| must not be null.
|
||||||
// the task cancellation.
|
explicit CancelableCallback(const base::Callback<void(A1)>& callback)
|
||||||
template <typename Signature>
|
: weak_factory_(this),
|
||||||
using CancelableOnceCallback =
|
callback_(callback) {
|
||||||
internal::CancelableCallbackImpl<OnceCallback<Signature>>;
|
DCHECK(!callback.is_null());
|
||||||
using CancelableOnceClosure = CancelableOnceCallback<void()>;
|
InitializeForwarder();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Signature>
|
~CancelableCallback() {}
|
||||||
using CancelableRepeatingCallback =
|
|
||||||
internal::CancelableCallbackImpl<RepeatingCallback<Signature>>;
|
// Cancels and drops the reference to the wrapped callback.
|
||||||
using CancelableRepeatingClosure = CancelableRepeatingCallback<void()>;
|
void Cancel() {
|
||||||
|
weak_factory_.InvalidateWeakPtrs();
|
||||||
|
forwarder_.Reset();
|
||||||
|
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(const base::Callback<void(A1)>& callback) {
|
||||||
|
DCHECK(!callback.is_null());
|
||||||
|
|
||||||
|
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
||||||
|
Cancel();
|
||||||
|
|
||||||
|
// |forwarder_| is no longer valid after Cancel(), so re-bind.
|
||||||
|
InitializeForwarder();
|
||||||
|
|
||||||
|
callback_ = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a callback that can be disabled by calling Cancel().
|
||||||
|
const base::Callback<void(A1)>& callback() const {
|
||||||
|
return forwarder_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Forward(A1 a1) const {
|
||||||
|
callback_.Run(a1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to bind |forwarder_| using a weak pointer from
|
||||||
|
// |weak_factory_|.
|
||||||
|
void InitializeForwarder() {
|
||||||
|
forwarder_ = base::Bind(&CancelableCallback<void(A1)>::Forward,
|
||||||
|
weak_factory_.GetWeakPtr());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used to ensure Forward() is not run when this object is destroyed.
|
||||||
|
base::WeakPtrFactory<CancelableCallback<void(A1)> > weak_factory_;
|
||||||
|
|
||||||
|
// The wrapper closure.
|
||||||
|
base::Callback<void(A1)> forwarder_;
|
||||||
|
|
||||||
|
// The stored closure that may be cancelled.
|
||||||
|
base::Callback<void(A1)> callback_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CancelableCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A1, typename A2>
|
||||||
|
class CancelableCallback<void(A1, A2)> {
|
||||||
|
public:
|
||||||
|
CancelableCallback() : weak_factory_(this) {}
|
||||||
|
|
||||||
|
// |callback| must not be null.
|
||||||
|
explicit CancelableCallback(const base::Callback<void(A1, A2)>& callback)
|
||||||
|
: weak_factory_(this),
|
||||||
|
callback_(callback) {
|
||||||
|
DCHECK(!callback.is_null());
|
||||||
|
InitializeForwarder();
|
||||||
|
}
|
||||||
|
|
||||||
|
~CancelableCallback() {}
|
||||||
|
|
||||||
|
// Cancels and drops the reference to the wrapped callback.
|
||||||
|
void Cancel() {
|
||||||
|
weak_factory_.InvalidateWeakPtrs();
|
||||||
|
forwarder_.Reset();
|
||||||
|
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(const base::Callback<void(A1, A2)>& callback) {
|
||||||
|
DCHECK(!callback.is_null());
|
||||||
|
|
||||||
|
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
||||||
|
Cancel();
|
||||||
|
|
||||||
|
// |forwarder_| is no longer valid after Cancel(), so re-bind.
|
||||||
|
InitializeForwarder();
|
||||||
|
|
||||||
|
callback_ = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a callback that can be disabled by calling Cancel().
|
||||||
|
const base::Callback<void(A1, A2)>& callback() const {
|
||||||
|
return forwarder_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Forward(A1 a1, A2 a2) const {
|
||||||
|
callback_.Run(a1, a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to bind |forwarder_| using a weak pointer from
|
||||||
|
// |weak_factory_|.
|
||||||
|
void InitializeForwarder() {
|
||||||
|
forwarder_ = base::Bind(&CancelableCallback<void(A1, A2)>::Forward,
|
||||||
|
weak_factory_.GetWeakPtr());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used to ensure Forward() is not run when this object is destroyed.
|
||||||
|
base::WeakPtrFactory<CancelableCallback<void(A1, A2)> > weak_factory_;
|
||||||
|
|
||||||
|
// The wrapper closure.
|
||||||
|
base::Callback<void(A1, A2)> forwarder_;
|
||||||
|
|
||||||
|
// The stored closure that may be cancelled.
|
||||||
|
base::Callback<void(A1, A2)> callback_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CancelableCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CancelableCallback<void(void)> CancelableClosure;
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -1,423 +0,0 @@
|
|||||||
// 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(BASE_COMPILER_SPECIFIC_H_)
|
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// 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.
|
|
||||||
#elif 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 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);
|
|
||||||
#define ALLOW_UNUSED_LOCAL(x) (void)x
|
|
||||||
|
|
||||||
// Annotate a typedef or function indicating it's ok if it's not used.
|
|
||||||
// Use like:
|
|
||||||
// typedef Foo Bar ALLOW_UNUSED_TYPE;
|
|
||||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
|
||||||
#define ALLOW_UNUSED_TYPE __attribute__((unused))
|
|
||||||
#else
|
|
||||||
#define ALLOW_UNUSED_TYPE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
// Annotate a function indicating the caller must examine the return value.
|
|
||||||
// Use like:
|
|
||||||
// int foo() WARN_UNUSED_RESULT;
|
|
||||||
// To explicitly ignore a result, see |ignore_result()| in base/macros.h.
|
|
||||||
#undef WARN_UNUSED_RESULT
|
|
||||||
#if defined(COMPILER_GCC) || defined(__clang__)
|
|
||||||
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
|
||||||
#else
|
|
||||||
#define WARN_UNUSED_RESULT
|
|
||||||
#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
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
// 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.
|
|
||||||
// TODO(cef): Change to "base/cxx17_backports.h" in M93.
|
|
||||||
#include "base/stl_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 <array>
|
|
||||||
#include <initializer_list>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// C++14 implementation of C++17's std::empty():
|
|
||||||
// http://en.cppreference.com/w/cpp/iterator/empty
|
|
||||||
template <typename Container>
|
|
||||||
constexpr auto empty(const Container& c) -> decltype(c.empty()) {
|
|
||||||
return c.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
constexpr bool empty(const T (&array)[N]) noexcept {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool empty(std::initializer_list<T> il) noexcept {
|
|
||||||
return il.size() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// C++14 implementation of C++17's std::data():
|
|
||||||
// http://en.cppreference.com/w/cpp/iterator/data
|
|
||||||
template <typename Container>
|
|
||||||
constexpr auto data(Container& c) -> decltype(c.data()) {
|
|
||||||
return c.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
// std::basic_string::data() had no mutable overload prior to C++17 [1].
|
|
||||||
// Hence this overload is provided.
|
|
||||||
// Note: str[0] is safe even for empty strings, as they are guaranteed to be
|
|
||||||
// null-terminated [2].
|
|
||||||
//
|
|
||||||
// [1] http://en.cppreference.com/w/cpp/string/basic_string/data
|
|
||||||
// [2] http://en.cppreference.com/w/cpp/string/basic_string/operator_at
|
|
||||||
template <typename CharT, typename Traits, typename Allocator>
|
|
||||||
CharT* data(std::basic_string<CharT, Traits, Allocator>& str) {
|
|
||||||
return std::addressof(str[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Container>
|
|
||||||
constexpr auto data(const Container& c) -> decltype(c.data()) {
|
|
||||||
return c.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
constexpr T* data(T (&array)[N]) noexcept {
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr const T* data(std::initializer_list<T> il) noexcept {
|
|
||||||
return il.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
// std::array::data() was not constexpr prior to C++17 [1].
|
|
||||||
// Hence these overloads are provided.
|
|
||||||
//
|
|
||||||
// [1] https://en.cppreference.com/w/cpp/container/array/data
|
|
||||||
template <typename T, size_t N>
|
|
||||||
constexpr T* data(std::array<T, N>& array) noexcept {
|
|
||||||
return !array.empty() ? &array[0] : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
constexpr const T* data(const std::array<T, N>& array) noexcept {
|
|
||||||
return !array.empty() ? &array[0] : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_CXX17_BACKPORTS_H_
|
|
||||||
@@ -32,7 +32,12 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_LOCK_H_
|
#define CEF_INCLUDE_BASE_CEF_LOCK_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_SYNCHRONIZATION_LOCK_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/synchronization/lock.h"
|
#include "base/synchronization/lock.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -120,7 +125,9 @@ class AutoLock {
|
|||||||
public:
|
public:
|
||||||
struct AlreadyAcquired {};
|
struct AlreadyAcquired {};
|
||||||
|
|
||||||
explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); }
|
explicit AutoLock(Lock& lock) : lock_(lock) {
|
||||||
|
lock_.Acquire();
|
||||||
|
}
|
||||||
|
|
||||||
AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) {
|
AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) {
|
||||||
lock_.AssertAcquired();
|
lock_.AssertAcquired();
|
||||||
@@ -146,7 +153,9 @@ class AutoUnlock {
|
|||||||
lock_.Release();
|
lock_.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoUnlock() { lock_.Acquire(); }
|
~AutoUnlock() {
|
||||||
|
lock_.Acquire();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Lock& lock_;
|
Lock& lock_;
|
||||||
|
|||||||
@@ -136,11 +136,7 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(DCHECK)
|
||||||
// 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.
|
// Do nothing if the macros provided by this header already exist.
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
// This can happen in cases where Chromium code is used directly by the
|
||||||
// client application. When using Chromium code directly always include
|
// client application. When using Chromium code directly always include
|
||||||
@@ -148,20 +144,23 @@
|
|||||||
|
|
||||||
// Always define the DCHECK_IS_ON macro which is used from other CEF headers.
|
// Always define the DCHECK_IS_ON macro which is used from other CEF headers.
|
||||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||||
#define DCHECK_IS_ON() false
|
#define DCHECK_IS_ON() 0
|
||||||
#else
|
#else
|
||||||
#define DCHECK_IS_ON() true
|
#define DCHECK_IS_ON() 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else // !defined(DCHECK)
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/logging.h"
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "include/base/cef_build.h"
|
#include "include/base/cef_build.h"
|
||||||
#include "include/base/cef_macros.h"
|
#include "include/base/cef_macros.h"
|
||||||
@@ -203,26 +202,31 @@ const LogSeverity LOG_DFATAL = LOG_FATAL;
|
|||||||
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
||||||
// better to have compact code for these operations.
|
// better to have compact code for these operations.
|
||||||
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
|
||||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_INFO, \
|
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO , \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
|
||||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_WARNING, \
|
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING , \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
|
||||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_ERROR, \
|
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR , \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
|
||||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_FATAL, \
|
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL , \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
|
||||||
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_DFATAL, \
|
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL , \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
|
|
||||||
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
|
#define COMPACT_GOOGLE_LOG_INFO \
|
||||||
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
|
COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
|
||||||
#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage)
|
#define COMPACT_GOOGLE_LOG_WARNING \
|
||||||
#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage)
|
COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
|
||||||
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(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)
|
#if defined(OS_WIN)
|
||||||
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
|
||||||
@@ -232,7 +236,7 @@ const LogSeverity LOG_DFATAL = LOG_FATAL;
|
|||||||
// the Windows SDK does for consistency.
|
// the Windows SDK does for consistency.
|
||||||
#define ERROR 0
|
#define ERROR 0
|
||||||
#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \
|
||||||
COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__)
|
COMPACT_GOOGLE_LOG_EX_ERROR(ClassName , ##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
|
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
|
||||||
// Needed for LOG_IS_ON(ERROR).
|
// Needed for LOG_IS_ON(ERROR).
|
||||||
const LogSeverity LOG_0 = LOG_ERROR;
|
const LogSeverity LOG_0 = LOG_ERROR;
|
||||||
@@ -242,7 +246,7 @@ const LogSeverity LOG_0 = LOG_ERROR;
|
|||||||
// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will
|
// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will
|
||||||
// always fire if they fail.
|
// always fire if they fail.
|
||||||
#define LOG_IS_ON(severity) \
|
#define LOG_IS_ON(severity) \
|
||||||
((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel())
|
((::cef::logging::LOG_ ## severity) >= ::cef::logging::GetMinLogLevel())
|
||||||
|
|
||||||
// We can't do any caching tricks with VLOG_IS_ON() like the
|
// We can't do any caching tricks with VLOG_IS_ON() like the
|
||||||
// google-glog version since it requires GCC extensions. This means
|
// google-glog version since it requires GCC extensions. This means
|
||||||
@@ -254,7 +258,7 @@ const LogSeverity LOG_0 = LOG_ERROR;
|
|||||||
// Helper macro which avoids evaluating the arguments to a stream if
|
// Helper macro which avoids evaluating the arguments to a stream if
|
||||||
// the condition doesn't hold.
|
// the condition doesn't hold.
|
||||||
#define LAZY_STREAM(stream, condition) \
|
#define LAZY_STREAM(stream, condition) \
|
||||||
!(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream)
|
!(condition) ? (void) 0 : ::cef::logging::LogMessageVoidify() & (stream)
|
||||||
|
|
||||||
// We use the preprocessor's merging operator, "##", so that, e.g.,
|
// We use the preprocessor's merging operator, "##", so that, e.g.,
|
||||||
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
|
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
|
||||||
@@ -264,7 +268,7 @@ const LogSeverity LOG_0 = LOG_ERROR;
|
|||||||
// impossible to stream something like a string directly to an unnamed
|
// impossible to stream something like a string directly to an unnamed
|
||||||
// ostream. We employ a neat hack by calling the stream() member
|
// ostream. We employ a neat hack by calling the stream() member
|
||||||
// function of LogMessage which seems to avoid the problem.
|
// function of LogMessage which seems to avoid the problem.
|
||||||
#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream()
|
#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
|
||||||
|
|
||||||
#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity))
|
#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity))
|
||||||
#define LOG_IF(severity, condition) \
|
#define LOG_IF(severity, condition) \
|
||||||
@@ -284,16 +288,14 @@ const LogSeverity LOG_0 = LOG_ERROR;
|
|||||||
LAZY_STREAM(VLOG_STREAM(verbose_level), \
|
LAZY_STREAM(VLOG_STREAM(verbose_level), \
|
||||||
VLOG_IS_ON(verbose_level) && (condition))
|
VLOG_IS_ON(verbose_level) && (condition))
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined (OS_WIN)
|
||||||
#define VPLOG_STREAM(verbose_level) \
|
#define VPLOG_STREAM(verbose_level) \
|
||||||
cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
|
cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
|
||||||
::cef::logging::GetLastSystemErrorCode()) \
|
::cef::logging::GetLastSystemErrorCode()).stream()
|
||||||
.stream()
|
|
||||||
#elif defined(OS_POSIX)
|
#elif defined(OS_POSIX)
|
||||||
#define VPLOG_STREAM(verbose_level) \
|
#define VPLOG_STREAM(verbose_level) \
|
||||||
cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
|
cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
|
||||||
::cef::logging::GetLastSystemErrorCode()) \
|
::cef::logging::GetLastSystemErrorCode()).stream()
|
||||||
.stream()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VPLOG(verbose_level) \
|
#define VPLOG(verbose_level) \
|
||||||
@@ -312,24 +314,23 @@ const LogSeverity LOG_0 = LOG_ERROR;
|
|||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define PLOG_STREAM(severity) \
|
#define PLOG_STREAM(severity) \
|
||||||
COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \
|
COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \
|
||||||
::cef::logging::GetLastSystemErrorCode()) \
|
::cef::logging::GetLastSystemErrorCode()).stream()
|
||||||
.stream()
|
|
||||||
#elif defined(OS_POSIX)
|
#elif defined(OS_POSIX)
|
||||||
#define PLOG_STREAM(severity) \
|
#define PLOG_STREAM(severity) \
|
||||||
COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \
|
COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \
|
||||||
::cef::logging::GetLastSystemErrorCode()) \
|
::cef::logging::GetLastSystemErrorCode()).stream()
|
||||||
.stream()
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
|
#define PLOG(severity) \
|
||||||
|
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
|
||||||
|
|
||||||
#define PLOG_IF(severity, condition) \
|
#define PLOG_IF(severity, condition) \
|
||||||
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
|
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
|
||||||
|
|
||||||
// The actual stream used isn't important.
|
// The actual stream used isn't important.
|
||||||
#define EAT_STREAM_PARAMETERS \
|
#define EAT_STREAM_PARAMETERS \
|
||||||
true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
|
true ? (void) 0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
|
||||||
|
|
||||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
// 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
|
// controlled by NDEBUG, so the check will be executed regardless of
|
||||||
@@ -352,15 +353,16 @@ const LogSeverity LOG_0 = LOG_ERROR;
|
|||||||
// TODO(akalin): Rewrite this so that constructs like if (...)
|
// TODO(akalin): Rewrite this so that constructs like if (...)
|
||||||
// CHECK_EQ(...) else { ... } work properly.
|
// CHECK_EQ(...) else { ... } work properly.
|
||||||
#define CHECK_OP(name, op, val1, val2) \
|
#define CHECK_OP(name, op, val1, val2) \
|
||||||
if (std::string* _result = cef::logging::Check##name##Impl( \
|
if (std::string* _result = \
|
||||||
(val1), (val2), #val1 " " #op " " #val2)) \
|
cef::logging::Check##name##Impl((val1), (val2), \
|
||||||
|
#val1 " " #op " " #val2)) \
|
||||||
cef::logging::LogMessage(__FILE__, __LINE__, _result).stream()
|
cef::logging::LogMessage(__FILE__, __LINE__, _result).stream()
|
||||||
|
|
||||||
// Build the error message string. This is separate from the "Impl"
|
// Build the error message string. This is separate from the "Impl"
|
||||||
// function template because it is not performance critical and so can
|
// function template because it is not performance critical and so can
|
||||||
// be out of line, while the "Impl" code should be inline. Caller
|
// be out of line, while the "Impl" code should be inline. Caller
|
||||||
// takes ownership of the returned string.
|
// takes ownership of the returned string.
|
||||||
template <class t1, class t2>
|
template<class t1, class t2>
|
||||||
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
|
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << names << " (" << v1 << " vs. " << v2 << ")";
|
ss << names << " (" << v1 << " vs. " << v2 << ")";
|
||||||
@@ -372,25 +374,20 @@ std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
|
|||||||
#if !defined(COMPILER_MSVC)
|
#if !defined(COMPILER_MSVC)
|
||||||
// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
|
// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
|
||||||
// in logging.cc.
|
// in logging.cc.
|
||||||
extern template std::string* MakeCheckOpString<int, int>(const int&,
|
extern template std::string* MakeCheckOpString<int, int>(
|
||||||
const int&,
|
const int&, const int&, const char* names);
|
||||||
const char* names);
|
extern template
|
||||||
extern template std::string* MakeCheckOpString<unsigned long, unsigned long>(
|
std::string* MakeCheckOpString<unsigned long, unsigned long>(
|
||||||
const unsigned long&,
|
const unsigned long&, const unsigned long&, const char* names);
|
||||||
const unsigned long&,
|
extern template
|
||||||
const char* names);
|
std::string* MakeCheckOpString<unsigned long, unsigned int>(
|
||||||
extern template std::string* MakeCheckOpString<unsigned long, unsigned int>(
|
const unsigned long&, const unsigned int&, const char* names);
|
||||||
const unsigned long&,
|
extern template
|
||||||
const unsigned int&,
|
std::string* MakeCheckOpString<unsigned int, unsigned long>(
|
||||||
const char* names);
|
const unsigned int&, const unsigned long&, const char* names);
|
||||||
extern template std::string* MakeCheckOpString<unsigned int, unsigned long>(
|
extern template
|
||||||
const unsigned int&,
|
std::string* MakeCheckOpString<std::string, std::string>(
|
||||||
const unsigned long&,
|
const std::string&, const std::string&, const char* name);
|
||||||
const char* names);
|
|
||||||
extern template std::string* MakeCheckOpString<std::string, std::string>(
|
|
||||||
const std::string&,
|
|
||||||
const std::string&,
|
|
||||||
const char* name);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Helper functions for CHECK_OP macro.
|
// Helper functions for CHECK_OP macro.
|
||||||
@@ -401,31 +398,27 @@ extern template std::string* MakeCheckOpString<std::string, std::string>(
|
|||||||
template <class t1, class t2> \
|
template <class t1, class t2> \
|
||||||
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
|
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
|
||||||
const char* names) { \
|
const char* names) { \
|
||||||
if (v1 op v2) \
|
if (v1 op v2) return NULL; \
|
||||||
return NULL; \
|
else return MakeCheckOpString(v1, v2, names); \
|
||||||
else \
|
|
||||||
return MakeCheckOpString(v1, v2, names); \
|
|
||||||
} \
|
} \
|
||||||
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
|
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
|
||||||
if (v1 op v2) \
|
if (v1 op v2) return NULL; \
|
||||||
return NULL; \
|
else return MakeCheckOpString(v1, v2, names); \
|
||||||
else \
|
|
||||||
return MakeCheckOpString(v1, v2, names); \
|
|
||||||
}
|
}
|
||||||
DEFINE_CHECK_OP_IMPL(EQ, ==)
|
DEFINE_CHECK_OP_IMPL(EQ, ==)
|
||||||
DEFINE_CHECK_OP_IMPL(NE, !=)
|
DEFINE_CHECK_OP_IMPL(NE, !=)
|
||||||
DEFINE_CHECK_OP_IMPL(LE, <=)
|
DEFINE_CHECK_OP_IMPL(LE, <=)
|
||||||
DEFINE_CHECK_OP_IMPL(LT, <)
|
DEFINE_CHECK_OP_IMPL(LT, < )
|
||||||
DEFINE_CHECK_OP_IMPL(GE, >=)
|
DEFINE_CHECK_OP_IMPL(GE, >=)
|
||||||
DEFINE_CHECK_OP_IMPL(GT, >)
|
DEFINE_CHECK_OP_IMPL(GT, > )
|
||||||
#undef DEFINE_CHECK_OP_IMPL
|
#undef DEFINE_CHECK_OP_IMPL
|
||||||
|
|
||||||
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
|
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
|
||||||
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
|
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
|
||||||
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
|
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
|
||||||
#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2)
|
#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
|
||||||
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
|
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
|
||||||
#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2)
|
#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
|
||||||
|
|
||||||
#if defined(NDEBUG)
|
#if defined(NDEBUG)
|
||||||
#define ENABLE_DLOG 0
|
#define ENABLE_DLOG 0
|
||||||
@@ -478,9 +471,11 @@ enum { DEBUG_MODE = ENABLE_DLOG };
|
|||||||
|
|
||||||
#undef ENABLE_DLOG
|
#undef ENABLE_DLOG
|
||||||
|
|
||||||
#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
|
#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 DPLOG(severity) \
|
||||||
|
LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
|
||||||
|
|
||||||
#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
|
#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
|
||||||
|
|
||||||
@@ -491,7 +486,7 @@ enum { DEBUG_MODE = ENABLE_DLOG };
|
|||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
|
|
||||||
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
||||||
COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__)
|
COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
|
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
|
||||||
const LogSeverity LOG_DCHECK = LOG_FATAL;
|
const LogSeverity LOG_DCHECK = LOG_FATAL;
|
||||||
|
|
||||||
@@ -499,7 +494,7 @@ const LogSeverity LOG_DCHECK = LOG_FATAL;
|
|||||||
|
|
||||||
// These are just dummy values.
|
// These are just dummy values.
|
||||||
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
|
||||||
COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__)
|
COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
|
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
|
||||||
const LogSeverity LOG_DCHECK = LOG_INFO;
|
const LogSeverity LOG_DCHECK = LOG_INFO;
|
||||||
|
|
||||||
@@ -524,9 +519,8 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
|
|||||||
if (DCHECK_IS_ON()) \
|
if (DCHECK_IS_ON()) \
|
||||||
if (std::string* _result = cef::logging::Check##name##Impl( \
|
if (std::string* _result = cef::logging::Check##name##Impl( \
|
||||||
(val1), (val2), #val1 " " #op " " #val2)) \
|
(val1), (val2), #val1 " " #op " " #val2)) \
|
||||||
cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \
|
cef::logging::LogMessage(__FILE__, __LINE__, \
|
||||||
_result) \
|
::cef::logging::LOG_DCHECK, _result).stream()
|
||||||
.stream()
|
|
||||||
|
|
||||||
// Equality/Inequality checks - compare two values, and log a
|
// Equality/Inequality checks - compare two values, and log a
|
||||||
// LOG_DCHECK message including the two values when the result is not
|
// LOG_DCHECK message including the two values when the result is not
|
||||||
@@ -550,11 +544,16 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
|
|||||||
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
|
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
|
||||||
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
|
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
|
||||||
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
|
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
|
||||||
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2)
|
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
|
||||||
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
||||||
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
|
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
|
||||||
|
|
||||||
|
#if defined(NDEBUG) && defined(OS_CHROMEOS)
|
||||||
|
#define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \
|
||||||
|
__FUNCTION__ << ". "
|
||||||
|
#else
|
||||||
#define NOTREACHED() DCHECK(false)
|
#define NOTREACHED() DCHECK(false)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Redefine the standard assert to use our nice log files
|
// Redefine the standard assert to use our nice log files
|
||||||
#undef assert
|
#undef assert
|
||||||
@@ -578,9 +577,7 @@ class LogMessage {
|
|||||||
LogMessage(const char* file, int line, std::string* result);
|
LogMessage(const char* file, int line, std::string* result);
|
||||||
|
|
||||||
// Used for DCHECK_EQ(), etc. Takes ownership of the given string.
|
// Used for DCHECK_EQ(), etc. Takes ownership of the given string.
|
||||||
LogMessage(const char* file,
|
LogMessage(const char* file, int line, LogSeverity severity,
|
||||||
int line,
|
|
||||||
LogSeverity severity,
|
|
||||||
std::string* result);
|
std::string* result);
|
||||||
|
|
||||||
~LogMessage();
|
~LogMessage();
|
||||||
@@ -620,7 +617,7 @@ class LogMessage {
|
|||||||
|
|
||||||
// A non-macro interface to the log facility; (useful
|
// A non-macro interface to the log facility; (useful
|
||||||
// when the logging level is not a compile-time constant).
|
// when the logging level is not a compile-time constant).
|
||||||
inline void LogAtLevel(int const log_level, std::string const& msg) {
|
inline void LogAtLevel(int const log_level, std::string const &msg) {
|
||||||
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
|
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,10 +626,10 @@ inline void LogAtLevel(int const log_level, std::string const& msg) {
|
|||||||
// is not used" and "statement has no effect".
|
// is not used" and "statement has no effect".
|
||||||
class LogMessageVoidify {
|
class LogMessageVoidify {
|
||||||
public:
|
public:
|
||||||
LogMessageVoidify() {}
|
LogMessageVoidify() { }
|
||||||
// This has to be an operator with a precedence lower than << but
|
// This has to be an operator with a precedence lower than << but
|
||||||
// higher than ?:
|
// higher than ?:
|
||||||
void operator&(std::ostream&) {}
|
void operator&(std::ostream&) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
@@ -742,13 +739,12 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
|
|||||||
#elif NOTIMPLEMENTED_POLICY == 4
|
#elif NOTIMPLEMENTED_POLICY == 4
|
||||||
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
|
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
|
||||||
#elif NOTIMPLEMENTED_POLICY == 5
|
#elif NOTIMPLEMENTED_POLICY == 5
|
||||||
#define NOTIMPLEMENTED() \
|
#define NOTIMPLEMENTED() do {\
|
||||||
do { \
|
static bool logged_once = false;\
|
||||||
static bool logged_once = false; \
|
LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
|
||||||
LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \
|
logged_once = true;\
|
||||||
logged_once = true; \
|
} while(0);\
|
||||||
} while (0); \
|
EAT_STREAM_PARAMETERS
|
||||||
EAT_STREAM_PARAMETERS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
@@ -36,43 +36,199 @@
|
|||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
|
|
||||||
|
// Chromium uses movable types.
|
||||||
|
#define MOVE_SCOPED_PTR(var) std::move(var)
|
||||||
|
|
||||||
|
// Chromium uses std types.
|
||||||
|
#define SCOPED_PTR(type) std::unique_ptr<type>
|
||||||
|
#define DEFAULT_DELETER(type) std::default_delete<type>
|
||||||
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
// ALL DISALLOW_xxx MACROS ARE DEPRECATED; DO NOT USE IN NEW CODE.
|
#include <stddef.h> // For size_t.
|
||||||
// Use explicit deletions instead. See the section on copyability/movability in
|
#include "include/base/cef_build.h" // For COMPILER_MSVC
|
||||||
// //styleguide/c++/c++-dos-and-donts.md for more information.
|
|
||||||
|
|
||||||
// DEPRECATED: See above. Makes a class uncopyable.
|
// CEF does not use movable types.
|
||||||
#define DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete
|
#define MOVE_SCOPED_PTR(var) var.Pass()
|
||||||
|
|
||||||
// DEPRECATED: See above. Makes a class unassignable.
|
// CEF uses base types.
|
||||||
#define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
|
#define SCOPED_PTR(type) scoped_ptr<type>
|
||||||
|
#define DEFAULT_DELETER(type) struct base::DefaultDeleter<type>
|
||||||
|
|
||||||
// DEPRECATED: See above. Makes a class uncopyable and unassignable.
|
#if !defined(arraysize)
|
||||||
|
|
||||||
|
// The arraysize(arr) macro returns the # of elements in an array arr.
|
||||||
|
// The expression is a compile-time constant, and therefore can be
|
||||||
|
// used in defining new arrays, for example. If you use arraysize on
|
||||||
|
// a pointer by mistake, you will get a compile-time error.
|
||||||
|
//
|
||||||
|
// One caveat is that arraysize() doesn't accept any array of an
|
||||||
|
// anonymous type or a type defined inside a function. In these rare
|
||||||
|
// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is
|
||||||
|
// due to a limitation in C++'s template system. The limitation might
|
||||||
|
// eventually be removed, but it hasn't happened yet.
|
||||||
|
|
||||||
|
// This template function declaration is used in defining arraysize.
|
||||||
|
// Note that the function doesn't need an implementation, as we only
|
||||||
|
// use its type.
|
||||||
|
template <typename T, size_t N>
|
||||||
|
char (&ArraySizeHelper(T (&array)[N]))[N];
|
||||||
|
|
||||||
|
// That gcc wants both of these prototypes seems mysterious. VC, for
|
||||||
|
// its part, can't decide which to use (another mystery). Matching of
|
||||||
|
// template overloads: the final frontier.
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
template <typename T, size_t N>
|
||||||
|
char (&ArraySizeHelper(const T (&array)[N]))[N];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
||||||
|
|
||||||
|
#endif // !arraysize
|
||||||
|
|
||||||
|
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
||||||
|
|
||||||
|
// A macro to disallow the copy constructor and operator= functions
|
||||||
|
// This should be used in the private: declarations for a class
|
||||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
DISALLOW_COPY(TypeName); \
|
TypeName(const TypeName&); \
|
||||||
DISALLOW_ASSIGN(TypeName)
|
void operator=(const TypeName&)
|
||||||
|
|
||||||
// DEPRECATED: See above. Disallow all implicit constructors, namely the
|
#endif // !DISALLOW_COPY_AND_ASSIGN
|
||||||
|
|
||||||
|
#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
|
||||||
|
|
||||||
|
// A macro to disallow all the implicit constructors, namely the
|
||||||
// default constructor, copy constructor and operator= functions.
|
// default constructor, copy constructor and operator= functions.
|
||||||
|
//
|
||||||
|
// This should be used in the private: declarations for a class
|
||||||
|
// that wants to prevent anyone from instantiating it. This is
|
||||||
|
// especially useful for classes containing only static methods.
|
||||||
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
||||||
TypeName() = delete; \
|
TypeName(); \
|
||||||
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
||||||
|
|
||||||
// Used to explicitly mark the return value of a function as unused. If you are
|
#endif // !DISALLOW_IMPLICIT_CONSTRUCTORS
|
||||||
// really sure you don't want to do anything with the return value of a function
|
|
||||||
// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
|
#if !defined(COMPILE_ASSERT)
|
||||||
|
|
||||||
|
// The COMPILE_ASSERT macro can be used to verify that a compile time
|
||||||
|
// expression is true. For example, you could use it to verify the
|
||||||
|
// size of a static array:
|
||||||
//
|
//
|
||||||
// std::unique_ptr<MyType> my_var = ...;
|
// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
|
||||||
// if (TakeOwnership(my_var.get()) == SUCCESS)
|
// content_type_names_incorrect_size);
|
||||||
// ignore_result(my_var.release());
|
|
||||||
//
|
//
|
||||||
template <typename T>
|
// or to make sure a struct is smaller than a certain size:
|
||||||
inline void ignore_result(const T&) {}
|
//
|
||||||
|
// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
|
||||||
|
//
|
||||||
|
// The second argument to the macro is the name of the variable. If
|
||||||
|
// the expression is false, most compilers will issue a warning/error
|
||||||
|
// containing the name of the variable.
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
|
||||||
|
// Under C++11, just use static_assert.
|
||||||
|
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace cef {
|
||||||
|
|
||||||
|
template <bool>
|
||||||
|
struct CompileAssert {
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cef
|
||||||
|
|
||||||
|
#define COMPILE_ASSERT(expr, msg) \
|
||||||
|
typedef cef::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] \
|
||||||
|
ALLOW_UNUSED_TYPE
|
||||||
|
|
||||||
|
// Implementation details of COMPILE_ASSERT:
|
||||||
|
//
|
||||||
|
// - COMPILE_ASSERT works by defining an array type that has -1
|
||||||
|
// elements (and thus is invalid) when the expression is false.
|
||||||
|
//
|
||||||
|
// - The simpler definition
|
||||||
|
//
|
||||||
|
// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
|
||||||
|
//
|
||||||
|
// does not work, as gcc supports variable-length arrays whose sizes
|
||||||
|
// are determined at run-time (this is gcc's extension and not part
|
||||||
|
// of the C++ standard). As a result, gcc fails to reject the
|
||||||
|
// following code with the simple definition:
|
||||||
|
//
|
||||||
|
// int foo;
|
||||||
|
// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
|
||||||
|
// // not a compile-time constant.
|
||||||
|
//
|
||||||
|
// - By using the type CompileAssert<(bool(expr))>, we ensures that
|
||||||
|
// expr is a compile-time constant. (Template arguments must be
|
||||||
|
// determined at compile-time.)
|
||||||
|
//
|
||||||
|
// - The outer parentheses in CompileAssert<(bool(expr))> are necessary
|
||||||
|
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
|
||||||
|
//
|
||||||
|
// CompileAssert<bool(expr)>
|
||||||
|
//
|
||||||
|
// instead, these compilers will refuse to compile
|
||||||
|
//
|
||||||
|
// COMPILE_ASSERT(5 > 0, some_message);
|
||||||
|
//
|
||||||
|
// (They seem to think the ">" in "5 > 0" marks the end of the
|
||||||
|
// template argument list.)
|
||||||
|
//
|
||||||
|
// - The array size is (bool(expr) ? 1 : -1), instead of simply
|
||||||
|
//
|
||||||
|
// ((expr) ? 1 : -1).
|
||||||
|
//
|
||||||
|
// This is to avoid running into a bug in MS VC 7.1, which
|
||||||
|
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
|
||||||
|
|
||||||
|
#endif // !(__cplusplus >= 201103L)
|
||||||
|
|
||||||
|
#endif // !defined(COMPILE_ASSERT)
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#if !defined(ALLOW_THIS_IN_INITIALIZER_LIST)
|
||||||
|
#if defined(COMPILER_MSVC)
|
||||||
|
|
||||||
|
// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
|
||||||
|
// The warning remains disabled until popped by MSVC_POP_WARNING.
|
||||||
|
#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
|
||||||
|
__pragma(warning(disable:n))
|
||||||
|
|
||||||
|
// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level
|
||||||
|
// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all
|
||||||
|
// warnings.
|
||||||
|
#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n))
|
||||||
|
|
||||||
|
// Pop effects of innermost MSVC_PUSH_* macro.
|
||||||
|
#define MSVC_POP_WARNING() __pragma(warning(pop))
|
||||||
|
|
||||||
|
// Allows |this| to be passed as an argument in constructor initializer lists.
|
||||||
|
// This uses push/pop instead of the seemingly simpler suppress feature to avoid
|
||||||
|
// having the warning be disabled for more than just |code|.
|
||||||
|
//
|
||||||
|
// Example usage:
|
||||||
|
// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {}
|
||||||
|
//
|
||||||
|
// Compiler warning C4355: 'this': used in base member initializer list:
|
||||||
|
// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx
|
||||||
|
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \
|
||||||
|
code \
|
||||||
|
MSVC_POP_WARNING()
|
||||||
|
#else // !COMPILER_MSVC
|
||||||
|
|
||||||
|
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code
|
||||||
|
|
||||||
|
#endif // !COMPILER_MSVC
|
||||||
|
#endif // !ALLOW_THIS_IN_INITIALIZER_LIST
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_
|
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||||
|
|||||||
259
include/base/cef_move.h
Normal file
259
include/base/cef_move.h
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
// 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_MOVE_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_MOVE_H_
|
||||||
|
|
||||||
|
#if defined(MOVE_ONLY_TYPE_FOR_CPP_03)
|
||||||
|
// Do nothing if the macro in this header has already been defined.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/move.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.
|
||||||
|
|
||||||
|
// Macro with the boilerplate that makes a type move-only in C++03.
|
||||||
|
//
|
||||||
|
// USAGE
|
||||||
|
//
|
||||||
|
// This macro should be used instead of DISALLOW_COPY_AND_ASSIGN to create
|
||||||
|
// a "move-only" type. Unlike DISALLOW_COPY_AND_ASSIGN, this macro should be
|
||||||
|
// the first line in a class declaration.
|
||||||
|
//
|
||||||
|
// A class using this macro must call .Pass() (or somehow be an r-value already)
|
||||||
|
// before it can be:
|
||||||
|
//
|
||||||
|
// * Passed as a function argument
|
||||||
|
// * Used as the right-hand side of an assignment
|
||||||
|
// * Returned from a function
|
||||||
|
//
|
||||||
|
// Each class will still need to define their own "move constructor" and "move
|
||||||
|
// operator=" to make this useful. Here's an example of the macro, the move
|
||||||
|
// constructor, and the move operator= from the scoped_ptr class:
|
||||||
|
//
|
||||||
|
// template <typename T>
|
||||||
|
// class scoped_ptr {
|
||||||
|
// MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
||||||
|
// public:
|
||||||
|
// scoped_ptr(RValue& other) : ptr_(other.release()) { }
|
||||||
|
// scoped_ptr& operator=(RValue& other) {
|
||||||
|
// swap(other);
|
||||||
|
// return *this;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// Note that the constructor must NOT be marked explicit.
|
||||||
|
//
|
||||||
|
// For consistency, the second parameter to the macro should always be RValue
|
||||||
|
// unless you have a strong reason to do otherwise. It is only exposed as a
|
||||||
|
// macro parameter so that the move constructor and move operator= don't look
|
||||||
|
// like they're using a phantom type.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// HOW THIS WORKS
|
||||||
|
//
|
||||||
|
// For a thorough explanation of this technique, see:
|
||||||
|
//
|
||||||
|
// http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Move_Constructor
|
||||||
|
//
|
||||||
|
// The summary is that we take advantage of 2 properties:
|
||||||
|
//
|
||||||
|
// 1) non-const references will not bind to r-values.
|
||||||
|
// 2) C++ can apply one user-defined conversion when initializing a
|
||||||
|
// variable.
|
||||||
|
//
|
||||||
|
// The first lets us disable the copy constructor and assignment operator
|
||||||
|
// by declaring private version of them with a non-const reference parameter.
|
||||||
|
//
|
||||||
|
// For l-values, direct initialization still fails like in
|
||||||
|
// DISALLOW_COPY_AND_ASSIGN because the copy constructor and assignment
|
||||||
|
// operators are private.
|
||||||
|
//
|
||||||
|
// For r-values, the situation is different. The copy constructor and
|
||||||
|
// assignment operator are not viable due to (1), so we are trying to call
|
||||||
|
// a non-existent constructor and non-existing operator= rather than a private
|
||||||
|
// one. Since we have not committed an error quite yet, we can provide an
|
||||||
|
// alternate conversion sequence and a constructor. We add
|
||||||
|
//
|
||||||
|
// * a private struct named "RValue"
|
||||||
|
// * a user-defined conversion "operator RValue()"
|
||||||
|
// * a "move constructor" and "move operator=" that take the RValue& as
|
||||||
|
// their sole parameter.
|
||||||
|
//
|
||||||
|
// Only r-values will trigger this sequence and execute our "move constructor"
|
||||||
|
// or "move operator=." L-values will match the private copy constructor and
|
||||||
|
// operator= first giving a "private in this context" error. This combination
|
||||||
|
// gives us a move-only type.
|
||||||
|
//
|
||||||
|
// For signaling a destructive transfer of data from an l-value, we provide a
|
||||||
|
// method named Pass() which creates an r-value for the current instance
|
||||||
|
// triggering the move constructor or move operator=.
|
||||||
|
//
|
||||||
|
// Other ways to get r-values is to use the result of an expression like a
|
||||||
|
// function call.
|
||||||
|
//
|
||||||
|
// Here's an example with comments explaining what gets triggered where:
|
||||||
|
//
|
||||||
|
// class Foo {
|
||||||
|
// MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue);
|
||||||
|
//
|
||||||
|
// public:
|
||||||
|
// ... API ...
|
||||||
|
// Foo(RValue other); // Move constructor.
|
||||||
|
// Foo& operator=(RValue rhs); // Move operator=
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// Foo MakeFoo(); // Function that returns a Foo.
|
||||||
|
//
|
||||||
|
// Foo f;
|
||||||
|
// Foo f_copy(f); // ERROR: Foo(Foo&) is private in this context.
|
||||||
|
// Foo f_assign;
|
||||||
|
// f_assign = f; // ERROR: operator=(Foo&) is private in this context.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Foo f(MakeFoo()); // R-value so alternate conversion executed.
|
||||||
|
// Foo f_copy(f.Pass()); // R-value so alternate conversion executed.
|
||||||
|
// f = f_copy.Pass(); // R-value so alternate conversion executed.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// IMPLEMENTATION SUBTLETIES WITH RValue
|
||||||
|
//
|
||||||
|
// The RValue struct is just a container for a pointer back to the original
|
||||||
|
// object. It should only ever be created as a temporary, and no external
|
||||||
|
// class should ever declare it or use it in a parameter.
|
||||||
|
//
|
||||||
|
// It is tempting to want to use the RValue type in function parameters, but
|
||||||
|
// excluding the limited usage here for the move constructor and move
|
||||||
|
// operator=, doing so would mean that the function could take both r-values
|
||||||
|
// and l-values equially which is unexpected. See COMPARED To Boost.Move for
|
||||||
|
// more details.
|
||||||
|
//
|
||||||
|
// An alternate, and incorrect, implementation of the RValue class used by
|
||||||
|
// Boost.Move makes RValue a fieldless child of the move-only type. RValue&
|
||||||
|
// is then used in place of RValue in the various operators. The RValue& is
|
||||||
|
// "created" by doing *reinterpret_cast<RValue*>(this). This has the appeal
|
||||||
|
// of never creating a temporary RValue struct even with optimizations
|
||||||
|
// disabled. Also, by virtue of inheritance you can treat the RValue
|
||||||
|
// reference as if it were the move-only type itself. Unfortunately,
|
||||||
|
// using the result of this reinterpret_cast<> is actually undefined behavior
|
||||||
|
// due to C++98 5.2.10.7. In certain compilers (e.g., NaCl) the optimizer
|
||||||
|
// will generate non-working code.
|
||||||
|
//
|
||||||
|
// In optimized builds, both implementations generate the same assembly so we
|
||||||
|
// choose the one that adheres to the standard.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// WHY HAVE typedef void MoveOnlyTypeForCPP03
|
||||||
|
//
|
||||||
|
// Callback<>/Bind() needs to understand movable-but-not-copyable semantics
|
||||||
|
// to call .Pass() appropriately when it is expected to transfer the value.
|
||||||
|
// The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check
|
||||||
|
// easy and automatic in helper templates for Callback<>/Bind().
|
||||||
|
// See IsMoveOnlyType template and its usage in base/callback_internal.h
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// COMPARED TO C++11
|
||||||
|
//
|
||||||
|
// In C++11, you would implement this functionality using an r-value reference
|
||||||
|
// and our .Pass() method would be replaced with a call to std::move().
|
||||||
|
//
|
||||||
|
// This emulation also has a deficiency where it uses up the single
|
||||||
|
// user-defined conversion allowed by C++ during initialization. This can
|
||||||
|
// cause problems in some API edge cases. For instance, in scoped_ptr, it is
|
||||||
|
// impossible to make a function "void Foo(scoped_ptr<Parent> p)" accept a
|
||||||
|
// value of type scoped_ptr<Child> even if you add a constructor to
|
||||||
|
// scoped_ptr<> that would make it look like it should work. C++11 does not
|
||||||
|
// have this deficiency.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// COMPARED TO Boost.Move
|
||||||
|
//
|
||||||
|
// Our implementation similar to Boost.Move, but we keep the RValue struct
|
||||||
|
// private to the move-only type, and we don't use the reinterpret_cast<> hack.
|
||||||
|
//
|
||||||
|
// In Boost.Move, RValue is the boost::rv<> template. This type can be used
|
||||||
|
// when writing APIs like:
|
||||||
|
//
|
||||||
|
// void MyFunc(boost::rv<Foo>& f)
|
||||||
|
//
|
||||||
|
// that can take advantage of rv<> to avoid extra copies of a type. However you
|
||||||
|
// would still be able to call this version of MyFunc with an l-value:
|
||||||
|
//
|
||||||
|
// Foo f;
|
||||||
|
// MyFunc(f); // Uh oh, we probably just destroyed |f| w/o calling Pass().
|
||||||
|
//
|
||||||
|
// unless someone is very careful to also declare a parallel override like:
|
||||||
|
//
|
||||||
|
// void MyFunc(const Foo& f)
|
||||||
|
//
|
||||||
|
// that would catch the l-values first. This was declared unsafe in C++11 and
|
||||||
|
// a C++11 compiler will explicitly fail MyFunc(f). Unfortunately, we cannot
|
||||||
|
// ensure this in C++03.
|
||||||
|
//
|
||||||
|
// Since we have no need for writing such APIs yet, our implementation keeps
|
||||||
|
// RValue private and uses a .Pass() method to do the conversion instead of
|
||||||
|
// trying to write a version of "std::move()." Writing an API like std::move()
|
||||||
|
// would require the RValue struct to be public.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// CAVEATS
|
||||||
|
//
|
||||||
|
// If you include a move-only type as a field inside a class that does not
|
||||||
|
// explicitly declare a copy constructor, the containing class's implicit
|
||||||
|
// copy constructor will change from Containing(const Containing&) to
|
||||||
|
// Containing(Containing&). This can cause some unexpected errors.
|
||||||
|
//
|
||||||
|
// http://llvm.org/bugs/show_bug.cgi?id=11528
|
||||||
|
//
|
||||||
|
// The workaround is to explicitly declare your copy constructor.
|
||||||
|
//
|
||||||
|
#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
|
||||||
|
private: \
|
||||||
|
struct rvalue_type { \
|
||||||
|
explicit rvalue_type(type* object) : object(object) {} \
|
||||||
|
type* object; \
|
||||||
|
}; \
|
||||||
|
type(type&); \
|
||||||
|
void operator=(type&); \
|
||||||
|
public: \
|
||||||
|
operator rvalue_type() { return rvalue_type(this); } \
|
||||||
|
type Pass() { return type(rvalue_type(this)); } \
|
||||||
|
typedef void MoveOnlyTypeForCPP03; \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_MOVE_H_
|
||||||
@@ -35,7 +35,12 @@
|
|||||||
#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||||
#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_THREADING_PLATFORM_THREAD_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/threading/platform_thread.h"
|
#include "base/threading/platform_thread.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -64,14 +69,21 @@ class PlatformThreadRef {
|
|||||||
public:
|
public:
|
||||||
typedef cef_platform_thread_handle_t RefType;
|
typedef cef_platform_thread_handle_t RefType;
|
||||||
|
|
||||||
PlatformThreadRef() : id_(0) {}
|
PlatformThreadRef()
|
||||||
|
: id_(0) {
|
||||||
|
}
|
||||||
|
|
||||||
explicit PlatformThreadRef(RefType id) : id_(id) {}
|
explicit PlatformThreadRef(RefType id)
|
||||||
|
: id_(id) {
|
||||||
|
}
|
||||||
|
|
||||||
bool operator==(PlatformThreadRef other) const { return id_ == other.id_; }
|
bool operator==(PlatformThreadRef other) const {
|
||||||
|
return id_ == other.id_;
|
||||||
bool is_null() const { return id_ == 0; }
|
}
|
||||||
|
|
||||||
|
bool is_null() const {
|
||||||
|
return id_ == 0;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
RefType id_;
|
RefType id_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
// 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_
|
|
||||||
@@ -33,7 +33,12 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_MEMORY_REF_COUNTED_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -41,133 +46,73 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <cassert>
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "include/base/cef_atomic_ref_count.h"
|
#include "include/base/cef_atomic_ref_count.h"
|
||||||
#include "include/base/cef_build.h"
|
#include "include/base/cef_build.h"
|
||||||
#include "include/base/cef_compiler_specific.h"
|
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_macros.h"
|
#include "include/base/cef_thread_collision_warner.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 base {
|
||||||
|
|
||||||
namespace cef_subtle {
|
namespace cef_subtle {
|
||||||
|
|
||||||
class RefCountedBase {
|
class RefCountedBase {
|
||||||
public:
|
public:
|
||||||
bool HasOneRef() const { return ref_count_ == 1; }
|
bool HasOneRef() const { return ref_count_ == 1; }
|
||||||
bool HasAtLeastOneRef() const { return ref_count_ >= 1; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit RefCountedBase(StartRefCountFromZeroTag) {
|
RefCountedBase()
|
||||||
#if DCHECK_IS_ON()
|
: ref_count_(0)
|
||||||
thread_checker_.DetachFromThread();
|
#if DCHECK_IS_ON()
|
||||||
#endif
|
, in_dtor_(false)
|
||||||
}
|
#endif
|
||||||
|
{
|
||||||
explicit RefCountedBase(StartRefCountFromOneTag) : ref_count_(1) {
|
|
||||||
#if DCHECK_IS_ON()
|
|
||||||
needs_adopt_ref_ = true;
|
|
||||||
thread_checker_.DetachFromThread();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~RefCountedBase() {
|
~RefCountedBase() {
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AddRef() const {
|
void AddRef() const {
|
||||||
#if DCHECK_IS_ON()
|
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
|
||||||
|
// Current thread books the critical section "AddRelease"
|
||||||
|
// without release it.
|
||||||
|
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(!in_dtor_);
|
DCHECK(!in_dtor_);
|
||||||
DCHECK(!needs_adopt_ref_)
|
#endif
|
||||||
<< "This RefCounted object is created with non-zero reference count."
|
++ref_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.
|
// Returns true if the object should self-delete.
|
||||||
bool Release() const {
|
bool Release() const {
|
||||||
ReleaseImpl();
|
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
|
||||||
|
// Current thread books the critical section "AddRelease"
|
||||||
#if DCHECK_IS_ON()
|
// without release it.
|
||||||
|
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(!in_dtor_);
|
DCHECK(!in_dtor_);
|
||||||
if (ref_count_ == 0)
|
#endif
|
||||||
|
if (--ref_count_ == 0) {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
in_dtor_ = true;
|
in_dtor_ = true;
|
||||||
|
#endif
|
||||||
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;
|
return true;
|
||||||
#endif
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename U>
|
mutable int ref_count_;
|
||||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
|
||||||
|
|
||||||
void Adopted() const {
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(needs_adopt_ref_);
|
mutable bool in_dtor_;
|
||||||
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
|
#endif
|
||||||
|
|
||||||
#if DCHECK_IS_ON()
|
DFAKE_MUTEX(add_release_);
|
||||||
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
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
|
||||||
};
|
};
|
||||||
@@ -175,123 +120,30 @@ class RefCountedBase {
|
|||||||
class RefCountedThreadSafeBase {
|
class RefCountedThreadSafeBase {
|
||||||
public:
|
public:
|
||||||
bool HasOneRef() const;
|
bool HasOneRef() const;
|
||||||
bool HasAtLeastOneRef() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromZeroTag) {}
|
RefCountedThreadSafeBase();
|
||||||
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromOneTag)
|
|
||||||
: ref_count_(1) {
|
|
||||||
#if DCHECK_IS_ON()
|
|
||||||
needs_adopt_ref_ = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DCHECK_IS_ON()
|
|
||||||
~RefCountedThreadSafeBase();
|
~RefCountedThreadSafeBase();
|
||||||
#else
|
|
||||||
~RefCountedThreadSafeBase() = default;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Release and AddRef are suitable for inlining on X86 because they generate
|
void AddRef() const;
|
||||||
// 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.
|
// Returns true if the object should self-delete.
|
||||||
bool Release() const;
|
bool Release() const;
|
||||||
void AddRef() const;
|
|
||||||
void AddRefWithCheck() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename U>
|
mutable AtomicRefCount ref_count_;
|
||||||
friend scoped_refptr<U> base::AdoptRef(U*);
|
|
||||||
|
|
||||||
void Adopted() const {
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(needs_adopt_ref_);
|
mutable bool in_dtor_;
|
||||||
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
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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
|
} // namespace cef_subtle
|
||||||
|
|
||||||
using ScopedAllowCrossThreadRefCountAccess =
|
|
||||||
cef_subtle::ScopedAllowCrossThreadRefCountAccess;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// A base class for reference counted classes. Otherwise, known as a cheap
|
// 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
|
// knock-off of WebKit's RefCounted<T> class. To use this guy just extend your
|
||||||
// class from it like so:
|
// class from it like so:
|
||||||
//
|
//
|
||||||
// class MyFoo : public base::RefCounted<MyFoo> {
|
// class MyFoo : public base::RefCounted<MyFoo> {
|
||||||
@@ -301,102 +153,43 @@ using ScopedAllowCrossThreadRefCountAccess =
|
|||||||
// ~MyFoo();
|
// ~MyFoo();
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// Usage Notes:
|
// You should always make your destructor private, to avoid any code deleting
|
||||||
// 1. You should always make your destructor non-public, to avoid any code
|
// the object accidently while there are references to it.
|
||||||
// deleting the object accidentally while there are references to it.
|
template <class T>
|
||||||
// 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 {
|
class RefCounted : public cef_subtle::RefCountedBase {
|
||||||
public:
|
public:
|
||||||
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
RefCounted() {}
|
||||||
cef_subtle::kStartRefCountFromZeroTag;
|
|
||||||
|
|
||||||
RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {}
|
void AddRef() const {
|
||||||
|
cef_subtle::RefCountedBase::AddRef();
|
||||||
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
|
}
|
||||||
|
|
||||||
void Release() const {
|
void Release() const {
|
||||||
if (cef_subtle::RefCountedBase::Release()) {
|
if (cef_subtle::RefCountedBase::Release()) {
|
||||||
// Prune the code paths which the static analyzer may take to simulate
|
delete static_cast<const T*>(this);
|
||||||
// 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:
|
protected:
|
||||||
~RefCounted() = default;
|
~RefCounted() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct DefaultRefCountedTraits<T>;
|
DISALLOW_COPY_AND_ASSIGN(RefCounted<T>);
|
||||||
template <typename U>
|
|
||||||
static void DeleteInternal(const U* x) {
|
|
||||||
delete x;
|
|
||||||
}
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCounted);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Forward declaration.
|
// Forward declaration.
|
||||||
template <class T, typename Traits>
|
template <class T, typename Traits> class RefCountedThreadSafe;
|
||||||
class RefCountedThreadSafe;
|
|
||||||
|
|
||||||
// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
|
// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
|
||||||
// count reaches 0. Overload to delete it on a different thread etc.
|
// count reaches 0. Overload to delete it on a different thread etc.
|
||||||
template <typename T>
|
template<typename T>
|
||||||
struct DefaultRefCountedThreadSafeTraits {
|
struct DefaultRefCountedThreadSafeTraits {
|
||||||
static void Destruct(const T* x) {
|
static void Destruct(const T* x) {
|
||||||
// Delete through RefCountedThreadSafe to make child classes only need to be
|
// Delete through RefCountedThreadSafe to make child classes only need to be
|
||||||
// friend with RefCountedThreadSafe instead of this struct, which is an
|
// friend with RefCountedThreadSafe instead of this struct, which is an
|
||||||
// implementation detail.
|
// implementation detail.
|
||||||
RefCountedThreadSafe<T, DefaultRefCountedThreadSafeTraits>::DeleteInternal(
|
RefCountedThreadSafe<T,
|
||||||
x);
|
DefaultRefCountedThreadSafeTraits>::DeleteInternal(x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,44 +205,27 @@ struct DefaultRefCountedThreadSafeTraits {
|
|||||||
// private:
|
// private:
|
||||||
// friend class base::RefCountedThreadSafe<MyFoo>;
|
// friend class base::RefCountedThreadSafe<MyFoo>;
|
||||||
// ~MyFoo();
|
// ~MyFoo();
|
||||||
//
|
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> >
|
||||||
// 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 {
|
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
||||||
public:
|
public:
|
||||||
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
RefCountedThreadSafe() {}
|
||||||
cef_subtle::kStartRefCountFromZeroTag;
|
|
||||||
|
|
||||||
explicit RefCountedThreadSafe()
|
void AddRef() const {
|
||||||
: cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
|
cef_subtle::RefCountedThreadSafeBase::AddRef();
|
||||||
|
}
|
||||||
void AddRef() const { AddRefImpl(T::kRefCountPreference); }
|
|
||||||
|
|
||||||
void Release() const {
|
void Release() const {
|
||||||
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
||||||
ANALYZER_SKIP_THIS_PATH();
|
|
||||||
Traits::Destruct(static_cast<const T*>(this));
|
Traits::Destruct(static_cast<const T*>(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~RefCountedThreadSafe() = default;
|
~RefCountedThreadSafe() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct DefaultRefCountedThreadSafeTraits<T>;
|
friend struct DefaultRefCountedThreadSafeTraits<T>;
|
||||||
template <typename U>
|
static void DeleteInternal(const T* x) { delete x; }
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
|
||||||
};
|
};
|
||||||
@@ -458,36 +234,151 @@ class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
|||||||
// A thread-safe wrapper for some piece of data so we can place other
|
// A thread-safe wrapper for some piece of data so we can place other
|
||||||
// things in scoped_refptrs<>.
|
// things in scoped_refptrs<>.
|
||||||
//
|
//
|
||||||
template <typename T>
|
template<typename T>
|
||||||
class RefCountedData
|
class RefCountedData
|
||||||
: public base::RefCountedThreadSafe<base::RefCountedData<T>> {
|
: public base::RefCountedThreadSafe< base::RefCountedData<T> > {
|
||||||
public:
|
public:
|
||||||
RefCountedData() : data() {}
|
RefCountedData() : data() {}
|
||||||
RefCountedData(const T& in_value) : data(in_value) {}
|
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;
|
T data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
|
friend class base::RefCountedThreadSafe<base::RefCountedData<T> >;
|
||||||
~RefCountedData() = default;
|
~RefCountedData() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
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
|
} // 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> {
|
||||||
|
// ...
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void some_function() {
|
||||||
|
// scoped_refptr<MyFoo> foo = new MyFoo();
|
||||||
|
// foo->Method(param);
|
||||||
|
// // |foo| is released when this function returns
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void some_other_function() {
|
||||||
|
// scoped_refptr<MyFoo> foo = new MyFoo();
|
||||||
|
// ...
|
||||||
|
// foo = NULL; // 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 = new MyFoo();
|
||||||
|
// scoped_refptr<MyFoo> b;
|
||||||
|
//
|
||||||
|
// b.swap(a);
|
||||||
|
// // now, |b| references the MyFoo object, and |a| references NULL.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// To make both |a| and |b| in the above example reference the same MyFoo
|
||||||
|
// object, simply use the assignment operator:
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// scoped_refptr<MyFoo> a = new MyFoo();
|
||||||
|
// scoped_refptr<MyFoo> b;
|
||||||
|
//
|
||||||
|
// b = a;
|
||||||
|
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
template <class T>
|
||||||
|
class scoped_refptr {
|
||||||
|
public:
|
||||||
|
typedef T element_type;
|
||||||
|
|
||||||
|
scoped_refptr() : ptr_(NULL) {
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr(T* p) : ptr_(p) {
|
||||||
|
if (ptr_)
|
||||||
|
ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr(const scoped_refptr<T>& r) : ptr_(r.ptr_) {
|
||||||
|
if (ptr_)
|
||||||
|
ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
scoped_refptr(const scoped_refptr<U>& r) : ptr_(r.get()) {
|
||||||
|
if (ptr_)
|
||||||
|
ptr_->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
~scoped_refptr() {
|
||||||
|
if (ptr_)
|
||||||
|
ptr_->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
T* get() const { return ptr_; }
|
||||||
|
|
||||||
|
// Allow scoped_refptr<C> to be used in boolean expression
|
||||||
|
// and comparison operations.
|
||||||
|
operator T*() const { return ptr_; }
|
||||||
|
|
||||||
|
T* operator->() const {
|
||||||
|
assert(ptr_ != NULL);
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr<T>& operator=(T* p) {
|
||||||
|
// AddRef first so that self assignment should work
|
||||||
|
if (p)
|
||||||
|
p->AddRef();
|
||||||
|
T* old_ptr = ptr_;
|
||||||
|
ptr_ = p;
|
||||||
|
if (old_ptr)
|
||||||
|
old_ptr->Release();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr<T>& operator=(const scoped_refptr<T>& r) {
|
||||||
|
return *this = r.ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
scoped_refptr<T>& operator=(const scoped_refptr<U>& r) {
|
||||||
|
return *this = r.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(T** pp) {
|
||||||
|
T* p = ptr_;
|
||||||
|
ptr_ = *pp;
|
||||||
|
*pp = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(scoped_refptr<T>& r) {
|
||||||
|
swap(&r.ptr_);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T* ptr_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handy utility for creating a scoped_refptr<T> out of a T* explicitly without
|
||||||
|
// having to retype all the template arguments
|
||||||
|
template <typename T>
|
||||||
|
scoped_refptr<T> make_scoped_refptr(T* t) {
|
||||||
|
return scoped_refptr<T>(t);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||||
|
|||||||
623
include/base/cef_scoped_ptr.h
Normal file
623
include/base/cef_scoped_ptr.h
Normal file
@@ -0,0 +1,623 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// Scopers help you manage ownership of a pointer, helping you easily manage a
|
||||||
|
// pointer within a scope, and automatically destroying the pointer at the end
|
||||||
|
// of a scope. There are two main classes you will use, which correspond to the
|
||||||
|
// operators new/delete and new[]/delete[].
|
||||||
|
//
|
||||||
|
// Example usage (scoped_ptr<T>):
|
||||||
|
// {
|
||||||
|
// scoped_ptr<Foo> foo(new Foo("wee"));
|
||||||
|
// } // foo goes out of scope, releasing the pointer with it.
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// scoped_ptr<Foo> foo; // No pointer managed.
|
||||||
|
// foo.reset(new Foo("wee")); // Now a pointer is managed.
|
||||||
|
// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed.
|
||||||
|
// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed.
|
||||||
|
// foo->Method(); // Foo::Method() called.
|
||||||
|
// foo.get()->Method(); // Foo::Method() called.
|
||||||
|
// SomeFunc(foo.release()); // SomeFunc takes ownership, foo no longer
|
||||||
|
// // manages a pointer.
|
||||||
|
// foo.reset(new Foo("wee4")); // foo manages a pointer again.
|
||||||
|
// foo.reset(); // Foo("wee4") destroyed, foo no longer
|
||||||
|
// // manages a pointer.
|
||||||
|
// } // foo wasn't managing a pointer, so nothing was destroyed.
|
||||||
|
//
|
||||||
|
// Example usage (scoped_ptr<T[]>):
|
||||||
|
// {
|
||||||
|
// scoped_ptr<Foo[]> foo(new Foo[100]);
|
||||||
|
// foo.get()->Method(); // Foo::Method on the 0th element.
|
||||||
|
// foo[10].Method(); // Foo::Method on the 10th element.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// These scopers also implement part of the functionality of C++11 unique_ptr
|
||||||
|
// in that they are "movable but not copyable." You can use the scopers in
|
||||||
|
// the parameter and return types of functions to signify ownership transfer
|
||||||
|
// in to and out of a function. When calling a function that has a scoper
|
||||||
|
// as the argument type, it must be called with the result of an analogous
|
||||||
|
// scoper's Pass() function or another function that generates a temporary;
|
||||||
|
// passing by copy will NOT work. Here is an example using scoped_ptr:
|
||||||
|
//
|
||||||
|
// void TakesOwnership(scoped_ptr<Foo> arg) {
|
||||||
|
// // Do something with arg
|
||||||
|
// }
|
||||||
|
// scoped_ptr<Foo> CreateFoo() {
|
||||||
|
// // No need for calling Pass() because we are constructing a temporary
|
||||||
|
// // for the return value.
|
||||||
|
// return scoped_ptr<Foo>(new Foo("new"));
|
||||||
|
// }
|
||||||
|
// scoped_ptr<Foo> PassThru(scoped_ptr<Foo> arg) {
|
||||||
|
// return arg.Pass();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
|
||||||
|
// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay").
|
||||||
|
// scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
|
||||||
|
// scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
|
||||||
|
// PassThru(ptr2.Pass()); // ptr2 is correspondingly NULL.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Notice that if you do not call Pass() when returning from PassThru(), or
|
||||||
|
// when invoking TakesOwnership(), the code will not compile because scopers
|
||||||
|
// are not copyable; they only implement move semantics which require calling
|
||||||
|
// the Pass() function to signify a destructive transfer of state. CreateFoo()
|
||||||
|
// is different though because we are constructing a temporary on the return
|
||||||
|
// line and thus can avoid needing to call Pass().
|
||||||
|
//
|
||||||
|
// Pass() properly handles upcast in initialization, i.e. you can use a
|
||||||
|
// scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
|
||||||
|
//
|
||||||
|
// scoped_ptr<Foo> foo(new Foo());
|
||||||
|
// scoped_ptr<FooParent> parent(foo.Pass());
|
||||||
|
//
|
||||||
|
// PassAs<>() should be used to upcast return value in return statement:
|
||||||
|
//
|
||||||
|
// scoped_ptr<Foo> CreateFoo() {
|
||||||
|
// scoped_ptr<FooChild> result(new FooChild());
|
||||||
|
// return result.PassAs<Foo>();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Note that PassAs<>() is implemented only for scoped_ptr<T>, but not for
|
||||||
|
// scoped_ptr<T[]>. This is because casting array pointers may not be safe.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(BASE_MEMORY_SCOPED_PTR_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// Do nothing when building CEF.
|
||||||
|
#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.
|
||||||
|
|
||||||
|
// This is an implementation designed to match the anticipated future TR2
|
||||||
|
// implementation of the scoped_ptr class.
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <algorithm> // For std::swap().
|
||||||
|
|
||||||
|
#include "include/base/cef_basictypes.h"
|
||||||
|
#include "include/base/cef_build.h"
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
|
#include "include/base/cef_move.h"
|
||||||
|
#include "include/base/cef_template_util.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
namespace subtle {
|
||||||
|
class RefCountedBase;
|
||||||
|
class RefCountedThreadSafeBase;
|
||||||
|
} // namespace subtle
|
||||||
|
|
||||||
|
// Function object which deletes its parameter, which must be a pointer.
|
||||||
|
// If C is an array type, invokes 'delete[]' on the parameter; otherwise,
|
||||||
|
// invokes 'delete'. The default deleter for scoped_ptr<T>.
|
||||||
|
template <class T>
|
||||||
|
struct DefaultDeleter {
|
||||||
|
DefaultDeleter() {}
|
||||||
|
template <typename U> DefaultDeleter(const DefaultDeleter<U>& other) {
|
||||||
|
// IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor
|
||||||
|
// if U* is implicitly convertible to T* and U is not an array type.
|
||||||
|
//
|
||||||
|
// Correct implementation should use SFINAE to disable this
|
||||||
|
// constructor. However, since there are no other 1-argument constructors,
|
||||||
|
// using a COMPILE_ASSERT() based on is_convertible<> and requiring
|
||||||
|
// complete types is simpler and will cause compile failures for equivalent
|
||||||
|
// misuses.
|
||||||
|
//
|
||||||
|
// Note, the is_convertible<U*, T*> check also ensures that U is not an
|
||||||
|
// array. T is guaranteed to be a non-array, so any U* where U is an array
|
||||||
|
// cannot convert to T*.
|
||||||
|
enum { T_must_be_complete = sizeof(T) };
|
||||||
|
enum { U_must_be_complete = sizeof(U) };
|
||||||
|
COMPILE_ASSERT((base::is_convertible<U*, T*>::value),
|
||||||
|
U_ptr_must_implicitly_convert_to_T_ptr);
|
||||||
|
}
|
||||||
|
inline void operator()(T* ptr) const {
|
||||||
|
enum { type_must_be_complete = sizeof(T) };
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Specialization of DefaultDeleter for array types.
|
||||||
|
template <class T>
|
||||||
|
struct DefaultDeleter<T[]> {
|
||||||
|
inline void operator()(T* ptr) const {
|
||||||
|
enum { type_must_be_complete = sizeof(T) };
|
||||||
|
delete[] ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Disable this operator for any U != T because it is undefined to execute
|
||||||
|
// an array delete when the static type of the array mismatches the dynamic
|
||||||
|
// type.
|
||||||
|
//
|
||||||
|
// References:
|
||||||
|
// C++98 [expr.delete]p3
|
||||||
|
// http://cplusplus.github.com/LWG/lwg-defects.html#938
|
||||||
|
template <typename U> void operator()(U* array) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, int n>
|
||||||
|
struct DefaultDeleter<T[n]> {
|
||||||
|
// Never allow someone to declare something like scoped_ptr<int[10]>.
|
||||||
|
COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function object which invokes 'free' on its parameter, which must be
|
||||||
|
// a pointer. Can be used to store malloc-allocated pointers in scoped_ptr:
|
||||||
|
//
|
||||||
|
// scoped_ptr<int, base::FreeDeleter> foo_ptr(
|
||||||
|
// static_cast<int*>(malloc(sizeof(int))));
|
||||||
|
struct FreeDeleter {
|
||||||
|
inline void operator()(void* ptr) const {
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace cef_internal {
|
||||||
|
|
||||||
|
template <typename T> struct IsNotRefCounted {
|
||||||
|
enum {
|
||||||
|
value = !base::is_convertible<T*, base::subtle::RefCountedBase*>::value &&
|
||||||
|
!base::is_convertible<T*, base::subtle::RefCountedThreadSafeBase*>::
|
||||||
|
value
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Minimal implementation of the core logic of scoped_ptr, suitable for
|
||||||
|
// reuse in both scoped_ptr and its specializations.
|
||||||
|
template <class T, class D>
|
||||||
|
class scoped_ptr_impl {
|
||||||
|
public:
|
||||||
|
explicit scoped_ptr_impl(T* p) : data_(p) { }
|
||||||
|
|
||||||
|
// Initializer for deleters that have data parameters.
|
||||||
|
scoped_ptr_impl(T* p, const D& d) : data_(p, d) {}
|
||||||
|
|
||||||
|
// Templated constructor that destructively takes the value from another
|
||||||
|
// scoped_ptr_impl.
|
||||||
|
template <typename U, typename V>
|
||||||
|
scoped_ptr_impl(scoped_ptr_impl<U, V>* other)
|
||||||
|
: data_(other->release(), other->get_deleter()) {
|
||||||
|
// We do not support move-only deleters. We could modify our move
|
||||||
|
// emulation to have base::subtle::move() and base::subtle::forward()
|
||||||
|
// functions that are imperfect emulations of their C++11 equivalents,
|
||||||
|
// but until there's a requirement, just assume deleters are copyable.
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U, typename V>
|
||||||
|
void TakeState(scoped_ptr_impl<U, V>* other) {
|
||||||
|
// See comment in templated constructor above regarding lack of support
|
||||||
|
// for move-only deleters.
|
||||||
|
reset(other->release());
|
||||||
|
get_deleter() = other->get_deleter();
|
||||||
|
}
|
||||||
|
|
||||||
|
~scoped_ptr_impl() {
|
||||||
|
if (data_.ptr != NULL) {
|
||||||
|
// Not using get_deleter() saves one function call in non-optimized
|
||||||
|
// builds.
|
||||||
|
static_cast<D&>(data_)(data_.ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(T* p) {
|
||||||
|
// This is a self-reset, which is no longer allowed: http://crbug.com/162971
|
||||||
|
if (p != NULL && p == data_.ptr)
|
||||||
|
abort();
|
||||||
|
|
||||||
|
// Note that running data_.ptr = p can lead to undefined behavior if
|
||||||
|
// get_deleter()(get()) deletes this. In order to prevent this, reset()
|
||||||
|
// should update the stored pointer before deleting its old value.
|
||||||
|
//
|
||||||
|
// However, changing reset() to use that behavior may cause current code to
|
||||||
|
// break in unexpected ways. If the destruction of the owned object
|
||||||
|
// dereferences the scoped_ptr when it is destroyed by a call to reset(),
|
||||||
|
// then it will incorrectly dispatch calls to |p| rather than the original
|
||||||
|
// value of |data_.ptr|.
|
||||||
|
//
|
||||||
|
// During the transition period, set the stored pointer to NULL while
|
||||||
|
// deleting the object. Eventually, this safety check will be removed to
|
||||||
|
// prevent the scenario initially described from occuring and
|
||||||
|
// http://crbug.com/176091 can be closed.
|
||||||
|
T* old = data_.ptr;
|
||||||
|
data_.ptr = NULL;
|
||||||
|
if (old != NULL)
|
||||||
|
static_cast<D&>(data_)(old);
|
||||||
|
data_.ptr = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* get() const { return data_.ptr; }
|
||||||
|
|
||||||
|
D& get_deleter() { return data_; }
|
||||||
|
const D& get_deleter() const { return data_; }
|
||||||
|
|
||||||
|
void swap(scoped_ptr_impl& p2) {
|
||||||
|
// Standard swap idiom: 'using std::swap' ensures that std::swap is
|
||||||
|
// present in the overload set, but we call swap unqualified so that
|
||||||
|
// any more-specific overloads can be used, if available.
|
||||||
|
using std::swap;
|
||||||
|
swap(static_cast<D&>(data_), static_cast<D&>(p2.data_));
|
||||||
|
swap(data_.ptr, p2.data_.ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
T* release() {
|
||||||
|
T* old_ptr = data_.ptr;
|
||||||
|
data_.ptr = NULL;
|
||||||
|
return old_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Needed to allow type-converting constructor.
|
||||||
|
template <typename U, typename V> friend class scoped_ptr_impl;
|
||||||
|
|
||||||
|
// Use the empty base class optimization to allow us to have a D
|
||||||
|
// member, while avoiding any space overhead for it when D is an
|
||||||
|
// empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good
|
||||||
|
// discussion of this technique.
|
||||||
|
struct Data : public D {
|
||||||
|
explicit Data(T* ptr_in) : ptr(ptr_in) {}
|
||||||
|
Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {}
|
||||||
|
T* ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
Data data_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cef_internal
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
|
||||||
|
// automatically deletes the pointer it holds (if any).
|
||||||
|
// That is, scoped_ptr<T> owns the T object that it points to.
|
||||||
|
// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
|
||||||
|
// Also like T*, scoped_ptr<T> is thread-compatible, and once you
|
||||||
|
// dereference it, you get the thread safety guarantees of T.
|
||||||
|
//
|
||||||
|
// The size of scoped_ptr is small. On most compilers, when using the
|
||||||
|
// DefaultDeleter, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters will
|
||||||
|
// increase the size proportional to whatever state they need to have. See
|
||||||
|
// comments inside scoped_ptr_impl<> for details.
|
||||||
|
//
|
||||||
|
// Current implementation targets having a strict subset of C++11's
|
||||||
|
// unique_ptr<> features. Known deficiencies include not supporting move-only
|
||||||
|
// deleteres, function pointers as deleters, and deleters with reference
|
||||||
|
// types.
|
||||||
|
template <class T, class D = base::DefaultDeleter<T> >
|
||||||
|
class scoped_ptr {
|
||||||
|
MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
||||||
|
|
||||||
|
COMPILE_ASSERT(base::cef_internal::IsNotRefCounted<T>::value,
|
||||||
|
T_is_refcounted_type_and_needs_scoped_refptr);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// The element and deleter types.
|
||||||
|
typedef T element_type;
|
||||||
|
typedef D deleter_type;
|
||||||
|
|
||||||
|
// Constructor. Defaults to initializing with NULL.
|
||||||
|
scoped_ptr() : impl_(NULL) { }
|
||||||
|
|
||||||
|
// Constructor. Takes ownership of p.
|
||||||
|
explicit scoped_ptr(element_type* p) : impl_(p) { }
|
||||||
|
|
||||||
|
// Constructor. Allows initialization of a stateful deleter.
|
||||||
|
scoped_ptr(element_type* p, const D& d) : impl_(p, d) { }
|
||||||
|
|
||||||
|
// Constructor. Allows construction from a scoped_ptr rvalue for a
|
||||||
|
// convertible type and deleter.
|
||||||
|
//
|
||||||
|
// IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct
|
||||||
|
// from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor
|
||||||
|
// has different post-conditions if D is a reference type. Since this
|
||||||
|
// implementation does not support deleters with reference type,
|
||||||
|
// we do not need a separate move constructor allowing us to avoid one
|
||||||
|
// use of SFINAE. You only need to care about this if you modify the
|
||||||
|
// implementation of scoped_ptr.
|
||||||
|
template <typename U, typename V>
|
||||||
|
scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
|
||||||
|
COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor. Move constructor for C++03 move emulation of this type.
|
||||||
|
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
|
||||||
|
|
||||||
|
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
|
||||||
|
// type and deleter.
|
||||||
|
//
|
||||||
|
// IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from
|
||||||
|
// the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated
|
||||||
|
// form has different requirements on for move-only Deleters. Since this
|
||||||
|
// implementation does not support move-only Deleters, we do not need a
|
||||||
|
// separate move assignment operator allowing us to avoid one use of SFINAE.
|
||||||
|
// You only need to care about this if you modify the implementation of
|
||||||
|
// scoped_ptr.
|
||||||
|
template <typename U, typename V>
|
||||||
|
scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
|
||||||
|
COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
|
||||||
|
impl_.TakeState(&rhs.impl_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset. Deletes the currently owned object, if any.
|
||||||
|
// Then takes ownership of a new object, if given.
|
||||||
|
void reset(element_type* p = NULL) { impl_.reset(p); }
|
||||||
|
|
||||||
|
// Accessors to get the owned object.
|
||||||
|
// operator* and operator-> will assert() if there is no current object.
|
||||||
|
element_type& operator*() const {
|
||||||
|
assert(impl_.get() != NULL);
|
||||||
|
return *impl_.get();
|
||||||
|
}
|
||||||
|
element_type* operator->() const {
|
||||||
|
assert(impl_.get() != NULL);
|
||||||
|
return impl_.get();
|
||||||
|
}
|
||||||
|
element_type* get() const { return impl_.get(); }
|
||||||
|
|
||||||
|
// Access to the deleter.
|
||||||
|
deleter_type& get_deleter() { return impl_.get_deleter(); }
|
||||||
|
const deleter_type& get_deleter() const { return impl_.get_deleter(); }
|
||||||
|
|
||||||
|
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
|
||||||
|
// implicitly convertible to a real bool (which is dangerous).
|
||||||
|
//
|
||||||
|
// Note that this trick is only safe when the == and != operators
|
||||||
|
// are declared explicitly, as otherwise "scoped_ptr1 ==
|
||||||
|
// scoped_ptr2" will compile but do the wrong thing (i.e., convert
|
||||||
|
// to Testable and then do the comparison).
|
||||||
|
private:
|
||||||
|
typedef base::cef_internal::scoped_ptr_impl<element_type, deleter_type>
|
||||||
|
scoped_ptr::*Testable;
|
||||||
|
|
||||||
|
public:
|
||||||
|
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
|
||||||
|
|
||||||
|
// Comparison operators.
|
||||||
|
// These return whether two scoped_ptr refer to the same object, not just to
|
||||||
|
// two different but equal objects.
|
||||||
|
bool operator==(const element_type* p) const { return impl_.get() == p; }
|
||||||
|
bool operator!=(const element_type* p) const { return impl_.get() != p; }
|
||||||
|
|
||||||
|
// Swap two scoped pointers.
|
||||||
|
void swap(scoped_ptr& p2) {
|
||||||
|
impl_.swap(p2.impl_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release a pointer.
|
||||||
|
// The return value is the current pointer held by this object.
|
||||||
|
// If this object holds a NULL pointer, the return value is NULL.
|
||||||
|
// After this operation, this object will hold a NULL pointer,
|
||||||
|
// and will not own the object any more.
|
||||||
|
element_type* release() WARN_UNUSED_RESULT {
|
||||||
|
return impl_.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
// C++98 doesn't support functions templates with default parameters which
|
||||||
|
// makes it hard to write a PassAs() that understands converting the deleter
|
||||||
|
// while preserving simple calling semantics.
|
||||||
|
//
|
||||||
|
// Until there is a use case for PassAs() with custom deleters, just ignore
|
||||||
|
// the custom deleter.
|
||||||
|
template <typename PassAsType>
|
||||||
|
scoped_ptr<PassAsType> PassAs() {
|
||||||
|
return scoped_ptr<PassAsType>(Pass());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Needed to reach into |impl_| in the constructor.
|
||||||
|
template <typename U, typename V> friend class scoped_ptr;
|
||||||
|
base::cef_internal::scoped_ptr_impl<element_type, deleter_type> impl_;
|
||||||
|
|
||||||
|
// Forbidden for API compatibility with std::unique_ptr.
|
||||||
|
explicit scoped_ptr(int disallow_construction_from_null);
|
||||||
|
|
||||||
|
// Forbid comparison of scoped_ptr types. If U != T, it totally
|
||||||
|
// doesn't make sense, and if U == T, it still doesn't make sense
|
||||||
|
// because you should never have the same object owned by two different
|
||||||
|
// scoped_ptrs.
|
||||||
|
template <class U> bool operator==(scoped_ptr<U> const& p2) const;
|
||||||
|
template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
class scoped_ptr<T[], D> {
|
||||||
|
MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
||||||
|
|
||||||
|
public:
|
||||||
|
// The element and deleter types.
|
||||||
|
typedef T element_type;
|
||||||
|
typedef D deleter_type;
|
||||||
|
|
||||||
|
// Constructor. Defaults to initializing with NULL.
|
||||||
|
scoped_ptr() : impl_(NULL) { }
|
||||||
|
|
||||||
|
// Constructor. Stores the given array. Note that the argument's type
|
||||||
|
// must exactly match T*. In particular:
|
||||||
|
// - it cannot be a pointer to a type derived from T, because it is
|
||||||
|
// inherently unsafe in the general case to access an array through a
|
||||||
|
// pointer whose dynamic type does not match its static type (eg., if
|
||||||
|
// T and the derived types had different sizes access would be
|
||||||
|
// incorrectly calculated). Deletion is also always undefined
|
||||||
|
// (C++98 [expr.delete]p3). If you're doing this, fix your code.
|
||||||
|
// - it cannot be NULL, because NULL is an integral expression, not a
|
||||||
|
// pointer to T. Use the no-argument version instead of explicitly
|
||||||
|
// passing NULL.
|
||||||
|
// - it cannot be const-qualified differently from T per unique_ptr spec
|
||||||
|
// (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting
|
||||||
|
// to work around this may use implicit_cast<const T*>().
|
||||||
|
// However, because of the first bullet in this comment, users MUST
|
||||||
|
// NOT use implicit_cast<Base*>() to upcast the static type of the array.
|
||||||
|
explicit scoped_ptr(element_type* array) : impl_(array) { }
|
||||||
|
|
||||||
|
// Constructor. Move constructor for C++03 move emulation of this type.
|
||||||
|
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
|
||||||
|
|
||||||
|
// operator=. Move operator= for C++03 move emulation of this type.
|
||||||
|
scoped_ptr& operator=(RValue rhs) {
|
||||||
|
impl_.TakeState(&rhs.object->impl_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset. Deletes the currently owned array, if any.
|
||||||
|
// Then takes ownership of a new object, if given.
|
||||||
|
void reset(element_type* array = NULL) { impl_.reset(array); }
|
||||||
|
|
||||||
|
// Accessors to get the owned array.
|
||||||
|
element_type& operator[](size_t i) const {
|
||||||
|
assert(impl_.get() != NULL);
|
||||||
|
return impl_.get()[i];
|
||||||
|
}
|
||||||
|
element_type* get() const { return impl_.get(); }
|
||||||
|
|
||||||
|
// Access to the deleter.
|
||||||
|
deleter_type& get_deleter() { return impl_.get_deleter(); }
|
||||||
|
const deleter_type& get_deleter() const { return impl_.get_deleter(); }
|
||||||
|
|
||||||
|
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
|
||||||
|
// implicitly convertible to a real bool (which is dangerous).
|
||||||
|
private:
|
||||||
|
typedef base::cef_internal::scoped_ptr_impl<element_type, deleter_type>
|
||||||
|
scoped_ptr::*Testable;
|
||||||
|
|
||||||
|
public:
|
||||||
|
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
|
||||||
|
|
||||||
|
// Comparison operators.
|
||||||
|
// These return whether two scoped_ptr refer to the same object, not just to
|
||||||
|
// two different but equal objects.
|
||||||
|
bool operator==(element_type* array) const { return impl_.get() == array; }
|
||||||
|
bool operator!=(element_type* array) const { return impl_.get() != array; }
|
||||||
|
|
||||||
|
// Swap two scoped pointers.
|
||||||
|
void swap(scoped_ptr& p2) {
|
||||||
|
impl_.swap(p2.impl_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release a pointer.
|
||||||
|
// The return value is the current pointer held by this object.
|
||||||
|
// If this object holds a NULL pointer, the return value is NULL.
|
||||||
|
// After this operation, this object will hold a NULL pointer,
|
||||||
|
// and will not own the object any more.
|
||||||
|
element_type* release() WARN_UNUSED_RESULT {
|
||||||
|
return impl_.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Force element_type to be a complete type.
|
||||||
|
enum { type_must_be_complete = sizeof(element_type) };
|
||||||
|
|
||||||
|
// Actually hold the data.
|
||||||
|
base::cef_internal::scoped_ptr_impl<element_type, deleter_type> impl_;
|
||||||
|
|
||||||
|
// Disable initialization from any type other than element_type*, by
|
||||||
|
// providing a constructor that matches such an initialization, but is
|
||||||
|
// private and has no definition. This is disabled because it is not safe to
|
||||||
|
// call delete[] on an array whose static type does not match its dynamic
|
||||||
|
// type.
|
||||||
|
template <typename U> explicit scoped_ptr(U* array);
|
||||||
|
explicit scoped_ptr(int disallow_construction_from_null);
|
||||||
|
|
||||||
|
// Disable reset() from any type other than element_type*, for the same
|
||||||
|
// reasons as the constructor above.
|
||||||
|
template <typename U> void reset(U* array);
|
||||||
|
void reset(int disallow_reset_from_null);
|
||||||
|
|
||||||
|
// Forbid comparison of scoped_ptr types. If U != T, it totally
|
||||||
|
// doesn't make sense, and if U == T, it still doesn't make sense
|
||||||
|
// because you should never have the same object owned by two different
|
||||||
|
// scoped_ptrs.
|
||||||
|
template <class U> bool operator==(scoped_ptr<U> const& p2) const;
|
||||||
|
template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Free functions
|
||||||
|
template <class T, class D>
|
||||||
|
void swap(scoped_ptr<T, D>& p1, scoped_ptr<T, D>& p2) {
|
||||||
|
p1.swap(p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
bool operator==(T* p1, const scoped_ptr<T, D>& p2) {
|
||||||
|
return p1 == p2.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class D>
|
||||||
|
bool operator!=(T* p1, const scoped_ptr<T, D>& p2) {
|
||||||
|
return p1 != p2.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// A function to convert T* into scoped_ptr<T>
|
||||||
|
// Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
|
||||||
|
// for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
|
||||||
|
template <typename T>
|
||||||
|
scoped_ptr<T> make_scoped_ptr(T* ptr) {
|
||||||
|
return scoped_ptr<T>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_
|
||||||
@@ -1,412 +0,0 @@
|
|||||||
// 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"
|
|
||||||
#include "include/base/cef_macros.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_
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
// Copyright (c) 2021 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.
|
|
||||||
|
|
||||||
// ScopedTypeRef<> is patterned after std::unique_ptr<>, but maintains ownership
|
|
||||||
// of a reference to any type that is maintained by Retain and Release methods.
|
|
||||||
//
|
|
||||||
// The Traits structure must provide the Retain and Release methods for type T.
|
|
||||||
// A default ScopedTypeRefTraits is used but not defined, and should be defined
|
|
||||||
// for each type to use this interface. For example, an appropriate definition
|
|
||||||
// of ScopedTypeRefTraits for CGLContextObj would be:
|
|
||||||
//
|
|
||||||
// template<>
|
|
||||||
// struct ScopedTypeRefTraits<CGLContextObj> {
|
|
||||||
// static CGLContextObj InvalidValue() { return nullptr; }
|
|
||||||
// static CGLContextObj Retain(CGLContextObj object) {
|
|
||||||
// CGLContextRetain(object);
|
|
||||||
// return object;
|
|
||||||
// }
|
|
||||||
// static void Release(CGLContextObj object) { CGLContextRelease(object); }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// For the many types that have pass-by-pointer create functions, the function
|
|
||||||
// InitializeInto() is provided to allow direct initialization and assumption
|
|
||||||
// of ownership of the object. For example, continuing to use the above
|
|
||||||
// CGLContextObj specialization:
|
|
||||||
//
|
|
||||||
// base::ScopedTypeRef<CGLContextObj> context;
|
|
||||||
// CGLCreateContext(pixel_format, share_group, context.InitializeInto());
|
|
||||||
//
|
|
||||||
// For initialization with an existing object, the caller may specify whether
|
|
||||||
// the ScopedTypeRef<> being initialized is assuming the caller's existing
|
|
||||||
// ownership of the object (and should not call Retain in initialization) or if
|
|
||||||
// it should not assume this ownership and must create its own (by calling
|
|
||||||
// Retain in initialization). This behavior is based on the |policy| parameter,
|
|
||||||
// with |ASSUME| for the former and |RETAIN| for the latter. The default policy
|
|
||||||
// is to |ASSUME|.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_SCOPED_TYPEREF_MAC_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_SCOPED_TYPEREF_MAC_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/mac/scoped_typeref.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_compiler_specific.h"
|
|
||||||
#include "include/base/cef_logging.h"
|
|
||||||
#include "include/base/internal/cef_scoped_policy.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct ScopedTypeRefTraits;
|
|
||||||
|
|
||||||
template<typename T, typename Traits = ScopedTypeRefTraits<T>>
|
|
||||||
class ScopedTypeRef {
|
|
||||||
public:
|
|
||||||
using element_type = T;
|
|
||||||
|
|
||||||
explicit constexpr ScopedTypeRef(
|
|
||||||
element_type object = Traits::InvalidValue(),
|
|
||||||
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
|
|
||||||
: object_(object) {
|
|
||||||
if (object_ && policy == base::scoped_policy::RETAIN)
|
|
||||||
object_ = Traits::Retain(object_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopedTypeRef(const ScopedTypeRef<T, Traits>& that)
|
|
||||||
: object_(that.object_) {
|
|
||||||
if (object_)
|
|
||||||
object_ = Traits::Retain(object_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This allows passing an object to a function that takes its superclass.
|
|
||||||
template <typename R, typename RTraits>
|
|
||||||
explicit ScopedTypeRef(const ScopedTypeRef<R, RTraits>& that_as_subclass)
|
|
||||||
: object_(that_as_subclass.get()) {
|
|
||||||
if (object_)
|
|
||||||
object_ = Traits::Retain(object_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopedTypeRef(ScopedTypeRef<T, Traits>&& that) : object_(that.object_) {
|
|
||||||
that.object_ = Traits::InvalidValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
~ScopedTypeRef() {
|
|
||||||
if (object_)
|
|
||||||
Traits::Release(object_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ScopedTypeRef& operator=(const ScopedTypeRef<T, Traits>& that) {
|
|
||||||
reset(that.get(), base::scoped_policy::RETAIN);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is to be used only to take ownership of objects that are created
|
|
||||||
// by pass-by-pointer create functions. To enforce this, require that the
|
|
||||||
// object be reset to NULL before this may be used.
|
|
||||||
element_type* InitializeInto() WARN_UNUSED_RESULT {
|
|
||||||
DCHECK(!object_);
|
|
||||||
return &object_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(const ScopedTypeRef<T, Traits>& that) {
|
|
||||||
reset(that.get(), base::scoped_policy::RETAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(element_type object = Traits::InvalidValue(),
|
|
||||||
base::scoped_policy::OwnershipPolicy policy =
|
|
||||||
base::scoped_policy::ASSUME) {
|
|
||||||
if (object && policy == base::scoped_policy::RETAIN)
|
|
||||||
object = Traits::Retain(object);
|
|
||||||
if (object_)
|
|
||||||
Traits::Release(object_);
|
|
||||||
object_ = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const element_type& that) const { return object_ == that; }
|
|
||||||
|
|
||||||
bool operator!=(const element_type& that) const { return object_ != that; }
|
|
||||||
|
|
||||||
operator element_type() const { return object_; }
|
|
||||||
|
|
||||||
element_type get() const { return object_; }
|
|
||||||
|
|
||||||
void swap(ScopedTypeRef& that) {
|
|
||||||
element_type temp = that.object_;
|
|
||||||
that.object_ = object_;
|
|
||||||
object_ = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ScopedTypeRef<>::release() is like std::unique_ptr<>::release. It is NOT
|
|
||||||
// a wrapper for Release(). To force a ScopedTypeRef<> object to call
|
|
||||||
// Release(), use ScopedTypeRef<>::reset().
|
|
||||||
element_type release() WARN_UNUSED_RESULT {
|
|
||||||
element_type temp = object_;
|
|
||||||
object_ = Traits::InvalidValue();
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
element_type object_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_SCOPED_TYPEREF_MAC_H_
|
|
||||||
227
include/base/cef_string16.h
Normal file
227
include/base/cef_string16.h
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_STRING16_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_STRING16_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(BASE_STRINGS_STRING16_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/strings/string16.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.
|
||||||
|
// WHAT:
|
||||||
|
// A version of std::basic_string that provides 2-byte characters even when
|
||||||
|
// wchar_t is not implemented as a 2-byte type. You can access this class as
|
||||||
|
// string16. We also define char16, which string16 is based upon.
|
||||||
|
//
|
||||||
|
// WHY:
|
||||||
|
// On Windows, wchar_t is 2 bytes, and it can conveniently handle UTF-16/UCS-2
|
||||||
|
// data. Plenty of existing code operates on strings encoded as UTF-16.
|
||||||
|
//
|
||||||
|
// On many other platforms, sizeof(wchar_t) is 4 bytes by default. We can make
|
||||||
|
// it 2 bytes by using the GCC flag -fshort-wchar. But then std::wstring fails
|
||||||
|
// at run time, because it calls some functions (like wcslen) that come from
|
||||||
|
// the system's native C library -- which was built with a 4-byte wchar_t!
|
||||||
|
// It's wasteful to use 4-byte wchar_t strings to carry UTF-16 data, and it's
|
||||||
|
// entirely improper on those systems where the encoding of wchar_t is defined
|
||||||
|
// as UTF-32.
|
||||||
|
//
|
||||||
|
// Here, we define string16, which is similar to std::wstring but replaces all
|
||||||
|
// libc functions with custom, 2-byte-char compatible routines. It is capable
|
||||||
|
// of carrying UTF-16-encoded data.
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/base/cef_basictypes.h"
|
||||||
|
|
||||||
|
#if defined(WCHAR_T_IS_UTF16)
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
typedef wchar_t char16;
|
||||||
|
typedef std::wstring string16;
|
||||||
|
typedef std::char_traits<wchar_t> string16_char_traits;
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#elif defined(WCHAR_T_IS_UTF32)
|
||||||
|
|
||||||
|
#include <stdint.h> // For uint16_t
|
||||||
|
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
typedef uint16_t char16;
|
||||||
|
|
||||||
|
// char16 versions of the functions required by string16_char_traits; these
|
||||||
|
// are based on the wide character functions of similar names ("w" or "wcs"
|
||||||
|
// instead of "c16").
|
||||||
|
int c16memcmp(const char16* s1, const char16* s2, size_t n);
|
||||||
|
size_t c16len(const char16* s);
|
||||||
|
const char16* c16memchr(const char16* s, char16 c, size_t n);
|
||||||
|
char16* c16memmove(char16* s1, const char16* s2, size_t n);
|
||||||
|
char16* c16memcpy(char16* s1, const char16* s2, size_t n);
|
||||||
|
char16* c16memset(char16* s, char16 c, size_t n);
|
||||||
|
|
||||||
|
struct string16_char_traits {
|
||||||
|
typedef char16 char_type;
|
||||||
|
typedef int int_type;
|
||||||
|
|
||||||
|
// int_type needs to be able to hold each possible value of char_type, and in
|
||||||
|
// addition, the distinct value of eof().
|
||||||
|
COMPILE_ASSERT(sizeof(int_type) > sizeof(char_type), unexpected_type_width);
|
||||||
|
|
||||||
|
typedef std::streamoff off_type;
|
||||||
|
typedef mbstate_t state_type;
|
||||||
|
typedef std::fpos<state_type> pos_type;
|
||||||
|
|
||||||
|
static void assign(char_type& c1, const char_type& c2) {
|
||||||
|
c1 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool eq(const char_type& c1, const char_type& c2) {
|
||||||
|
return c1 == c2;
|
||||||
|
}
|
||||||
|
static bool lt(const char_type& c1, const char_type& c2) {
|
||||||
|
return c1 < c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compare(const char_type* s1, const char_type* s2, size_t n) {
|
||||||
|
return c16memcmp(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t length(const char_type* s) {
|
||||||
|
return c16len(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char_type* find(const char_type* s, size_t n,
|
||||||
|
const char_type& a) {
|
||||||
|
return c16memchr(s, a, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type* move(char_type* s1, const char_type* s2, int_type n) {
|
||||||
|
return c16memmove(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
|
||||||
|
return c16memcpy(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type* assign(char_type* s, size_t n, char_type a) {
|
||||||
|
return c16memset(s, a, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int_type not_eof(const int_type& c) {
|
||||||
|
return eq_int_type(c, eof()) ? 0 : c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char_type to_char_type(const int_type& c) {
|
||||||
|
return char_type(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int_type to_int_type(const char_type& c) {
|
||||||
|
return int_type(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool eq_int_type(const int_type& c1, const int_type& c2) {
|
||||||
|
return c1 == c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int_type eof() {
|
||||||
|
return static_cast<int_type>(EOF);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::basic_string<char16, base::string16_char_traits> string16;
|
||||||
|
|
||||||
|
extern std::ostream& operator<<(std::ostream& out, const string16& str);
|
||||||
|
|
||||||
|
// This is required by googletest to print a readable output on test failures.
|
||||||
|
extern void PrintTo(const string16& str, std::ostream* out);
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
// The string class will be explicitly instantiated only once, in string16.cc.
|
||||||
|
//
|
||||||
|
// std::basic_string<> in GNU libstdc++ contains a static data member,
|
||||||
|
// _S_empty_rep_storage, to represent empty strings. When an operation such
|
||||||
|
// as assignment or destruction is performed on a string, causing its existing
|
||||||
|
// data member to be invalidated, it must not be freed if this static data
|
||||||
|
// member is being used. Otherwise, it counts as an attempt to free static
|
||||||
|
// (and not allocated) data, which is a memory error.
|
||||||
|
//
|
||||||
|
// Generally, due to C++ template magic, _S_empty_rep_storage will be marked
|
||||||
|
// as a coalesced symbol, meaning that the linker will combine multiple
|
||||||
|
// instances into a single one when generating output.
|
||||||
|
//
|
||||||
|
// If a string class is used by multiple shared libraries, a problem occurs.
|
||||||
|
// Each library will get its own copy of _S_empty_rep_storage. When strings
|
||||||
|
// are passed across a library boundary for alteration or destruction, memory
|
||||||
|
// errors will result. GNU libstdc++ contains a configuration option,
|
||||||
|
// --enable-fully-dynamic-string (_GLIBCXX_FULLY_DYNAMIC_STRING), which
|
||||||
|
// disables the static data member optimization, but it's a good optimization
|
||||||
|
// and non-STL code is generally at the mercy of the system's STL
|
||||||
|
// configuration. Fully-dynamic strings are not the default for GNU libstdc++
|
||||||
|
// libstdc++ itself or for the libstdc++ installations on the systems we care
|
||||||
|
// about, such as Mac OS X and relevant flavors of Linux.
|
||||||
|
//
|
||||||
|
// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 .
|
||||||
|
//
|
||||||
|
// To avoid problems, string classes need to be explicitly instantiated only
|
||||||
|
// once, in exactly one library. All other string users see it via an "extern"
|
||||||
|
// declaration. This is precisely how GNU libstdc++ handles
|
||||||
|
// std::basic_string<char> (string) and std::basic_string<wchar_t> (wstring).
|
||||||
|
//
|
||||||
|
// This also works around a Mac OS X linker bug in ld64-85.2.1 (Xcode 3.1.2),
|
||||||
|
// in which the linker does not fully coalesce symbols when dead code
|
||||||
|
// stripping is enabled. This bug causes the memory errors described above
|
||||||
|
// to occur even when a std::basic_string<> does not cross shared library
|
||||||
|
// boundaries, such as in statically-linked executables.
|
||||||
|
//
|
||||||
|
// TODO(mark): File this bug with Apple and update this note with a bug number.
|
||||||
|
|
||||||
|
extern template
|
||||||
|
class std::basic_string<base::char16, base::string16_char_traits>;
|
||||||
|
|
||||||
|
#endif // WCHAR_T_IS_UTF32
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_STRING16_H_
|
||||||
@@ -32,7 +32,12 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_TEMPLATE_UTIL_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/template_util.h"
|
#include "base/template_util.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -40,370 +45,148 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <cstddef> // For size_t.
|
||||||
#include <iosfwd>
|
|
||||||
#include <iterator>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "include/base/cef_build.h"
|
#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 {
|
namespace base {
|
||||||
|
|
||||||
template <class T> struct is_non_const_reference : std::false_type {};
|
// template definitions from tr1
|
||||||
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 {
|
template<class T, T v>
|
||||||
|
struct integral_constant {
|
||||||
// Implementation detail of base::void_t below.
|
static const T value = v;
|
||||||
template <typename...>
|
typedef T value_type;
|
||||||
struct make_void {
|
typedef integral_constant<T, v> type;
|
||||||
using type = void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
template <class T, T v> const T integral_constant<T, v>::value;
|
||||||
|
|
||||||
// base::void_t is an implementation of std::void_t from C++17.
|
typedef integral_constant<bool, true> true_type;
|
||||||
//
|
typedef integral_constant<bool, false> false_type;
|
||||||
// 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 {
|
template <class T> struct is_pointer : false_type {};
|
||||||
|
template <class T> struct is_pointer<T*> : true_type {};
|
||||||
|
|
||||||
// Uses expression SFINAE to detect whether using operator<< would work.
|
// Member function pointer detection up to four params. Add more as needed
|
||||||
template <typename T, typename = void>
|
// below. This is built-in to C++ 11, and we can remove this when we switch.
|
||||||
struct SupportsOstreamOperator : std::false_type {};
|
template<typename T>
|
||||||
template <typename T>
|
struct is_member_function_pointer : false_type {};
|
||||||
struct SupportsOstreamOperator<T,
|
|
||||||
decltype(void(std::declval<std::ostream&>()
|
|
||||||
<< std::declval<T>()))>
|
|
||||||
: std::true_type {};
|
|
||||||
|
|
||||||
template <typename T, typename = void>
|
template <typename R, typename Z>
|
||||||
struct SupportsToString : std::false_type {};
|
struct is_member_function_pointer<R(Z::*)()> : true_type {};
|
||||||
template <typename T>
|
template <typename R, typename Z>
|
||||||
struct SupportsToString<T, decltype(void(std::declval<T>().ToString()))>
|
struct is_member_function_pointer<R(Z::*)() const> : true_type {};
|
||||||
: std::true_type {};
|
|
||||||
|
|
||||||
// Used to detech whether the given type is an iterator. This is normally used
|
template <typename R, typename Z, typename A>
|
||||||
// with std::enable_if to provide disambiguation for functions that take
|
struct is_member_function_pointer<R(Z::*)(A)> : true_type {};
|
||||||
// templatzed iterators as input.
|
template <typename R, typename Z, typename A>
|
||||||
template <typename T, typename = void>
|
struct is_member_function_pointer<R(Z::*)(A) const> : true_type {};
|
||||||
struct is_iterator : std::false_type {};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename R, typename Z, typename A, typename B>
|
||||||
struct is_iterator<T,
|
struct is_member_function_pointer<R(Z::*)(A, B)> : true_type {};
|
||||||
void_t<typename std::iterator_traits<T>::iterator_category>>
|
template <typename R, typename Z, typename A, typename B>
|
||||||
: std::true_type {};
|
struct is_member_function_pointer<R(Z::*)(A, B) const> : true_type {};
|
||||||
|
|
||||||
// Helper to express preferences in an overload set. If more than one overload
|
template <typename R, typename Z, typename A, typename B, typename C>
|
||||||
// are available for a given set of parameters the overload with the higher
|
struct is_member_function_pointer<R(Z::*)(A, B, C)> : true_type {};
|
||||||
// priority will be chosen.
|
template <typename R, typename Z, typename A, typename B, typename C>
|
||||||
template <size_t I>
|
struct is_member_function_pointer<R(Z::*)(A, B, C) const> : true_type {};
|
||||||
struct priority_tag : priority_tag<I - 1> {};
|
|
||||||
|
|
||||||
template <>
|
template <typename R, typename Z, typename A, typename B, typename C,
|
||||||
struct priority_tag<0> {};
|
typename D>
|
||||||
|
struct is_member_function_pointer<R(Z::*)(A, B, C, D)> : true_type {};
|
||||||
|
template <typename R, typename Z, typename A, typename B, typename C,
|
||||||
|
typename D>
|
||||||
|
struct is_member_function_pointer<R(Z::*)(A, B, C, D) const> : true_type {};
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// is_trivially_copyable is especially hard to get right.
|
template <class T, class U> struct is_same : public false_type {};
|
||||||
// - Older versions of libstdc++ will fail to have it like they do for other
|
template <class T> struct is_same<T,T> : true_type {};
|
||||||
// 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
|
template<class> struct is_array : public false_type {};
|
||||||
// namespace and it works with gcc as needed.
|
template<class T, size_t n> struct is_array<T[n]> : public true_type {};
|
||||||
#if defined(CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX) || \
|
template<class T> struct is_array<T[]> : public true_type {};
|
||||||
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
|
template <class T> struct is_non_const_reference : false_type {};
|
||||||
// Workaround for g++7 and earlier family.
|
template <class T> struct is_non_const_reference<T&> : true_type {};
|
||||||
// Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80654, without this
|
template <class T> struct is_non_const_reference<const T&> : false_type {};
|
||||||
// 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>
|
template <class T> struct is_const : false_type {};
|
||||||
struct is_trivially_copy_constructible<std::vector<T...>> : std::false_type {};
|
template <class T> struct is_const<const T> : true_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
|
template <class T> struct is_void : false_type {};
|
||||||
// C++17. A tag type used to request in-place construction in template vararg
|
template <> struct is_void<void> : true_type {};
|
||||||
// constructors.
|
|
||||||
|
|
||||||
// Specification:
|
namespace cef_internal {
|
||||||
// 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
|
// Types YesType and NoType are guaranteed such that sizeof(YesType) <
|
||||||
// C++17. A tag type used for in-place construction when the type to construct
|
// sizeof(NoType).
|
||||||
// needs to be specified, such as with base::unique_any, designed to be a
|
typedef char YesType;
|
||||||
// drop-in replacement.
|
|
||||||
|
|
||||||
// Specification:
|
struct NoType {
|
||||||
// http://en.cppreference.com/w/cpp/utility/in_place
|
YesType dummy[2];
|
||||||
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>
|
// This class is an implementation detail for is_convertible, and you
|
||||||
struct is_in_place_type_t<in_place_type_t<Ts...>> {
|
// don't need to know how it works to use is_convertible. For those
|
||||||
static constexpr bool value = true;
|
// who care: we declare two different functions, one whose argument is
|
||||||
|
// of type To and one with a variadic argument list. We give them
|
||||||
|
// return types of different size, so we can use sizeof to trick the
|
||||||
|
// compiler into telling us which function it would have chosen if we
|
||||||
|
// had called it with an argument of type From. See Alexandrescu's
|
||||||
|
// _Modern C++ Design_ for more details on this sort of trick.
|
||||||
|
|
||||||
|
struct ConvertHelper {
|
||||||
|
template <typename To>
|
||||||
|
static YesType Test(To);
|
||||||
|
|
||||||
|
template <typename To>
|
||||||
|
static NoType Test(...);
|
||||||
|
|
||||||
|
template <typename From>
|
||||||
|
static From& Create();
|
||||||
};
|
};
|
||||||
|
|
||||||
// C++14 implementation of C++17's std::bool_constant.
|
// Used to determine if a type is a struct/union/class. Inspired by Boost's
|
||||||
//
|
// is_class type_trait implementation.
|
||||||
// Reference: https://en.cppreference.com/w/cpp/types/integral_constant
|
struct IsClassHelper {
|
||||||
// Specification: https://wg21.link/meta.type.synop
|
template <typename C>
|
||||||
template <bool B>
|
static YesType Test(void(C::*)(void));
|
||||||
using bool_constant = std::integral_constant<bool, B>;
|
|
||||||
|
|
||||||
// C++14 implementation of C++17's std::conjunction.
|
template <typename C>
|
||||||
//
|
static NoType Test(...);
|
||||||
// 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.
|
} // namespace cef_internal
|
||||||
|
|
||||||
|
// Inherits from true_type if From is convertible to To, false_type otherwise.
|
||||||
//
|
//
|
||||||
// Reference: https://en.cppreference.com/w/cpp/types/disjunction
|
// Note that if the type is convertible, this will be a true_type REGARDLESS
|
||||||
// Specification: https://wg21.link/meta.logical#itemdecl:2
|
// of whether or not the conversion would emit a warning.
|
||||||
template <typename...>
|
template <typename From, typename To>
|
||||||
struct disjunction : std::false_type {};
|
struct is_convertible
|
||||||
|
: integral_constant<bool,
|
||||||
template <typename B1>
|
sizeof(cef_internal::ConvertHelper::Test<To>(
|
||||||
struct disjunction<B1> : B1 {};
|
cef_internal::ConvertHelper::Create<From>())) ==
|
||||||
|
sizeof(cef_internal::YesType)> {
|
||||||
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
|
|
||||||
template <typename Functor, typename... Args>
|
|
||||||
using invoke_result = std::result_of<Functor && (Args && ...)>;
|
|
||||||
|
|
||||||
// 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>
|
template <typename T>
|
||||||
struct IsScopedEnumImpl<T, /*std::is_enum<T>::value=*/true>
|
struct is_class
|
||||||
: negation<std::is_convertible<T, std::underlying_type_t<T>>> {};
|
: integral_constant<bool,
|
||||||
|
sizeof(cef_internal::IsClassHelper::Test<T>(0)) ==
|
||||||
} // namespace internal
|
sizeof(cef_internal::YesType)> {
|
||||||
|
|
||||||
// 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.
|
template<bool B, class T = void>
|
||||||
//
|
struct enable_if {};
|
||||||
// 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.
|
template<class T>
|
||||||
// As opposed to std::iter_value_t, this implementation does not restrict
|
struct enable_if<true, T> { typedef T type; };
|
||||||
// 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
|
} // namespace base
|
||||||
|
|
||||||
#undef CR_USE_FALLBACKS_FOR_GCC_WITH_LIBCXX
|
|
||||||
#undef CR_USE_FALLBACKS_FOR_OLD_EXPERIMENTAL_GLIBCXX
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
||||||
|
|||||||
@@ -32,7 +32,12 @@
|
|||||||
#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_THREADING_THREAD_CHECKER_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/threading/thread_checker.h"
|
#include "base/threading/thread_checker.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -53,6 +58,7 @@
|
|||||||
#define ENABLE_THREAD_CHECKER 0
|
#define ENABLE_THREAD_CHECKER 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
namespace cef_internal {
|
namespace cef_internal {
|
||||||
@@ -63,7 +69,9 @@ namespace cef_internal {
|
|||||||
// right version for your build configuration.
|
// right version for your build configuration.
|
||||||
class ThreadCheckerDoNothing {
|
class ThreadCheckerDoNothing {
|
||||||
public:
|
public:
|
||||||
bool CalledOnValidThread() const { return true; }
|
bool CalledOnValidThread() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void DetachFromThread() {}
|
void DetachFromThread() {}
|
||||||
};
|
};
|
||||||
@@ -102,9 +110,11 @@ class ThreadCheckerDoNothing {
|
|||||||
//
|
//
|
||||||
// In Release mode, CalledOnValidThread will always return true.
|
// In Release mode, CalledOnValidThread will always return true.
|
||||||
#if ENABLE_THREAD_CHECKER
|
#if ENABLE_THREAD_CHECKER
|
||||||
class ThreadChecker : public cef_internal::ThreadCheckerImpl {};
|
class ThreadChecker : public cef_internal::ThreadCheckerImpl {
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {};
|
class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {
|
||||||
|
};
|
||||||
#endif // ENABLE_THREAD_CHECKER
|
#endif // ENABLE_THREAD_CHECKER
|
||||||
|
|
||||||
#undef ENABLE_THREAD_CHECKER
|
#undef ENABLE_THREAD_CHECKER
|
||||||
|
|||||||
288
include/base/cef_thread_collision_warner.h
Normal file
288
include/base/cef_thread_collision_warner.h
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
// 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_THREAD_COLLISION_WARNER_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_THREAD_COLLISION_WARNER_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(BASE_THREADING_THREAD_COLLISION_WARNER_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/threading/thread_collision_warner.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 "include/base/cef_atomicops.h"
|
||||||
|
#include "include/base/cef_basictypes.h"
|
||||||
|
#include "include/base/cef_build.h"
|
||||||
|
#include "include/base/cef_logging.h"
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
|
|
||||||
|
// A helper class alongside macros to be used to verify assumptions about thread
|
||||||
|
// safety of a class.
|
||||||
|
//
|
||||||
|
// Example: Queue implementation non thread-safe but still usable if clients
|
||||||
|
// are synchronized somehow.
|
||||||
|
//
|
||||||
|
// In this case the macro DFAKE_SCOPED_LOCK has to be
|
||||||
|
// used, it checks that if a thread is inside the push/pop then
|
||||||
|
// noone else is still inside the pop/push
|
||||||
|
//
|
||||||
|
// class NonThreadSafeQueue {
|
||||||
|
// public:
|
||||||
|
// ...
|
||||||
|
// void push(int) { DFAKE_SCOPED_LOCK(push_pop_); ... }
|
||||||
|
// int pop() { DFAKE_SCOPED_LOCK(push_pop_); ... }
|
||||||
|
// ...
|
||||||
|
// private:
|
||||||
|
// DFAKE_MUTEX(push_pop_);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example: Queue implementation non thread-safe but still usable if clients
|
||||||
|
// are synchronized somehow, it calls a method to "protect" from
|
||||||
|
// a "protected" method
|
||||||
|
//
|
||||||
|
// In this case the macro DFAKE_SCOPED_RECURSIVE_LOCK
|
||||||
|
// has to be used, it checks that if a thread is inside the push/pop
|
||||||
|
// then noone else is still inside the pop/push
|
||||||
|
//
|
||||||
|
// class NonThreadSafeQueue {
|
||||||
|
// public:
|
||||||
|
// void push(int) {
|
||||||
|
// DFAKE_SCOPED_LOCK(push_pop_);
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// int pop() {
|
||||||
|
// DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_);
|
||||||
|
// bar();
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// void bar() { DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_); ... }
|
||||||
|
// ...
|
||||||
|
// private:
|
||||||
|
// DFAKE_MUTEX(push_pop_);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example: Queue implementation not usable even if clients are synchronized,
|
||||||
|
// so only one thread in the class life cycle can use the two members
|
||||||
|
// push/pop.
|
||||||
|
//
|
||||||
|
// In this case the macro DFAKE_SCOPED_LOCK_THREAD_LOCKED pins the
|
||||||
|
// specified
|
||||||
|
// critical section the first time a thread enters push or pop, from
|
||||||
|
// that time on only that thread is allowed to execute push or pop.
|
||||||
|
//
|
||||||
|
// class NonThreadSafeQueue {
|
||||||
|
// public:
|
||||||
|
// ...
|
||||||
|
// void push(int) { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... }
|
||||||
|
// int pop() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(push_pop_); ... }
|
||||||
|
// ...
|
||||||
|
// private:
|
||||||
|
// DFAKE_MUTEX(push_pop_);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example: Class that has to be contructed/destroyed on same thread, it has
|
||||||
|
// a "shareable" method (with external synchronization) and a not
|
||||||
|
// shareable method (even with external synchronization).
|
||||||
|
//
|
||||||
|
// In this case 3 Critical sections have to be defined
|
||||||
|
//
|
||||||
|
// class ExoticClass {
|
||||||
|
// public:
|
||||||
|
// ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
|
||||||
|
// ~ExoticClass() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
|
||||||
|
//
|
||||||
|
// void Shareable() { DFAKE_SCOPED_LOCK(shareable_section_); ... }
|
||||||
|
// void NotShareable() { DFAKE_SCOPED_LOCK_THREAD_LOCKED(ctor_dtor_); ... }
|
||||||
|
// ...
|
||||||
|
// private:
|
||||||
|
// DFAKE_MUTEX(ctor_dtor_);
|
||||||
|
// DFAKE_MUTEX(shareable_section_);
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
|
||||||
|
// Defines a class member that acts like a mutex. It is used only as a
|
||||||
|
// verification tool.
|
||||||
|
#define DFAKE_MUTEX(obj) \
|
||||||
|
mutable base::ThreadCollisionWarner obj
|
||||||
|
// Asserts the call is never called simultaneously in two threads. Used at
|
||||||
|
// member function scope.
|
||||||
|
#define DFAKE_SCOPED_LOCK(obj) \
|
||||||
|
base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj)
|
||||||
|
// Asserts the call is never called simultaneously in two threads. Used at
|
||||||
|
// member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks.
|
||||||
|
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \
|
||||||
|
base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj)
|
||||||
|
// Asserts the code is always executed in the same thread.
|
||||||
|
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \
|
||||||
|
base::ThreadCollisionWarner::Check check_##obj(&obj)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define DFAKE_MUTEX(obj) typedef void InternalFakeMutexType##obj
|
||||||
|
#define DFAKE_SCOPED_LOCK(obj) ((void)0)
|
||||||
|
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) ((void)0)
|
||||||
|
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) ((void)0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
// The class ThreadCollisionWarner uses an Asserter to notify the collision
|
||||||
|
// AsserterBase is the interfaces and DCheckAsserter is the default asserter
|
||||||
|
// used. During the unit tests is used another class that doesn't "DCHECK"
|
||||||
|
// in case of collision (check thread_collision_warner_unittests.cc)
|
||||||
|
struct AsserterBase {
|
||||||
|
virtual ~AsserterBase() {}
|
||||||
|
virtual void warn() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DCheckAsserter : public AsserterBase {
|
||||||
|
virtual ~DCheckAsserter() {}
|
||||||
|
virtual void warn() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ThreadCollisionWarner {
|
||||||
|
public:
|
||||||
|
// The parameter asserter is there only for test purpose
|
||||||
|
explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter())
|
||||||
|
: valid_thread_id_(0),
|
||||||
|
counter_(0),
|
||||||
|
asserter_(asserter) {}
|
||||||
|
|
||||||
|
~ThreadCollisionWarner() {
|
||||||
|
delete asserter_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This class is meant to be used through the macro
|
||||||
|
// DFAKE_SCOPED_LOCK_THREAD_LOCKED
|
||||||
|
// it doesn't leave the critical section, as opposed to ScopedCheck,
|
||||||
|
// because the critical section being pinned is allowed to be used only
|
||||||
|
// from one thread
|
||||||
|
class Check {
|
||||||
|
public:
|
||||||
|
explicit Check(ThreadCollisionWarner* warner)
|
||||||
|
: warner_(warner) {
|
||||||
|
warner_->EnterSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
~Check() {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ThreadCollisionWarner* warner_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(Check);
|
||||||
|
};
|
||||||
|
|
||||||
|
// This class is meant to be used through the macro
|
||||||
|
// DFAKE_SCOPED_LOCK
|
||||||
|
class ScopedCheck {
|
||||||
|
public:
|
||||||
|
explicit ScopedCheck(ThreadCollisionWarner* warner)
|
||||||
|
: warner_(warner) {
|
||||||
|
warner_->Enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedCheck() {
|
||||||
|
warner_->Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ThreadCollisionWarner* warner_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ScopedCheck);
|
||||||
|
};
|
||||||
|
|
||||||
|
// This class is meant to be used through the macro
|
||||||
|
// DFAKE_SCOPED_RECURSIVE_LOCK
|
||||||
|
class ScopedRecursiveCheck {
|
||||||
|
public:
|
||||||
|
explicit ScopedRecursiveCheck(ThreadCollisionWarner* warner)
|
||||||
|
: warner_(warner) {
|
||||||
|
warner_->EnterSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedRecursiveCheck() {
|
||||||
|
warner_->Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
ThreadCollisionWarner* warner_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ScopedRecursiveCheck);
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
// This method stores the current thread identifier and does a DCHECK
|
||||||
|
// if a another thread has already done it, it is safe if same thread
|
||||||
|
// calls this multiple time (recursion allowed).
|
||||||
|
void EnterSelf();
|
||||||
|
|
||||||
|
// Same as EnterSelf but recursion is not allowed.
|
||||||
|
void Enter();
|
||||||
|
|
||||||
|
// Removes the thread_id stored in order to allow other threads to
|
||||||
|
// call EnterSelf or Enter.
|
||||||
|
void Leave();
|
||||||
|
|
||||||
|
// This stores the thread id that is inside the critical section, if the
|
||||||
|
// value is 0 then no thread is inside.
|
||||||
|
volatile subtle::Atomic32 valid_thread_id_;
|
||||||
|
|
||||||
|
// Counter to trace how many time a critical section was "pinned"
|
||||||
|
// (when allowed) in order to unpin it when counter_ reaches 0.
|
||||||
|
volatile subtle::Atomic32 counter_;
|
||||||
|
|
||||||
|
// Here only for class unit tests purpose, during the test I need to not
|
||||||
|
// DCHECK but notify the collision with something else.
|
||||||
|
AsserterBase* asserter_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ThreadCollisionWarner);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_THREAD_COLLISION_WARNER_H_
|
||||||
@@ -140,7 +140,12 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(TRACE_EVENT0)
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -161,23 +166,26 @@
|
|||||||
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \
|
||||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||||
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
|
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
arg2_val) \
|
||||||
arg2_val, false); \
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, \
|
||||||
|
arg2_name, arg2_val, false); \
|
||||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||||
|
|
||||||
// Implementation detail: trace event macros create temporary variable names.
|
// Implementation detail: trace event macros create temporary variable names.
|
||||||
// These macros give each temporary variable a unique name based on the line
|
// These macros give each temporary variable a unique name based on the line
|
||||||
// number to prevent name collisions.
|
// number to prevent name collisions.
|
||||||
#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b
|
#define CEF_INTERNAL_TRACE_EVENT_UID3(a,b) \
|
||||||
#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) 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) \
|
#define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \
|
||||||
CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
|
CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
|
||||||
|
|
||||||
// Implementation detail: internal macro to end end event when the scope ends.
|
// Implementation detail: internal macro to end end event when the scope ends.
|
||||||
#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \
|
#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \
|
||||||
cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \
|
cef_trace_event::CefTraceEndOnScopeClose \
|
||||||
profileScope)(category, name)
|
CEF_INTERNAL_TRACE_EVENT_UID(profileScope)(category, name)
|
||||||
|
|
||||||
// Records a single event called "name" immediately, with 0, 1 or 2
|
// Records a single event called "name" immediately, with 0, 1 or 2
|
||||||
// associated arguments. If the category is not enabled, then this
|
// associated arguments. If the category is not enabled, then this
|
||||||
@@ -188,8 +196,8 @@
|
|||||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false)
|
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false)
|
||||||
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false)
|
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, \
|
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \
|
||||||
arg2_val) \
|
arg2_name, arg2_val) \
|
||||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, false)
|
arg2_val, false)
|
||||||
#define TRACE_EVENT_COPY_INSTANT0(category, name) \
|
#define TRACE_EVENT_COPY_INSTANT0(category, name) \
|
||||||
@@ -210,8 +218,8 @@
|
|||||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false)
|
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false)
|
||||||
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false)
|
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, \
|
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \
|
||||||
arg2_val) \
|
arg2_name, arg2_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, false)
|
arg2_val, false)
|
||||||
#define TRACE_EVENT_COPY_BEGIN0(category, name) \
|
#define TRACE_EVENT_COPY_BEGIN0(category, name) \
|
||||||
@@ -231,16 +239,16 @@
|
|||||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, false)
|
cef_trace_event_end(category, name, NULL, 0, NULL, 0, false)
|
||||||
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false)
|
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, \
|
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \
|
||||||
arg2_val) \
|
arg2_name, arg2_val) \
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, false)
|
arg2_val, false)
|
||||||
#define TRACE_EVENT_COPY_END0(category, name) \
|
#define TRACE_EVENT_COPY_END0(category, name) \
|
||||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, true)
|
cef_trace_event_end(category, name, NULL, 0, NULL, 0, true)
|
||||||
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true)
|
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, \
|
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \
|
||||||
arg2_val) \
|
arg2_name, arg2_val) \
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, true)
|
arg2_val, true)
|
||||||
|
|
||||||
@@ -258,8 +266,8 @@
|
|||||||
// values as a stacked-bar chart.
|
// values as a stacked-bar chart.
|
||||||
// - category and name strings must have application lifetime (statics or
|
// - category and name strings must have application lifetime (statics or
|
||||||
// literals). They may not include " chars.
|
// literals). They may not include " chars.
|
||||||
#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
|
#define TRACE_COUNTER2(category, name, value1_name, value1_val, \
|
||||||
value2_val) \
|
value2_name, value2_val) \
|
||||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
||||||
value2_val, false)
|
value2_val, false)
|
||||||
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
|
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
|
||||||
@@ -293,11 +301,12 @@
|
|||||||
value2_name, value2_val) \
|
value2_name, value2_val) \
|
||||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||||
value2_name, value2_val, false)
|
value2_name, value2_val, false)
|
||||||
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, \
|
||||||
value2_name, value2_val) \
|
value1_val, value2_name, value2_val) \
|
||||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||||
value2_name, value2_val, true)
|
value2_name, value2_val, true)
|
||||||
|
|
||||||
|
|
||||||
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
|
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
|
||||||
// associated arguments. If the category is not enabled, then this
|
// associated arguments. If the category is not enabled, then this
|
||||||
// does nothing.
|
// does nothing.
|
||||||
@@ -325,11 +334,12 @@
|
|||||||
arg2_name, arg2_val, false)
|
arg2_name, arg2_val, false)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \
|
#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \
|
||||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true)
|
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) \
|
#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, \
|
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
||||||
0, true)
|
0, true)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, \
|
||||||
arg2_name, arg2_val) \
|
arg1_val, arg2_name, arg2_val) \
|
||||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
||||||
arg2_name, arg2_val, true)
|
arg2_name, arg2_val, true)
|
||||||
|
|
||||||
@@ -341,14 +351,14 @@
|
|||||||
// ASYNC_STEP_PAST events.
|
// ASYNC_STEP_PAST events.
|
||||||
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
|
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false)
|
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, \
|
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, \
|
||||||
arg1_val) \
|
arg1_name, arg1_val) \
|
||||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
||||||
arg1_val, false)
|
arg1_val, false)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \
|
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true)
|
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, \
|
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, \
|
||||||
arg1_val) \
|
arg1_name, arg1_val) \
|
||||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
||||||
arg1_val, true)
|
arg1_val, true)
|
||||||
|
|
||||||
@@ -360,14 +370,14 @@
|
|||||||
// ASYNC_STEP_INTO events.
|
// ASYNC_STEP_INTO events.
|
||||||
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
|
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false)
|
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, \
|
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, \
|
||||||
arg1_val) \
|
arg1_name, arg1_val) \
|
||||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
||||||
arg1_val, false)
|
arg1_val, false)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \
|
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true)
|
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, \
|
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, \
|
||||||
arg1_val) \
|
arg1_name, arg1_val) \
|
||||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
||||||
arg1_val, true)
|
arg1_val, true)
|
||||||
|
|
||||||
@@ -384,11 +394,12 @@
|
|||||||
arg2_name, arg2_val, false)
|
arg2_name, arg2_val, false)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \
|
#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \
|
||||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true)
|
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) \
|
#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, \
|
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
||||||
true)
|
true)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, \
|
||||||
arg2_name, arg2_val) \
|
arg1_val, arg2_name, arg2_val) \
|
||||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
||||||
arg2_name, arg2_val, true)
|
arg2_name, arg2_val, true)
|
||||||
|
|
||||||
@@ -398,7 +409,8 @@ namespace cef_trace_event {
|
|||||||
class CefTraceEndOnScopeClose {
|
class CefTraceEndOnScopeClose {
|
||||||
public:
|
public:
|
||||||
CefTraceEndOnScopeClose(const char* category, const char* name)
|
CefTraceEndOnScopeClose(const char* category, const char* name)
|
||||||
: category_(category), name_(name) {}
|
: category_(category), name_(name) {
|
||||||
|
}
|
||||||
~CefTraceEndOnScopeClose() {
|
~CefTraceEndOnScopeClose() {
|
||||||
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false);
|
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@
|
|||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// 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,
|
// 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
|
// and which may be invalidated (i.e. reset to NULL) by the object, or its
|
||||||
// owner, at any time, most commonly when the object is about to be deleted.
|
// 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
|
// Weak pointers are useful when an object needs to be accessed safely by one
|
||||||
@@ -42,24 +42,25 @@
|
|||||||
//
|
//
|
||||||
// class Controller {
|
// class Controller {
|
||||||
// public:
|
// public:
|
||||||
|
// Controller() : weak_factory_(this) {}
|
||||||
// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
|
// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
|
||||||
// void WorkComplete(const Result& result) { ... }
|
// void WorkComplete(const Result& result) { ... }
|
||||||
// private:
|
// private:
|
||||||
// // Member variables should appear before the WeakPtrFactory, to ensure
|
// // Member variables should appear before the WeakPtrFactory, to ensure
|
||||||
// // that any WeakPtrs to Controller are invalidated before its members
|
// // that any WeakPtrs to Controller are invalidated before its members
|
||||||
// // variable's destructors are executed, rendering them invalid.
|
// // variable's destructors are executed, rendering them invalid.
|
||||||
// WeakPtrFactory<Controller> weak_factory_{this};
|
// WeakPtrFactory<Controller> weak_factory_;
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// class Worker {
|
// class Worker {
|
||||||
// public:
|
// public:
|
||||||
// static void StartNew(WeakPtr<Controller> controller) {
|
// static void StartNew(const WeakPtr<Controller>& controller) {
|
||||||
// Worker* worker = new Worker(std::move(controller));
|
// Worker* worker = new Worker(controller);
|
||||||
// // Kick off asynchronous processing...
|
// // Kick off asynchronous processing...
|
||||||
// }
|
// }
|
||||||
// private:
|
// private:
|
||||||
// Worker(WeakPtr<Controller> controller)
|
// Worker(const WeakPtr<Controller>& controller)
|
||||||
// : controller_(std::move(controller)) {}
|
// : controller_(controller) {}
|
||||||
// void DidCompleteAsynchronousProcessing(const Result& result) {
|
// void DidCompleteAsynchronousProcessing(const Result& result) {
|
||||||
// if (controller_)
|
// if (controller_)
|
||||||
// controller_->WorkComplete(result);
|
// controller_->WorkComplete(result);
|
||||||
@@ -74,19 +75,18 @@
|
|||||||
// ------------------------- IMPORTANT: Thread-safety -------------------------
|
// ------------------------- IMPORTANT: Thread-safety -------------------------
|
||||||
|
|
||||||
// Weak pointers may be passed safely between threads, but must always be
|
// Weak pointers may be passed safely between threads, but must always be
|
||||||
// dereferenced and invalidated on the same ThreaddTaskRunner otherwise
|
// dereferenced and invalidated on the same thread otherwise checking the
|
||||||
// checking the pointer would be racey.
|
// pointer would be racey.
|
||||||
//
|
//
|
||||||
// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory
|
// 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
|
// is dereferenced, the factory and its WeakPtrs become bound to the calling
|
||||||
// thread or current ThreaddWorkerPool token, and cannot be dereferenced or
|
// thread, and cannot be dereferenced or invalidated on any other thread. Bound
|
||||||
// invalidated on any other task runner. Bound WeakPtrs can still be handed
|
// WeakPtrs can still be handed off to other threads, e.g. to use to post tasks
|
||||||
// off to other task runners, e.g. to use to post tasks back to object on the
|
// back to object on the bound thread.
|
||||||
// bound thread.
|
|
||||||
//
|
//
|
||||||
// If all WeakPtr objects are destroyed or invalidated then the factory is
|
// If all WeakPtr objects are destroyed or invalidated then the factory is
|
||||||
// unbound from the ThreaddTaskRunner/Thread. The WeakPtrFactory may then be
|
// unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be
|
||||||
// destroyed, or new WeakPtr objects may be used, from a different thread.
|
// destroyed, or new WeakPtr objects may be used, from a different sequence.
|
||||||
//
|
//
|
||||||
// Thus, at least one WeakPtr object must exist and have been dereferenced on
|
// 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
|
// the correct thread to enforce that other WeakPtr objects will enforce they
|
||||||
@@ -96,7 +96,12 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(BASE_MEMORY_WEAK_PTR_H_)
|
||||||
|
// Do nothing if the Chromium header has already been included.
|
||||||
|
// 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.
|
||||||
|
#elif defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -104,30 +109,25 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <cstddef>
|
#include "include/base/cef_basictypes.h"
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
#include "include/base/cef_atomic_flag.h"
|
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
#include "include/base/cef_ref_counted.h"
|
#include "include/base/cef_ref_counted.h"
|
||||||
|
#include "include/base/cef_template_util.h"
|
||||||
#include "include/base/cef_thread_checker.h"
|
#include "include/base/cef_thread_checker.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> class SupportsWeakPtr;
|
||||||
class SupportsWeakPtr;
|
template <typename T> class WeakPtr;
|
||||||
template <typename T>
|
|
||||||
class WeakPtr;
|
|
||||||
|
|
||||||
namespace internal {
|
namespace cef_internal {
|
||||||
// These classes are part of the WeakPtr implementation.
|
// These classes are part of the WeakPtr implementation.
|
||||||
// DO NOT USE THESE CLASSES DIRECTLY YOURSELF.
|
// DO NOT USE THESE CLASSES DIRECTLY YOURSELF.
|
||||||
|
|
||||||
class WeakReference {
|
class WeakReference {
|
||||||
public:
|
public:
|
||||||
// Although Flag is bound to a specific ThreaddTaskRunner, it may be
|
// Although Flag is bound to a specific thread, it may be deleted from another
|
||||||
// deleted from another via base::WeakPtr::~WeakPtr().
|
// via base::WeakPtr::~WeakPtr().
|
||||||
class Flag : public RefCountedThreadSafe<Flag> {
|
class Flag : public RefCountedThreadSafe<Flag> {
|
||||||
public:
|
public:
|
||||||
Flag();
|
Flag();
|
||||||
@@ -135,30 +135,23 @@ class WeakReference {
|
|||||||
void Invalidate();
|
void Invalidate();
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
bool MaybeValid() const;
|
|
||||||
|
|
||||||
void DetachFromThread();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedThreadSafe<Flag>;
|
friend class base::RefCountedThreadSafe<Flag>;
|
||||||
|
|
||||||
~Flag();
|
~Flag();
|
||||||
|
|
||||||
base::ThreadChecker thread_checker_;
|
// The current Chromium implementation uses SequenceChecker instead of
|
||||||
AtomicFlag invalidated_;
|
// ThreadChecker to support SequencedWorkerPools. CEF does not yet expose
|
||||||
|
// the concept of SequencedWorkerPools.
|
||||||
|
ThreadChecker thread_checker_;
|
||||||
|
bool is_valid_;
|
||||||
};
|
};
|
||||||
|
|
||||||
WeakReference();
|
WeakReference();
|
||||||
explicit WeakReference(const scoped_refptr<Flag>& flag);
|
explicit WeakReference(const Flag* flag);
|
||||||
~WeakReference();
|
~WeakReference();
|
||||||
|
|
||||||
WeakReference(WeakReference&& other) noexcept;
|
bool is_valid() const;
|
||||||
WeakReference(const WeakReference& other);
|
|
||||||
WeakReference& operator=(WeakReference&& other) noexcept = default;
|
|
||||||
WeakReference& operator=(const WeakReference& other) = default;
|
|
||||||
|
|
||||||
bool IsValid() const;
|
|
||||||
bool MaybeValid() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scoped_refptr<const Flag> flag_;
|
scoped_refptr<const Flag> flag_;
|
||||||
@@ -171,12 +164,14 @@ class WeakReferenceOwner {
|
|||||||
|
|
||||||
WeakReference GetRef() const;
|
WeakReference GetRef() const;
|
||||||
|
|
||||||
bool HasRefs() const { return !flag_->HasOneRef(); }
|
bool HasRefs() const {
|
||||||
|
return flag_.get() && !flag_->HasOneRef();
|
||||||
|
}
|
||||||
|
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scoped_refptr<WeakReference::Flag> flag_;
|
mutable scoped_refptr<WeakReference::Flag> flag_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class simplifies the implementation of WeakPtr's type conversion
|
// This class simplifies the implementation of WeakPtr's type conversion
|
||||||
@@ -188,24 +183,10 @@ class WeakPtrBase {
|
|||||||
WeakPtrBase();
|
WeakPtrBase();
|
||||||
~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:
|
protected:
|
||||||
WeakPtrBase(const WeakReference& ref, uintptr_t ptr);
|
explicit WeakPtrBase(const WeakReference& ref);
|
||||||
|
|
||||||
WeakReference ref_;
|
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
|
// This class provides a common implementation of common functions that would
|
||||||
@@ -217,14 +198,13 @@ class SupportsWeakPtrBase {
|
|||||||
// conversion will only compile if there is exists a Base which inherits
|
// conversion will only compile if there is exists a Base which inherits
|
||||||
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
|
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
|
||||||
// function that makes calling this easier.
|
// function that makes calling this easier.
|
||||||
//
|
template<typename Derived>
|
||||||
// Precondition: t != nullptr
|
|
||||||
template <typename Derived>
|
|
||||||
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
|
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
|
||||||
static_assert(
|
typedef
|
||||||
std::is_base_of<internal::SupportsWeakPtrBase, Derived>::value,
|
is_convertible<Derived, cef_internal::SupportsWeakPtrBase&> convertible;
|
||||||
"AsWeakPtr argument must inherit from SupportsWeakPtr");
|
COMPILE_ASSERT(convertible::value,
|
||||||
return AsWeakPtrImpl<Derived>(t);
|
AsWeakPtr_argument_inherits_from_SupportsWeakPtr);
|
||||||
|
return AsWeakPtrImpl<Derived>(t, *t);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -232,17 +212,16 @@ class SupportsWeakPtrBase {
|
|||||||
// which is an instance of SupportsWeakPtr<Base>. We can then safely
|
// which is an instance of SupportsWeakPtr<Base>. We can then safely
|
||||||
// static_cast the Base* to a Derived*.
|
// static_cast the Base* to a Derived*.
|
||||||
template <typename Derived, typename Base>
|
template <typename Derived, typename Base>
|
||||||
static WeakPtr<Derived> AsWeakPtrImpl(SupportsWeakPtr<Base>* t) {
|
static WeakPtr<Derived> AsWeakPtrImpl(
|
||||||
WeakPtr<Base> ptr = t->AsWeakPtr();
|
Derived* t, const SupportsWeakPtr<Base>&) {
|
||||||
return WeakPtr<Derived>(
|
WeakPtr<Base> ptr = t->Base::AsWeakPtr();
|
||||||
ptr.ref_, static_cast<Derived*>(reinterpret_cast<Base*>(ptr.ptr_)));
|
return WeakPtr<Derived>(ptr.ref_, static_cast<Derived*>(ptr.ptr_));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace cef_internal
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> class WeakPtrFactory;
|
||||||
class WeakPtrFactory;
|
|
||||||
|
|
||||||
// The WeakPtr class holds a weak reference to |T*|.
|
// The WeakPtr class holds a weak reference to |T*|.
|
||||||
//
|
//
|
||||||
@@ -258,96 +237,66 @@ class WeakPtrFactory;
|
|||||||
// foo->method();
|
// foo->method();
|
||||||
//
|
//
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class WeakPtr : public internal::WeakPtrBase {
|
class WeakPtr : public cef_internal::WeakPtrBase {
|
||||||
public:
|
public:
|
||||||
WeakPtr() = default;
|
WeakPtr() : ptr_(NULL) {
|
||||||
WeakPtr(std::nullptr_t) {}
|
}
|
||||||
|
|
||||||
// Allow conversion from U to T provided U "is a" T. Note that this
|
// Allow conversion from U to T provided U "is a" T. Note that this
|
||||||
// is separate from the (implicit) copy and move constructors.
|
// is separate from the (implicit) copy constructor.
|
||||||
template <typename U>
|
template <typename U>
|
||||||
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other) {
|
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other), ptr_(other.ptr_) {
|
||||||
// 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 {
|
T* get() const { return ref_.is_valid() ? ptr_ : NULL; }
|
||||||
return ref_.IsValid() ? reinterpret_cast<T*>(ptr_) : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
T& operator*() const {
|
T& operator*() const {
|
||||||
CHECK(ref_.IsValid());
|
DCHECK(get() != NULL);
|
||||||
return *get();
|
return *get();
|
||||||
}
|
}
|
||||||
T* operator->() const {
|
T* operator->() const {
|
||||||
CHECK(ref_.IsValid());
|
DCHECK(get() != NULL);
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow conditionals to test validity, e.g. if (weak_ptr) {...};
|
// Allow WeakPtr<element_type> to be used in boolean expressions, but not
|
||||||
explicit operator bool() const { return get() != nullptr; }
|
// implicitly convertible to a real bool (which is dangerous).
|
||||||
|
|
||||||
// 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
|
// Note that this trick is only safe when the == and != operators
|
||||||
// instance isn't being re-assigned or reset() racily with this call.
|
// are declared explicitly, as otherwise "weak_ptr1 == weak_ptr2"
|
||||||
bool MaybeValid() const { return ref_.MaybeValid(); }
|
// will compile but do the wrong thing (i.e., convert to Testable
|
||||||
|
// and then do the comparison).
|
||||||
|
private:
|
||||||
|
typedef T* WeakPtr::*Testable;
|
||||||
|
|
||||||
// Returns whether the object |this| points to has been invalidated. This can
|
public:
|
||||||
// be used to distinguish a WeakPtr to a destroyed object from one that has
|
operator Testable() const { return get() ? &WeakPtr::ptr_ : NULL; }
|
||||||
// been explicitly set to null.
|
|
||||||
bool WasInvalidated() const { return ptr_ && !ref_.IsValid(); }
|
void reset() {
|
||||||
|
ref_ = cef_internal::WeakReference();
|
||||||
|
ptr_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class internal::SupportsWeakPtrBase;
|
// Explicitly declare comparison operators as required by the bool
|
||||||
template <typename U>
|
// trick, but keep them private.
|
||||||
friend class WeakPtr;
|
template <class U> bool operator==(WeakPtr<U> const&) const;
|
||||||
|
template <class U> bool operator!=(WeakPtr<U> const&) const;
|
||||||
|
|
||||||
|
friend class cef_internal::SupportsWeakPtrBase;
|
||||||
|
template <typename U> friend class WeakPtr;
|
||||||
friend class SupportsWeakPtr<T>;
|
friend class SupportsWeakPtr<T>;
|
||||||
friend class WeakPtrFactory<T>;
|
friend class WeakPtrFactory<T>;
|
||||||
|
|
||||||
WeakPtr(const internal::WeakReference& ref, T* ptr)
|
WeakPtr(const cef_internal::WeakReference& ref, T* ptr)
|
||||||
: WeakPtrBase(ref, reinterpret_cast<uintptr_t>(ptr)) {}
|
: WeakPtrBase(ref),
|
||||||
};
|
ptr_(ptr) {
|
||||||
|
}
|
||||||
|
|
||||||
// Allow callers to compare WeakPtrs against nullptr to test validity.
|
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
|
||||||
template <class T>
|
// value is undefined (as opposed to NULL).
|
||||||
bool operator!=(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
T* ptr_;
|
||||||
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
|
// A class may be composed of a WeakPtrFactory and thereby
|
||||||
// control how it exposes weak pointers to itself. This is helpful if you only
|
// control how it exposes weak pointers to itself. This is helpful if you only
|
||||||
@@ -355,16 +304,18 @@ class WeakPtrFactoryBase {
|
|||||||
// useful when working with primitive types. For example, you could have a
|
// 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.
|
// WeakPtrFactory<bool> that is used to pass around a weak reference to a bool.
|
||||||
template <class T>
|
template <class T>
|
||||||
class WeakPtrFactory : public internal::WeakPtrFactoryBase {
|
class WeakPtrFactory {
|
||||||
public:
|
public:
|
||||||
explicit WeakPtrFactory(T* ptr)
|
explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {
|
||||||
: WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}
|
}
|
||||||
|
|
||||||
~WeakPtrFactory() = default;
|
~WeakPtrFactory() {
|
||||||
|
ptr_ = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
WeakPtr<T> GetWeakPtr() const {
|
WeakPtr<T> GetWeakPtr() {
|
||||||
return WeakPtr<T>(weak_reference_owner_.GetRef(),
|
DCHECK(ptr_);
|
||||||
reinterpret_cast<T*>(ptr_));
|
return WeakPtr<T>(weak_reference_owner_.GetRef(), ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call this method to invalidate all existing weak pointers.
|
// Call this method to invalidate all existing weak pointers.
|
||||||
@@ -380,6 +331,8 @@ class WeakPtrFactory : public internal::WeakPtrFactoryBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
||||||
|
T* ptr_;
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory);
|
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -389,19 +342,19 @@ class WeakPtrFactory : public internal::WeakPtrFactoryBase {
|
|||||||
// weak pointers to the class until after the derived class' members have been
|
// weak pointers to the class until after the derived class' members have been
|
||||||
// destroyed, its use can lead to subtle use-after-destroy issues.
|
// destroyed, its use can lead to subtle use-after-destroy issues.
|
||||||
template <class T>
|
template <class T>
|
||||||
class SupportsWeakPtr : public internal::SupportsWeakPtrBase {
|
class SupportsWeakPtr : public cef_internal::SupportsWeakPtrBase {
|
||||||
public:
|
public:
|
||||||
SupportsWeakPtr() = default;
|
SupportsWeakPtr() {}
|
||||||
|
|
||||||
WeakPtr<T> AsWeakPtr() {
|
WeakPtr<T> AsWeakPtr() {
|
||||||
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
|
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~SupportsWeakPtr() = default;
|
~SupportsWeakPtr() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
internal::WeakReferenceOwner weak_reference_owner_;
|
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
||||||
DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr);
|
DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -425,7 +378,7 @@ class SupportsWeakPtr : public internal::SupportsWeakPtrBase {
|
|||||||
|
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
WeakPtr<Derived> AsWeakPtr(Derived* t) {
|
WeakPtr<Derived> AsWeakPtr(Derived* t) {
|
||||||
return internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
|
return cef_internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|||||||
126
include/base/internal/cef_atomicops_atomicword_compat.h
Normal file
126
include/base/internal/cef_atomicops_atomicword_compat.h
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
// 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_atomicops.h
|
||||||
|
// instead.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_
|
||||||
|
|
||||||
|
// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
|
||||||
|
// which in turn means int. On some LP32 platforms, intptr_t is an int, but
|
||||||
|
// on others, it's a long. When AtomicWord and Atomic32 are based on different
|
||||||
|
// fundamental types, their pointers are incompatible.
|
||||||
|
//
|
||||||
|
// This file defines function overloads to allow both AtomicWord and Atomic32
|
||||||
|
// data to be used with this interface.
|
||||||
|
//
|
||||||
|
// On LP64 platforms, AtomicWord and Atomic64 are both always long,
|
||||||
|
// so this problem doesn't occur.
|
||||||
|
|
||||||
|
#if !defined(ARCH_CPU_64_BITS)
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace subtle {
|
||||||
|
|
||||||
|
inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
|
||||||
|
AtomicWord old_value,
|
||||||
|
AtomicWord new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,
|
||||||
|
AtomicWord new_value) {
|
||||||
|
return NoBarrier_AtomicExchange(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,
|
||||||
|
AtomicWord increment) {
|
||||||
|
return NoBarrier_AtomicIncrement(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), increment);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,
|
||||||
|
AtomicWord increment) {
|
||||||
|
return Barrier_AtomicIncrement(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), increment);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
|
||||||
|
AtomicWord old_value,
|
||||||
|
AtomicWord new_value) {
|
||||||
|
return base::subtle::Acquire_CompareAndSwap(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
|
||||||
|
AtomicWord old_value,
|
||||||
|
AtomicWord new_value) {
|
||||||
|
return base::subtle::Release_CompareAndSwap(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {
|
||||||
|
NoBarrier_Store(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
||||||
|
return base::subtle::Acquire_Store(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
||||||
|
return base::subtle::Release_Store(
|
||||||
|
reinterpret_cast<volatile Atomic32*>(ptr), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) {
|
||||||
|
return NoBarrier_Load(
|
||||||
|
reinterpret_cast<volatile const Atomic32*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
|
||||||
|
return base::subtle::Acquire_Load(
|
||||||
|
reinterpret_cast<volatile const Atomic32*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
|
||||||
|
return base::subtle::Release_Load(
|
||||||
|
reinterpret_cast<volatile const Atomic32*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace base::subtle
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !defined(ARCH_CPU_64_BITS)
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_
|
||||||
223
include/base/internal/cef_atomicops_mac.h
Normal file
223
include/base/internal/cef_atomicops_mac.h
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
// 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_atomicops.h
|
||||||
|
// instead.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_
|
||||||
|
|
||||||
|
#include <libkern/OSAtomic.h>
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace subtle {
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
Atomic32 prev_value;
|
||||||
|
do {
|
||||||
|
if (OSAtomicCompareAndSwap32(old_value, new_value,
|
||||||
|
const_cast<Atomic32*>(ptr))) {
|
||||||
|
return old_value;
|
||||||
|
}
|
||||||
|
prev_value = *ptr;
|
||||||
|
} while (prev_value == old_value);
|
||||||
|
return prev_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
Atomic32 old_value;
|
||||||
|
do {
|
||||||
|
old_value = *ptr;
|
||||||
|
} while (!OSAtomicCompareAndSwap32(old_value, new_value,
|
||||||
|
const_cast<Atomic32*>(ptr)));
|
||||||
|
return old_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment) {
|
||||||
|
return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment) {
|
||||||
|
return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MemoryBarrier() {
|
||||||
|
OSMemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
Atomic32 prev_value;
|
||||||
|
do {
|
||||||
|
if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,
|
||||||
|
const_cast<Atomic32*>(ptr))) {
|
||||||
|
return old_value;
|
||||||
|
}
|
||||||
|
prev_value = *ptr;
|
||||||
|
} while (prev_value == old_value);
|
||||||
|
return prev_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
*ptr = value;
|
||||||
|
MemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
MemoryBarrier();
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||||
|
Atomic32 value = *ptr;
|
||||||
|
MemoryBarrier();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
|
MemoryBarrier();
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __LP64__
|
||||||
|
|
||||||
|
// 64-bit implementation on 64-bit platform
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
Atomic64 prev_value;
|
||||||
|
do {
|
||||||
|
if (OSAtomicCompareAndSwap64(old_value, new_value,
|
||||||
|
reinterpret_cast<volatile int64_t*>(ptr))) {
|
||||||
|
return old_value;
|
||||||
|
}
|
||||||
|
prev_value = *ptr;
|
||||||
|
} while (prev_value == old_value);
|
||||||
|
return prev_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
Atomic64 old_value;
|
||||||
|
do {
|
||||||
|
old_value = *ptr;
|
||||||
|
} while (!OSAtomicCompareAndSwap64(old_value, new_value,
|
||||||
|
reinterpret_cast<volatile int64_t*>(ptr)));
|
||||||
|
return old_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
|
Atomic64 increment) {
|
||||||
|
return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
|
Atomic64 increment) {
|
||||||
|
return OSAtomicAdd64Barrier(increment,
|
||||||
|
reinterpret_cast<volatile int64_t*>(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
Atomic64 prev_value;
|
||||||
|
do {
|
||||||
|
if (OSAtomicCompareAndSwap64Barrier(
|
||||||
|
old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
|
||||||
|
return old_value;
|
||||||
|
}
|
||||||
|
prev_value = *ptr;
|
||||||
|
} while (prev_value == old_value);
|
||||||
|
return prev_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
// The lib kern interface does not distinguish between
|
||||||
|
// Acquire and Release memory barriers; they are equivalent.
|
||||||
|
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
*ptr = value;
|
||||||
|
MemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
MemoryBarrier();
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||||
|
Atomic64 value = *ptr;
|
||||||
|
MemoryBarrier();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
|
MemoryBarrier();
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(__LP64__)
|
||||||
|
|
||||||
|
} // namespace base::subtle
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_
|
||||||
265
include/base/internal/cef_atomicops_x86_gcc.h
Normal file
265
include/base/internal/cef_atomicops_x86_gcc.h
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
// 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_atomicops.h
|
||||||
|
// instead.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_
|
||||||
|
|
||||||
|
// This struct is not part of the public API of this module; clients may not
|
||||||
|
// use it.
|
||||||
|
// Features of this x86. Values may not be correct before main() is run,
|
||||||
|
// but are set conservatively.
|
||||||
|
struct AtomicOps_x86CPUFeatureStruct {
|
||||||
|
bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence
|
||||||
|
// after acquire compare-and-swap.
|
||||||
|
};
|
||||||
|
extern struct AtomicOps_x86CPUFeatureStruct
|
||||||
|
AtomicOps_Internalx86CPUFeatures;
|
||||||
|
|
||||||
|
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace subtle {
|
||||||
|
|
||||||
|
// 32-bit low-level operations on any platform.
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
Atomic32 prev;
|
||||||
|
__asm__ __volatile__("lock; cmpxchgl %1,%2"
|
||||||
|
: "=a" (prev)
|
||||||
|
: "q" (new_value), "m" (*ptr), "0" (old_value)
|
||||||
|
: "memory");
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
__asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg.
|
||||||
|
: "=r" (new_value)
|
||||||
|
: "m" (*ptr), "0" (new_value)
|
||||||
|
: "memory");
|
||||||
|
return new_value; // Now it's the previous value.
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment) {
|
||||||
|
Atomic32 temp = increment;
|
||||||
|
__asm__ __volatile__("lock; xaddl %0,%1"
|
||||||
|
: "+r" (temp), "+m" (*ptr)
|
||||||
|
: : "memory");
|
||||||
|
// temp now holds the old value of *ptr
|
||||||
|
return temp + increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment) {
|
||||||
|
Atomic32 temp = increment;
|
||||||
|
__asm__ __volatile__("lock; xaddl %0,%1"
|
||||||
|
: "+r" (temp), "+m" (*ptr)
|
||||||
|
: : "memory");
|
||||||
|
// temp now holds the old value of *ptr
|
||||||
|
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||||
|
__asm__ __volatile__("lfence" : : : "memory");
|
||||||
|
}
|
||||||
|
return temp + increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||||
|
__asm__ __volatile__("lfence" : : : "memory");
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MemoryBarrier() {
|
||||||
|
__asm__ __volatile__("mfence" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
*ptr = value;
|
||||||
|
MemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
ATOMICOPS_COMPILER_BARRIER();
|
||||||
|
*ptr = value; // An x86 store acts as a release barrier.
|
||||||
|
// See comments in Atomic64 version of Release_Store(), below.
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||||
|
Atomic32 value = *ptr; // An x86 load acts as a acquire barrier.
|
||||||
|
// See comments in Atomic64 version of Release_Store(), below.
|
||||||
|
ATOMICOPS_COMPILER_BARRIER();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
|
MemoryBarrier();
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__x86_64__)
|
||||||
|
|
||||||
|
// 64-bit low-level operations on 64-bit platform.
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
Atomic64 prev;
|
||||||
|
__asm__ __volatile__("lock; cmpxchgq %1,%2"
|
||||||
|
: "=a" (prev)
|
||||||
|
: "q" (new_value), "m" (*ptr), "0" (old_value)
|
||||||
|
: "memory");
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
__asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg.
|
||||||
|
: "=r" (new_value)
|
||||||
|
: "m" (*ptr), "0" (new_value)
|
||||||
|
: "memory");
|
||||||
|
return new_value; // Now it's the previous value.
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
|
Atomic64 increment) {
|
||||||
|
Atomic64 temp = increment;
|
||||||
|
__asm__ __volatile__("lock; xaddq %0,%1"
|
||||||
|
: "+r" (temp), "+m" (*ptr)
|
||||||
|
: : "memory");
|
||||||
|
// temp now contains the previous value of *ptr
|
||||||
|
return temp + increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
|
Atomic64 increment) {
|
||||||
|
Atomic64 temp = increment;
|
||||||
|
__asm__ __volatile__("lock; xaddq %0,%1"
|
||||||
|
: "+r" (temp), "+m" (*ptr)
|
||||||
|
: : "memory");
|
||||||
|
// temp now contains the previous value of *ptr
|
||||||
|
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||||
|
__asm__ __volatile__("lfence" : : : "memory");
|
||||||
|
}
|
||||||
|
return temp + increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
*ptr = value;
|
||||||
|
MemoryBarrier();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
ATOMICOPS_COMPILER_BARRIER();
|
||||||
|
|
||||||
|
*ptr = value; // An x86 store acts as a release barrier
|
||||||
|
// for current AMD/Intel chips as of Jan 2008.
|
||||||
|
// See also Acquire_Load(), below.
|
||||||
|
|
||||||
|
// When new chips come out, check:
|
||||||
|
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
|
||||||
|
// System Programming Guide, Chatper 7: Multiple-processor management,
|
||||||
|
// Section 7.2, Memory Ordering.
|
||||||
|
// Last seen at:
|
||||||
|
// http://developer.intel.com/design/pentium4/manuals/index_new.htm
|
||||||
|
//
|
||||||
|
// x86 stores/loads fail to act as barriers for a few instructions (clflush
|
||||||
|
// maskmovdqu maskmovq movntdq movnti movntpd movntps movntq) but these are
|
||||||
|
// not generated by the compiler, and are rare. Users of these instructions
|
||||||
|
// need to know about cache behaviour in any case since all of these involve
|
||||||
|
// either flushing cache lines or non-temporal cache hints.
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||||
|
Atomic64 value = *ptr; // An x86 load acts as a acquire barrier,
|
||||||
|
// for current AMD/Intel chips as of Jan 2008.
|
||||||
|
// See also Release_Store(), above.
|
||||||
|
ATOMICOPS_COMPILER_BARRIER();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
|
MemoryBarrier();
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
||||||
|
__asm__ __volatile__("lfence" : : : "memory");
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(__x86_64__)
|
||||||
|
|
||||||
|
} // namespace base::subtle
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#undef ATOMICOPS_COMPILER_BARRIER
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_
|
||||||
224
include/base/internal/cef_atomicops_x86_msvc.h
Normal file
224
include/base/internal/cef_atomicops_x86_msvc.h
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
// Copyright (c) 2008 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_atomicops.h
|
||||||
|
// instead.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <intrin.h>
|
||||||
|
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
|
|
||||||
|
#if defined(ARCH_CPU_64_BITS)
|
||||||
|
// windows.h #defines this (only on x64). This causes problems because the
|
||||||
|
// public API also uses MemoryBarrier at the public name for this fence. So, on
|
||||||
|
// X64, undef it, and call its documented
|
||||||
|
// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
|
||||||
|
// implementation directly.
|
||||||
|
#undef MemoryBarrier
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace subtle {
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
LONG result = _InterlockedCompareExchange(
|
||||||
|
reinterpret_cast<volatile LONG*>(ptr),
|
||||||
|
static_cast<LONG>(new_value),
|
||||||
|
static_cast<LONG>(old_value));
|
||||||
|
return static_cast<Atomic32>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
LONG result = _InterlockedExchange(
|
||||||
|
reinterpret_cast<volatile LONG*>(ptr),
|
||||||
|
static_cast<LONG>(new_value));
|
||||||
|
return static_cast<Atomic32>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment) {
|
||||||
|
return _InterlockedExchangeAdd(
|
||||||
|
reinterpret_cast<volatile LONG*>(ptr),
|
||||||
|
static_cast<LONG>(increment)) + increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
||||||
|
Atomic32 increment) {
|
||||||
|
return Barrier_AtomicIncrement(ptr, increment);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !(defined(_MSC_VER) && _MSC_VER >= 1400)
|
||||||
|
#error "We require at least vs2005 for MemoryBarrier"
|
||||||
|
#endif
|
||||||
|
inline void MemoryBarrier() {
|
||||||
|
#if defined(ARCH_CPU_64_BITS)
|
||||||
|
// See #undef and note at the top of this file.
|
||||||
|
__faststorefence();
|
||||||
|
#else
|
||||||
|
// We use MemoryBarrier from WinNT.h
|
||||||
|
::MemoryBarrier();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
||||||
|
Atomic32 old_value,
|
||||||
|
Atomic32 new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
NoBarrier_AtomicExchange(ptr, value);
|
||||||
|
// acts as a barrier in this implementation
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
||||||
|
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
|
||||||
|
// See comments in Atomic64 version of Release_Store() below.
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
||||||
|
Atomic32 value = *ptr;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
||||||
|
MemoryBarrier();
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
|
||||||
|
// 64-bit low-level operations on 64-bit platform.
|
||||||
|
|
||||||
|
COMPILE_ASSERT(sizeof(Atomic64) == sizeof(PVOID), atomic_word_is_atomic);
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
PVOID result = InterlockedCompareExchangePointer(
|
||||||
|
reinterpret_cast<volatile PVOID*>(ptr),
|
||||||
|
reinterpret_cast<PVOID>(new_value), reinterpret_cast<PVOID>(old_value));
|
||||||
|
return reinterpret_cast<Atomic64>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
PVOID result = InterlockedExchangePointer(
|
||||||
|
reinterpret_cast<volatile PVOID*>(ptr),
|
||||||
|
reinterpret_cast<PVOID>(new_value));
|
||||||
|
return reinterpret_cast<Atomic64>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
|
Atomic64 increment) {
|
||||||
|
return InterlockedExchangeAdd64(
|
||||||
|
reinterpret_cast<volatile LONGLONG*>(ptr),
|
||||||
|
static_cast<LONGLONG>(increment)) + increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
||||||
|
Atomic64 increment) {
|
||||||
|
return Barrier_AtomicIncrement(ptr, increment);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
NoBarrier_AtomicExchange(ptr, value);
|
||||||
|
// acts as a barrier in this implementation
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
||||||
|
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
|
||||||
|
|
||||||
|
// When new chips come out, check:
|
||||||
|
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
|
||||||
|
// System Programming Guide, Chatper 7: Multiple-processor management,
|
||||||
|
// Section 7.2, Memory Ordering.
|
||||||
|
// Last seen at:
|
||||||
|
// http://developer.intel.com/design/pentium4/manuals/index_new.htm
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
||||||
|
Atomic64 value = *ptr;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
||||||
|
MemoryBarrier();
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
||||||
|
Atomic64 old_value,
|
||||||
|
Atomic64 new_value) {
|
||||||
|
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // defined(_WIN64)
|
||||||
|
|
||||||
|
} // namespace base::subtle
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_
|
||||||
File diff suppressed because it is too large
Load Diff
390
include/base/internal/cef_bind_internal_win.h
Normal file
390
include/base/internal/cef_bind_internal_win.h
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
// 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_bind.h instead.
|
||||||
|
|
||||||
|
// Specializations of RunnableAdapter<> for Windows specific calling
|
||||||
|
// conventions. Please see base/bind_internal.h for more info.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_
|
||||||
|
|
||||||
|
// In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
|
||||||
|
// the same as __cdecl which would turn the following specializations into
|
||||||
|
// multiple definitions.
|
||||||
|
#if !defined(ARCH_CPU_X86_64)
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace cef_internal {
|
||||||
|
|
||||||
|
template <typename Functor>
|
||||||
|
class RunnableAdapter;
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 0.
|
||||||
|
template <typename R>
|
||||||
|
class RunnableAdapter<R(__stdcall *)()> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)();
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)())
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run() {
|
||||||
|
return function_();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)();
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 0.
|
||||||
|
template <typename R>
|
||||||
|
class RunnableAdapter<R(__fastcall *)()> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)();
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)())
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run() {
|
||||||
|
return function_();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)();
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 1.
|
||||||
|
template <typename R, typename A1>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
|
||||||
|
return function_(a1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 1.
|
||||||
|
template <typename R, typename A1>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
|
||||||
|
return function_(a1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 2.
|
||||||
|
template <typename R, typename A1, typename A2>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1, A2)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1, A2))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2) {
|
||||||
|
return function_(a1, a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1, A2);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 2.
|
||||||
|
template <typename R, typename A1, typename A2>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1, A2)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1, A2))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2) {
|
||||||
|
return function_(a1, a2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1, A2);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 3.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1, A2, A3)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3) {
|
||||||
|
return function_(a1, a2, a3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1, A2, A3);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 3.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1, A2, A3)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3) {
|
||||||
|
return function_(a1, a2, a3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1, A2, A3);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 4.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4) {
|
||||||
|
return function_(a1, a2, a3, a4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1, A2, A3, A4);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 4.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4) {
|
||||||
|
return function_(a1, a2, a3, a4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1, A2, A3, A4);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 5.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4, A5)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4, A5);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename CallbackParamTraits<A5>::ForwardType a5) {
|
||||||
|
return function_(a1, a2, a3, a4, a5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1, A2, A3, A4, A5);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 5.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4, A5)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4, A5);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename CallbackParamTraits<A5>::ForwardType a5) {
|
||||||
|
return function_(a1, a2, a3, a4, a5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1, A2, A3, A4, A5);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 6.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5, typename A6>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4, A5, A6)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4, A5, A6);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5, A6))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename CallbackParamTraits<A6>::ForwardType a6) {
|
||||||
|
return function_(a1, a2, a3, a4, a5, a6);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1, A2, A3, A4, A5, A6);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 6.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5, typename A6>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4, A5, A6)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4, A5, A6);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5, A6))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename CallbackParamTraits<A6>::ForwardType a6) {
|
||||||
|
return function_(a1, a2, a3, a4, a5, a6);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1, A2, A3, A4, A5, A6);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __stdcall Function: Arity 7.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5, typename A6, typename A7>
|
||||||
|
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4, A5, A6, A7)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5, A6, A7))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename CallbackParamTraits<A6>::ForwardType a6,
|
||||||
|
typename CallbackParamTraits<A7>::ForwardType a7) {
|
||||||
|
return function_(a1, a2, a3, a4, a5, a6, a7);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__stdcall *function_)(A1, A2, A3, A4, A5, A6, A7);
|
||||||
|
};
|
||||||
|
|
||||||
|
// __fastcall Function: Arity 7.
|
||||||
|
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||||
|
typename A5, typename A6, typename A7>
|
||||||
|
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4, A5, A6, A7)> {
|
||||||
|
public:
|
||||||
|
typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
|
||||||
|
|
||||||
|
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5, A6, A7))
|
||||||
|
: function_(function) {
|
||||||
|
}
|
||||||
|
|
||||||
|
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
||||||
|
typename CallbackParamTraits<A2>::ForwardType a2,
|
||||||
|
typename CallbackParamTraits<A3>::ForwardType a3,
|
||||||
|
typename CallbackParamTraits<A4>::ForwardType a4,
|
||||||
|
typename CallbackParamTraits<A5>::ForwardType a5,
|
||||||
|
typename CallbackParamTraits<A6>::ForwardType a6,
|
||||||
|
typename CallbackParamTraits<A7>::ForwardType a7) {
|
||||||
|
return function_(a1, a2, a3, a4, a5, a6, a7);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
R (__fastcall *function_)(A1, A2, A3, A4, A5, A6, A7);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cef_internal
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !defined(ARCH_CPU_X86_64)
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_
|
||||||
@@ -36,156 +36,72 @@
|
|||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||||
#define 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 <stddef.h>
|
||||||
|
|
||||||
|
#include "include/base/cef_atomic_ref_count.h"
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
#include "include/base/cef_ref_counted.h"
|
#include "include/base/cef_ref_counted.h"
|
||||||
|
#include "include/base/cef_scoped_ptr.h"
|
||||||
namespace base {
|
#include "include/base/cef_template_util.h"
|
||||||
|
|
||||||
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>
|
template <typename T>
|
||||||
using PassingType = std::conditional_t<std::is_scalar<T>::value, T, T&&>;
|
class ScopedVector;
|
||||||
|
|
||||||
// BindStateBase is used to provide an opaque handle that the Callback
|
namespace base {
|
||||||
// class can use to represent a function object with bound arguments. It
|
namespace cef_internal {
|
||||||
// behaves as an existential type that is used by a corresponding
|
class CallbackBase;
|
||||||
// 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 {
|
// At the base level, the only task is to add reference counting data. Don't use
|
||||||
IS_CANCELLED,
|
// RefCountedThreadSafe since it requires the destructor to be a virtual method.
|
||||||
MAYBE_VALID,
|
// 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.
|
||||||
using InvokeFuncStorage = void (*)();
|
class BindStateBase {
|
||||||
|
protected:
|
||||||
BindStateBase(const BindStateBase&) = delete;
|
explicit BindStateBase(void (*destructor)(BindStateBase*))
|
||||||
BindStateBase& operator=(const BindStateBase&) = delete;
|
: ref_count_(0), destructor_(destructor) {}
|
||||||
|
~BindStateBase() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
friend class scoped_refptr<BindStateBase>;
|
||||||
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 CallbackBase;
|
||||||
friend class CallbackBaseCopyable;
|
|
||||||
|
|
||||||
// Allowlist subclasses that access the destructor of BindStateBase.
|
void AddRef();
|
||||||
template <typename Functor, typename... BoundArgs>
|
void Release();
|
||||||
friend struct BindState;
|
|
||||||
friend struct ::base::FakeBindState;
|
|
||||||
|
|
||||||
bool IsCancelled() const {
|
AtomicRefCount ref_count_;
|
||||||
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|.
|
// Pointer to a function that will properly destroy |this|.
|
||||||
void (*destructor_)(const BindStateBase*);
|
void (*destructor_)(BindStateBase*);
|
||||||
bool (*query_cancellation_traits_)(const BindStateBase*,
|
|
||||||
CancellationQueryMode mode);
|
DISALLOW_COPY_AND_ASSIGN(BindStateBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Holds the Callback methods that don't require specialization to reduce
|
// Holds the Callback methods that don't require specialization to reduce
|
||||||
// template bloat.
|
// template bloat.
|
||||||
// CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and
|
|
||||||
// CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation.
|
|
||||||
class CallbackBase {
|
class CallbackBase {
|
||||||
public:
|
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).
|
// Returns true if Callback is null (doesn't refer to anything).
|
||||||
bool is_null() const { return !bind_state_; }
|
bool is_null() const { return bind_state_.get() == NULL; }
|
||||||
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.
|
// Returns the Callback into an uninitialized state.
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class FinallyExecutorCommon;
|
// In C++, it is safe to cast function pointers to function pointers of
|
||||||
friend class ThenAndCatchExecutorCommon;
|
// 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
|
||||||
template <typename ReturnType>
|
// the original type on usage.
|
||||||
friend class PostTaskExecutor;
|
typedef void(*InvokeFuncStorage)(void);
|
||||||
|
|
||||||
using InvokeFuncStorage = BindStateBase::InvokeFuncStorage;
|
|
||||||
|
|
||||||
// Returns true if this callback equals |other|. |other| may be null.
|
// Returns true if this callback equals |other|. |other| may be null.
|
||||||
bool EqualsInternal(const CallbackBase& other) const;
|
bool Equals(const CallbackBase& other) const;
|
||||||
|
|
||||||
constexpr inline CallbackBase();
|
|
||||||
|
|
||||||
// Allow initializing of |bind_state_| via the constructor to avoid default
|
// Allow initializing of |bind_state_| via the constructor to avoid default
|
||||||
// initialization of the scoped_refptr.
|
// initialization of the scoped_refptr. We do not also initialize
|
||||||
explicit inline CallbackBase(BindStateBase* bind_state);
|
// |polymorphic_invoke_| here because doing a normal assignment in the
|
||||||
|
// derived Callback templates makes for much nicer compiler errors.
|
||||||
InvokeFuncStorage polymorphic_invoke() const {
|
explicit CallbackBase(BindStateBase* bind_state);
|
||||||
return bind_state_->polymorphic_invoke_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force the destructor to be instantiated inside this translation unit so
|
// Force the destructor to be instantiated inside this translation unit so
|
||||||
// that our subclasses will not get inlined versions. Avoids more template
|
// that our subclasses will not get inlined versions. Avoids more template
|
||||||
@@ -193,83 +109,115 @@ class CallbackBase {
|
|||||||
~CallbackBase();
|
~CallbackBase();
|
||||||
|
|
||||||
scoped_refptr<BindStateBase> bind_state_;
|
scoped_refptr<BindStateBase> bind_state_;
|
||||||
|
InvokeFuncStorage polymorphic_invoke_;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr CallbackBase::CallbackBase() = default;
|
// A helper template to determine if given type is non-const move-only-type,
|
||||||
CallbackBase::CallbackBase(CallbackBase&&) noexcept = default;
|
// i.e. if a value of the given type should be passed via .Pass() in a
|
||||||
CallbackBase::CallbackBase(BindStateBase* bind_state)
|
// destructive way.
|
||||||
: bind_state_(AdoptRef(bind_state)) {}
|
template <typename T> struct IsMoveOnlyType {
|
||||||
|
template <typename U>
|
||||||
|
static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
|
||||||
|
|
||||||
// CallbackBase<Copyable> is a direct base class of Copyable Callbacks.
|
template <typename U>
|
||||||
class CallbackBaseCopyable : public CallbackBase {
|
static NoType Test(...);
|
||||||
public:
|
|
||||||
CallbackBaseCopyable(const CallbackBaseCopyable& c);
|
|
||||||
CallbackBaseCopyable(CallbackBaseCopyable&& c) noexcept = default;
|
|
||||||
CallbackBaseCopyable& operator=(const CallbackBaseCopyable& c);
|
|
||||||
CallbackBaseCopyable& operator=(CallbackBaseCopyable&& c) noexcept;
|
|
||||||
|
|
||||||
protected:
|
static const bool value = sizeof(Test<T>(0)) == sizeof(YesType) &&
|
||||||
constexpr CallbackBaseCopyable() = default;
|
!is_const<T>::value;
|
||||||
explicit CallbackBaseCopyable(BindStateBase* bind_state)
|
|
||||||
: CallbackBase(bind_state) {}
|
|
||||||
~CallbackBaseCopyable() = default;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helpers for the `Then()` implementation.
|
// This is a typetraits object that's used to take an argument type, and
|
||||||
template <typename OriginalCallback, typename ThenCallback>
|
// extract a suitable type for storing and forwarding arguments.
|
||||||
struct ThenHelper;
|
//
|
||||||
|
// In particular, it strips off references, and converts arrays to
|
||||||
// Specialization when original callback returns `void`.
|
// pointers for storage; and it avoids accidentally trying to create a
|
||||||
template <template <typename> class OriginalCallback,
|
// "reference of a reference" if the argument is a reference type.
|
||||||
template <typename>
|
//
|
||||||
class ThenCallback,
|
// This array type becomes an issue for storage because we are passing bound
|
||||||
typename... OriginalArgs,
|
// parameters by const reference. In this case, we end up passing an actual
|
||||||
typename ThenR,
|
// array type in the initializer list which C++ does not allow. This will
|
||||||
typename... ThenArgs>
|
// break passing of C-string literals.
|
||||||
struct ThenHelper<OriginalCallback<void(OriginalArgs...)>,
|
template <typename T, bool is_move_only = IsMoveOnlyType<T>::value>
|
||||||
ThenCallback<ThenR(ThenArgs...)>> {
|
struct CallbackParamTraits {
|
||||||
static_assert(sizeof...(ThenArgs) == 0,
|
typedef const T& ForwardType;
|
||||||
"|then| callback cannot accept parameters if |this| has a "
|
typedef T StorageType;
|
||||||
"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.
|
// The Storage should almost be impossible to trigger unless someone manually
|
||||||
template <template <typename> class OriginalCallback,
|
// specifies type of the bind parameters. However, in case they do,
|
||||||
template <typename>
|
// this will guard against us accidentally storing a reference parameter.
|
||||||
class ThenCallback,
|
//
|
||||||
typename OriginalR,
|
// The ForwardType should only be used for unbound arguments.
|
||||||
typename... OriginalArgs,
|
template <typename T>
|
||||||
typename ThenR,
|
struct CallbackParamTraits<T&, false> {
|
||||||
typename... ThenArgs>
|
typedef T& ForwardType;
|
||||||
struct ThenHelper<OriginalCallback<OriginalR(OriginalArgs...)>,
|
typedef T StorageType;
|
||||||
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
|
// Note that for array types, we implicitly add a const in the conversion. This
|
||||||
|
// means that it is not possible to bind array arguments to functions that take
|
||||||
|
// a non-const pointer. Trying to specialize the template based on a "const
|
||||||
|
// T[n]" does not seem to match correctly, so we are stuck with this
|
||||||
|
// restriction.
|
||||||
|
template <typename T, size_t n>
|
||||||
|
struct CallbackParamTraits<T[n], false> {
|
||||||
|
typedef const T* ForwardType;
|
||||||
|
typedef const T* StorageType;
|
||||||
|
};
|
||||||
|
|
||||||
|
// See comment for CallbackParamTraits<T[n]>.
|
||||||
|
template <typename T>
|
||||||
|
struct CallbackParamTraits<T[], false> {
|
||||||
|
typedef const T* ForwardType;
|
||||||
|
typedef const T* StorageType;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Parameter traits for movable-but-not-copyable scopers.
|
||||||
|
//
|
||||||
|
// Callback<>/Bind() understands movable-but-not-copyable semantics where
|
||||||
|
// the type cannot be copied but can still have its state destructively
|
||||||
|
// transferred (aka. moved) to another instance of the same type by calling a
|
||||||
|
// helper function. When used with Bind(), this signifies transferal of the
|
||||||
|
// object's state to the target function.
|
||||||
|
//
|
||||||
|
// For these types, the ForwardType must not be a const reference, or a
|
||||||
|
// reference. A const reference is inappropriate, and would break const
|
||||||
|
// correctness, because we are implementing a destructive move. A non-const
|
||||||
|
// reference cannot be used with temporaries which means the result of a
|
||||||
|
// function or a cast would not be usable with Callback<> or Bind().
|
||||||
|
template <typename T>
|
||||||
|
struct CallbackParamTraits<T, true> {
|
||||||
|
typedef T ForwardType;
|
||||||
|
typedef T StorageType;
|
||||||
|
};
|
||||||
|
|
||||||
|
// CallbackForward() is a very limited simulation of C++11's std::forward()
|
||||||
|
// used by the Callback/Bind system for a set of movable-but-not-copyable
|
||||||
|
// types. It is needed because forwarding a movable-but-not-copyable
|
||||||
|
// argument to another function requires us to invoke the proper move
|
||||||
|
// operator to create a rvalue version of the type. The supported types are
|
||||||
|
// whitelisted below as overloads of the CallbackForward() function. The
|
||||||
|
// default template compiles out to be a no-op.
|
||||||
|
//
|
||||||
|
// In C++11, std::forward would replace all uses of this function. However, it
|
||||||
|
// is impossible to implement a general std::forward with C++11 due to a lack
|
||||||
|
// of rvalue references.
|
||||||
|
//
|
||||||
|
// In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to
|
||||||
|
// simulate std::forward() and forward the result of one Callback as a
|
||||||
|
// parameter to another callback. This is to support Callbacks that return
|
||||||
|
// the movable-but-not-copyable types whitelisted above.
|
||||||
|
template <typename T>
|
||||||
|
typename enable_if<!IsMoveOnlyType<T>::value, T>::type& CallbackForward(T& t) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) {
|
||||||
|
return t.Pass();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cef_internal
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
|
|
||||||
// reserved. Use of this source code is governed by a BSD-style license that
|
|
||||||
// can be found in the LICENSE file.
|
|
||||||
//
|
|
||||||
// Include net error codes from the Chromium source location. When creating a
|
|
||||||
// CEF binary distribution this file will be replaced with the Chromium version.
|
|
||||||
|
|
||||||
#include "net/base/net_error_list.h"
|
|
||||||
@@ -32,9 +32,10 @@
|
|||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||||
#define 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_build.h"
|
||||||
|
#include "include/base/cef_ref_counted.h"
|
||||||
#include "include/base/cef_template_util.h"
|
#include "include/base/cef_template_util.h"
|
||||||
|
#include "include/base/cef_tuple.h"
|
||||||
|
|
||||||
// It is dangerous to post a task with a T* argument where T is a subtype of
|
// 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
|
// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
|
||||||
@@ -45,30 +46,108 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
// This is a base internal implementation file used by task.h and callback.h.
|
namespace cef_internal {
|
||||||
// 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>
|
template <typename T>
|
||||||
struct IsRefCountedType<T,
|
struct NeedsScopedRefptrButGetsRawPtr {
|
||||||
void_t<decltype(std::declval<T*>()->AddRef()),
|
#if defined(OS_WIN)
|
||||||
decltype(std::declval<T*>()->Release())>>
|
enum {
|
||||||
: std::true_type {};
|
value = base::false_type::value
|
||||||
|
};
|
||||||
// Human readable translation: you needed to be a scoped_refptr if you are a raw
|
#else
|
||||||
// pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) type.
|
enum {
|
||||||
template <typename T>
|
// Human readable translation: you needed to be a scoped_refptr if you are a
|
||||||
struct NeedsScopedRefptrButGetsRawPtr
|
// raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase)
|
||||||
: conjunction<std::is_pointer<T>,
|
// type.
|
||||||
IsRefCountedType<std::remove_pointer_t<T>>> {
|
value = (is_pointer<T>::value &&
|
||||||
static_assert(!std::is_reference<T>::value,
|
(is_convertible<T, subtle::RefCountedBase*>::value ||
|
||||||
"NeedsScopedRefptrButGetsRawPtr requires non-reference type.");
|
is_convertible<T, subtle::RefCountedThreadSafeBase*>::value))
|
||||||
|
};
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace internal
|
template <typename Params>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly {
|
||||||
|
enum { value = 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple0> {
|
||||||
|
enum { value = 1 };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple1<A> > {
|
||||||
|
enum { value = !NeedsScopedRefptrButGetsRawPtr<A>::value };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple2<A, B> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, typename C>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple3<A, B, C> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<C>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, typename C, typename D>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple4<A, B, C, D> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<D>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, typename C, typename D, typename E>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple5<A, B, C, D, E> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<E>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, typename C, typename D, typename E,
|
||||||
|
typename F>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple6<A, B, C, D, E, F> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<E>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<F>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, typename C, typename D, typename E,
|
||||||
|
typename F, typename G>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple7<A, B, C, D, E, F, G> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<E>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<F>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<G>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename A, typename B, typename C, typename D, typename E,
|
||||||
|
typename F, typename G, typename H>
|
||||||
|
struct ParamsUseScopedRefptrCorrectly<Tuple8<A, B, C, D, E, F, G, H> > {
|
||||||
|
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<E>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<F>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<G>::value ||
|
||||||
|
NeedsScopedRefptrButGetsRawPtr<H>::value) };
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cef_internal
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
// Do not include this header file directly. Use base/mac/scoped_block.h
|
|
||||||
// instead.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_BLOCK_MAC_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_BLOCK_MAC_H_
|
|
||||||
|
|
||||||
#include <Block.h>
|
|
||||||
|
|
||||||
#include "include/base/cef_scoped_typeref_mac.h"
|
|
||||||
|
|
||||||
#if defined(__has_feature) && __has_feature(objc_arc)
|
|
||||||
#error "Cannot include include/base/internal/cef_scoped_block_mac.h in file built with ARC."
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace mac {
|
|
||||||
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template <typename B>
|
|
||||||
struct ScopedBlockTraits {
|
|
||||||
static B InvalidValue() { return nullptr; }
|
|
||||||
static B Retain(B block) { return Block_copy(block); }
|
|
||||||
static void Release(B block) { Block_release(block); }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
// ScopedBlock<> is patterned after ScopedCFTypeRef<>, but uses Block_copy() and
|
|
||||||
// Block_release() instead of CFRetain() and CFRelease().
|
|
||||||
template <typename B>
|
|
||||||
using ScopedBlock = ScopedTypeRef<B, internal::ScopedBlockTraits<B>>;
|
|
||||||
|
|
||||||
} // namespace mac
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_BLOCK_MAC_H_
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
// 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_
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=c487e5fd787b1be8224a8981839e0cfdd0ed74f3$
|
|
||||||
//
|
|
||||||
|
|
||||||
#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_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=a4b63e6e7942e3a3961b4f7141a963980178ae6f$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||||
@@ -61,7 +59,7 @@ typedef struct _cef_app_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Provides an opportunity to view and/or modify command-line arguments before
|
// Provides an opportunity to view and/or modify command-line arguments before
|
||||||
@@ -74,9 +72,8 @@ typedef struct _cef_app_t {
|
|||||||
// modify command-line arguments for non-browser processes as this may result
|
// modify command-line arguments for non-browser processes as this may result
|
||||||
// in undefined behavior including crashes.
|
// in undefined behavior including crashes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_command_line_processing)(
|
void (CEF_CALLBACK *on_before_command_line_processing)(
|
||||||
struct _cef_app_t* self,
|
struct _cef_app_t* self, const cef_string_t* process_type,
|
||||||
const cef_string_t* process_type,
|
|
||||||
struct _cef_command_line_t* command_line);
|
struct _cef_command_line_t* command_line);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -85,8 +82,7 @@ typedef struct _cef_app_t {
|
|||||||
// each process and the registered schemes should be the same across all
|
// each process and the registered schemes should be the same across all
|
||||||
// processes.
|
// processes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_register_custom_schemes)(
|
void (CEF_CALLBACK *on_register_custom_schemes)(struct _cef_app_t* self,
|
||||||
struct _cef_app_t* self,
|
|
||||||
struct _cef_scheme_registrar_t* registrar);
|
struct _cef_scheme_registrar_t* registrar);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -95,24 +91,25 @@ typedef struct _cef_app_t {
|
|||||||
// If no handler is returned resources will be loaded from pack files. This
|
// 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.
|
// function is called by the browser and render processes on multiple threads.
|
||||||
///
|
///
|
||||||
struct _cef_resource_bundle_handler_t*(
|
struct _cef_resource_bundle_handler_t* (
|
||||||
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK *get_resource_bundle_handler)(struct _cef_app_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for functionality specific to the browser process. This
|
// Return the handler for functionality specific to the browser process. This
|
||||||
// function is called on multiple threads in the browser process.
|
// function is called on multiple threads in the browser process.
|
||||||
///
|
///
|
||||||
struct _cef_browser_process_handler_t*(
|
struct _cef_browser_process_handler_t* (
|
||||||
CEF_CALLBACK* get_browser_process_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK *get_browser_process_handler)(struct _cef_app_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for functionality specific to the render process. This
|
// Return the handler for functionality specific to the render process. This
|
||||||
// function is called on the render process main thread.
|
// function is called on the render process main thread.
|
||||||
///
|
///
|
||||||
struct _cef_render_process_handler_t*(
|
struct _cef_render_process_handler_t* (
|
||||||
CEF_CALLBACK* get_render_process_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK *get_render_process_handler)(struct _cef_app_t* self);
|
||||||
} cef_app_t;
|
} cef_app_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called from the application entry point function to
|
// 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
|
// execute a secondary process. It can be used to run secondary processes from
|
||||||
@@ -126,8 +123,7 @@ typedef struct _cef_app_t {
|
|||||||
// cef_sandbox_win.h for details).
|
// cef_sandbox_win.h for details).
|
||||||
///
|
///
|
||||||
CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
|
CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
|
||||||
cef_app_t* application,
|
cef_app_t* application, void* windows_sandbox_info);
|
||||||
void* windows_sandbox_info);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to initialize
|
// This function should be called on the main application thread to initialize
|
||||||
@@ -137,8 +133,7 @@ CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
|
|||||||
// be NULL (see cef_sandbox_win.h for details).
|
// be NULL (see cef_sandbox_win.h for details).
|
||||||
///
|
///
|
||||||
CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
|
CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
|
||||||
const struct _cef_settings_t* settings,
|
const struct _cef_settings_t* settings, cef_app_t* application,
|
||||||
cef_app_t* application,
|
|
||||||
void* windows_sandbox_info);
|
void* windows_sandbox_info);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=7a483ed552ecca4f1aaa03800d366beca1ea2dee$
|
|
||||||
//
|
|
||||||
|
|
||||||
#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. OnAudioSteamStopped 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_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=2b9508a328ed0218e2c576af455f8d76e5978545$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure used for asynchronous continuation of authentication
|
// Callback structure used for asynchronous continuation of authentication
|
||||||
// requests.
|
// requests.
|
||||||
@@ -54,21 +53,21 @@ typedef struct _cef_auth_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue the authentication request.
|
// Continue the authentication request.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_auth_callback_t* self,
|
void (CEF_CALLBACK *cont)(struct _cef_auth_callback_t* self,
|
||||||
const cef_string_t* username,
|
const cef_string_t* username, const cef_string_t* password);
|
||||||
const cef_string_t* password);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel the authentication request.
|
// Cancel the authentication request.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_auth_callback_t* self);
|
void (CEF_CALLBACK *cancel)(struct _cef_auth_callback_t* self);
|
||||||
} cef_auth_callback_t;
|
} cef_auth_callback_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
|
||||||
|
|
||||||
@@ -44,9 +45,10 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// All ref-counted framework structures must include this structure first.
|
// Structure defining the reference count implementation functions. All
|
||||||
|
// framework structures must include the cef_base_t structure first.
|
||||||
///
|
///
|
||||||
typedef struct _cef_base_ref_counted_t {
|
typedef struct _cef_base_t {
|
||||||
///
|
///
|
||||||
// Size of the data structure.
|
// Size of the data structure.
|
||||||
///
|
///
|
||||||
@@ -56,50 +58,31 @@ typedef struct _cef_base_ref_counted_t {
|
|||||||
// Called to increment the reference count for the object. Should be called
|
// Called to increment the reference count for the object. Should be called
|
||||||
// for every new copy of a pointer to a given object.
|
// for every new copy of a pointer to a given object.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* add_ref)(struct _cef_base_ref_counted_t* self);
|
void (CEF_CALLBACK *add_ref)(struct _cef_base_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to decrement the reference count for the object. If the reference
|
// 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
|
// count falls to 0 the object should self-delete. Returns true (1) if the
|
||||||
// resulting reference count is 0.
|
// resulting reference count is 0.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* release)(struct _cef_base_ref_counted_t* self);
|
int (CEF_CALLBACK *release)(struct _cef_base_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the current reference count is 1.
|
// Returns true (1) if the current reference count is 1.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_one_ref)(struct _cef_base_ref_counted_t* self);
|
int (CEF_CALLBACK *has_one_ref)(struct _cef_base_t* self);
|
||||||
|
} cef_base_t;
|
||||||
|
|
||||||
///
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
///
|
// Check that the structure |s|, which is defined with a cef_base_t member named
|
||||||
// All scoped framework structures must include this structure first.
|
// |base|, is large enough to contain the specified member |f|.
|
||||||
///
|
|
||||||
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) \
|
#define CEF_MEMBER_EXISTS(s, f) \
|
||||||
((intptr_t) & \
|
((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= \
|
||||||
((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= *reinterpret_cast<size_t*>(s))
|
reinterpret_cast<cef_base_t*>(s)->size)
|
||||||
|
|
||||||
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
|
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,22 +33,21 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=ade537f836add7fe0b5fd94ceba26d678abb3e43$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#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_command_line_capi.h"
|
||||||
|
#include "include/capi/cef_print_handler_capi.h"
|
||||||
#include "include/capi/cef_values_capi.h"
|
#include "include/capi/cef_values_capi.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to implement browser process callbacks. The functions of this
|
// Structure used to implement browser process callbacks. The functions of this
|
||||||
// structure will be called on the browser process main thread unless otherwise
|
// structure will be called on the browser process main thread unless otherwise
|
||||||
@@ -58,13 +57,13 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process UI thread immediately after the CEF context
|
// Called on the browser process UI thread immediately after the CEF context
|
||||||
// has been initialized.
|
// has been initialized.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_context_initialized)(
|
void (CEF_CALLBACK *on_context_initialized)(
|
||||||
struct _cef_browser_process_handler_t* self);
|
struct _cef_browser_process_handler_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -74,10 +73,28 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
// opportunity to modify the child process command line. Do not keep a
|
// opportunity to modify the child process command line. Do not keep a
|
||||||
// reference to |command_line| outside of this function.
|
// reference to |command_line| outside of this function.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_child_process_launch)(
|
void (CEF_CALLBACK *on_before_child_process_launch)(
|
||||||
struct _cef_browser_process_handler_t* self,
|
struct _cef_browser_process_handler_t* self,
|
||||||
struct _cef_command_line_t* command_line);
|
struct _cef_command_line_t* command_line);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called on the browser process IO thread after the main thread has been
|
||||||
|
// created for a new render process. Provides an opportunity to specify extra
|
||||||
|
// information that will be passed to
|
||||||
|
// cef_render_process_handler_t::on_render_thread_created() in the render
|
||||||
|
// process. Do not keep a reference to |extra_info| outside of this function.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_render_process_thread_created)(
|
||||||
|
struct _cef_browser_process_handler_t* self,
|
||||||
|
struct _cef_list_value_t* extra_info);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Return the handler for printing on Linux. If a print handler is not
|
||||||
|
// provided then printing will not be supported on the Linux platform.
|
||||||
|
///
|
||||||
|
struct _cef_print_handler_t* (CEF_CALLBACK *get_print_handler)(
|
||||||
|
struct _cef_browser_process_handler_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called from any thread when work has been scheduled for the browser process
|
// Called from any thread when work has been scheduled for the browser process
|
||||||
// main (UI) thread. This callback is used in combination with CefSettings.
|
// main (UI) thread. This callback is used in combination with CefSettings.
|
||||||
@@ -91,21 +108,11 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
// specified delay and any currently pending scheduled call should be
|
// specified delay and any currently pending scheduled call should be
|
||||||
// cancelled.
|
// cancelled.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_schedule_message_pump_work)(
|
void (CEF_CALLBACK *on_schedule_message_pump_work)(
|
||||||
struct _cef_browser_process_handler_t* self,
|
struct _cef_browser_process_handler_t* self, int64 delay_ms);
|
||||||
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;
|
} cef_browser_process_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=cd8c183355a6808abd763ecc0396b5da6c15b3f9$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Generic callback structure used for asynchronous continuation.
|
// Generic callback structure used for asynchronous continuation.
|
||||||
///
|
///
|
||||||
@@ -53,19 +52,20 @@ typedef struct _cef_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue processing.
|
// Continue processing.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_callback_t* self);
|
void (CEF_CALLBACK *cont)(struct _cef_callback_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel processing.
|
// Cancel processing.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_callback_t* self);
|
void (CEF_CALLBACK *cancel)(struct _cef_callback_t* self);
|
||||||
} cef_callback_t;
|
} cef_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Generic callback structure used for asynchronous completion.
|
// Generic callback structure used for asynchronous completion.
|
||||||
///
|
///
|
||||||
@@ -73,14 +73,15 @@ typedef struct _cef_completion_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called once the task is complete.
|
// Method that will be called once the task is complete.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_complete)(struct _cef_completion_callback_t* self);
|
void (CEF_CALLBACK *on_complete)(struct _cef_completion_callback_t* self);
|
||||||
} cef_completion_callback_t;
|
} cef_completion_callback_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,14 +33,11 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=845a1d1dda63a06f4ae33ed39acfd2599b46a885$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/capi/cef_audio_handler_capi.h"
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
#include "include/capi/cef_context_menu_handler_capi.h"
|
#include "include/capi/cef_context_menu_handler_capi.h"
|
||||||
#include "include/capi/cef_dialog_handler_capi.h"
|
#include "include/capi/cef_dialog_handler_capi.h"
|
||||||
@@ -49,12 +46,11 @@
|
|||||||
#include "include/capi/cef_drag_handler_capi.h"
|
#include "include/capi/cef_drag_handler_capi.h"
|
||||||
#include "include/capi/cef_find_handler_capi.h"
|
#include "include/capi/cef_find_handler_capi.h"
|
||||||
#include "include/capi/cef_focus_handler_capi.h"
|
#include "include/capi/cef_focus_handler_capi.h"
|
||||||
#include "include/capi/cef_frame_handler_capi.h"
|
#include "include/capi/cef_geolocation_handler_capi.h"
|
||||||
#include "include/capi/cef_jsdialog_handler_capi.h"
|
#include "include/capi/cef_jsdialog_handler_capi.h"
|
||||||
#include "include/capi/cef_keyboard_handler_capi.h"
|
#include "include/capi/cef_keyboard_handler_capi.h"
|
||||||
#include "include/capi/cef_life_span_handler_capi.h"
|
#include "include/capi/cef_life_span_handler_capi.h"
|
||||||
#include "include/capi/cef_load_handler_capi.h"
|
#include "include/capi/cef_load_handler_capi.h"
|
||||||
#include "include/capi/cef_print_handler_capi.h"
|
|
||||||
#include "include/capi/cef_process_message_capi.h"
|
#include "include/capi/cef_process_message_capi.h"
|
||||||
#include "include/capi/cef_render_handler_capi.h"
|
#include "include/capi/cef_render_handler_capi.h"
|
||||||
#include "include/capi/cef_request_handler_capi.h"
|
#include "include/capi/cef_request_handler_capi.h"
|
||||||
@@ -63,6 +59,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to provide handler implementations.
|
// Implement this structure to provide handler implementations.
|
||||||
///
|
///
|
||||||
@@ -70,124 +67,108 @@ typedef struct _cef_client_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
|
||||||
// Return the handler for audio rendering events.
|
|
||||||
///
|
|
||||||
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
|
|
||||||
struct _cef_client_t* self);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for context menus. If no handler is provided the default
|
// Return the handler for context menus. If no handler is provided the default
|
||||||
// implementation will be used.
|
// implementation will be used.
|
||||||
///
|
///
|
||||||
struct _cef_context_menu_handler_t*(CEF_CALLBACK* get_context_menu_handler)(
|
struct _cef_context_menu_handler_t* (CEF_CALLBACK *get_context_menu_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for dialogs. If no handler is provided the default
|
// Return the handler for dialogs. If no handler is provided the default
|
||||||
// implementation will be used.
|
// implementation will be used.
|
||||||
///
|
///
|
||||||
struct _cef_dialog_handler_t*(CEF_CALLBACK* get_dialog_handler)(
|
struct _cef_dialog_handler_t* (CEF_CALLBACK *get_dialog_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser display state events.
|
// Return the handler for browser display state events.
|
||||||
///
|
///
|
||||||
struct _cef_display_handler_t*(CEF_CALLBACK* get_display_handler)(
|
struct _cef_display_handler_t* (CEF_CALLBACK *get_display_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for download events. If no handler is returned downloads
|
// Return the handler for download events. If no handler is returned downloads
|
||||||
// will not be allowed.
|
// will not be allowed.
|
||||||
///
|
///
|
||||||
struct _cef_download_handler_t*(CEF_CALLBACK* get_download_handler)(
|
struct _cef_download_handler_t* (CEF_CALLBACK *get_download_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for drag events.
|
// Return the handler for drag events.
|
||||||
///
|
///
|
||||||
struct _cef_drag_handler_t*(CEF_CALLBACK* get_drag_handler)(
|
struct _cef_drag_handler_t* (CEF_CALLBACK *get_drag_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for find result events.
|
// Return the handler for find result events.
|
||||||
///
|
///
|
||||||
struct _cef_find_handler_t*(CEF_CALLBACK* get_find_handler)(
|
struct _cef_find_handler_t* (CEF_CALLBACK *get_find_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for focus events.
|
// Return the handler for focus events.
|
||||||
///
|
///
|
||||||
struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)(
|
struct _cef_focus_handler_t* (CEF_CALLBACK *get_focus_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for events related to cef_frame_t lifespan. This
|
// Return the handler for geolocation permissions requests. If no handler is
|
||||||
// function will be called once during cef_browser_t creation and the result
|
// provided geolocation access will be denied by default.
|
||||||
// will be cached for performance reasons.
|
|
||||||
///
|
///
|
||||||
struct _cef_frame_handler_t*(CEF_CALLBACK* get_frame_handler)(
|
struct _cef_geolocation_handler_t* (CEF_CALLBACK *get_geolocation_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for JavaScript dialogs. If no handler is provided the
|
// Return the handler for JavaScript dialogs. If no handler is provided the
|
||||||
// default implementation will be used.
|
// default implementation will be used.
|
||||||
///
|
///
|
||||||
struct _cef_jsdialog_handler_t*(CEF_CALLBACK* get_jsdialog_handler)(
|
struct _cef_jsdialog_handler_t* (CEF_CALLBACK *get_jsdialog_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for keyboard events.
|
// Return the handler for keyboard events.
|
||||||
///
|
///
|
||||||
struct _cef_keyboard_handler_t*(CEF_CALLBACK* get_keyboard_handler)(
|
struct _cef_keyboard_handler_t* (CEF_CALLBACK *get_keyboard_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser life span events.
|
// Return the handler for browser life span events.
|
||||||
///
|
///
|
||||||
struct _cef_life_span_handler_t*(CEF_CALLBACK* get_life_span_handler)(
|
struct _cef_life_span_handler_t* (CEF_CALLBACK *get_life_span_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser load status events.
|
// Return the handler for browser load status events.
|
||||||
///
|
///
|
||||||
struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)(
|
struct _cef_load_handler_t* (CEF_CALLBACK *get_load_handler)(
|
||||||
struct _cef_client_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Return the handler for printing on Linux. If a print handler is not
|
|
||||||
// provided then printing will not be supported on the Linux platform.
|
|
||||||
///
|
|
||||||
struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)(
|
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for off-screen rendering events.
|
// Return the handler for off-screen rendering events.
|
||||||
///
|
///
|
||||||
struct _cef_render_handler_t*(CEF_CALLBACK* get_render_handler)(
|
struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser request events.
|
// Return the handler for browser request events.
|
||||||
///
|
///
|
||||||
struct _cef_request_handler_t*(CEF_CALLBACK* get_request_handler)(
|
struct _cef_request_handler_t* (CEF_CALLBACK *get_request_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when a new message is received from a different process. Return true
|
// Called when a new message is received from a different process. Return true
|
||||||
// (1) if the message was handled or false (0) otherwise. It is safe to keep
|
// (1) if the message was handled or false (0) otherwise. Do not keep a
|
||||||
// a reference to |message| outside of this callback.
|
// reference to or attempt to access the message outside of this callback.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_process_message_received)(
|
int (CEF_CALLBACK *on_process_message_received)(struct _cef_client_t* self,
|
||||||
struct _cef_client_t* self,
|
struct _cef_browser_t* browser, cef_process_id_t source_process,
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
cef_process_id_t source_process,
|
|
||||||
struct _cef_process_message_t* message);
|
struct _cef_process_message_t* message);
|
||||||
} cef_client_t;
|
} cef_client_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=3ecebd6b30bb8fb837e062eacd021c1a1ff3620a$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to create and/or parse command line arguments. Arguments with
|
// Structure used to create and/or parse command line arguments. Arguments with
|
||||||
// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
|
// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
|
||||||
@@ -53,32 +52,31 @@ extern "C" {
|
|||||||
// optionally have a value specified using the '=' delimiter (e.g.
|
// optionally have a value specified using the '=' delimiter (e.g.
|
||||||
// "-switch=value"). An argument of "--" will terminate switch parsing with all
|
// "-switch=value"). An argument of "--" will terminate switch parsing with all
|
||||||
// subsequent tokens, regardless of prefix, being interpreted as non-switch
|
// subsequent tokens, regardless of prefix, being interpreted as non-switch
|
||||||
// arguments. Switch names should be lowercase ASCII and will be converted to
|
// arguments. Switch names are considered case-insensitive. This structure can
|
||||||
// such if necessary. Switch values will retain the original case and UTF8
|
// be used before cef_initialize() is called.
|
||||||
// encoding. This structure can be used before cef_initialize() is called.
|
|
||||||
///
|
///
|
||||||
typedef struct _cef_command_line_t {
|
typedef struct _cef_command_line_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this object is valid. Do not call any other functions
|
// Returns true (1) if this object is valid. Do not call any other functions
|
||||||
// if this function returns false (0).
|
// if this function returns false (0).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_valid)(struct _cef_command_line_t* self);
|
int (CEF_CALLBACK *is_valid)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the values of this object are read-only. Some APIs may
|
// Returns true (1) if the values of this object are read-only. Some APIs may
|
||||||
// expose read-only objects.
|
// expose read-only objects.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_read_only)(struct _cef_command_line_t* self);
|
int (CEF_CALLBACK *is_read_only)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a writable copy of this object.
|
// Returns a writable copy of this object.
|
||||||
///
|
///
|
||||||
struct _cef_command_line_t*(CEF_CALLBACK* copy)(
|
struct _cef_command_line_t* (CEF_CALLBACK *copy)(
|
||||||
struct _cef_command_line_t* self);
|
struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -86,28 +84,27 @@ typedef struct _cef_command_line_t {
|
|||||||
// The first argument must be the name of the program. This function is only
|
// The first argument must be the name of the program. This function is only
|
||||||
// supported on non-Windows platforms.
|
// supported on non-Windows platforms.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* init_from_argv)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *init_from_argv)(struct _cef_command_line_t* self,
|
||||||
int argc,
|
int argc, const char* const* argv);
|
||||||
const char* const* argv);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Initialize the command line with the string returned by calling
|
// Initialize the command line with the string returned by calling
|
||||||
// GetCommandLineW(). This function is only supported on Windows.
|
// GetCommandLineW(). This function is only supported on Windows.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* init_from_string)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *init_from_string)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* command_line);
|
const cef_string_t* command_line);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Reset the command-line switches and arguments but leave the program
|
// Reset the command-line switches and arguments but leave the program
|
||||||
// component unchanged.
|
// component unchanged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* reset)(struct _cef_command_line_t* self);
|
void (CEF_CALLBACK *reset)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieve the original command line string as a vector of strings. The argv
|
// Retrieve the original command line string as a vector of strings. The argv
|
||||||
// array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
|
// array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_argv)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *get_argv)(struct _cef_command_line_t* self,
|
||||||
cef_string_list_t argv);
|
cef_string_list_t argv);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -115,31 +112,31 @@ typedef struct _cef_command_line_t {
|
|||||||
// function cautiously because quoting behavior is unclear.
|
// function cautiously because quoting behavior is unclear.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_command_line_string)(
|
cef_string_userfree_t (CEF_CALLBACK *get_command_line_string)(
|
||||||
struct _cef_command_line_t* self);
|
struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Get the program part of the command line string (the first item).
|
// Get the program part of the command line string (the first item).
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_program)(
|
cef_string_userfree_t (CEF_CALLBACK *get_program)(
|
||||||
struct _cef_command_line_t* self);
|
struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the program part of the command line string (the first item).
|
// Set the program part of the command line string (the first item).
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_program)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *set_program)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* program);
|
const cef_string_t* program);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the command line has switches.
|
// Returns true (1) if the command line has switches.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_switches)(struct _cef_command_line_t* self);
|
int (CEF_CALLBACK *has_switches)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the command line contains the given switch.
|
// Returns true (1) if the command line contains the given switch.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_switch)(struct _cef_command_line_t* self,
|
int (CEF_CALLBACK *has_switch)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* name);
|
const cef_string_t* name);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -147,56 +144,56 @@ typedef struct _cef_command_line_t {
|
|||||||
// value or isn't present this function returns the NULL string.
|
// value or isn't present this function returns the NULL string.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_switch_value)(
|
cef_string_userfree_t (CEF_CALLBACK *get_switch_value)(
|
||||||
struct _cef_command_line_t* self,
|
struct _cef_command_line_t* self, const cef_string_t* name);
|
||||||
const cef_string_t* name);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the map of switch names and values. If a switch has no value an
|
// Returns the map of switch names and values. If a switch has no value an
|
||||||
// NULL string is returned.
|
// NULL string is returned.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_switches)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *get_switches)(struct _cef_command_line_t* self,
|
||||||
cef_string_map_t switches);
|
cef_string_map_t switches);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a switch to the end of the command line. If the switch has no value
|
// Add a switch to the end of the command line. If the switch has no value
|
||||||
// pass an NULL value string.
|
// pass an NULL value string.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* append_switch)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *append_switch)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* name);
|
const cef_string_t* name);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a switch with the specified value to the end of the command line.
|
// Add a switch with the specified value to the end of the command line.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* append_switch_with_value)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *append_switch_with_value)(
|
||||||
const cef_string_t* name,
|
struct _cef_command_line_t* self, const cef_string_t* name,
|
||||||
const cef_string_t* value);
|
const cef_string_t* value);
|
||||||
|
|
||||||
///
|
///
|
||||||
// True if there are remaining command line arguments.
|
// True if there are remaining command line arguments.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_arguments)(struct _cef_command_line_t* self);
|
int (CEF_CALLBACK *has_arguments)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Get the remaining command line arguments.
|
// Get the remaining command line arguments.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_arguments)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *get_arguments)(struct _cef_command_line_t* self,
|
||||||
cef_string_list_t arguments);
|
cef_string_list_t arguments);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add an argument to the end of the command line.
|
// Add an argument to the end of the command line.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* append_argument)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *append_argument)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* argument);
|
const cef_string_t* argument);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert a command before the current command. Common for debuggers, like
|
// Insert a command before the current command. Common for debuggers, like
|
||||||
// "valgrind" or "gdb --args".
|
// "valgrind" or "gdb --args".
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* prepend_wrapper)(struct _cef_command_line_t* self,
|
void (CEF_CALLBACK *prepend_wrapper)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* wrapper);
|
const cef_string_t* wrapper);
|
||||||
} cef_command_line_t;
|
} cef_command_line_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Create a new cef_command_line_t instance.
|
// Create a new cef_command_line_t instance.
|
||||||
///
|
///
|
||||||
@@ -208,6 +205,7 @@ CEF_EXPORT cef_command_line_t* cef_command_line_create();
|
|||||||
///
|
///
|
||||||
CEF_EXPORT cef_command_line_t* cef_command_line_get_global();
|
CEF_EXPORT cef_command_line_t* cef_command_line_get_global();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=175779df75a1405fcc5c337a09e6322c556698ba$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
||||||
@@ -58,22 +56,22 @@ typedef struct _cef_run_context_menu_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Complete context menu display by selecting the specified |command_id| and
|
// Complete context menu display by selecting the specified |command_id| and
|
||||||
// |event_flags|.
|
// |event_flags|.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_run_context_menu_callback_t* self,
|
void (CEF_CALLBACK *cont)(struct _cef_run_context_menu_callback_t* self,
|
||||||
int command_id,
|
int command_id, cef_event_flags_t event_flags);
|
||||||
cef_event_flags_t event_flags);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel context menu display.
|
// Cancel context menu display.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_run_context_menu_callback_t* self);
|
void (CEF_CALLBACK *cancel)(struct _cef_run_context_menu_callback_t* self);
|
||||||
} cef_run_context_menu_callback_t;
|
} cef_run_context_menu_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle context menu events. The functions of this
|
// Implement this structure to handle context menu events. The functions of this
|
||||||
// structure will be called on the UI thread.
|
// structure will be called on the UI thread.
|
||||||
@@ -82,7 +80,7 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called before a context menu is displayed. |params| provides information
|
// Called before a context menu is displayed. |params| provides information
|
||||||
@@ -91,11 +89,9 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
// modified to show a custom menu. Do not keep references to |params| or
|
// modified to show a custom menu. Do not keep references to |params| or
|
||||||
// |model| outside of this callback.
|
// |model| outside of this callback.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_context_menu)(
|
void (CEF_CALLBACK *on_before_context_menu)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
struct _cef_context_menu_params_t* params,
|
|
||||||
struct _cef_menu_model_t* model);
|
struct _cef_menu_model_t* model);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -106,10 +102,8 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
// selected command ID. For default display return false (0). Do not keep
|
// selected command ID. For default display return false (0). Do not keep
|
||||||
// references to |params| or |model| outside of this callback.
|
// references to |params| or |model| outside of this callback.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* run_context_menu)(
|
int (CEF_CALLBACK *run_context_menu)(struct _cef_context_menu_handler_t* self,
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
struct _cef_context_menu_params_t* params,
|
struct _cef_context_menu_params_t* params,
|
||||||
struct _cef_menu_model_t* model,
|
struct _cef_menu_model_t* model,
|
||||||
struct _cef_run_context_menu_callback_t* callback);
|
struct _cef_run_context_menu_callback_t* callback);
|
||||||
@@ -123,24 +117,21 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
// on_before_context_menu(). Do not keep a reference to |params| outside of
|
// on_before_context_menu(). Do not keep a reference to |params| outside of
|
||||||
// this callback.
|
// this callback.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_context_menu_command)(
|
int (CEF_CALLBACK *on_context_menu_command)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_frame_t* frame, struct _cef_context_menu_params_t* params,
|
||||||
struct _cef_frame_t* frame,
|
int command_id, cef_event_flags_t event_flags);
|
||||||
struct _cef_context_menu_params_t* params,
|
|
||||||
int command_id,
|
|
||||||
cef_event_flags_t event_flags);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the context menu is dismissed irregardless of whether the menu
|
// Called when the context menu is dismissed irregardless of whether the menu
|
||||||
// was NULL or a command was selected.
|
// was NULL or a command was selected.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_context_menu_dismissed)(
|
void (CEF_CALLBACK *on_context_menu_dismissed)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self, struct _cef_browser_t* browser,
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* frame);
|
struct _cef_frame_t* frame);
|
||||||
} cef_context_menu_handler_t;
|
} cef_context_menu_handler_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Provides information about the context menu state. The ethods of this
|
// Provides information about the context menu state. The ethods of this
|
||||||
// structure can only be accessed on browser process the UI thread.
|
// structure can only be accessed on browser process the UI thread.
|
||||||
@@ -149,25 +140,25 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the X coordinate of the mouse where the context menu was invoked.
|
// Returns the X coordinate of the mouse where the context menu was invoked.
|
||||||
// Coords are relative to the associated RenderView's origin.
|
// Coords are relative to the associated RenderView's origin.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_xcoord)(struct _cef_context_menu_params_t* self);
|
int (CEF_CALLBACK *get_xcoord)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the Y coordinate of the mouse where the context menu was invoked.
|
// Returns the Y coordinate of the mouse where the context menu was invoked.
|
||||||
// Coords are relative to the associated RenderView's origin.
|
// Coords are relative to the associated RenderView's origin.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_ycoord)(struct _cef_context_menu_params_t* self);
|
int (CEF_CALLBACK *get_ycoord)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns flags representing the type of node that the context menu was
|
// Returns flags representing the type of node that the context menu was
|
||||||
// invoked on.
|
// invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_type_flags_t(CEF_CALLBACK* get_type_flags)(
|
cef_context_menu_type_flags_t (CEF_CALLBACK *get_type_flags)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -175,7 +166,7 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// context menu was invoked on.
|
// context menu was invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_link_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -183,7 +174,7 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// don't validate this field in the frontend process.
|
// don't validate this field in the frontend process.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_unfiltered_link_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_unfiltered_link_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -191,36 +182,28 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// invoked on. Example of elements with source URLs are img, audio, and video.
|
// invoked on. Example of elements with source URLs are img, audio, and video.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_source_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_source_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu was invoked on an image which has non-
|
// Returns true (1) if the context menu was invoked on an image which has non-
|
||||||
// NULL contents.
|
// NULL contents.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_image_contents)(
|
int (CEF_CALLBACK *has_image_contents)(
|
||||||
struct _cef_context_menu_params_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the title text or the alt text if the context menu was invoked on
|
|
||||||
// an image.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_title_text)(
|
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL of the top level page that the context menu was invoked on.
|
// Returns the URL of the top level page that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_page_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_page_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL of the subframe that the context menu was invoked on.
|
// Returns the URL of the subframe that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_frame_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_frame_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -228,20 +211,20 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// invoked on.
|
// invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_frame_charset)(
|
cef_string_userfree_t (CEF_CALLBACK *get_frame_charset)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the type of context node that the context menu was invoked on.
|
// Returns the type of context node that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_media_type_t(CEF_CALLBACK* get_media_type)(
|
cef_context_menu_media_type_t (CEF_CALLBACK *get_media_type)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns flags representing the actions supported by the media element, if
|
// Returns flags representing the actions supported by the media element, if
|
||||||
// any, that the context menu was invoked on.
|
// any, that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_media_state_flags_t(CEF_CALLBACK* get_media_state_flags)(
|
cef_context_menu_media_state_flags_t (CEF_CALLBACK *get_media_state_flags)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -249,7 +232,7 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// invoked on.
|
// invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_text)(
|
cef_string_userfree_t (CEF_CALLBACK *get_selection_text)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -257,7 +240,7 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// invoked on.
|
// invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_misspelled_word)(
|
cef_string_userfree_t (CEF_CALLBACK *get_misspelled_word)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -265,27 +248,26 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// |suggestions| from the spell check service for the misspelled word if there
|
// |suggestions| from the spell check service for the misspelled word if there
|
||||||
// is one.
|
// is one.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_dictionary_suggestions)(
|
int (CEF_CALLBACK *get_dictionary_suggestions)(
|
||||||
struct _cef_context_menu_params_t* self,
|
struct _cef_context_menu_params_t* self, cef_string_list_t suggestions);
|
||||||
cef_string_list_t suggestions);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu was invoked on an editable node.
|
// Returns true (1) if the context menu was invoked on an editable node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_editable)(struct _cef_context_menu_params_t* self);
|
int (CEF_CALLBACK *is_editable)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu was invoked on an editable node where
|
// Returns true (1) if the context menu was invoked on an editable node where
|
||||||
// spell-check is enabled.
|
// spell-check is enabled.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_spell_check_enabled)(
|
int (CEF_CALLBACK *is_spell_check_enabled)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns flags representing the actions supported by the editable node, if
|
// Returns flags representing the actions supported by the editable node, if
|
||||||
// any, that the context menu was invoked on.
|
// any, that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_edit_state_flags_t(CEF_CALLBACK* get_edit_state_flags)(
|
cef_context_menu_edit_state_flags_t (CEF_CALLBACK *get_edit_state_flags)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -293,9 +275,15 @@ typedef struct _cef_context_menu_params_t {
|
|||||||
// renderer process (for example, plugin placeholder or pepper plugin menu
|
// renderer process (for example, plugin placeholder or pepper plugin menu
|
||||||
// items).
|
// items).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self);
|
int (CEF_CALLBACK *is_custom_menu)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Returns true (1) if the context menu was invoked from a pepper plugin.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *is_pepper_menu)(struct _cef_context_menu_params_t* self);
|
||||||
} cef_context_menu_params_t;
|
} cef_context_menu_params_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=b19ef1c8a781f8d59276357609fe64370bb8a107$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||||
@@ -59,26 +57,34 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Visit all cookies on the UI thread. The returned cookies are ordered by
|
// Set the schemes supported by this manager. The default schemes ("http",
|
||||||
|
// "https", "ws" and "wss") will always be supported. If |callback| is non-
|
||||||
|
// NULL it will be executed asnychronously on the IO thread after the change
|
||||||
|
// has been applied. Must be called before any cookies are accessed.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *set_supported_schemes)(struct _cef_cookie_manager_t* self,
|
||||||
|
cef_string_list_t schemes, struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Visit all cookies on the IO thread. The returned cookies are ordered by
|
||||||
// longest path, then by earliest creation date. Returns false (0) if cookies
|
// longest path, then by earliest creation date. Returns false (0) if cookies
|
||||||
// cannot be accessed.
|
// cannot be accessed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* visit_all_cookies)(struct _cef_cookie_manager_t* self,
|
int (CEF_CALLBACK *visit_all_cookies)(struct _cef_cookie_manager_t* self,
|
||||||
struct _cef_cookie_visitor_t* visitor);
|
struct _cef_cookie_visitor_t* visitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Visit a subset of cookies on the UI thread. The results are filtered by the
|
// Visit a subset of cookies on the IO thread. The results are filtered by the
|
||||||
// given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
|
// given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
|
||||||
// HTTP-only cookies will also be included in the results. The returned
|
// HTTP-only cookies will also be included in the results. The returned
|
||||||
// cookies are ordered by longest path, then by earliest creation date.
|
// cookies are ordered by longest path, then by earliest creation date.
|
||||||
// Returns false (0) if cookies cannot be accessed.
|
// Returns false (0) if cookies cannot be accessed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* visit_url_cookies)(struct _cef_cookie_manager_t* self,
|
int (CEF_CALLBACK *visit_url_cookies)(struct _cef_cookie_manager_t* self,
|
||||||
const cef_string_t* url,
|
const cef_string_t* url, int includeHttpOnly,
|
||||||
int includeHttpOnly,
|
|
||||||
struct _cef_cookie_visitor_t* visitor);
|
struct _cef_cookie_visitor_t* visitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -87,12 +93,11 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
// check for disallowed characters (e.g. the ';' character is disallowed
|
// check for disallowed characters (e.g. the ';' character is disallowed
|
||||||
// within the cookie value attribute) and fail without setting the cookie if
|
// within the cookie value attribute) and fail without setting the cookie if
|
||||||
// such characters are found. If |callback| is non-NULL it will be executed
|
// such characters are found. If |callback| is non-NULL it will be executed
|
||||||
// asnychronously on the UI thread after the cookie has been set. Returns
|
// asnychronously on the IO thread after the cookie has been set. Returns
|
||||||
// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self,
|
int (CEF_CALLBACK *set_cookie)(struct _cef_cookie_manager_t* self,
|
||||||
const cef_string_t* url,
|
const cef_string_t* url, const struct _cef_cookie_t* cookie,
|
||||||
const struct _cef_cookie_t* cookie,
|
|
||||||
struct _cef_set_cookie_callback_t* callback);
|
struct _cef_set_cookie_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -101,46 +106,73 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
// both will be deleted. If only |url| is specified all host cookies (but not
|
// both will be deleted. If only |url| is specified all host cookies (but not
|
||||||
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
||||||
// cookies for all hosts and domains will be deleted. If |callback| is non-
|
// cookies for all hosts and domains will be deleted. If |callback| is non-
|
||||||
// NULL it will be executed asnychronously on the UI thread after the cookies
|
// NULL it will be executed asnychronously on the IO thread after the cookies
|
||||||
// have been deleted. Returns false (0) if a non-NULL invalid URL is specified
|
// have been deleted. Returns false (0) if a non-NULL invalid URL is specified
|
||||||
// or if cookies cannot be accessed. Cookies can alternately be deleted using
|
// or if cookies cannot be accessed. Cookies can alternately be deleted using
|
||||||
// the Visit*Cookies() functions.
|
// the Visit*Cookies() functions.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* delete_cookies)(
|
int (CEF_CALLBACK *delete_cookies)(struct _cef_cookie_manager_t* self,
|
||||||
struct _cef_cookie_manager_t* self,
|
const cef_string_t* url, const cef_string_t* cookie_name,
|
||||||
const cef_string_t* url,
|
|
||||||
const cef_string_t* cookie_name,
|
|
||||||
struct _cef_delete_cookies_callback_t* callback);
|
struct _cef_delete_cookies_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Sets the directory path that will be used for storing cookie data. If
|
||||||
|
// |path| is NULL data will be stored in memory only. Otherwise, data will be
|
||||||
|
// stored at the specified |path|. To persist session cookies (cookies without
|
||||||
|
// an expiry date or validity interval) set |persist_session_cookies| to true
|
||||||
|
// (1). Session cookies are generally intended to be transient and most Web
|
||||||
|
// browsers do not persist them. If |callback| is non-NULL it will be executed
|
||||||
|
// asnychronously on the IO thread after the manager's storage has been
|
||||||
|
// initialized. Returns false (0) if cookies cannot be accessed.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *set_storage_path)(struct _cef_cookie_manager_t* self,
|
||||||
|
const cef_string_t* path, int persist_session_cookies,
|
||||||
|
struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
|
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
|
||||||
// be executed asnychronously on the UI thread after the flush is complete.
|
// be executed asnychronously on the IO thread after the flush is complete.
|
||||||
// Returns false (0) if cookies cannot be accessed.
|
// Returns false (0) if cookies cannot be accessed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self,
|
int (CEF_CALLBACK *flush_store)(struct _cef_cookie_manager_t* self,
|
||||||
struct _cef_completion_callback_t* callback);
|
struct _cef_completion_callback_t* callback);
|
||||||
} cef_cookie_manager_t;
|
} cef_cookie_manager_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the global cookie manager. By default data will be stored at
|
// Returns the global cookie manager. By default data will be stored at
|
||||||
// CefSettings.cache_path if specified or in memory otherwise. If |callback| is
|
// CefSettings.cache_path if specified or in memory otherwise. If |callback| is
|
||||||
// non-NULL it will be executed asnychronously on the UI thread after the
|
// non-NULL it will be executed asnychronously on the IO thread after the
|
||||||
// manager's storage has been initialized. Using this function is equivalent to
|
// manager's storage has been initialized. Using this function is equivalent to
|
||||||
// calling cef_request_context_t::cef_request_context_get_global_context()->GetD
|
// calling cef_request_tContext::cef_request_context_get_global_context()->get_d
|
||||||
// efaultCookieManager().
|
// efault_cookie_manager().
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
||||||
struct _cef_completion_callback_t* callback);
|
struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Creates a new cookie manager. If |path| is NULL data will be stored in memory
|
||||||
|
// only. Otherwise, data will be stored at the specified |path|. To persist
|
||||||
|
// session cookies (cookies without an expiry date or validity interval) set
|
||||||
|
// |persist_session_cookies| to true (1). Session cookies are generally intended
|
||||||
|
// to be transient and most Web browsers do not persist them. If |callback| is
|
||||||
|
// non-NULL it will be executed asnychronously on the IO thread after the
|
||||||
|
// manager's storage has been initialized.
|
||||||
|
///
|
||||||
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
|
||||||
|
const cef_string_t* path, int persist_session_cookies,
|
||||||
|
struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure to implement for visiting cookie values. The functions of this
|
// Structure to implement for visiting cookie values. The functions of this
|
||||||
// structure will always be called on the UI thread.
|
// structure will always be called on the IO thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_cookie_visitor_t {
|
typedef struct _cef_cookie_visitor_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called once for each cookie. |count| is the 0-based
|
// Method that will be called once for each cookie. |count| is the 0-based
|
||||||
@@ -149,13 +181,12 @@ typedef struct _cef_cookie_visitor_t {
|
|||||||
// Return false (0) to stop visiting cookies. This function may never be
|
// Return false (0) to stop visiting cookies. This function may never be
|
||||||
// called if no cookies are found.
|
// called if no cookies are found.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* visit)(struct _cef_cookie_visitor_t* self,
|
int (CEF_CALLBACK *visit)(struct _cef_cookie_visitor_t* self,
|
||||||
const struct _cef_cookie_t* cookie,
|
const struct _cef_cookie_t* cookie, int count, int total,
|
||||||
int count,
|
|
||||||
int total,
|
|
||||||
int* deleteCookie);
|
int* deleteCookie);
|
||||||
} cef_cookie_visitor_t;
|
} cef_cookie_visitor_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure to implement to be notified of asynchronous completion via
|
// Structure to implement to be notified of asynchronous completion via
|
||||||
// cef_cookie_manager_t::set_cookie().
|
// cef_cookie_manager_t::set_cookie().
|
||||||
@@ -164,16 +195,17 @@ typedef struct _cef_set_cookie_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called upon completion. |success| will be true (1) if
|
// Method that will be called upon completion. |success| will be true (1) if
|
||||||
// the cookie was set successfully.
|
// the cookie was set successfully.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_complete)(struct _cef_set_cookie_callback_t* self,
|
void (CEF_CALLBACK *on_complete)(struct _cef_set_cookie_callback_t* self,
|
||||||
int success);
|
int success);
|
||||||
} cef_set_cookie_callback_t;
|
} cef_set_cookie_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure to implement to be notified of asynchronous completion via
|
// Structure to implement to be notified of asynchronous completion via
|
||||||
// cef_cookie_manager_t::delete_cookies().
|
// cef_cookie_manager_t::delete_cookies().
|
||||||
@@ -182,16 +214,17 @@ typedef struct _cef_delete_cookies_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called upon completion. |num_deleted| will be the
|
// Method that will be called upon completion. |num_deleted| will be the
|
||||||
// number of cookies that were deleted.
|
// number of cookies that were deleted or -1 if unknown.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self,
|
void (CEF_CALLBACK *on_complete)(struct _cef_delete_cookies_callback_t* self,
|
||||||
int num_deleted);
|
int num_deleted);
|
||||||
} cef_delete_cookies_callback_t;
|
} cef_delete_cookies_callback_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=5e19231e3476eef376c2742e8d375bee7bd4ea2d$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///
|
|
||||||
// Crash reporting is configured using an INI-style config file named
|
|
||||||
// "crash_reporter.cfg". On Windows and Linux this file must be placed next to
|
|
||||||
// the main application executable. On macOS this file must be placed in the
|
|
||||||
// top-level app bundle Resources directory (e.g.
|
|
||||||
// "<appname>.app/Contents/Resources"). File contents are as follows:
|
|
||||||
//
|
|
||||||
// # Comments start with a hash character and must be on their own line.
|
|
||||||
//
|
|
||||||
// [Config]
|
|
||||||
// ProductName=<Value of the "prod" crash key; defaults to "cef">
|
|
||||||
// ProductVersion=<Value of the "ver" crash key; defaults to the CEF version>
|
|
||||||
// AppName=<Windows only; App-specific folder name component for storing crash
|
|
||||||
// information; default to "CEF">
|
|
||||||
// ExternalHandler=<Windows only; Name of the external handler exe to use
|
|
||||||
// instead of re-launching the main exe; default to empty>
|
|
||||||
// BrowserCrashForwardingEnabled=<macOS only; True if browser process crashes
|
|
||||||
// should be forwarded to the system crash
|
|
||||||
// reporter; default to false>
|
|
||||||
// ServerURL=<crash server URL; default to empty>
|
|
||||||
// RateLimitEnabled=<True if uploads should be rate limited; default to true>
|
|
||||||
// MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled;
|
|
||||||
// default to 5>
|
|
||||||
// MaxDatabaseSizeInMb=<Total crash report disk usage greater than this value
|
|
||||||
// will cause older reports to be deleted; default to 20>
|
|
||||||
// MaxDatabaseAgeInDays=<Crash reports older than this value will be deleted;
|
|
||||||
// default to 5>
|
|
||||||
//
|
|
||||||
// [CrashKeys]
|
|
||||||
// my_key1=<small|medium|large>
|
|
||||||
// my_key2=<small|medium|large>
|
|
||||||
//
|
|
||||||
// Config section:
|
|
||||||
//
|
|
||||||
// If "ProductName" and/or "ProductVersion" are set then the specified values
|
|
||||||
// will be included in the crash dump metadata. On macOS if these values are set
|
|
||||||
// to NULL then they will be retrieved from the Info.plist file using the
|
|
||||||
// "CFBundleName" and "CFBundleShortVersionString" keys respectively.
|
|
||||||
//
|
|
||||||
// If "AppName" is set on Windows then crash report information (metrics,
|
|
||||||
// database and dumps) will be stored locally on disk under the
|
|
||||||
// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other
|
|
||||||
// platforms the CefSettings.user_data_path value will be used.
|
|
||||||
//
|
|
||||||
// If "ExternalHandler" is set on Windows then the specified exe will be
|
|
||||||
// launched as the crashpad-handler instead of re-launching the main process
|
|
||||||
// exe. The value can be an absolute path or a path relative to the main exe
|
|
||||||
// directory. On Linux the CefSettings.browser_subprocess_path value will be
|
|
||||||
// used. On macOS the existing subprocess app bundle will be used.
|
|
||||||
//
|
|
||||||
// If "BrowserCrashForwardingEnabled" is set to true (1) on macOS then browser
|
|
||||||
// process crashes will be forwarded to the system crash reporter. This results
|
|
||||||
// in the crash UI dialog being displayed to the user and crash reports being
|
|
||||||
// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports
|
|
||||||
// from non-browser processes and Debug builds is always disabled.
|
|
||||||
//
|
|
||||||
// If "ServerURL" is set then crashes will be uploaded as a multi-part POST
|
|
||||||
// request to the specified URL. Otherwise, reports will only be stored locally
|
|
||||||
// on disk.
|
|
||||||
//
|
|
||||||
// If "RateLimitEnabled" is set to true (1) then crash report uploads will be
|
|
||||||
// rate limited as follows:
|
|
||||||
// 1. If "MaxUploadsPerDay" is set to a positive value then at most the
|
|
||||||
// specified number of crashes will be uploaded in each 24 hour period.
|
|
||||||
// 2. If crash upload fails due to a network or server error then an
|
|
||||||
// incremental backoff delay up to a maximum of 24 hours will be applied for
|
|
||||||
// retries.
|
|
||||||
// 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the
|
|
||||||
// "MaxUploadsPerDay" value will be reduced to 1 until the client is
|
|
||||||
// restarted. This helps to avoid an upload flood when the network or
|
|
||||||
// server error is resolved.
|
|
||||||
// Rate limiting is not supported on Linux.
|
|
||||||
//
|
|
||||||
// If "MaxDatabaseSizeInMb" is set to a positive value then crash report storage
|
|
||||||
// on disk will be limited to that size in megabytes. For example, on Windows
|
|
||||||
// each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20 equates to
|
|
||||||
// about 34 crash reports stored on disk. Not supported on Linux.
|
|
||||||
//
|
|
||||||
// If "MaxDatabaseAgeInDays" is set to a positive value then crash reports older
|
|
||||||
// than the specified age in days will be deleted. Not supported on Linux.
|
|
||||||
//
|
|
||||||
// CrashKeys section:
|
|
||||||
//
|
|
||||||
// A maximum of 26 crash keys of each size can be specified for use by the
|
|
||||||
// application. Crash key values will be truncated based on the specified size
|
|
||||||
// (small = 64 bytes, medium = 256 bytes, large = 1024 bytes). The value of
|
|
||||||
// crash keys can be set from any thread or process using the
|
|
||||||
// CefSetCrashKeyValue function. These key/value pairs will be sent to the crash
|
|
||||||
// server along with the crash dump file.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_crash_reporting_enabled();
|
|
||||||
|
|
||||||
///
|
|
||||||
// Sets or clears a specific key-value pair from the crash metadata.
|
|
||||||
///
|
|
||||||
CEF_EXPORT void cef_set_crash_key_value(const cef_string_t* key,
|
|
||||||
const cef_string_t* value);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=1a256c04042ebd4867f39e1c31def558871b2bab$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _cef_browser_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Callback structure for cef_browser_host_t::AddDevToolsMessageObserver. The
|
|
||||||
// functions of this structure will be called on the browser process UI thread.
|
|
||||||
///
|
|
||||||
typedef struct _cef_dev_tools_message_observer_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be called on receipt of a DevTools protocol message.
|
|
||||||
// |browser| is the originating browser instance. |message| is a UTF8-encoded
|
|
||||||
// JSON dictionary representing either a function result or an event.
|
|
||||||
// |message| is only valid for the scope of this callback and should be copied
|
|
||||||
// if necessary. Return true (1) if the message was handled or false (0) if
|
|
||||||
// the message should be further processed and passed to the
|
|
||||||
// OnDevToolsMethodResult or OnDevToolsEvent functions as appropriate.
|
|
||||||
//
|
|
||||||
// Method result dictionaries include an "id" (int) value that identifies the
|
|
||||||
// orginating function call sent from cef_browser_host_t::SendDevToolsMessage,
|
|
||||||
// and optionally either a "result" (dictionary) or "error" (dictionary)
|
|
||||||
// value. The "error" dictionary will contain "code" (int) and "message"
|
|
||||||
// (string) values. Event dictionaries include a "function" (string) value and
|
|
||||||
// optionally a "params" (dictionary) value. See the DevTools protocol
|
|
||||||
// documentation at https://chromedevtools.github.io/devtools-protocol/ for
|
|
||||||
// details of supported function calls and the expected "result" or "params"
|
|
||||||
// dictionary contents. JSON dictionaries can be parsed using the CefParseJSON
|
|
||||||
// function if desired, however be aware of performance considerations when
|
|
||||||
// parsing large messages (some of which may exceed 1MB in size).
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* on_dev_tools_message)(
|
|
||||||
struct _cef_dev_tools_message_observer_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
const void* message,
|
|
||||||
size_t message_size);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be called after attempted execution of a DevTools protocol
|
|
||||||
// function. |browser| is the originating browser instance. |message_id| is
|
|
||||||
// the "id" value that identifies the originating function call message. If
|
|
||||||
// the function succeeded |success| will be true (1) and |result| will be the
|
|
||||||
// UTF8-encoded JSON "result" dictionary value (which may be NULL). If the
|
|
||||||
// function failed |success| will be false (0) and |result| will be the
|
|
||||||
// UTF8-encoded JSON "error" dictionary value. |result| is only valid for the
|
|
||||||
// scope of this callback and should be copied if necessary. See the
|
|
||||||
// OnDevToolsMessage documentation for additional details on |result|
|
|
||||||
// contents.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_dev_tools_method_result)(
|
|
||||||
struct _cef_dev_tools_message_observer_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
int message_id,
|
|
||||||
int success,
|
|
||||||
const void* result,
|
|
||||||
size_t result_size);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be called on receipt of a DevTools protocol event.
|
|
||||||
// |browser| is the originating browser instance. |function| is the "function"
|
|
||||||
// value. |params| is the UTF8-encoded JSON "params" dictionary value (which
|
|
||||||
// may be NULL). |params| is only valid for the scope of this callback and
|
|
||||||
// should be copied if necessary. See the OnDevToolsMessage documentation for
|
|
||||||
// additional details on |params| contents.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_dev_tools_event)(
|
|
||||||
struct _cef_dev_tools_message_observer_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
const cef_string_t* method,
|
|
||||||
const void* params,
|
|
||||||
size_t params_size);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be called when the DevTools agent has attached. |browser|
|
|
||||||
// is the originating browser instance. This will generally occur in response
|
|
||||||
// to the first message sent while the agent is detached.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_dev_tools_agent_attached)(
|
|
||||||
struct _cef_dev_tools_message_observer_t* self,
|
|
||||||
struct _cef_browser_t* browser);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be called when the DevTools agent has detached. |browser|
|
|
||||||
// is the originating browser instance. Any function results that were pending
|
|
||||||
// before the agent became detached will not be delivered, and any active
|
|
||||||
// event subscriptions will be canceled.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_dev_tools_agent_detached)(
|
|
||||||
struct _cef_dev_tools_message_observer_t* self,
|
|
||||||
struct _cef_browser_t* browser);
|
|
||||||
} cef_dev_tools_message_observer_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=5ae5556e4085faf8cf17ee757f5eeac9197f75c0$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure for asynchronous continuation of file dialog requests.
|
// Callback structure for asynchronous continuation of file dialog requests.
|
||||||
///
|
///
|
||||||
@@ -54,7 +53,7 @@ typedef struct _cef_file_dialog_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue the file selection. |selected_accept_filter| should be the 0-based
|
// Continue the file selection. |selected_accept_filter| should be the 0-based
|
||||||
@@ -63,16 +62,16 @@ typedef struct _cef_file_dialog_callback_t {
|
|||||||
// or a list of values depending on the dialog mode. An NULL |file_paths|
|
// or a list of values depending on the dialog mode. An NULL |file_paths|
|
||||||
// value is treated the same as calling cancel().
|
// value is treated the same as calling cancel().
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_file_dialog_callback_t* self,
|
void (CEF_CALLBACK *cont)(struct _cef_file_dialog_callback_t* self,
|
||||||
int selected_accept_filter,
|
int selected_accept_filter, cef_string_list_t file_paths);
|
||||||
cef_string_list_t file_paths);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel the file selection.
|
// Cancel the file selection.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_file_dialog_callback_t* self);
|
void (CEF_CALLBACK *cancel)(struct _cef_file_dialog_callback_t* self);
|
||||||
} cef_file_dialog_callback_t;
|
} cef_file_dialog_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle dialog events. The functions of this
|
// Implement this structure to handle dialog events. The functions of this
|
||||||
// structure will be called on the browser process UI thread.
|
// structure will be called on the browser process UI thread.
|
||||||
@@ -81,7 +80,7 @@ typedef struct _cef_dialog_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to run a file chooser dialog. |mode| represents the type of dialog
|
// Called to run a file chooser dialog. |mode| represents the type of dialog
|
||||||
@@ -98,17 +97,14 @@ typedef struct _cef_dialog_handler_t {
|
|||||||
// return true (1) and execute |callback| either inline or at a later time. To
|
// return true (1) and execute |callback| either inline or at a later time. To
|
||||||
// display the default dialog return false (0).
|
// display the default dialog return false (0).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_file_dialog)(
|
int (CEF_CALLBACK *on_file_dialog)(struct _cef_dialog_handler_t* self,
|
||||||
struct _cef_dialog_handler_t* self,
|
struct _cef_browser_t* browser, cef_file_dialog_mode_t mode,
|
||||||
struct _cef_browser_t* browser,
|
const cef_string_t* title, const cef_string_t* default_file_path,
|
||||||
cef_file_dialog_mode_t mode,
|
cef_string_list_t accept_filters, int selected_accept_filter,
|
||||||
const cef_string_t* title,
|
|
||||||
const cef_string_t* default_file_path,
|
|
||||||
cef_string_list_t accept_filters,
|
|
||||||
int selected_accept_filter,
|
|
||||||
struct _cef_file_dialog_callback_t* callback);
|
struct _cef_file_dialog_callback_t* callback);
|
||||||
} cef_dialog_handler_t;
|
} cef_dialog_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=067fd169a30bec1ad8eeacc5ab1ac750cf59640e$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||||
@@ -48,6 +46,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to browser display state.
|
// Implement this structure to handle events related to browser display state.
|
||||||
// The functions of this structure will be called on the UI thread.
|
// The functions of this structure will be called on the UI thread.
|
||||||
@@ -56,29 +55,26 @@ typedef struct _cef_display_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when a frame's address has changed.
|
// Called when a frame's address has changed.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_address_change)(struct _cef_display_handler_t* self,
|
void (CEF_CALLBACK *on_address_change)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
const cef_string_t* url);
|
const cef_string_t* url);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the page title changes.
|
// Called when the page title changes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_title_change)(struct _cef_display_handler_t* self,
|
void (CEF_CALLBACK *on_title_change)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, const cef_string_t* title);
|
||||||
const cef_string_t* title);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the page icon changes.
|
// Called when the page icon changes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_favicon_urlchange)(struct _cef_display_handler_t* self,
|
void (CEF_CALLBACK *on_favicon_urlchange)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, cef_string_list_t icon_urls);
|
||||||
cef_string_list_t icon_urls);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when web content in the page has toggled fullscreen mode. If
|
// Called when web content in the page has toggled fullscreen mode. If
|
||||||
@@ -87,9 +83,8 @@ typedef struct _cef_display_handler_t {
|
|||||||
// automatically return to its original size and position. The client is
|
// automatically return to its original size and position. The client is
|
||||||
// responsible for resizing the browser if desired.
|
// responsible for resizing the browser if desired.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_fullscreen_mode_change)(
|
void (CEF_CALLBACK *on_fullscreen_mode_change)(
|
||||||
struct _cef_display_handler_t* self,
|
struct _cef_display_handler_t* self, struct _cef_browser_t* browser,
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
int fullscreen);
|
int fullscreen);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -100,62 +95,26 @@ typedef struct _cef_display_handler_t {
|
|||||||
// tooltip. When window rendering is disabled the application is responsible
|
// tooltip. When window rendering is disabled the application is responsible
|
||||||
// for drawing tooltips and the return value is ignored.
|
// for drawing tooltips and the return value is ignored.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_tooltip)(struct _cef_display_handler_t* self,
|
int (CEF_CALLBACK *on_tooltip)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, cef_string_t* text);
|
||||||
cef_string_t* text);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser receives a status message. |value| contains the
|
// Called when the browser receives a status message. |value| contains the
|
||||||
// text that will be displayed in the status message.
|
// text that will be displayed in the status message.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_status_message)(struct _cef_display_handler_t* self,
|
void (CEF_CALLBACK *on_status_message)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, const cef_string_t* value);
|
||||||
const cef_string_t* value);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to display a console message. Return true (1) to stop the message
|
// Called to display a console message. Return true (1) to stop the message
|
||||||
// from being output to the console.
|
// from being output to the console.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_console_message)(struct _cef_display_handler_t* self,
|
int (CEF_CALLBACK *on_console_message)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, const cef_string_t* message,
|
||||||
cef_log_severity_t level,
|
const cef_string_t* source, int line);
|
||||||
const cef_string_t* message,
|
|
||||||
const cef_string_t* source,
|
|
||||||
int line);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when auto-resize is enabled via
|
|
||||||
// cef_browser_host_t::SetAutoResizeEnabled and the contents have auto-
|
|
||||||
// resized. |new_size| will be the desired size in view coordinates. Return
|
|
||||||
// true (1) if the resize was handled or false (0) for default handling.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
const cef_size_t* new_size);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when the overall page loading progress has changed. |progress|
|
|
||||||
// ranges from 0.0 to 1.0.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_loading_progress_change)(
|
|
||||||
struct _cef_display_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
double progress);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
|
||||||
// |custom_cursor_info| will be populated with the custom cursor information.
|
|
||||||
// Return true (1) if the cursor change was handled or false (0) for default
|
|
||||||
// handling.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* on_cursor_change)(
|
|
||||||
struct _cef_display_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
cef_cursor_handle_t cursor,
|
|
||||||
cef_cursor_type_t type,
|
|
||||||
const struct _cef_cursor_info_t* custom_cursor_info);
|
|
||||||
} cef_display_handler_t;
|
} cef_display_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=0517dc6c42fdde9fecfc4549fab1ea12b614e143$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DOM_CAPI_H_
|
||||||
@@ -57,7 +55,7 @@ typedef struct _cef_domvisitor_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method executed for visiting the DOM. The document object passed to this
|
// Method executed for visiting the DOM. The document object passed to this
|
||||||
@@ -66,10 +64,11 @@ typedef struct _cef_domvisitor_t {
|
|||||||
// keep references to or attempt to access any DOM objects outside the scope
|
// keep references to or attempt to access any DOM objects outside the scope
|
||||||
// of this function.
|
// of this function.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* visit)(struct _cef_domvisitor_t* self,
|
void (CEF_CALLBACK *visit)(struct _cef_domvisitor_t* self,
|
||||||
struct _cef_domdocument_t* document);
|
struct _cef_domdocument_t* document);
|
||||||
} cef_domvisitor_t;
|
} cef_domvisitor_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to represent a DOM document. The functions of this structure
|
// Structure used to represent a DOM document. The functions of this structure
|
||||||
// should only be called on the render process main thread thread.
|
// should only be called on the render process main thread thread.
|
||||||
@@ -78,87 +77,86 @@ typedef struct _cef_domdocument_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the document type.
|
// Returns the document type.
|
||||||
///
|
///
|
||||||
cef_dom_document_type_t(CEF_CALLBACK* get_type)(
|
cef_dom_document_type_t (CEF_CALLBACK *get_type)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the root document node.
|
// Returns the root document node.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_document)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_document)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the BODY node of an HTML document.
|
// Returns the BODY node of an HTML document.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_body)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_body)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the HEAD node of an HTML document.
|
// Returns the HEAD node of an HTML document.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_head)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_head)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the title of an HTML document.
|
// Returns the title of an HTML document.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_title)(
|
cef_string_userfree_t (CEF_CALLBACK *get_title)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the document element with the specified ID value.
|
// Returns the document element with the specified ID value.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_element_by_id)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_element_by_id)(
|
||||||
struct _cef_domdocument_t* self,
|
struct _cef_domdocument_t* self, const cef_string_t* id);
|
||||||
const cef_string_t* id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the node that currently has keyboard focus.
|
// Returns the node that currently has keyboard focus.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_focused_node)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_focused_node)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if a portion of the document is selected.
|
// Returns true (1) if a portion of the document is selected.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_selection)(struct _cef_domdocument_t* self);
|
int (CEF_CALLBACK *has_selection)(struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the selection offset within the start node.
|
// Returns the selection offset within the start node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_selection_start_offset)(
|
int (CEF_CALLBACK *get_selection_start_offset)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the selection offset within the end node.
|
// Returns the selection offset within the end node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_selection_end_offset)(struct _cef_domdocument_t* self);
|
int (CEF_CALLBACK *get_selection_end_offset)(struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the contents of this selection as markup.
|
// Returns the contents of this selection as markup.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_as_markup)(
|
cef_string_userfree_t (CEF_CALLBACK *get_selection_as_markup)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the contents of this selection as text.
|
// Returns the contents of this selection as text.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_as_text)(
|
cef_string_userfree_t (CEF_CALLBACK *get_selection_as_text)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the base URL for the document.
|
// Returns the base URL for the document.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_base_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_base_url)(
|
||||||
struct _cef_domdocument_t* self);
|
struct _cef_domdocument_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -166,11 +164,11 @@ typedef struct _cef_domdocument_t {
|
|||||||
// partial URL.
|
// partial URL.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_complete_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_complete_url)(
|
||||||
struct _cef_domdocument_t* self,
|
struct _cef_domdocument_t* self, const cef_string_t* partialURL);
|
||||||
const cef_string_t* partialURL);
|
|
||||||
} cef_domdocument_t;
|
} cef_domdocument_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to represent a DOM node. The functions of this structure
|
// Structure used to represent a DOM node. The functions of this structure
|
||||||
// should only be called on the render process main thread.
|
// should only be called on the render process main thread.
|
||||||
@@ -179,167 +177,163 @@ typedef struct _cef_domnode_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the type for this node.
|
// Returns the type for this node.
|
||||||
///
|
///
|
||||||
cef_dom_node_type_t(CEF_CALLBACK* get_type)(struct _cef_domnode_t* self);
|
cef_dom_node_type_t (CEF_CALLBACK *get_type)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this is a text node.
|
// Returns true (1) if this is a text node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_text)(struct _cef_domnode_t* self);
|
int (CEF_CALLBACK *is_text)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this is an element node.
|
// Returns true (1) if this is an element node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_element)(struct _cef_domnode_t* self);
|
int (CEF_CALLBACK *is_element)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this is an editable node.
|
// Returns true (1) if this is an editable node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_editable)(struct _cef_domnode_t* self);
|
int (CEF_CALLBACK *is_editable)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this is a form control element node.
|
// Returns true (1) if this is a form control element node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_form_control_element)(struct _cef_domnode_t* self);
|
int (CEF_CALLBACK *is_form_control_element)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the type of this form control element node.
|
// Returns the type of this form control element node.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_form_control_element_type)(
|
cef_string_userfree_t (CEF_CALLBACK *get_form_control_element_type)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this object is pointing to the same handle as |that|
|
// Returns true (1) if this object is pointing to the same handle as |that|
|
||||||
// object.
|
// object.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_same)(struct _cef_domnode_t* self,
|
int (CEF_CALLBACK *is_same)(struct _cef_domnode_t* self,
|
||||||
struct _cef_domnode_t* that);
|
struct _cef_domnode_t* that);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the name of this node.
|
// Returns the name of this node.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_domnode_t* self);
|
cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the value of this node.
|
// Returns the value of this node.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_value)(struct _cef_domnode_t* self);
|
cef_string_userfree_t (CEF_CALLBACK *get_value)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the value of this node. Returns true (1) on success.
|
// Set the value of this node. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_value)(struct _cef_domnode_t* self,
|
int (CEF_CALLBACK *set_value)(struct _cef_domnode_t* self,
|
||||||
const cef_string_t* value);
|
const cef_string_t* value);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the contents of this node as markup.
|
// Returns the contents of this node as markup.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_as_markup)(
|
cef_string_userfree_t (CEF_CALLBACK *get_as_markup)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the document associated with this node.
|
// Returns the document associated with this node.
|
||||||
///
|
///
|
||||||
struct _cef_domdocument_t*(CEF_CALLBACK* get_document)(
|
struct _cef_domdocument_t* (CEF_CALLBACK *get_document)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the parent node.
|
// Returns the parent node.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_parent)(struct _cef_domnode_t* self);
|
struct _cef_domnode_t* (CEF_CALLBACK *get_parent)(
|
||||||
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the previous sibling node.
|
// Returns the previous sibling node.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_previous_sibling)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_previous_sibling)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the next sibling node.
|
// Returns the next sibling node.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_next_sibling)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_next_sibling)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this node has child nodes.
|
// Returns true (1) if this node has child nodes.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_children)(struct _cef_domnode_t* self);
|
int (CEF_CALLBACK *has_children)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the first child node.
|
// Return the first child node.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_first_child)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_first_child)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the last child node.
|
// Returns the last child node.
|
||||||
///
|
///
|
||||||
struct _cef_domnode_t*(CEF_CALLBACK* get_last_child)(
|
struct _cef_domnode_t* (CEF_CALLBACK *get_last_child)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
|
|
||||||
// The following functions are valid only for element nodes.
|
// The following functions are valid only for element nodes.
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the tag name of this element.
|
// Returns the tag name of this element.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_element_tag_name)(
|
cef_string_userfree_t (CEF_CALLBACK *get_element_tag_name)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this element has attributes.
|
// Returns true (1) if this element has attributes.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_element_attributes)(struct _cef_domnode_t* self);
|
int (CEF_CALLBACK *has_element_attributes)(struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this element has an attribute named |attrName|.
|
// Returns true (1) if this element has an attribute named |attrName|.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_element_attribute)(struct _cef_domnode_t* self,
|
int (CEF_CALLBACK *has_element_attribute)(struct _cef_domnode_t* self,
|
||||||
const cef_string_t* attrName);
|
const cef_string_t* attrName);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the element attribute named |attrName|.
|
// Returns the element attribute named |attrName|.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_element_attribute)(
|
cef_string_userfree_t (CEF_CALLBACK *get_element_attribute)(
|
||||||
struct _cef_domnode_t* self,
|
struct _cef_domnode_t* self, const cef_string_t* attrName);
|
||||||
const cef_string_t* attrName);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a map of all element attributes.
|
// Returns a map of all element attributes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_element_attributes)(struct _cef_domnode_t* self,
|
void (CEF_CALLBACK *get_element_attributes)(struct _cef_domnode_t* self,
|
||||||
cef_string_map_t attrMap);
|
cef_string_map_t attrMap);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the value for the element attribute named |attrName|. Returns true (1)
|
// Set the value for the element attribute named |attrName|. Returns true (1)
|
||||||
// on success.
|
// on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_element_attribute)(struct _cef_domnode_t* self,
|
int (CEF_CALLBACK *set_element_attribute)(struct _cef_domnode_t* self,
|
||||||
const cef_string_t* attrName,
|
const cef_string_t* attrName, const cef_string_t* value);
|
||||||
const cef_string_t* value);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the inner text of the element.
|
// Returns the inner text of the element.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_element_inner_text)(
|
cef_string_userfree_t (CEF_CALLBACK *get_element_inner_text)(
|
||||||
struct _cef_domnode_t* self);
|
struct _cef_domnode_t* self);
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the bounds of the element.
|
|
||||||
///
|
|
||||||
cef_rect_t(CEF_CALLBACK* get_element_bounds)(struct _cef_domnode_t* self);
|
|
||||||
} cef_domnode_t;
|
} cef_domnode_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=f0ceb73b289072a01c45c6e7abf339a4ec924d29$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_HANDLER_CAPI_H_
|
||||||
@@ -48,6 +46,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure used to asynchronously continue a download.
|
// Callback structure used to asynchronously continue a download.
|
||||||
///
|
///
|
||||||
@@ -55,7 +54,7 @@ typedef struct _cef_before_download_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Call to continue the download. Set |download_path| to the full file path
|
// Call to continue the download. Set |download_path| to the full file path
|
||||||
@@ -63,11 +62,11 @@ typedef struct _cef_before_download_callback_t {
|
|||||||
// suggested name and the default temp directory. Set |show_dialog| to true
|
// suggested name and the default temp directory. Set |show_dialog| to true
|
||||||
// (1) if you do wish to show the default "Save As" dialog.
|
// (1) if you do wish to show the default "Save As" dialog.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_before_download_callback_t* self,
|
void (CEF_CALLBACK *cont)(struct _cef_before_download_callback_t* self,
|
||||||
const cef_string_t* download_path,
|
const cef_string_t* download_path, int show_dialog);
|
||||||
int show_dialog);
|
|
||||||
} cef_before_download_callback_t;
|
} cef_before_download_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure used to asynchronously cancel a download.
|
// Callback structure used to asynchronously cancel a download.
|
||||||
///
|
///
|
||||||
@@ -75,24 +74,25 @@ typedef struct _cef_download_item_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Call to cancel the download.
|
// Call to cancel the download.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_download_item_callback_t* self);
|
void (CEF_CALLBACK *cancel)(struct _cef_download_item_callback_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Call to pause the download.
|
// Call to pause the download.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* pause)(struct _cef_download_item_callback_t* self);
|
void (CEF_CALLBACK *pause)(struct _cef_download_item_callback_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Call to resume the download.
|
// Call to resume the download.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* resume)(struct _cef_download_item_callback_t* self);
|
void (CEF_CALLBACK *resume)(struct _cef_download_item_callback_t* self);
|
||||||
} cef_download_item_callback_t;
|
} cef_download_item_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to handle file downloads. The functions of this structure will
|
// Structure used to handle file downloads. The functions of this structure will
|
||||||
// called on the browser process UI thread.
|
// called on the browser process UI thread.
|
||||||
@@ -101,7 +101,7 @@ typedef struct _cef_download_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called before a download begins. |suggested_name| is the suggested name for
|
// Called before a download begins. |suggested_name| is the suggested name for
|
||||||
@@ -110,8 +110,7 @@ typedef struct _cef_download_handler_t {
|
|||||||
// download if desired. Do not keep a reference to |download_item| outside of
|
// download if desired. Do not keep a reference to |download_item| outside of
|
||||||
// this function.
|
// this function.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_download)(
|
void (CEF_CALLBACK *on_before_download)(struct _cef_download_handler_t* self,
|
||||||
struct _cef_download_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
struct _cef_download_item_t* download_item,
|
struct _cef_download_item_t* download_item,
|
||||||
const cef_string_t* suggested_name,
|
const cef_string_t* suggested_name,
|
||||||
@@ -124,13 +123,13 @@ typedef struct _cef_download_handler_t {
|
|||||||
// download if desired. Do not keep a reference to |download_item| outside of
|
// download if desired. Do not keep a reference to |download_item| outside of
|
||||||
// this function.
|
// this function.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_download_updated)(
|
void (CEF_CALLBACK *on_download_updated)(struct _cef_download_handler_t* self,
|
||||||
struct _cef_download_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
struct _cef_download_item_t* download_item,
|
struct _cef_download_item_t* download_item,
|
||||||
struct _cef_download_item_callback_t* callback);
|
struct _cef_download_item_callback_t* callback);
|
||||||
} cef_download_handler_t;
|
} cef_download_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=d84044bb582b029af5fa46c75f35b3da948dffd2$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DOWNLOAD_ITEM_CAPI_H_
|
||||||
@@ -46,6 +44,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to represent a download item.
|
// Structure used to represent a download item.
|
||||||
///
|
///
|
||||||
@@ -53,108 +52,109 @@ typedef struct _cef_download_item_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this object is valid. Do not call any other functions
|
// Returns true (1) if this object is valid. Do not call any other functions
|
||||||
// if this function returns false (0).
|
// if this function returns false (0).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_valid)(struct _cef_download_item_t* self);
|
int (CEF_CALLBACK *is_valid)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the download is in progress.
|
// Returns true (1) if the download is in progress.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_in_progress)(struct _cef_download_item_t* self);
|
int (CEF_CALLBACK *is_in_progress)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the download is complete.
|
// Returns true (1) if the download is complete.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_complete)(struct _cef_download_item_t* self);
|
int (CEF_CALLBACK *is_complete)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the download has been canceled or interrupted.
|
// Returns true (1) if the download has been canceled or interrupted.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_canceled)(struct _cef_download_item_t* self);
|
int (CEF_CALLBACK *is_canceled)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a simple speed estimate in bytes/s.
|
// Returns a simple speed estimate in bytes/s.
|
||||||
///
|
///
|
||||||
int64(CEF_CALLBACK* get_current_speed)(struct _cef_download_item_t* self);
|
int64 (CEF_CALLBACK *get_current_speed)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the rough percent complete or -1 if the receive total size is
|
// Returns the rough percent complete or -1 if the receive total size is
|
||||||
// unknown.
|
// unknown.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_percent_complete)(struct _cef_download_item_t* self);
|
int (CEF_CALLBACK *get_percent_complete)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the total number of bytes.
|
// Returns the total number of bytes.
|
||||||
///
|
///
|
||||||
int64(CEF_CALLBACK* get_total_bytes)(struct _cef_download_item_t* self);
|
int64 (CEF_CALLBACK *get_total_bytes)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the number of received bytes.
|
// Returns the number of received bytes.
|
||||||
///
|
///
|
||||||
int64(CEF_CALLBACK* get_received_bytes)(struct _cef_download_item_t* self);
|
int64 (CEF_CALLBACK *get_received_bytes)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the time that the download started.
|
// Returns the time that the download started.
|
||||||
///
|
///
|
||||||
cef_time_t(CEF_CALLBACK* get_start_time)(struct _cef_download_item_t* self);
|
cef_time_t (CEF_CALLBACK *get_start_time)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the time that the download ended.
|
// Returns the time that the download ended.
|
||||||
///
|
///
|
||||||
cef_time_t(CEF_CALLBACK* get_end_time)(struct _cef_download_item_t* self);
|
cef_time_t (CEF_CALLBACK *get_end_time)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the full path to the downloaded or downloading file.
|
// Returns the full path to the downloaded or downloading file.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_full_path)(
|
cef_string_userfree_t (CEF_CALLBACK *get_full_path)(
|
||||||
struct _cef_download_item_t* self);
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the unique identifier for this download.
|
// Returns the unique identifier for this download.
|
||||||
///
|
///
|
||||||
uint32(CEF_CALLBACK* get_id)(struct _cef_download_item_t* self);
|
uint32 (CEF_CALLBACK *get_id)(struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL.
|
// Returns the URL.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_url)(
|
||||||
struct _cef_download_item_t* self);
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the original URL before any redirections.
|
// Returns the original URL before any redirections.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_original_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_original_url)(
|
||||||
struct _cef_download_item_t* self);
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the suggested file name.
|
// Returns the suggested file name.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_suggested_file_name)(
|
cef_string_userfree_t (CEF_CALLBACK *get_suggested_file_name)(
|
||||||
struct _cef_download_item_t* self);
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the content disposition.
|
// Returns the content disposition.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_content_disposition)(
|
cef_string_userfree_t (CEF_CALLBACK *get_content_disposition)(
|
||||||
struct _cef_download_item_t* self);
|
struct _cef_download_item_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the mime type.
|
// Returns the mime type.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_mime_type)(
|
cef_string_userfree_t (CEF_CALLBACK *get_mime_type)(
|
||||||
struct _cef_download_item_t* self);
|
struct _cef_download_item_t* self);
|
||||||
} cef_download_item_t;
|
} cef_download_item_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,21 +33,19 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=9663321e2be1d000ac54e195c81f210ae40773d1$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DRAG_DATA_CAPI_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
#include "include/capi/cef_image_capi.h"
|
|
||||||
#include "include/capi/cef_stream_capi.h"
|
#include "include/capi/cef_stream_capi.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to represent drag data. The functions of this structure may be
|
// Structure used to represent drag data. The functions of this structure may be
|
||||||
// called on any thread.
|
// called on any thread.
|
||||||
@@ -56,66 +54,66 @@ typedef struct _cef_drag_data_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a copy of the current object.
|
// Returns a copy of the current object.
|
||||||
///
|
///
|
||||||
struct _cef_drag_data_t*(CEF_CALLBACK* clone)(struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* (CEF_CALLBACK *clone)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this object is read-only.
|
// Returns true (1) if this object is read-only.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_read_only)(struct _cef_drag_data_t* self);
|
int (CEF_CALLBACK *is_read_only)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the drag data is a link.
|
// Returns true (1) if the drag data is a link.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_link)(struct _cef_drag_data_t* self);
|
int (CEF_CALLBACK *is_link)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the drag data is a text or html fragment.
|
// Returns true (1) if the drag data is a text or html fragment.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_fragment)(struct _cef_drag_data_t* self);
|
int (CEF_CALLBACK *is_fragment)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the drag data is a file.
|
// Returns true (1) if the drag data is a file.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_file)(struct _cef_drag_data_t* self);
|
int (CEF_CALLBACK *is_file)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the link URL that is being dragged.
|
// Return the link URL that is being dragged.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_link_url)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the title associated with the link being dragged.
|
// Return the title associated with the link being dragged.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_link_title)(
|
cef_string_userfree_t (CEF_CALLBACK *get_link_title)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the metadata, if any, associated with the link being dragged.
|
// Return the metadata, if any, associated with the link being dragged.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_link_metadata)(
|
cef_string_userfree_t (CEF_CALLBACK *get_link_metadata)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the plain text fragment that is being dragged.
|
// Return the plain text fragment that is being dragged.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_fragment_text)(
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_text)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the text/html fragment that is being dragged.
|
// Return the text/html fragment that is being dragged.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_fragment_html)(
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_html)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -123,14 +121,14 @@ typedef struct _cef_drag_data_t {
|
|||||||
// resolving relative URLs and may be NULL.
|
// resolving relative URLs and may be NULL.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_fragment_base_url)(
|
cef_string_userfree_t (CEF_CALLBACK *get_fragment_base_url)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the name of the file being dragged out of the browser window.
|
// Return the name of the file being dragged out of the browser window.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_file_name)(
|
cef_string_userfree_t (CEF_CALLBACK *get_file_name)(
|
||||||
struct _cef_drag_data_t* self);
|
struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -139,50 +137,50 @@ typedef struct _cef_drag_data_t {
|
|||||||
// this function will return the size of the file contents in bytes. Call
|
// this function will return the size of the file contents in bytes. Call
|
||||||
// get_file_name() to get a suggested name for the file.
|
// get_file_name() to get a suggested name for the file.
|
||||||
///
|
///
|
||||||
size_t(CEF_CALLBACK* get_file_contents)(struct _cef_drag_data_t* self,
|
size_t (CEF_CALLBACK *get_file_contents)(struct _cef_drag_data_t* self,
|
||||||
struct _cef_stream_writer_t* writer);
|
struct _cef_stream_writer_t* writer);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieve the list of file names that are being dragged into the browser
|
// Retrieve the list of file names that are being dragged into the browser
|
||||||
// window.
|
// window.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_file_names)(struct _cef_drag_data_t* self,
|
int (CEF_CALLBACK *get_file_names)(struct _cef_drag_data_t* self,
|
||||||
cef_string_list_t names);
|
cef_string_list_t names);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the link URL that is being dragged.
|
// Set the link URL that is being dragged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_link_url)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *set_link_url)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* url);
|
const cef_string_t* url);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the title associated with the link being dragged.
|
// Set the title associated with the link being dragged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_link_title)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *set_link_title)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* title);
|
const cef_string_t* title);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the metadata associated with the link being dragged.
|
// Set the metadata associated with the link being dragged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_link_metadata)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *set_link_metadata)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* data);
|
const cef_string_t* data);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the plain text fragment that is being dragged.
|
// Set the plain text fragment that is being dragged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_fragment_text)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *set_fragment_text)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* text);
|
const cef_string_t* text);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the text/html fragment that is being dragged.
|
// Set the text/html fragment that is being dragged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_fragment_html)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *set_fragment_html)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* html);
|
const cef_string_t* html);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the base URL that the fragment came from.
|
// Set the base URL that the fragment came from.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_fragment_base_url)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *set_fragment_base_url)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* base_url);
|
const cef_string_t* base_url);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -190,37 +188,22 @@ typedef struct _cef_drag_data_t {
|
|||||||
// cef_browser_host_t::DragTargetDragEnter as the web view does not allow us
|
// cef_browser_host_t::DragTargetDragEnter as the web view does not allow us
|
||||||
// to drag in this kind of data.
|
// to drag in this kind of data.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* reset_file_contents)(struct _cef_drag_data_t* self);
|
void (CEF_CALLBACK *reset_file_contents)(struct _cef_drag_data_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a file that is being dragged into the webview.
|
// Add a file that is being dragged into the webview.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* add_file)(struct _cef_drag_data_t* self,
|
void (CEF_CALLBACK *add_file)(struct _cef_drag_data_t* self,
|
||||||
const cef_string_t* path,
|
const cef_string_t* path, const cef_string_t* display_name);
|
||||||
const cef_string_t* display_name);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Get the image representation of drag data. May return NULL if no image
|
|
||||||
// representation is available.
|
|
||||||
///
|
|
||||||
struct _cef_image_t*(CEF_CALLBACK* get_image)(struct _cef_drag_data_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Get the image hotspot (drag start location relative to image dimensions).
|
|
||||||
///
|
|
||||||
cef_point_t(CEF_CALLBACK* get_image_hotspot)(struct _cef_drag_data_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if an image representation of drag data is available.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* has_image)(struct _cef_drag_data_t* self);
|
|
||||||
} cef_drag_data_t;
|
} cef_drag_data_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Create a new cef_drag_data_t object.
|
// Create a new cef_drag_data_t object.
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_drag_data_t* cef_drag_data_create();
|
CEF_EXPORT cef_drag_data_t* cef_drag_data_create();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=1cc1f134e68406ae3b05f7e181e12f27262772f0$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_DRAG_HANDLER_CAPI_H_
|
||||||
@@ -43,12 +41,12 @@
|
|||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
#include "include/capi/cef_browser_capi.h"
|
#include "include/capi/cef_browser_capi.h"
|
||||||
#include "include/capi/cef_drag_data_capi.h"
|
#include "include/capi/cef_drag_data_capi.h"
|
||||||
#include "include/capi/cef_frame_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to dragging. The functions
|
// Implement this structure to handle events related to dragging. The functions
|
||||||
// of this structure will be called on the UI thread.
|
// of this structure will be called on the UI thread.
|
||||||
@@ -57,7 +55,7 @@ typedef struct _cef_drag_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when an external drag event enters the browser window. |dragData|
|
// Called when an external drag event enters the browser window. |dragData|
|
||||||
@@ -65,9 +63,8 @@ typedef struct _cef_drag_handler_t {
|
|||||||
// operation. Return false (0) for default drag handling behavior or true (1)
|
// operation. Return false (0) for default drag handling behavior or true (1)
|
||||||
// to cancel the drag event.
|
// to cancel the drag event.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_drag_enter)(struct _cef_drag_handler_t* self,
|
int (CEF_CALLBACK *on_drag_enter)(struct _cef_drag_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, struct _cef_drag_data_t* dragData,
|
||||||
struct _cef_drag_data_t* dragData,
|
|
||||||
cef_drag_operations_mask_t mask);
|
cef_drag_operations_mask_t mask);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -77,14 +74,12 @@ typedef struct _cef_drag_handler_t {
|
|||||||
// never be called. If the last draggable region is removed from a document
|
// never be called. If the last draggable region is removed from a document
|
||||||
// this function will be called with an NULL vector.
|
// this function will be called with an NULL vector.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_draggable_regions_changed)(
|
void (CEF_CALLBACK *on_draggable_regions_changed)(
|
||||||
struct _cef_drag_handler_t* self,
|
struct _cef_drag_handler_t* self, struct _cef_browser_t* browser,
|
||||||
struct _cef_browser_t* browser,
|
size_t regionsCount, cef_draggable_region_t const* regions);
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
size_t regionsCount,
|
|
||||||
cef_draggable_region_t const* regions);
|
|
||||||
} cef_drag_handler_t;
|
} cef_drag_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=5d5251098be1477705de2a21502dec2d8338ce00$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
#include "include/capi/cef_values_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _cef_extension_handler_t;
|
|
||||||
struct _cef_request_context_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Object representing an extension. Methods may be called on any thread unless
|
|
||||||
// otherwise indicated.
|
|
||||||
///
|
|
||||||
typedef struct _cef_extension_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the unique extension identifier. This is calculated based on the
|
|
||||||
// extension public key, if available, or on the extension path. See
|
|
||||||
// https://developer.chrome.com/extensions/manifest/key for details.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_identifier)(
|
|
||||||
struct _cef_extension_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the absolute path to the extension directory on disk. This value
|
|
||||||
// will be prefixed with PK_DIR_RESOURCES if a relative path was passed to
|
|
||||||
// cef_request_context_t::LoadExtension.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_path)(struct _cef_extension_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the extension manifest contents as a cef_dictionary_value_t object.
|
|
||||||
// See https://developer.chrome.com/extensions/manifest for details.
|
|
||||||
///
|
|
||||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_manifest)(
|
|
||||||
struct _cef_extension_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this object is the same extension as |that| object.
|
|
||||||
// Extensions are considered the same if identifier, path and loader context
|
|
||||||
// match.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_same)(struct _cef_extension_t* self,
|
|
||||||
struct _cef_extension_t* that);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the handler for this extension. Will return NULL for internal
|
|
||||||
// extensions or if no handler was passed to
|
|
||||||
// cef_request_context_t::LoadExtension.
|
|
||||||
///
|
|
||||||
struct _cef_extension_handler_t*(CEF_CALLBACK* get_handler)(
|
|
||||||
struct _cef_extension_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the request context that loaded this extension. Will return NULL
|
|
||||||
// for internal extensions or if the extension has been unloaded. See the
|
|
||||||
// cef_request_context_t::LoadExtension documentation for more information
|
|
||||||
// about loader contexts. Must be called on the browser process UI thread.
|
|
||||||
///
|
|
||||||
struct _cef_request_context_t*(CEF_CALLBACK* get_loader_context)(
|
|
||||||
struct _cef_extension_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this extension is currently loaded. Must be called on
|
|
||||||
// the browser process UI thread.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_loaded)(struct _cef_extension_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Unload this extension if it is not an internal extension and is currently
|
|
||||||
// loaded. Will result in a call to
|
|
||||||
// cef_extension_handler_t::OnExtensionUnloaded on success.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* unload)(struct _cef_extension_t* self);
|
|
||||||
} cef_extension_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_CAPI_H_
|
|
||||||
@@ -1,210 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=c952241dabb9d99109ebb64acba0124e43150628$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
#include "include/capi/cef_browser_capi.h"
|
|
||||||
#include "include/capi/cef_extension_capi.h"
|
|
||||||
#include "include/capi/cef_stream_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _cef_client_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Callback structure used for asynchronous continuation of
|
|
||||||
// cef_extension_handler_t::GetExtensionResource.
|
|
||||||
///
|
|
||||||
typedef struct _cef_get_extension_resource_callback_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Continue the request. Read the resource contents from |stream|.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_get_extension_resource_callback_t* self,
|
|
||||||
struct _cef_stream_reader_t* stream);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Cancel the request.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* cancel)(
|
|
||||||
struct _cef_get_extension_resource_callback_t* self);
|
|
||||||
} cef_get_extension_resource_callback_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Implement this structure to handle events related to browser extensions. The
|
|
||||||
// functions of this structure will be called on the UI thread. See
|
|
||||||
// cef_request_context_t::LoadExtension for information about extension loading.
|
|
||||||
///
|
|
||||||
typedef struct _cef_extension_handler_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called if the cef_request_context_t::LoadExtension request fails. |result|
|
|
||||||
// will be the error code.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_extension_load_failed)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
cef_errorcode_t result);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called if the cef_request_context_t::LoadExtension request succeeds.
|
|
||||||
// |extension| is the loaded extension.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_extension_loaded)(struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called after the cef_extension_t::Unload request has completed.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_extension_unloaded)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when an extension needs a browser to host a background script
|
|
||||||
// specified via the "background" manifest key. The browser will have no
|
|
||||||
// visible window and cannot be displayed. |extension| is the extension that
|
|
||||||
// is loading the background script. |url| is an internally generated
|
|
||||||
// reference to an HTML page that will be used to load the background script
|
|
||||||
// via a <script> src attribute. To allow creation of the browser optionally
|
|
||||||
// modify |client| and |settings| and return false (0). To cancel creation of
|
|
||||||
// the browser (and consequently cancel load of the background script) return
|
|
||||||
// true (1). Successful creation will be indicated by a call to
|
|
||||||
// cef_life_span_handler_t::OnAfterCreated, and
|
|
||||||
// cef_browser_host_t::IsBackgroundHost will return true (1) for the resulting
|
|
||||||
// browser. See https://developer.chrome.com/extensions/event_pages for more
|
|
||||||
// information about extension background script usage.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* on_before_background_browser)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension,
|
|
||||||
const cef_string_t* url,
|
|
||||||
struct _cef_client_t** client,
|
|
||||||
struct _cef_browser_settings_t* settings);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when an extension API (e.g. chrome.tabs.create) requests creation of
|
|
||||||
// a new browser. |extension| and |browser| are the source of the API call.
|
|
||||||
// |active_browser| may optionally be specified via the windowId property or
|
|
||||||
// returned via the get_active_browser() callback and provides the default
|
|
||||||
// |client| and |settings| values for the new browser. |index| is the position
|
|
||||||
// value optionally specified via the index property. |url| is the URL that
|
|
||||||
// will be loaded in the browser. |active| is true (1) if the new browser
|
|
||||||
// should be active when opened. To allow creation of the browser optionally
|
|
||||||
// modify |windowInfo|, |client| and |settings| and return false (0). To
|
|
||||||
// cancel creation of the browser return true (1). Successful creation will be
|
|
||||||
// indicated by a call to cef_life_span_handler_t::OnAfterCreated. Any
|
|
||||||
// modifications to |windowInfo| will be ignored if |active_browser| is
|
|
||||||
// wrapped in a cef_browser_view_t.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* on_before_browser)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_browser_t* active_browser,
|
|
||||||
int index,
|
|
||||||
const cef_string_t* url,
|
|
||||||
int active,
|
|
||||||
struct _cef_window_info_t* windowInfo,
|
|
||||||
struct _cef_client_t** client,
|
|
||||||
struct _cef_browser_settings_t* settings);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when no tabId is specified to an extension API call that accepts a
|
|
||||||
// tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the
|
|
||||||
// source of the API call. Return the browser that will be acted on by the API
|
|
||||||
// call or return NULL to act on |browser|. The returned browser must share
|
|
||||||
// the same cef_request_context_t as |browser|. Incognito browsers should not
|
|
||||||
// be considered unless the source extension has incognito access enabled, in
|
|
||||||
// which case |include_incognito| will be true (1).
|
|
||||||
///
|
|
||||||
struct _cef_browser_t*(CEF_CALLBACK* get_active_browser)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
int include_incognito);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when the tabId associated with |target_browser| is specified to an
|
|
||||||
// extension API call that accepts a tabId parameter (e.g. chrome.tabs.*).
|
|
||||||
// |extension| and |browser| are the source of the API call. Return true (1)
|
|
||||||
// to allow access of false (0) to deny access. Access to incognito browsers
|
|
||||||
// should not be allowed unless the source extension has incognito access
|
|
||||||
// enabled, in which case |include_incognito| will be true (1).
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* can_access_browser)(struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
int include_incognito,
|
|
||||||
struct _cef_browser_t* target_browser);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called to retrieve an extension resource that would normally be loaded from
|
|
||||||
// disk (e.g. if a file parameter is specified to chrome.tabs.executeScript).
|
|
||||||
// |extension| and |browser| are the source of the resource request. |file| is
|
|
||||||
// the requested relative file path. To handle the resource request return
|
|
||||||
// true (1) and execute |callback| either synchronously or asynchronously. For
|
|
||||||
// the default behavior which reads the resource from the extension directory
|
|
||||||
// on disk return false (0). Localization substitutions will not be applied to
|
|
||||||
// resources handled via this function.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* get_extension_resource)(
|
|
||||||
struct _cef_extension_handler_t* self,
|
|
||||||
struct _cef_extension_t* extension,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
const cef_string_t* file,
|
|
||||||
struct _cef_get_extension_resource_callback_t* callback);
|
|
||||||
} cef_extension_handler_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=00d75d4f1968686cec7db84a59df89d98d8fe146$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///
|
|
||||||
// Creates a directory and all parent directories if they don't already exist.
|
|
||||||
// Returns true (1) on successful creation or if the directory already exists.
|
|
||||||
// The directory is only readable by the current user. Calling this function on
|
|
||||||
// the browser process UI or IO threads is not allowed.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_create_directory(const cef_string_t* full_path);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Get the temporary directory provided by the system.
|
|
||||||
//
|
|
||||||
// WARNING: In general, you should use the temp directory variants below instead
|
|
||||||
// of this function. Those variants will ensure that the proper permissions are
|
|
||||||
// set so that other users on the system can't edit them while they're open
|
|
||||||
// (which could lead to security issues).
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_get_temp_directory(cef_string_t* temp_dir);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Creates a new directory. On Windows if |prefix| is provided the new directory
|
|
||||||
// name is in the format of "prefixyyyy". Returns true (1) on success and sets
|
|
||||||
// |new_temp_path| to the full path of the directory that was created. The
|
|
||||||
// directory is only readable by the current user. Calling this function on the
|
|
||||||
// browser process UI or IO threads is not allowed.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_create_new_temp_directory(const cef_string_t* prefix,
|
|
||||||
cef_string_t* new_temp_path);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Creates a directory within another directory. Extra characters will be
|
|
||||||
// appended to |prefix| to ensure that the new directory does not have the same
|
|
||||||
// name as an existing directory. Returns true (1) on success and sets |new_dir|
|
|
||||||
// to the full path of the directory that was created. The directory is only
|
|
||||||
// readable by the current user. Calling this function on the browser process UI
|
|
||||||
// or IO threads is not allowed.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_create_temp_directory_in_directory(
|
|
||||||
const cef_string_t* base_dir,
|
|
||||||
const cef_string_t* prefix,
|
|
||||||
cef_string_t* new_dir);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if the given path exists and is a directory. Calling this
|
|
||||||
// function on the browser process UI or IO threads is not allowed.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_directory_exists(const cef_string_t* path);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Deletes the given path whether it's a file or a directory. If |path| is a
|
|
||||||
// directory all contents will be deleted. If |recursive| is true (1) any sub-
|
|
||||||
// directories and their contents will also be deleted (equivalent to executing
|
|
||||||
// "rm -rf", so use with caution). On POSIX environments if |path| is a symbolic
|
|
||||||
// link then only the symlink will be deleted. Returns true (1) on successful
|
|
||||||
// deletion or if |path| does not exist. Calling this function on the browser
|
|
||||||
// process UI or IO threads is not allowed.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_delete_file(const cef_string_t* path, int recursive);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Writes the contents of |src_dir| into a zip archive at |dest_file|. If
|
|
||||||
// |include_hidden_files| is true (1) files starting with "." will be included.
|
|
||||||
// Returns true (1) on success. Calling this function on the browser process UI
|
|
||||||
// or IO threads is not allowed.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_zip_directory(const cef_string_t* src_dir,
|
|
||||||
const cef_string_t* dest_file,
|
|
||||||
int include_hidden_files);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Loads the existing "Certificate Revocation Lists" file that is managed by
|
|
||||||
// Google Chrome. This file can generally be found in Chrome's User Data
|
|
||||||
// directory (e.g. "C:\Users\[User]\AppData\Local\Google\Chrome\User Data\" on
|
|
||||||
// Windows) and is updated periodically by Chrome's component updater service.
|
|
||||||
// Must be called in the browser process after the context has been initialized.
|
|
||||||
// See https://dev.chromium.org/Home/chromium-security/crlsets for background.
|
|
||||||
///
|
|
||||||
CEF_EXPORT void cef_load_crlsets_file(const cef_string_t* path);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_FILE_UTIL_CAPI_H_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=03bb69a14868a95abf3bf7b1608dc351480e307f$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_FIND_HANDLER_CAPI_H_
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to find results. The
|
// Implement this structure to handle events related to find results. The
|
||||||
// functions of this structure will be called on the UI thread.
|
// functions of this structure will be called on the UI thread.
|
||||||
@@ -55,7 +54,7 @@ typedef struct _cef_find_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to report find results returned by cef_browser_host_t::find().
|
// Called to report find results returned by cef_browser_host_t::find().
|
||||||
@@ -65,15 +64,13 @@ typedef struct _cef_find_handler_t {
|
|||||||
// current position in the search results, and |finalUpdate| is true (1) if
|
// current position in the search results, and |finalUpdate| is true (1) if
|
||||||
// this is the last find notification.
|
// this is the last find notification.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_find_result)(struct _cef_find_handler_t* self,
|
void (CEF_CALLBACK *on_find_result)(struct _cef_find_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, int identifier, int count,
|
||||||
int identifier,
|
const cef_rect_t* selectionRect, int activeMatchOrdinal,
|
||||||
int count,
|
|
||||||
const cef_rect_t* selectionRect,
|
|
||||||
int activeMatchOrdinal,
|
|
||||||
int finalUpdate);
|
int finalUpdate);
|
||||||
} cef_find_handler_t;
|
} cef_find_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=0fccb41381e922e9d9545ae45ba3e6cf1916c4b0$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_FOCUS_HANDLER_CAPI_H_
|
||||||
@@ -49,6 +47,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to focus. The functions of
|
// Implement this structure to handle events related to focus. The functions of
|
||||||
// this structure will be called on the UI thread.
|
// this structure will be called on the UI thread.
|
||||||
@@ -57,7 +56,7 @@ typedef struct _cef_focus_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser component is about to loose focus. For instance, if
|
// Called when the browser component is about to loose focus. For instance, if
|
||||||
@@ -65,26 +64,25 @@ typedef struct _cef_focus_handler_t {
|
|||||||
// will be true (1) if the browser is giving focus to the next component and
|
// will be true (1) if the browser is giving focus to the next component and
|
||||||
// false (0) if the browser is giving focus to the previous component.
|
// false (0) if the browser is giving focus to the previous component.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_take_focus)(struct _cef_focus_handler_t* self,
|
void (CEF_CALLBACK *on_take_focus)(struct _cef_focus_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, int next);
|
||||||
int next);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser component is requesting focus. |source| indicates
|
// Called when the browser component is requesting focus. |source| indicates
|
||||||
// where the focus request is originating from. Return false (0) to allow the
|
// where the focus request is originating from. Return false (0) to allow the
|
||||||
// focus to be set or true (1) to cancel setting the focus.
|
// focus to be set or true (1) to cancel setting the focus.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_set_focus)(struct _cef_focus_handler_t* self,
|
int (CEF_CALLBACK *on_set_focus)(struct _cef_focus_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, cef_focus_source_t source);
|
||||||
cef_focus_source_t source);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser component has received focus.
|
// Called when the browser component has received focus.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_got_focus)(struct _cef_focus_handler_t* self,
|
void (CEF_CALLBACK *on_got_focus)(struct _cef_focus_handler_t* self,
|
||||||
struct _cef_browser_t* browser);
|
struct _cef_browser_t* browser);
|
||||||
} cef_focus_handler_t;
|
} cef_focus_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=872fd1e811d41f56f03da0da75a8f2e89cad40cd$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
||||||
@@ -42,7 +40,6 @@
|
|||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
#include "include/capi/cef_dom_capi.h"
|
#include "include/capi/cef_dom_capi.h"
|
||||||
#include "include/capi/cef_process_message_capi.h"
|
|
||||||
#include "include/capi/cef_request_capi.h"
|
#include "include/capi/cef_request_capi.h"
|
||||||
#include "include/capi/cef_stream_capi.h"
|
#include "include/capi/cef_stream_capi.h"
|
||||||
#include "include/capi/cef_string_visitor_capi.h"
|
#include "include/capi/cef_string_visitor_capi.h"
|
||||||
@@ -52,8 +49,6 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct _cef_browser_t;
|
struct _cef_browser_t;
|
||||||
struct _cef_urlrequest_client_t;
|
|
||||||
struct _cef_urlrequest_t;
|
|
||||||
struct _cef_v8context_t;
|
struct _cef_v8context_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -66,85 +61,89 @@ typedef struct _cef_frame_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// True if this object is currently attached to a valid frame.
|
// True if this object is currently attached to a valid frame.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_valid)(struct _cef_frame_t* self);
|
int (CEF_CALLBACK *is_valid)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute undo in this frame.
|
// Execute undo in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* undo)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *undo)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute redo in this frame.
|
// Execute redo in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* redo)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *redo)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute cut in this frame.
|
// Execute cut in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cut)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *cut)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute copy in this frame.
|
// Execute copy in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* copy)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *copy)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute paste in this frame.
|
// Execute paste in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* paste)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *paste)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute delete in this frame.
|
// Execute delete in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* del)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *del)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute select all in this frame.
|
// Execute select all in this frame.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* select_all)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *select_all)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Save this frame's HTML source to a temporary file and open it in the
|
// Save this frame's HTML source to a temporary file and open it in the
|
||||||
// default text viewing application. This function can only be called from the
|
// default text viewing application. This function can only be called from the
|
||||||
// browser process.
|
// browser process.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* view_source)(struct _cef_frame_t* self);
|
void (CEF_CALLBACK *view_source)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieve this frame's HTML source as a string sent to the specified
|
// Retrieve this frame's HTML source as a string sent to the specified
|
||||||
// visitor.
|
// visitor.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_source)(struct _cef_frame_t* self,
|
void (CEF_CALLBACK *get_source)(struct _cef_frame_t* self,
|
||||||
struct _cef_string_visitor_t* visitor);
|
struct _cef_string_visitor_t* visitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieve this frame's display text as a string sent to the specified
|
// Retrieve this frame's display text as a string sent to the specified
|
||||||
// visitor.
|
// visitor.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_text)(struct _cef_frame_t* self,
|
void (CEF_CALLBACK *get_text)(struct _cef_frame_t* self,
|
||||||
struct _cef_string_visitor_t* visitor);
|
struct _cef_string_visitor_t* visitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Load the request represented by the |request| object.
|
// Load the request represented by the |request| object.
|
||||||
//
|
|
||||||
// WARNING: This function will fail with "bad IPC message" reason
|
|
||||||
// INVALID_INITIATOR_ORIGIN (213) unless you first navigate to the request
|
|
||||||
// origin using some other mechanism (LoadURL, link click, etc).
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* load_request)(struct _cef_frame_t* self,
|
void (CEF_CALLBACK *load_request)(struct _cef_frame_t* self,
|
||||||
struct _cef_request_t* request);
|
struct _cef_request_t* request);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Load the specified |url|.
|
// Load the specified |url|.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* load_url)(struct _cef_frame_t* self,
|
void (CEF_CALLBACK *load_url)(struct _cef_frame_t* self,
|
||||||
const cef_string_t* url);
|
const cef_string_t* url);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Load the contents of |string_val| with the specified dummy |url|. |url|
|
||||||
|
// should have a standard scheme (for example, http scheme) or behaviors like
|
||||||
|
// link clicks and web security restrictions may not behave as expected.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *load_string)(struct _cef_frame_t* self,
|
||||||
|
const cef_string_t* string_val, const cef_string_t* url);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Execute a string of JavaScript code in this frame. The |script_url|
|
// Execute a string of JavaScript code in this frame. The |script_url|
|
||||||
// parameter is the URL where the script in question can be found, if any. The
|
// parameter is the URL where the script in question can be found, if any. The
|
||||||
@@ -152,20 +151,19 @@ typedef struct _cef_frame_t {
|
|||||||
// error. The |start_line| parameter is the base line number to use for error
|
// error. The |start_line| parameter is the base line number to use for error
|
||||||
// reporting.
|
// reporting.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* execute_java_script)(struct _cef_frame_t* self,
|
void (CEF_CALLBACK *execute_java_script)(struct _cef_frame_t* self,
|
||||||
const cef_string_t* code,
|
const cef_string_t* code, const cef_string_t* script_url,
|
||||||
const cef_string_t* script_url,
|
|
||||||
int start_line);
|
int start_line);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this is the main (top-level) frame.
|
// Returns true (1) if this is the main (top-level) frame.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_main)(struct _cef_frame_t* self);
|
int (CEF_CALLBACK *is_main)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this is the focused frame.
|
// Returns true (1) if this is the focused frame.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_focused)(struct _cef_frame_t* self);
|
int (CEF_CALLBACK *is_focused)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the name for this frame. If the frame has an assigned name (for
|
// Returns the name for this frame. If the frame has an assigned name (for
|
||||||
@@ -175,86 +173,47 @@ typedef struct _cef_frame_t {
|
|||||||
// value.
|
// value.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_frame_t* self);
|
cef_string_userfree_t (CEF_CALLBACK *get_name)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the globally unique identifier for this frame or < 0 if the
|
// Returns the globally unique identifier for this frame or < 0 if the
|
||||||
// underlying frame does not yet exist.
|
// underlying frame does not yet exist.
|
||||||
///
|
///
|
||||||
int64(CEF_CALLBACK* get_identifier)(struct _cef_frame_t* self);
|
int64 (CEF_CALLBACK *get_identifier)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the parent of this frame or NULL if this is the main (top-level)
|
// Returns the parent of this frame or NULL if this is the main (top-level)
|
||||||
// frame.
|
// frame.
|
||||||
///
|
///
|
||||||
struct _cef_frame_t*(CEF_CALLBACK* get_parent)(struct _cef_frame_t* self);
|
struct _cef_frame_t* (CEF_CALLBACK *get_parent)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL currently loaded in this frame.
|
// Returns the URL currently loaded in this frame.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_url)(struct _cef_frame_t* self);
|
cef_string_userfree_t (CEF_CALLBACK *get_url)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the browser that this frame belongs to.
|
// Returns the browser that this frame belongs to.
|
||||||
///
|
///
|
||||||
struct _cef_browser_t*(CEF_CALLBACK* get_browser)(struct _cef_frame_t* self);
|
struct _cef_browser_t* (CEF_CALLBACK *get_browser)(struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Get the V8 context associated with the frame. This function can only be
|
// Get the V8 context associated with the frame. This function can only be
|
||||||
// called from the render process.
|
// called from the render process.
|
||||||
///
|
///
|
||||||
struct _cef_v8context_t*(CEF_CALLBACK* get_v8context)(
|
struct _cef_v8context_t* (CEF_CALLBACK *get_v8context)(
|
||||||
struct _cef_frame_t* self);
|
struct _cef_frame_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Visit the DOM document. This function can only be called from the render
|
// Visit the DOM document. This function can only be called from the render
|
||||||
// process.
|
// process.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* visit_dom)(struct _cef_frame_t* self,
|
void (CEF_CALLBACK *visit_dom)(struct _cef_frame_t* self,
|
||||||
struct _cef_domvisitor_t* visitor);
|
struct _cef_domvisitor_t* visitor);
|
||||||
|
|
||||||
///
|
|
||||||
// Create a new URL request that will be treated as originating from this
|
|
||||||
// frame and the associated browser. This request may be intercepted by the
|
|
||||||
// client via cef_resource_request_handler_t or cef_scheme_handler_factory_t.
|
|
||||||
// Use cef_urlrequest_t::Create instead if you do not want the request to have
|
|
||||||
// this association, in which case it may be handled differently (see
|
|
||||||
// documentation on that function). Requests may originate from both the
|
|
||||||
// browser process and the render process.
|
|
||||||
//
|
|
||||||
// For requests originating from the browser process:
|
|
||||||
// - POST data may only contain a single element of type PDE_TYPE_FILE or
|
|
||||||
// PDE_TYPE_BYTES.
|
|
||||||
// For requests originating from the render process:
|
|
||||||
// - POST data may only contain a single element of type PDE_TYPE_BYTES.
|
|
||||||
// - If the response contains Content-Disposition or Mime-Type header values
|
|
||||||
// that would not normally be rendered then the response may receive
|
|
||||||
// special handling inside the browser (for example, via the file download
|
|
||||||
// code path instead of the URL request code path).
|
|
||||||
//
|
|
||||||
// The |request| object will be marked as read-only after calling this
|
|
||||||
// function.
|
|
||||||
///
|
|
||||||
struct _cef_urlrequest_t*(CEF_CALLBACK* create_urlrequest)(
|
|
||||||
struct _cef_frame_t* self,
|
|
||||||
struct _cef_request_t* request,
|
|
||||||
struct _cef_urlrequest_client_t* client);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Send a message to the specified |target_process|. Ownership of the message
|
|
||||||
// contents will be transferred and the |message| reference will be
|
|
||||||
// invalidated. Message delivery is not guaranteed in all cases (for example,
|
|
||||||
// if the browser is closing, navigating, or if the target process crashes).
|
|
||||||
// Send an ACK message back from the target process if confirmation is
|
|
||||||
// required.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* send_process_message)(
|
|
||||||
struct _cef_frame_t* self,
|
|
||||||
cef_process_id_t target_process,
|
|
||||||
struct _cef_process_message_t* message);
|
|
||||||
} cef_frame_t;
|
} cef_frame_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,194 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=f6be5f7509ee3ccfe16f226470897223cc131014$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
#include "include/capi/cef_browser_capi.h"
|
|
||||||
#include "include/capi/cef_frame_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///
|
|
||||||
// Implement this structure to handle events related to cef_frame_t life span.
|
|
||||||
// The order of callbacks is:
|
|
||||||
//
|
|
||||||
// (1) During initial cef_browser_host_t creation and navigation of the main
|
|
||||||
// frame: - cef_frame_handler_t::OnFrameCreated => The initial main frame object
|
|
||||||
// has been
|
|
||||||
// created. Any commands will be queued until the frame is attached.
|
|
||||||
// - cef_frame_handler_t::OnMainFrameChanged => The initial main frame object
|
|
||||||
// has
|
|
||||||
// been assigned to the browser.
|
|
||||||
// - cef_life_span_handler_t::OnAfterCreated => The browser is now valid and can
|
|
||||||
// be
|
|
||||||
// used.
|
|
||||||
// - cef_frame_handler_t::OnFrameAttached => The initial main frame object is
|
|
||||||
// now
|
|
||||||
// connected to its peer in the renderer process. Commands can be routed.
|
|
||||||
//
|
|
||||||
// (2) During further cef_browser_host_t navigation/loading of the main frame
|
|
||||||
// and/or sub-frames: - cef_frame_handler_t::OnFrameCreated => A new main frame
|
|
||||||
// or sub-frame object has
|
|
||||||
// been created. Any commands will be queued until the frame is attached.
|
|
||||||
// - cef_frame_handler_t::OnFrameAttached => A new main frame or sub-frame
|
|
||||||
// object is
|
|
||||||
// now connected to its peer in the renderer process. Commands can be routed.
|
|
||||||
// - cef_frame_handler_t::OnFrameDetached => An existing main frame or sub-frame
|
|
||||||
// object has lost its connection to the renderer process. If multiple objects
|
|
||||||
// are detached at the same time then notifications will be sent for any
|
|
||||||
// sub-frame objects before the main frame object. Commands can no longer be
|
|
||||||
// routed and will be discarded.
|
|
||||||
// - cef_frame_handler_t::OnMainFrameChanged => A new main frame object has been
|
|
||||||
// assigned to the browser. This will only occur with cross-origin navigation
|
|
||||||
// or re-navigation after renderer process termination (due to crashes, etc).
|
|
||||||
//
|
|
||||||
// (3) During final cef_browser_host_t destruction of the main frame: -
|
|
||||||
// cef_frame_handler_t::OnFrameDetached => Any sub-frame objects have lost their
|
|
||||||
// connection to the renderer process. Commands can no longer be routed and
|
|
||||||
// will be discarded.
|
|
||||||
// - cef_life_span_handler_t::OnBeforeClose => The browser has been destroyed. -
|
|
||||||
// cef_frame_handler_t::OnFrameDetached => The main frame object have lost its
|
|
||||||
// connection to the renderer process. Notifications will be sent for any
|
|
||||||
// sub-frame objects before the main frame object. Commands can no longer be
|
|
||||||
// routed and will be discarded.
|
|
||||||
// - cef_frame_handler_t::OnMainFrameChanged => The final main frame object has
|
|
||||||
// been
|
|
||||||
// removed from the browser.
|
|
||||||
//
|
|
||||||
// Cross-origin navigation and/or loading receives special handling.
|
|
||||||
//
|
|
||||||
// When the main frame navigates to a different origin the OnMainFrameChanged
|
|
||||||
// callback (2) will be executed with the old and new main frame objects.
|
|
||||||
//
|
|
||||||
// When a new sub-frame is loaded in, or an existing sub-frame is navigated to,
|
|
||||||
// a different origin from the parent frame, a temporary sub-frame object will
|
|
||||||
// first be created in the parent's renderer process. That temporary sub-frame
|
|
||||||
// will then be discarded after the real cross-origin sub-frame is created in
|
|
||||||
// the new/target renderer process. The client will receive cross-origin
|
|
||||||
// navigation callbacks (2) for the transition from the temporary sub-frame to
|
|
||||||
// the real sub-frame. The temporary sub-frame will not recieve or execute
|
|
||||||
// commands during this transitional period (any sent commands will be
|
|
||||||
// discarded).
|
|
||||||
//
|
|
||||||
// When a new popup browser is created in a different origin from the parent
|
|
||||||
// browser, a temporary main frame object for the popup will first be created in
|
|
||||||
// the parent's renderer process. That temporary main frame will then be
|
|
||||||
// discarded after the real cross-origin main frame is created in the new/target
|
|
||||||
// renderer process. The client will recieve creation and initial navigation
|
|
||||||
// callbacks (1) for the temporary main frame, followed by cross-origin
|
|
||||||
// navigation callbacks (2) for the transition from the temporary main frame to
|
|
||||||
// the real main frame. The temporary main frame may receive and execute
|
|
||||||
// commands during this transitional period (any sent commands may be executed,
|
|
||||||
// but the behavior is potentially undesirable since they execute in the parent
|
|
||||||
// browser's renderer process and not the new/target renderer process).
|
|
||||||
//
|
|
||||||
// Callbacks will not be executed for placeholders that may be created during
|
|
||||||
// pre-commit navigation for sub-frames that do not yet exist in the renderer
|
|
||||||
// process. Placeholders will have cef_frame_t::get_identifier() == -4.
|
|
||||||
//
|
|
||||||
// The functions of this structure will be called on the UI thread unless
|
|
||||||
// otherwise indicated.
|
|
||||||
///
|
|
||||||
typedef struct _cef_frame_handler_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when a new frame is created. This will be the first notification
|
|
||||||
// that references |frame|. Any commands that require transport to the
|
|
||||||
// associated renderer process (LoadRequest, SendProcessMessage, GetSource,
|
|
||||||
// etc.) will be queued until OnFrameAttached is called for |frame|.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_frame_created)(struct _cef_frame_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* frame);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when a frame can begin routing commands to/from the associated
|
|
||||||
// renderer process. |reattached| will be true (1) if the frame was re-
|
|
||||||
// attached after exiting the BackForwardCache. Any commands that were queued
|
|
||||||
// have now been dispatched.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_frame_attached)(struct _cef_frame_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
int reattached);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when a frame loses its connection to the renderer process and will
|
|
||||||
// be destroyed. Any pending or future commands will be discarded and
|
|
||||||
// cef_frame_t::is_valid() will now return false (0) for |frame|. If called
|
|
||||||
// after cef_life_span_handler_t::on_before_close() during browser destruction
|
|
||||||
// then cef_browser_t::is_valid() will return false (0) for |browser|.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_frame_detached)(struct _cef_frame_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* frame);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called when the main frame changes due to (a) initial browser creation, (b)
|
|
||||||
// final browser destruction, (c) cross-origin navigation or (d) re-navigation
|
|
||||||
// after renderer process termination (due to crashes, etc). |old_frame| will
|
|
||||||
// be NULL and |new_frame| will be non-NULL when a main frame is assigned to
|
|
||||||
// |browser| for the first time. |old_frame| will be non-NULL and |new_frame|
|
|
||||||
// will be NULL and when a main frame is removed from |browser| for the last
|
|
||||||
// time. Both |old_frame| and |new_frame| will be non-NULL for cross-origin
|
|
||||||
// navigations or re-navigation after renderer process termination. This
|
|
||||||
// function will be called after on_frame_created() for |new_frame| and/or
|
|
||||||
// after on_frame_detached() for |old_frame|. If called after
|
|
||||||
// cef_life_span_handler_t::on_before_close() during browser destruction then
|
|
||||||
// cef_browser_t::is_valid() will return false (0) for |browser|.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_main_frame_changed)(struct _cef_frame_handler_t* self,
|
|
||||||
struct _cef_browser_t* browser,
|
|
||||||
struct _cef_frame_t* old_frame,
|
|
||||||
struct _cef_frame_t* new_frame);
|
|
||||||
} cef_frame_handler_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_FRAME_HANDLER_CAPI_H_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,11 +33,9 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=8cde223bdb8d25ff163edd95da0d9e238b298016$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
@@ -46,18 +44,36 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Generic callback structure used for managing the lifespan of a registration.
|
// Implement this structure to receive geolocation updates. The functions of
|
||||||
|
// this structure will be called on the browser process UI thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_registration_t {
|
typedef struct _cef_get_geolocation_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
} cef_registration_t;
|
|
||||||
|
///
|
||||||
|
// Called with the 'best available' location information or, if the location
|
||||||
|
// update failed, with error information.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_location_update)(
|
||||||
|
struct _cef_get_geolocation_callback_t* self,
|
||||||
|
const struct _cef_geoposition_t* position);
|
||||||
|
} cef_get_geolocation_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Request a one-time geolocation update. This function bypasses any user
|
||||||
|
// permission checks so should only be used by code that is allowed to access
|
||||||
|
// location information.
|
||||||
|
///
|
||||||
|
CEF_EXPORT int cef_get_geolocation(cef_get_geolocation_callback_t* callback);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_REGISTRATION_CAPI_H_
|
#endif // CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,63 +33,73 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=93eb2bc0f51da08a41fb906436654b3452b74fb3$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
#include "include/capi/cef_values_capi.h"
|
#include "include/capi/cef_browser_capi.h"
|
||||||
#include "include/capi/cef_x509_certificate_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure representing the SSL information for a navigation entry.
|
// Callback structure used for asynchronous continuation of geolocation
|
||||||
|
// permission requests.
|
||||||
///
|
///
|
||||||
typedef struct _cef_sslstatus_t {
|
typedef struct _cef_geolocation_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the status is related to a secure SSL/TLS connection.
|
// Call to allow or deny geolocation access.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_secure_connection)(struct _cef_sslstatus_t* self);
|
void (CEF_CALLBACK *cont)(struct _cef_geolocation_callback_t* self,
|
||||||
|
int allow);
|
||||||
|
} cef_geolocation_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Implement this structure to handle events related to geolocation permission
|
||||||
|
// requests. The functions of this structure will be called on the browser
|
||||||
|
// process UI thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_geolocation_handler_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a bitmask containing any and all problems verifying the server
|
// Called when a page requests permission to access geolocation information.
|
||||||
// certificate.
|
// |requesting_url| is the URL requesting permission and |request_id| is the
|
||||||
|
// unique ID for the permission request. Return true (1) and call
|
||||||
|
// cef_geolocation_callback_t::cont() either in this function or at a later
|
||||||
|
// time to continue or cancel the request. Return false (0) to cancel the
|
||||||
|
// request immediately.
|
||||||
///
|
///
|
||||||
cef_cert_status_t(CEF_CALLBACK* get_cert_status)(
|
int (CEF_CALLBACK *on_request_geolocation_permission)(
|
||||||
struct _cef_sslstatus_t* self);
|
struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser,
|
||||||
|
const cef_string_t* requesting_url, int request_id,
|
||||||
|
struct _cef_geolocation_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the SSL version used for the SSL connection.
|
// Called when a geolocation access request is canceled. |request_id| is the
|
||||||
|
// unique ID for the permission request.
|
||||||
///
|
///
|
||||||
cef_ssl_version_t(CEF_CALLBACK* get_sslversion)(
|
void (CEF_CALLBACK *on_cancel_geolocation_permission)(
|
||||||
struct _cef_sslstatus_t* self);
|
struct _cef_geolocation_handler_t* self, struct _cef_browser_t* browser,
|
||||||
|
int request_id);
|
||||||
|
} cef_geolocation_handler_t;
|
||||||
|
|
||||||
///
|
|
||||||
// Returns a bitmask containing the page security content status.
|
|
||||||
///
|
|
||||||
cef_ssl_content_status_t(CEF_CALLBACK* get_content_status)(
|
|
||||||
struct _cef_sslstatus_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the X.509 certificate.
|
|
||||||
///
|
|
||||||
struct _cef_x509certificate_t*(CEF_CALLBACK* get_x509certificate)(
|
|
||||||
struct _cef_sslstatus_t* self);
|
|
||||||
} cef_sslstatus_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_
|
#endif // CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=bf890f7b8e8edd423d71ad5a4d5bd43d81f1eb01$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if the application text direction is right-to-left.
|
|
||||||
///
|
|
||||||
CEF_EXPORT int cef_is_rtl();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_I18N_UTIL_CAPI_H_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=d9da8862142742e780086714bbd4fb44ac95cf2c$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_
|
||||||
@@ -47,30 +45,31 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Container for a single image represented at different scale factors. All
|
// Container for a single image represented at different scale factors. All
|
||||||
// image representations should be the same size in density independent pixel
|
// image representations should be the same size in density independent pixel
|
||||||
// (DIP) units. For example, if the image at scale factor 1.0 is 100x100 pixels
|
// (DIP) units. For example, if the image at scale factor 1.0 is 100x100 pixels
|
||||||
// then the image at scale factor 2.0 should be 200x200 pixels -- both images
|
// then the image at scale factor 2.0 should be 200x200 pixels -- both images
|
||||||
// will display with a DIP size of 100x100 units. The functions of this
|
// will display with a DIP size of 100x100 units. The functions of this
|
||||||
// structure can be called on any browser process thread.
|
// structure must be called on the browser process UI thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_image_t {
|
typedef struct _cef_image_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this Image is NULL.
|
// Returns true (1) if this Image is NULL.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_empty)(struct _cef_image_t* self);
|
int (CEF_CALLBACK *is_empty)(struct _cef_image_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this Image and |that| Image share the same underlying
|
// Returns true (1) if this Image and |that| Image share the same underlying
|
||||||
// storage. Will also return true (1) if both images are NULL.
|
// storage. Will also return true (1) if both images are NULL.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_same)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *is_same)(struct _cef_image_t* self,
|
||||||
struct _cef_image_t* that);
|
struct _cef_image_t* that);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -80,13 +79,9 @@ typedef struct _cef_image_t {
|
|||||||
// pixel data and should be |pixel_width| x |pixel_height| x 4 bytes in size.
|
// pixel data and should be |pixel_width| x |pixel_height| x 4 bytes in size.
|
||||||
// |color_type| and |alpha_type| values specify the pixel format.
|
// |color_type| and |alpha_type| values specify the pixel format.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_bitmap)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *add_bitmap)(struct _cef_image_t* self, float scale_factor,
|
||||||
float scale_factor,
|
int pixel_width, int pixel_height, cef_color_type_t color_type,
|
||||||
int pixel_width,
|
cef_alpha_type_t alpha_type, const void* pixel_data,
|
||||||
int pixel_height,
|
|
||||||
cef_color_type_t color_type,
|
|
||||||
cef_alpha_type_t alpha_type,
|
|
||||||
const void* pixel_data,
|
|
||||||
size_t pixel_data_size);
|
size_t pixel_data_size);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -94,42 +89,38 @@ typedef struct _cef_image_t {
|
|||||||
// data of size |png_data_size|. Any alpha transparency in the PNG data will
|
// data of size |png_data_size|. Any alpha transparency in the PNG data will
|
||||||
// be maintained.
|
// be maintained.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_png)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *add_png)(struct _cef_image_t* self, float scale_factor,
|
||||||
float scale_factor,
|
const void* png_data, size_t png_data_size);
|
||||||
const void* png_data,
|
|
||||||
size_t png_data_size);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Create a JPEG image representation for |scale_factor|. |jpeg_data| is the
|
// Create a JPEG image representation for |scale_factor|. |jpeg_data| is the
|
||||||
// image data of size |jpeg_data_size|. The JPEG format does not support
|
// image data of size |jpeg_data_size|. The JPEG format does not support
|
||||||
// transparency so the alpha byte will be set to 0xFF for all pixels.
|
// transparency so the alpha byte will be set to 0xFF for all pixels.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_jpeg)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *add_jpeg)(struct _cef_image_t* self, float scale_factor,
|
||||||
float scale_factor,
|
const void* jpeg_data, size_t jpeg_data_size);
|
||||||
const void* jpeg_data,
|
|
||||||
size_t jpeg_data_size);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the image width in density independent pixel (DIP) units.
|
// Returns the image width in density independent pixel (DIP) units.
|
||||||
///
|
///
|
||||||
size_t(CEF_CALLBACK* get_width)(struct _cef_image_t* self);
|
size_t (CEF_CALLBACK *get_width)(struct _cef_image_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the image height in density independent pixel (DIP) units.
|
// Returns the image height in density independent pixel (DIP) units.
|
||||||
///
|
///
|
||||||
size_t(CEF_CALLBACK* get_height)(struct _cef_image_t* self);
|
size_t (CEF_CALLBACK *get_height)(struct _cef_image_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this image contains a representation for
|
// Returns true (1) if this image contains a representation for
|
||||||
// |scale_factor|.
|
// |scale_factor|.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_representation)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *has_representation)(struct _cef_image_t* self,
|
||||||
float scale_factor);
|
float scale_factor);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Removes the representation for |scale_factor|. Returns true (1) on success.
|
// Removes the representation for |scale_factor|. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* remove_representation)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *remove_representation)(struct _cef_image_t* self,
|
||||||
float scale_factor);
|
float scale_factor);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -138,10 +129,8 @@ typedef struct _cef_image_t {
|
|||||||
// representation. |pixel_width| and |pixel_height| are the representation
|
// representation. |pixel_width| and |pixel_height| are the representation
|
||||||
// size in pixel coordinates. Returns true (1) on success.
|
// size in pixel coordinates. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_representation_info)(struct _cef_image_t* self,
|
int (CEF_CALLBACK *get_representation_info)(struct _cef_image_t* self,
|
||||||
float scale_factor,
|
float scale_factor, float* actual_scale_factor, int* pixel_width,
|
||||||
float* actual_scale_factor,
|
|
||||||
int* pixel_width,
|
|
||||||
int* pixel_height);
|
int* pixel_height);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -152,13 +141,10 @@ typedef struct _cef_image_t {
|
|||||||
// Returns a cef_binary_value_t containing the pixel data on success or NULL
|
// Returns a cef_binary_value_t containing the pixel data on success or NULL
|
||||||
// on failure.
|
// on failure.
|
||||||
///
|
///
|
||||||
struct _cef_binary_value_t*(CEF_CALLBACK* get_as_bitmap)(
|
struct _cef_binary_value_t* (CEF_CALLBACK *get_as_bitmap)(
|
||||||
struct _cef_image_t* self,
|
struct _cef_image_t* self, float scale_factor,
|
||||||
float scale_factor,
|
cef_color_type_t color_type, cef_alpha_type_t alpha_type,
|
||||||
cef_color_type_t color_type,
|
int* pixel_width, int* pixel_height);
|
||||||
cef_alpha_type_t alpha_type,
|
|
||||||
int* pixel_width,
|
|
||||||
int* pixel_height);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the PNG representation that most closely matches |scale_factor|. If
|
// Returns the PNG representation that most closely matches |scale_factor|. If
|
||||||
@@ -168,12 +154,9 @@ typedef struct _cef_image_t {
|
|||||||
// cef_binary_value_t containing the PNG image data on success or NULL on
|
// cef_binary_value_t containing the PNG image data on success or NULL on
|
||||||
// failure.
|
// failure.
|
||||||
///
|
///
|
||||||
struct _cef_binary_value_t*(CEF_CALLBACK* get_as_png)(
|
struct _cef_binary_value_t* (CEF_CALLBACK *get_as_png)(
|
||||||
struct _cef_image_t* self,
|
struct _cef_image_t* self, float scale_factor, int with_transparency,
|
||||||
float scale_factor,
|
int* pixel_width, int* pixel_height);
|
||||||
int with_transparency,
|
|
||||||
int* pixel_width,
|
|
||||||
int* pixel_height);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the JPEG representation that most closely matches |scale_factor|.
|
// Returns the JPEG representation that most closely matches |scale_factor|.
|
||||||
@@ -184,20 +167,19 @@ typedef struct _cef_image_t {
|
|||||||
// cef_binary_value_t containing the JPEG image data on success or NULL on
|
// cef_binary_value_t containing the JPEG image data on success or NULL on
|
||||||
// failure.
|
// failure.
|
||||||
///
|
///
|
||||||
struct _cef_binary_value_t*(CEF_CALLBACK* get_as_jpeg)(
|
struct _cef_binary_value_t* (CEF_CALLBACK *get_as_jpeg)(
|
||||||
struct _cef_image_t* self,
|
struct _cef_image_t* self, float scale_factor, int quality,
|
||||||
float scale_factor,
|
int* pixel_width, int* pixel_height);
|
||||||
int quality,
|
|
||||||
int* pixel_width,
|
|
||||||
int* pixel_height);
|
|
||||||
} cef_image_t;
|
} cef_image_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Create a new cef_image_t. It will initially be NULL. Use the Add*() functions
|
// Create a new cef_image_t. It will initially be NULL. Use the Add*() functions
|
||||||
// to add representations at different scale factors.
|
// to add representations at different scale factors.
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_image_t* cef_image_create();
|
CEF_EXPORT cef_image_t* cef_image_create();
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=d991e2a7d1a58a013e4d3a963361fed6918f4ec3$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_JSDIALOG_HANDLER_CAPI_H_
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure used for asynchronous continuation of JavaScript dialog
|
// Callback structure used for asynchronous continuation of JavaScript dialog
|
||||||
// requests.
|
// requests.
|
||||||
@@ -55,17 +54,17 @@ typedef struct _cef_jsdialog_callback_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue the JS dialog request. Set |success| to true (1) if the OK button
|
// Continue the JS dialog request. Set |success| to true (1) if the OK button
|
||||||
// was pressed. The |user_input| value should be specified for prompt dialogs.
|
// was pressed. The |user_input| value should be specified for prompt dialogs.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_jsdialog_callback_t* self,
|
void (CEF_CALLBACK *cont)(struct _cef_jsdialog_callback_t* self, int success,
|
||||||
int success,
|
|
||||||
const cef_string_t* user_input);
|
const cef_string_t* user_input);
|
||||||
} cef_jsdialog_callback_t;
|
} cef_jsdialog_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to JavaScript dialogs. The
|
// Implement this structure to handle events related to JavaScript dialogs. The
|
||||||
// functions of this structure will be called on the UI thread.
|
// functions of this structure will be called on the UI thread.
|
||||||
@@ -74,7 +73,7 @@ typedef struct _cef_jsdialog_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to run a JavaScript dialog. If |origin_url| is non-NULL it can be
|
// Called to run a JavaScript dialog. If |origin_url| is non-NULL it can be
|
||||||
@@ -93,14 +92,11 @@ typedef struct _cef_jsdialog_handler_t {
|
|||||||
// the application must execute |callback| once the custom dialog is
|
// the application must execute |callback| once the custom dialog is
|
||||||
// dismissed.
|
// dismissed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_jsdialog)(struct _cef_jsdialog_handler_t* self,
|
int (CEF_CALLBACK *on_jsdialog)(struct _cef_jsdialog_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, const cef_string_t* origin_url,
|
||||||
const cef_string_t* origin_url,
|
cef_jsdialog_type_t dialog_type, const cef_string_t* message_text,
|
||||||
cef_jsdialog_type_t dialog_type,
|
|
||||||
const cef_string_t* message_text,
|
|
||||||
const cef_string_t* default_prompt_text,
|
const cef_string_t* default_prompt_text,
|
||||||
struct _cef_jsdialog_callback_t* callback,
|
struct _cef_jsdialog_callback_t* callback, int* suppress_message);
|
||||||
int* suppress_message);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to run a dialog asking the user if they want to leave a page. Return
|
// Called to run a dialog asking the user if they want to leave a page. Return
|
||||||
@@ -110,11 +106,9 @@ typedef struct _cef_jsdialog_handler_t {
|
|||||||
// dialog is used the application must execute |callback| once the custom
|
// dialog is used the application must execute |callback| once the custom
|
||||||
// dialog is dismissed.
|
// dialog is dismissed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_before_unload_dialog)(
|
int (CEF_CALLBACK *on_before_unload_dialog)(
|
||||||
struct _cef_jsdialog_handler_t* self,
|
struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser,
|
||||||
struct _cef_browser_t* browser,
|
const cef_string_t* message_text, int is_reload,
|
||||||
const cef_string_t* message_text,
|
|
||||||
int is_reload,
|
|
||||||
struct _cef_jsdialog_callback_t* callback);
|
struct _cef_jsdialog_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -122,17 +116,17 @@ typedef struct _cef_jsdialog_handler_t {
|
|||||||
// be called due to events like page navigation irregardless of whether any
|
// be called due to events like page navigation irregardless of whether any
|
||||||
// dialogs are currently pending.
|
// dialogs are currently pending.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_reset_dialog_state)(
|
void (CEF_CALLBACK *on_reset_dialog_state)(
|
||||||
struct _cef_jsdialog_handler_t* self,
|
struct _cef_jsdialog_handler_t* self, struct _cef_browser_t* browser);
|
||||||
struct _cef_browser_t* browser);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the default implementation dialog is closed.
|
// Called when the default implementation dialog is closed.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_dialog_closed)(struct _cef_jsdialog_handler_t* self,
|
void (CEF_CALLBACK *on_dialog_closed)(struct _cef_jsdialog_handler_t* self,
|
||||||
struct _cef_browser_t* browser);
|
struct _cef_browser_t* browser);
|
||||||
} cef_jsdialog_handler_t;
|
} cef_jsdialog_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=d804a2db0f9ac13afd249407c85cb8d5852508ac$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_KEYBOARD_HANDLER_CAPI_H_
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to keyboard input. The
|
// Implement this structure to handle events related to keyboard input. The
|
||||||
// functions of this structure will be called on the UI thread.
|
// functions of this structure will be called on the UI thread.
|
||||||
@@ -55,7 +54,7 @@ typedef struct _cef_keyboard_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called before a keyboard event is sent to the renderer. |event| contains
|
// Called before a keyboard event is sent to the renderer. |event| contains
|
||||||
@@ -64,11 +63,9 @@ typedef struct _cef_keyboard_handler_t {
|
|||||||
// (0) otherwise. If the event will be handled in on_key_event() as a keyboard
|
// (0) otherwise. If the event will be handled in on_key_event() as a keyboard
|
||||||
// shortcut set |is_keyboard_shortcut| to true (1) and return false (0).
|
// shortcut set |is_keyboard_shortcut| to true (1) and return false (0).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_pre_key_event)(struct _cef_keyboard_handler_t* self,
|
int (CEF_CALLBACK *on_pre_key_event)(struct _cef_keyboard_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, const struct _cef_key_event_t* event,
|
||||||
const struct _cef_key_event_t* event,
|
cef_event_handle_t os_event, int* is_keyboard_shortcut);
|
||||||
cef_event_handle_t os_event,
|
|
||||||
int* is_keyboard_shortcut);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after the renderer and JavaScript in the page has had a chance to
|
// Called after the renderer and JavaScript in the page has had a chance to
|
||||||
@@ -76,12 +73,12 @@ typedef struct _cef_keyboard_handler_t {
|
|||||||
// |os_event| is the operating system event message, if any. Return true (1)
|
// |os_event| is the operating system event message, if any. Return true (1)
|
||||||
// if the keyboard event was handled or false (0) otherwise.
|
// if the keyboard event was handled or false (0) otherwise.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_key_event)(struct _cef_keyboard_handler_t* self,
|
int (CEF_CALLBACK *on_key_event)(struct _cef_keyboard_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, const struct _cef_key_event_t* event,
|
||||||
const struct _cef_key_event_t* event,
|
|
||||||
cef_event_handle_t os_event);
|
cef_event_handle_t os_event);
|
||||||
} cef_keyboard_handler_t;
|
} cef_keyboard_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=e44bb89a337942c82bfa246275b4b033821b2782$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
|
||||||
@@ -58,10 +56,10 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the UI thread before a new popup browser is created. The
|
// Called on the IO thread before a new popup browser is created. The
|
||||||
// |browser| and |frame| values represent the source of the popup request. The
|
// |browser| and |frame| values represent the source of the popup request. The
|
||||||
// |target_url| and |target_frame_name| values indicate where the popup
|
// |target_url| and |target_frame_name| values indicate where the popup
|
||||||
// browser should navigate and may be NULL if not specified with the request.
|
// browser should navigate and may be NULL if not specified with the request.
|
||||||
@@ -78,35 +76,21 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
// is set to false (0) the new browser will not be scriptable and may not be
|
// is set to false (0) the new browser will not be scriptable and may not be
|
||||||
// hosted in the same renderer process as the source browser. Any
|
// hosted in the same renderer process as the source browser. Any
|
||||||
// modifications to |windowInfo| will be ignored if the parent browser is
|
// modifications to |windowInfo| will be ignored if the parent browser is
|
||||||
// wrapped in a cef_browser_view_t. Popup browser creation will be canceled if
|
// wrapped in a cef_browser_view_t.
|
||||||
// the parent browser is destroyed before the popup browser creation completes
|
|
||||||
// (indicated by a call to OnAfterCreated for the popup browser). The
|
|
||||||
// |extra_info| parameter provides an opportunity to specify extra information
|
|
||||||
// specific to the created popup browser that will be passed to
|
|
||||||
// cef_render_process_handler_t::on_browser_created() in the render process.
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_before_popup)(
|
int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self,
|
||||||
struct _cef_life_span_handler_t* self,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
struct _cef_browser_t* browser,
|
const cef_string_t* target_url, const cef_string_t* target_frame_name,
|
||||||
struct _cef_frame_t* frame,
|
cef_window_open_disposition_t target_disposition, int user_gesture,
|
||||||
const cef_string_t* target_url,
|
|
||||||
const cef_string_t* target_frame_name,
|
|
||||||
cef_window_open_disposition_t target_disposition,
|
|
||||||
int user_gesture,
|
|
||||||
const struct _cef_popup_features_t* popupFeatures,
|
const struct _cef_popup_features_t* popupFeatures,
|
||||||
struct _cef_window_info_t* windowInfo,
|
struct _cef_window_info_t* windowInfo, struct _cef_client_t** client,
|
||||||
struct _cef_client_t** client,
|
struct _cef_browser_settings_t* settings, int* no_javascript_access);
|
||||||
struct _cef_browser_settings_t* settings,
|
|
||||||
struct _cef_dictionary_value_t** extra_info,
|
|
||||||
int* no_javascript_access);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after a new browser is created. It is now safe to begin performing
|
// Called after a new browser is created. This callback will be the first
|
||||||
// actions with |browser|. cef_frame_handler_t callbacks related to initial
|
// notification that references |browser|.
|
||||||
// main frame creation will arrive before this callback. See
|
|
||||||
// cef_frame_handler_t documentation for additional usage information.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_after_created)(struct _cef_life_span_handler_t* self,
|
void (CEF_CALLBACK *on_after_created)(struct _cef_life_span_handler_t* self,
|
||||||
struct _cef_browser_t* browser);
|
struct _cef_browser_t* browser);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -118,7 +102,7 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
// has been fired.
|
// has been fired.
|
||||||
//
|
//
|
||||||
// An application should handle top-level owner window close notifications by
|
// An application should handle top-level owner window close notifications by
|
||||||
// calling cef_browser_host_t::try_close_browser() or
|
// calling cef_browser_host_t::Tryclose_browser() or
|
||||||
// cef_browser_host_t::CloseBrowser(false (0)) instead of allowing the window
|
// cef_browser_host_t::CloseBrowser(false (0)) instead of allowing the window
|
||||||
// to close immediately (see the examples below). This gives CEF an
|
// to close immediately (see the examples below). This gives CEF an
|
||||||
// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
// opportunity to process the 'onbeforeunload' event and optionally cancel the
|
||||||
@@ -148,7 +132,7 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
// The below examples describe what should happen during window close when the
|
// The below examples describe what should happen during window close when the
|
||||||
// browser is parented to an application-provided top-level window.
|
// browser is parented to an application-provided top-level window.
|
||||||
//
|
//
|
||||||
// Example 1: Using cef_browser_host_t::try_close_browser(). This is
|
// Example 1: Using cef_browser_host_t::Tryclose_browser(). This is
|
||||||
// recommended for clients using standard close handling and windows created
|
// recommended for clients using standard close handling and windows created
|
||||||
// on the browser process UI thread. 1. User clicks the window close button
|
// on the browser process UI thread. 1. User clicks the window close button
|
||||||
// which sends a close notification to
|
// which sends a close notification to
|
||||||
@@ -198,25 +182,21 @@ typedef struct _cef_life_span_handler_t {
|
|||||||
// browsers
|
// browsers
|
||||||
// exist.
|
// exist.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* do_close)(struct _cef_life_span_handler_t* self,
|
int (CEF_CALLBACK *do_close)(struct _cef_life_span_handler_t* self,
|
||||||
struct _cef_browser_t* browser);
|
struct _cef_browser_t* browser);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called just before a browser is destroyed. Release all references to the
|
// Called just before a browser is destroyed. Release all references to the
|
||||||
// browser object and do not attempt to execute any functions on the browser
|
// browser object and do not attempt to execute any functions on the browser
|
||||||
// object (other than IsValid, GetIdentifier or IsSame) after this callback
|
// object after this callback returns. This callback will be the last
|
||||||
// returns. cef_frame_handler_t callbacks related to final main frame
|
// notification that references |browser|. See do_close() documentation for
|
||||||
// destruction will arrive after this callback and cef_browser_t::IsValid will
|
// additional usage information.
|
||||||
// return false (0) at that time. Any in-progress network requests associated
|
|
||||||
// with |browser| will be aborted when the browser is destroyed, and
|
|
||||||
// cef_resource_request_handler_t callbacks related to those requests may
|
|
||||||
// still arrive on the IO thread after this callback. See cef_frame_handler_t
|
|
||||||
// and do_close() documentation for additional usage information.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_close)(struct _cef_life_span_handler_t* self,
|
void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self,
|
||||||
struct _cef_browser_t* browser);
|
struct _cef_browser_t* browser);
|
||||||
} cef_life_span_handler_t;
|
} cef_life_span_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=6c6a719d7cbbc01adfdc9bbe0dff6da10e06e3f3$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_LOAD_HANDLER_CAPI_H_
|
||||||
@@ -48,6 +46,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to browser load status. The
|
// Implement this structure to handle events related to browser load status. The
|
||||||
// functions of this structure will be called on the browser process UI thread
|
// functions of this structure will be called on the browser process UI thread
|
||||||
@@ -57,7 +56,7 @@ typedef struct _cef_load_handler_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the loading state has changed. This callback will be executed
|
// Called when the loading state has changed. This callback will be executed
|
||||||
@@ -66,27 +65,23 @@ typedef struct _cef_load_handler_t {
|
|||||||
// of failure. It will be called before any calls to OnLoadStart and after all
|
// of failure. It will be called before any calls to OnLoadStart and after all
|
||||||
// calls to OnLoadError and/or OnLoadEnd.
|
// calls to OnLoadError and/or OnLoadEnd.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_loading_state_change)(struct _cef_load_handler_t* self,
|
void (CEF_CALLBACK *on_loading_state_change)(struct _cef_load_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, int isLoading, int canGoBack,
|
||||||
int isLoading,
|
|
||||||
int canGoBack,
|
|
||||||
int canGoForward);
|
int canGoForward);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after a navigation has been committed and before the browser begins
|
// Called when the browser begins loading a frame. The |frame| value will
|
||||||
// loading contents in the frame. The |frame| value will never be NULL -- call
|
// never be NULL -- call the is_main() function to check if this frame is the
|
||||||
// the is_main() function to check if this frame is the main frame.
|
// main frame. |transition_type| provides information about the source of the
|
||||||
// |transition_type| provides information about the source of the navigation
|
// navigation and an accurate value is only available in the browser process.
|
||||||
// and an accurate value is only available in the browser process. Multiple
|
// Multiple frames may be loading at the same time. Sub-frames may start or
|
||||||
// frames may be loading at the same time. Sub-frames may start or continue
|
// continue loading after the main frame load has ended. This function will
|
||||||
// loading after the main frame load has ended. This function will not be
|
// always be called for all frames irrespective of whether the request
|
||||||
// called for same page navigations (fragments, history state, etc.) or for
|
// completes successfully. For notification of overall browser load status use
|
||||||
// navigations that fail or are canceled before commit. For notification of
|
// OnLoadingStateChange instead.
|
||||||
// overall browser load status use OnLoadingStateChange instead.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_load_start)(struct _cef_load_handler_t* self,
|
void (CEF_CALLBACK *on_load_start)(struct _cef_load_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
cef_transition_type_t transition_type);
|
cef_transition_type_t transition_type);
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -94,31 +89,27 @@ typedef struct _cef_load_handler_t {
|
|||||||
// never be NULL -- call the is_main() function to check if this frame is the
|
// never be NULL -- call the is_main() function to check if this frame is the
|
||||||
// main frame. Multiple frames may be loading at the same time. Sub-frames may
|
// main frame. Multiple frames may be loading at the same time. Sub-frames may
|
||||||
// start or continue loading after the main frame load has ended. This
|
// start or continue loading after the main frame load has ended. This
|
||||||
// function will not be called for same page navigations (fragments, history
|
// function will always be called for all frames irrespective of whether the
|
||||||
// state, etc.) or for navigations that fail or are canceled before commit.
|
// request completes successfully. For notification of overall browser load
|
||||||
// For notification of overall browser load status use OnLoadingStateChange
|
// status use OnLoadingStateChange instead.
|
||||||
// instead.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_load_end)(struct _cef_load_handler_t* self,
|
void (CEF_CALLBACK *on_load_end)(struct _cef_load_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
struct _cef_frame_t* frame,
|
|
||||||
int httpStatusCode);
|
int httpStatusCode);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when a navigation fails or is canceled. This function may be called
|
// Called when the resource load for a navigation fails or is canceled.
|
||||||
// by itself if before commit or in combination with OnLoadStart/OnLoadEnd if
|
// |errorCode| is the error code number, |errorText| is the error text and
|
||||||
// after commit. |errorCode| is the error code number, |errorText| is the
|
// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
|
||||||
// error text and |failedUrl| is the URL that failed to load. See
|
// for complete descriptions of the error codes.
|
||||||
// net\base\net_error_list.h for complete descriptions of the error codes.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_load_error)(struct _cef_load_handler_t* self,
|
void (CEF_CALLBACK *on_load_error)(struct _cef_load_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
|
||||||
struct _cef_frame_t* frame,
|
cef_errorcode_t errorCode, const cef_string_t* errorText,
|
||||||
cef_errorcode_t errorCode,
|
|
||||||
const cef_string_t* errorText,
|
|
||||||
const cef_string_t* failedUrl);
|
const cef_string_t* failedUrl);
|
||||||
} cef_load_handler_t;
|
} cef_load_handler_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,349 +0,0 @@
|
|||||||
// Copyright (c) 2021 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=79e4e38c732c0cfeef495c8a9726e105054012bb$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
|
|
||||||
#define CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
|
||||||
#include "include/capi/cef_callback_capi.h"
|
|
||||||
#include "include/capi/cef_registration_capi.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _cef_media_observer_t;
|
|
||||||
struct _cef_media_route_create_callback_t;
|
|
||||||
struct _cef_media_route_t;
|
|
||||||
struct _cef_media_sink_device_info_callback_t;
|
|
||||||
struct _cef_media_sink_t;
|
|
||||||
struct _cef_media_source_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Supports discovery of and communication with media devices on the local
|
|
||||||
// network via the Cast and DIAL protocols. The functions of this structure may
|
|
||||||
// be called on any browser process thread unless otherwise indicated.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_router_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Add an observer for MediaRouter events. The observer will remain registered
|
|
||||||
// until the returned Registration object is destroyed.
|
|
||||||
///
|
|
||||||
struct _cef_registration_t*(CEF_CALLBACK* add_observer)(
|
|
||||||
struct _cef_media_router_t* self,
|
|
||||||
struct _cef_media_observer_t* observer);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns a MediaSource object for the specified media source URN. Supported
|
|
||||||
// URN schemes include "cast:" and "dial:", and will be already known by the
|
|
||||||
// client application (e.g. "cast:<appId>?clientId=<clientId>").
|
|
||||||
///
|
|
||||||
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
|
|
||||||
struct _cef_media_router_t* self,
|
|
||||||
const cef_string_t* urn);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Trigger an asynchronous call to cef_media_observer_t::OnSinks on all
|
|
||||||
// registered observers.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* notify_current_sinks)(struct _cef_media_router_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Create a new route between |source| and |sink|. Source and sink must be
|
|
||||||
// valid, compatible (as reported by cef_media_sink_t::IsCompatibleWith), and
|
|
||||||
// a route between them must not already exist. |callback| will be executed on
|
|
||||||
// success or failure. If route creation succeeds it will also trigger an
|
|
||||||
// asynchronous call to cef_media_observer_t::OnRoutes on all registered
|
|
||||||
// observers.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* create_route)(
|
|
||||||
struct _cef_media_router_t* self,
|
|
||||||
struct _cef_media_source_t* source,
|
|
||||||
struct _cef_media_sink_t* sink,
|
|
||||||
struct _cef_media_route_create_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Trigger an asynchronous call to cef_media_observer_t::OnRoutes on all
|
|
||||||
// registered observers.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* notify_current_routes)(struct _cef_media_router_t* self);
|
|
||||||
} cef_media_router_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the MediaRouter object associated with the global request context. If
|
|
||||||
// |callback| is non-NULL it will be executed asnychronously on the UI thread
|
|
||||||
// after the manager's storage has been initialized. Equivalent to calling cef_r
|
|
||||||
// equest_context_t::cef_request_context_get_global_context()->get_media_router(
|
|
||||||
// ).
|
|
||||||
///
|
|
||||||
CEF_EXPORT cef_media_router_t* cef_media_router_get_global(
|
|
||||||
struct _cef_completion_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Implemented by the client to observe MediaRouter events and registered via
|
|
||||||
// cef_media_router_t::AddObserver. The functions of this structure will be
|
|
||||||
// called on the browser process UI thread.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_observer_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// The list of available media sinks has changed or
|
|
||||||
// cef_media_router_t::NotifyCurrentSinks was called.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_sinks)(struct _cef_media_observer_t* self,
|
|
||||||
size_t sinksCount,
|
|
||||||
struct _cef_media_sink_t* const* sinks);
|
|
||||||
|
|
||||||
///
|
|
||||||
// The list of available media routes has changed or
|
|
||||||
// cef_media_router_t::NotifyCurrentRoutes was called.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_routes)(struct _cef_media_observer_t* self,
|
|
||||||
size_t routesCount,
|
|
||||||
struct _cef_media_route_t* const* routes);
|
|
||||||
|
|
||||||
///
|
|
||||||
// The connection state of |route| has changed.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_route_state_changed)(
|
|
||||||
struct _cef_media_observer_t* self,
|
|
||||||
struct _cef_media_route_t* route,
|
|
||||||
cef_media_route_connection_state_t state);
|
|
||||||
|
|
||||||
///
|
|
||||||
// A message was recieved over |route|. |message| is only valid for the scope
|
|
||||||
// of this callback and should be copied if necessary.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_route_message_received)(
|
|
||||||
struct _cef_media_observer_t* self,
|
|
||||||
struct _cef_media_route_t* route,
|
|
||||||
const void* message,
|
|
||||||
size_t message_size);
|
|
||||||
} cef_media_observer_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Represents the route between a media source and sink. Instances of this
|
|
||||||
// object are created via cef_media_router_t::CreateRoute and retrieved via
|
|
||||||
// cef_media_observer_t::OnRoutes. Contains the status and metadata of a routing
|
|
||||||
// operation. The functions of this structure may be called on any browser
|
|
||||||
// process thread unless otherwise indicated.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_route_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the ID for this route.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_route_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the source associated with this route.
|
|
||||||
///
|
|
||||||
struct _cef_media_source_t*(CEF_CALLBACK* get_source)(
|
|
||||||
struct _cef_media_route_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the sink associated with this route.
|
|
||||||
///
|
|
||||||
struct _cef_media_sink_t*(CEF_CALLBACK* get_sink)(
|
|
||||||
struct _cef_media_route_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Send a message over this route. |message| will be copied if necessary.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* send_route_message)(struct _cef_media_route_t* self,
|
|
||||||
const void* message,
|
|
||||||
size_t message_size);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Terminate this route. Will result in an asynchronous call to
|
|
||||||
// cef_media_observer_t::OnRoutes on all registered observers.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* terminate)(struct _cef_media_route_t* self);
|
|
||||||
} cef_media_route_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Callback structure for cef_media_router_t::CreateRoute. The functions of this
|
|
||||||
// structure will be called on the browser process UI thread.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_route_create_callback_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be executed when the route creation has finished. |result|
|
|
||||||
// will be CEF_MRCR_OK if the route creation succeeded. |error| will be a
|
|
||||||
// description of the error if the route creation failed. |route| is the
|
|
||||||
// resulting route, or NULL if the route creation failed.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_media_route_create_finished)(
|
|
||||||
struct _cef_media_route_create_callback_t* self,
|
|
||||||
cef_media_route_create_result_t result,
|
|
||||||
const cef_string_t* error,
|
|
||||||
struct _cef_media_route_t* route);
|
|
||||||
} cef_media_route_create_callback_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Represents a sink to which media can be routed. Instances of this object are
|
|
||||||
// retrieved via cef_media_observer_t::OnSinks. The functions of this structure
|
|
||||||
// may be called on any browser process thread unless otherwise indicated.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_sink_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the ID for this sink.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_sink_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the name of this sink.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_name)(struct _cef_media_sink_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the description of this sink.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_description)(
|
|
||||||
struct _cef_media_sink_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the icon type for this sink.
|
|
||||||
///
|
|
||||||
cef_media_sink_icon_type_t(CEF_CALLBACK* get_icon_type)(
|
|
||||||
struct _cef_media_sink_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Asynchronously retrieves device info.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* get_device_info)(
|
|
||||||
struct _cef_media_sink_t* self,
|
|
||||||
struct _cef_media_sink_device_info_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this sink accepts content via Cast.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_cast_sink)(struct _cef_media_sink_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this sink accepts content via DIAL.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_dial_sink)(struct _cef_media_sink_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this sink is compatible with |source|.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_compatible_with)(struct _cef_media_sink_t* self,
|
|
||||||
struct _cef_media_source_t* source);
|
|
||||||
} cef_media_sink_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Callback structure for cef_media_sink_t::GetDeviceInfo. The functions of this
|
|
||||||
// structure will be called on the browser process UI thread.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_sink_device_info_callback_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Method that will be executed asyncronously once device information has been
|
|
||||||
// retrieved.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* on_media_sink_device_info)(
|
|
||||||
struct _cef_media_sink_device_info_callback_t* self,
|
|
||||||
const struct _cef_media_sink_device_info_t* device_info);
|
|
||||||
} cef_media_sink_device_info_callback_t;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Represents a source from which media can be routed. Instances of this object
|
|
||||||
// are retrieved via cef_media_router_t::GetSource. The functions of this
|
|
||||||
// structure may be called on any browser process thread unless otherwise
|
|
||||||
// indicated.
|
|
||||||
///
|
|
||||||
typedef struct _cef_media_source_t {
|
|
||||||
///
|
|
||||||
// Base structure.
|
|
||||||
///
|
|
||||||
cef_base_ref_counted_t base;
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns the ID (media source URN or URL) for this source.
|
|
||||||
///
|
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_id)(struct _cef_media_source_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this source outputs its content via Cast.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_cast_source)(struct _cef_media_source_t* self);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this source outputs its content via DIAL.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_dial_source)(struct _cef_media_source_t* self);
|
|
||||||
} cef_media_source_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=28fa978051bd3ddff69d58e0dc8f445f64a61480$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_CAPI_H_
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Supports creation and modification of menus. See cef_menu_id_t for the
|
// Supports creation and modification of menus. See cef_menu_id_t for the
|
||||||
// command ids that have default implementations. All user-defined command ids
|
// command ids that have default implementations. All user-defined command ids
|
||||||
@@ -57,453 +56,339 @@ typedef struct _cef_menu_model_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if this menu is a submenu.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_sub_menu)(struct _cef_menu_model_t* self);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Clears the menu. Returns true (1) on success.
|
// Clears the menu. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* clear)(struct _cef_menu_model_t* self);
|
int (CEF_CALLBACK *clear)(struct _cef_menu_model_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the number of items in this menu.
|
// Returns the number of items in this menu.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_count)(struct _cef_menu_model_t* self);
|
int (CEF_CALLBACK *get_count)(struct _cef_menu_model_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a separator to the menu. Returns true (1) on success.
|
// Add a separator to the menu. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_separator)(struct _cef_menu_model_t* self);
|
int (CEF_CALLBACK *add_separator)(struct _cef_menu_model_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add an item to the menu. Returns true (1) on success.
|
// Add an item to the menu. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_item)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *add_item)(struct _cef_menu_model_t* self, int command_id,
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label);
|
const cef_string_t* label);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a check item to the menu. Returns true (1) on success.
|
// Add a check item to the menu. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_check_item)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *add_check_item)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, const cef_string_t* label);
|
||||||
const cef_string_t* label);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a radio item to the menu. Only a single item with the specified
|
// Add a radio item to the menu. Only a single item with the specified
|
||||||
// |group_id| can be checked at a time. Returns true (1) on success.
|
// |group_id| can be checked at a time. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* add_radio_item)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *add_radio_item)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, const cef_string_t* label, int group_id);
|
||||||
const cef_string_t* label,
|
|
||||||
int group_id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a sub-menu to the menu. The new sub-menu is returned.
|
// Add a sub-menu to the menu. The new sub-menu is returned.
|
||||||
///
|
///
|
||||||
struct _cef_menu_model_t*(CEF_CALLBACK* add_sub_menu)(
|
struct _cef_menu_model_t* (CEF_CALLBACK *add_sub_menu)(
|
||||||
struct _cef_menu_model_t* self,
|
struct _cef_menu_model_t* self, int command_id,
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label);
|
const cef_string_t* label);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert a separator in the menu at the specified |index|. Returns true (1)
|
// Insert a separator in the menu at the specified |index|. Returns true (1)
|
||||||
// on success.
|
// on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* insert_separator_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *insert_separator_at)(struct _cef_menu_model_t* self,
|
||||||
int index);
|
int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert an item in the menu at the specified |index|. Returns true (1) on
|
// Insert an item in the menu at the specified |index|. Returns true (1) on
|
||||||
// success.
|
// success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* insert_item_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *insert_item_at)(struct _cef_menu_model_t* self, int index,
|
||||||
int index,
|
int command_id, const cef_string_t* label);
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert a check item in the menu at the specified |index|. Returns true (1)
|
// Insert a check item in the menu at the specified |index|. Returns true (1)
|
||||||
// on success.
|
// on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* insert_check_item_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *insert_check_item_at)(struct _cef_menu_model_t* self,
|
||||||
int index,
|
int index, int command_id, const cef_string_t* label);
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert a radio item in the menu at the specified |index|. Only a single
|
// Insert a radio item in the menu at the specified |index|. Only a single
|
||||||
// item with the specified |group_id| can be checked at a time. Returns true
|
// item with the specified |group_id| can be checked at a time. Returns true
|
||||||
// (1) on success.
|
// (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* insert_radio_item_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *insert_radio_item_at)(struct _cef_menu_model_t* self,
|
||||||
int index,
|
int index, int command_id, const cef_string_t* label, int group_id);
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label,
|
|
||||||
int group_id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert a sub-menu in the menu at the specified |index|. The new sub-menu is
|
// Insert a sub-menu in the menu at the specified |index|. The new sub-menu is
|
||||||
// returned.
|
// returned.
|
||||||
///
|
///
|
||||||
struct _cef_menu_model_t*(CEF_CALLBACK* insert_sub_menu_at)(
|
struct _cef_menu_model_t* (CEF_CALLBACK *insert_sub_menu_at)(
|
||||||
struct _cef_menu_model_t* self,
|
struct _cef_menu_model_t* self, int index, int command_id,
|
||||||
int index,
|
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label);
|
const cef_string_t* label);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Removes the item with the specified |command_id|. Returns true (1) on
|
// Removes the item with the specified |command_id|. Returns true (1) on
|
||||||
// success.
|
// success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* remove)(struct _cef_menu_model_t* self, int command_id);
|
int (CEF_CALLBACK *remove)(struct _cef_menu_model_t* self, int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Removes the item at the specified |index|. Returns true (1) on success.
|
// Removes the item at the specified |index|. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* remove_at)(struct _cef_menu_model_t* self, int index);
|
int (CEF_CALLBACK *remove_at)(struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the index associated with the specified |command_id| or -1 if not
|
// Returns the index associated with the specified |command_id| or -1 if not
|
||||||
// found due to the command id not existing in the menu.
|
// found due to the command id not existing in the menu.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_index_of)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *get_index_of)(struct _cef_menu_model_t* self,
|
||||||
int command_id);
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the command id at the specified |index| or -1 if not found due to
|
// Returns the command id at the specified |index| or -1 if not found due to
|
||||||
// invalid range or the index being a separator.
|
// invalid range or the index being a separator.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_command_id_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *get_command_id_at)(struct _cef_menu_model_t* self,
|
||||||
int index);
|
int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets the command id at the specified |index|. Returns true (1) on success.
|
// Sets the command id at the specified |index|. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_command_id_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_command_id_at)(struct _cef_menu_model_t* self,
|
||||||
int index,
|
int index, int command_id);
|
||||||
int command_id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the label for the specified |command_id| or NULL if not found.
|
// Returns the label for the specified |command_id| or NULL if not found.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_label)(struct _cef_menu_model_t* self,
|
cef_string_userfree_t (CEF_CALLBACK *get_label)(
|
||||||
int command_id);
|
struct _cef_menu_model_t* self, int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the label at the specified |index| or NULL if not found due to
|
// Returns the label at the specified |index| or NULL if not found due to
|
||||||
// invalid range or the index being a separator.
|
// invalid range or the index being a separator.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(
|
cef_string_userfree_t (CEF_CALLBACK *get_label_at)(
|
||||||
CEF_CALLBACK* get_label_at)(struct _cef_menu_model_t* self, int index);
|
struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets the label for the specified |command_id|. Returns true (1) on success.
|
// Sets the label for the specified |command_id|. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_label)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_label)(struct _cef_menu_model_t* self, int command_id,
|
||||||
int command_id,
|
|
||||||
const cef_string_t* label);
|
const cef_string_t* label);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the label at the specified |index|. Returns true (1) on success.
|
// Set the label at the specified |index|. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_label_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_label_at)(struct _cef_menu_model_t* self, int index,
|
||||||
int index,
|
|
||||||
const cef_string_t* label);
|
const cef_string_t* label);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the item type for the specified |command_id|.
|
// Returns the item type for the specified |command_id|.
|
||||||
///
|
///
|
||||||
cef_menu_item_type_t(CEF_CALLBACK* get_type)(struct _cef_menu_model_t* self,
|
cef_menu_item_type_t (CEF_CALLBACK *get_type)(struct _cef_menu_model_t* self,
|
||||||
int command_id);
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the item type at the specified |index|.
|
// Returns the item type at the specified |index|.
|
||||||
///
|
///
|
||||||
cef_menu_item_type_t(
|
cef_menu_item_type_t (CEF_CALLBACK *get_type_at)(
|
||||||
CEF_CALLBACK* get_type_at)(struct _cef_menu_model_t* self, int index);
|
struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the group id for the specified |command_id| or -1 if invalid.
|
// Returns the group id for the specified |command_id| or -1 if invalid.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_group_id)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *get_group_id)(struct _cef_menu_model_t* self,
|
||||||
int command_id);
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the group id at the specified |index| or -1 if invalid.
|
// Returns the group id at the specified |index| or -1 if invalid.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_group_id_at)(struct _cef_menu_model_t* self, int index);
|
int (CEF_CALLBACK *get_group_id_at)(struct _cef_menu_model_t* self,
|
||||||
|
int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets the group id for the specified |command_id|. Returns true (1) on
|
// Sets the group id for the specified |command_id|. Returns true (1) on
|
||||||
// success.
|
// success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_group_id)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_group_id)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, int group_id);
|
||||||
int group_id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets the group id at the specified |index|. Returns true (1) on success.
|
// Sets the group id at the specified |index|. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_group_id_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_group_id_at)(struct _cef_menu_model_t* self, int index,
|
||||||
int index,
|
|
||||||
int group_id);
|
int group_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the submenu for the specified |command_id| or NULL if invalid.
|
// Returns the submenu for the specified |command_id| or NULL if invalid.
|
||||||
///
|
///
|
||||||
struct _cef_menu_model_t*(CEF_CALLBACK* get_sub_menu)(
|
struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu)(
|
||||||
struct _cef_menu_model_t* self,
|
struct _cef_menu_model_t* self, int command_id);
|
||||||
int command_id);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the submenu at the specified |index| or NULL if invalid.
|
// Returns the submenu at the specified |index| or NULL if invalid.
|
||||||
///
|
///
|
||||||
struct _cef_menu_model_t*(
|
struct _cef_menu_model_t* (CEF_CALLBACK *get_sub_menu_at)(
|
||||||
CEF_CALLBACK* get_sub_menu_at)(struct _cef_menu_model_t* self, int index);
|
struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |command_id| is visible.
|
// Returns true (1) if the specified |command_id| is visible.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_visible)(struct _cef_menu_model_t* self, int command_id);
|
int (CEF_CALLBACK *is_visible)(struct _cef_menu_model_t* self,
|
||||||
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |index| is visible.
|
// Returns true (1) if the specified |index| is visible.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_visible_at)(struct _cef_menu_model_t* self, int index);
|
int (CEF_CALLBACK *is_visible_at)(struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Change the visibility of the specified |command_id|. Returns true (1) on
|
// Change the visibility of the specified |command_id|. Returns true (1) on
|
||||||
// success.
|
// success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_visible)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_visible)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, int visible);
|
||||||
int visible);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Change the visibility at the specified |index|. Returns true (1) on
|
// Change the visibility at the specified |index|. Returns true (1) on
|
||||||
// success.
|
// success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_visible_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_visible_at)(struct _cef_menu_model_t* self, int index,
|
||||||
int index,
|
|
||||||
int visible);
|
int visible);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |command_id| is enabled.
|
// Returns true (1) if the specified |command_id| is enabled.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_enabled)(struct _cef_menu_model_t* self, int command_id);
|
int (CEF_CALLBACK *is_enabled)(struct _cef_menu_model_t* self,
|
||||||
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |index| is enabled.
|
// Returns true (1) if the specified |index| is enabled.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_enabled_at)(struct _cef_menu_model_t* self, int index);
|
int (CEF_CALLBACK *is_enabled_at)(struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Change the enabled status of the specified |command_id|. Returns true (1)
|
// Change the enabled status of the specified |command_id|. Returns true (1)
|
||||||
// on success.
|
// on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_enabled)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_enabled)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, int enabled);
|
||||||
int enabled);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Change the enabled status at the specified |index|. Returns true (1) on
|
// Change the enabled status at the specified |index|. Returns true (1) on
|
||||||
// success.
|
// success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_enabled_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_enabled_at)(struct _cef_menu_model_t* self, int index,
|
||||||
int index,
|
|
||||||
int enabled);
|
int enabled);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |command_id| is checked. Only applies to
|
// Returns true (1) if the specified |command_id| is checked. Only applies to
|
||||||
// check and radio items.
|
// check and radio items.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_checked)(struct _cef_menu_model_t* self, int command_id);
|
int (CEF_CALLBACK *is_checked)(struct _cef_menu_model_t* self,
|
||||||
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |index| is checked. Only applies to check
|
// Returns true (1) if the specified |index| is checked. Only applies to check
|
||||||
// and radio items.
|
// and radio items.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_checked_at)(struct _cef_menu_model_t* self, int index);
|
int (CEF_CALLBACK *is_checked_at)(struct _cef_menu_model_t* self, int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Check the specified |command_id|. Only applies to check and radio items.
|
// Check the specified |command_id|. Only applies to check and radio items.
|
||||||
// Returns true (1) on success.
|
// Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_checked)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_checked)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, int checked);
|
||||||
int checked);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Check the specified |index|. Only applies to check and radio items. Returns
|
// Check the specified |index|. Only applies to check and radio items. Returns
|
||||||
// true (1) on success.
|
// true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_checked_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_checked_at)(struct _cef_menu_model_t* self, int index,
|
||||||
int index,
|
|
||||||
int checked);
|
int checked);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |command_id| has a keyboard accelerator
|
// Returns true (1) if the specified |command_id| has a keyboard accelerator
|
||||||
// assigned.
|
// assigned.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_accelerator)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *has_accelerator)(struct _cef_menu_model_t* self,
|
||||||
int command_id);
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the specified |index| has a keyboard accelerator
|
// Returns true (1) if the specified |index| has a keyboard accelerator
|
||||||
// assigned.
|
// assigned.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_accelerator_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *has_accelerator_at)(struct _cef_menu_model_t* self,
|
||||||
int index);
|
int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the keyboard accelerator for the specified |command_id|. |key_code| can
|
// Set the keyboard accelerator for the specified |command_id|. |key_code| can
|
||||||
// be any virtual key or character value. Returns true (1) on success.
|
// be any virtual key or character value. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_accelerator)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_accelerator)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, int key_code, int shift_pressed, int ctrl_pressed,
|
||||||
int key_code,
|
|
||||||
int shift_pressed,
|
|
||||||
int ctrl_pressed,
|
|
||||||
int alt_pressed);
|
int alt_pressed);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the keyboard accelerator at the specified |index|. |key_code| can be
|
// Set the keyboard accelerator at the specified |index|. |key_code| can be
|
||||||
// any virtual key or character value. Returns true (1) on success.
|
// any virtual key or character value. Returns true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_accelerator_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *set_accelerator_at)(struct _cef_menu_model_t* self,
|
||||||
int index,
|
int index, int key_code, int shift_pressed, int ctrl_pressed,
|
||||||
int key_code,
|
|
||||||
int shift_pressed,
|
|
||||||
int ctrl_pressed,
|
|
||||||
int alt_pressed);
|
int alt_pressed);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Remove the keyboard accelerator for the specified |command_id|. Returns
|
// Remove the keyboard accelerator for the specified |command_id|. Returns
|
||||||
// true (1) on success.
|
// true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* remove_accelerator)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *remove_accelerator)(struct _cef_menu_model_t* self,
|
||||||
int command_id);
|
int command_id);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Remove the keyboard accelerator at the specified |index|. Returns true (1)
|
// Remove the keyboard accelerator at the specified |index|. Returns true (1)
|
||||||
// on success.
|
// on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* remove_accelerator_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *remove_accelerator_at)(struct _cef_menu_model_t* self,
|
||||||
int index);
|
int index);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieves the keyboard accelerator for the specified |command_id|. Returns
|
// Retrieves the keyboard accelerator for the specified |command_id|. Returns
|
||||||
// true (1) on success.
|
// true (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_accelerator)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *get_accelerator)(struct _cef_menu_model_t* self,
|
||||||
int command_id,
|
int command_id, int* key_code, int* shift_pressed, int* ctrl_pressed,
|
||||||
int* key_code,
|
|
||||||
int* shift_pressed,
|
|
||||||
int* ctrl_pressed,
|
|
||||||
int* alt_pressed);
|
int* alt_pressed);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieves the keyboard accelerator for the specified |index|. Returns true
|
// Retrieves the keyboard accelerator for the specified |index|. Returns true
|
||||||
// (1) on success.
|
// (1) on success.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_accelerator_at)(struct _cef_menu_model_t* self,
|
int (CEF_CALLBACK *get_accelerator_at)(struct _cef_menu_model_t* self,
|
||||||
int index,
|
int index, int* key_code, int* shift_pressed, int* ctrl_pressed,
|
||||||
int* key_code,
|
|
||||||
int* shift_pressed,
|
|
||||||
int* ctrl_pressed,
|
|
||||||
int* alt_pressed);
|
int* alt_pressed);
|
||||||
|
|
||||||
///
|
|
||||||
// Set the explicit color for |command_id| and |color_type| to |color|.
|
|
||||||
// Specify a |color| value of 0 to remove the explicit color. If no explicit
|
|
||||||
// color or default color is set for |color_type| then the system color will
|
|
||||||
// be used. Returns true (1) on success.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* set_color)(struct _cef_menu_model_t* self,
|
|
||||||
int command_id,
|
|
||||||
cef_menu_color_type_t color_type,
|
|
||||||
cef_color_t color);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Set the explicit color for |command_id| and |index| to |color|. Specify a
|
|
||||||
// |color| value of 0 to remove the explicit color. Specify an |index| value
|
|
||||||
// of -1 to set the default color for items that do not have an explicit color
|
|
||||||
// set. If no explicit color or default color is set for |color_type| then the
|
|
||||||
// system color will be used. Returns true (1) on success.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* set_color_at)(struct _cef_menu_model_t* self,
|
|
||||||
int index,
|
|
||||||
cef_menu_color_type_t color_type,
|
|
||||||
cef_color_t color);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns in |color| the color that was explicitly set for |command_id| and
|
|
||||||
// |color_type|. If a color was not set then 0 will be returned in |color|.
|
|
||||||
// Returns true (1) on success.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* get_color)(struct _cef_menu_model_t* self,
|
|
||||||
int command_id,
|
|
||||||
cef_menu_color_type_t color_type,
|
|
||||||
cef_color_t* color);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Returns in |color| the color that was explicitly set for |command_id| and
|
|
||||||
// |color_type|. Specify an |index| value of -1 to return the default color in
|
|
||||||
// |color|. If a color was not set then 0 will be returned in |color|. Returns
|
|
||||||
// true (1) on success.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* get_color_at)(struct _cef_menu_model_t* self,
|
|
||||||
int index,
|
|
||||||
cef_menu_color_type_t color_type,
|
|
||||||
cef_color_t* color);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Sets the font list for the specified |command_id|. If |font_list| is NULL
|
|
||||||
// the system font will be used. Returns true (1) on success. The format is
|
|
||||||
// "<FONT_FAMILY_LIST>,[STYLES] <SIZE>", where: - FONT_FAMILY_LIST is a comma-
|
|
||||||
// separated list of font family names, - STYLES is an optional space-
|
|
||||||
// separated list of style names (case-sensitive
|
|
||||||
// "Bold" and "Italic" are supported), and
|
|
||||||
// - SIZE is an integer font size in pixels with the suffix "px".
|
|
||||||
//
|
|
||||||
// Here are examples of valid font description strings: - "Arial, Helvetica,
|
|
||||||
// Bold Italic 14px" - "Arial, 14px"
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* set_font_list)(struct _cef_menu_model_t* self,
|
|
||||||
int command_id,
|
|
||||||
const cef_string_t* font_list);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Sets the font list for the specified |index|. Specify an |index| value of
|
|
||||||
// -1 to set the default font. If |font_list| is NULL the system font will be
|
|
||||||
// used. Returns true (1) on success. The format is
|
|
||||||
// "<FONT_FAMILY_LIST>,[STYLES] <SIZE>", where: - FONT_FAMILY_LIST is a comma-
|
|
||||||
// separated list of font family names, - STYLES is an optional space-
|
|
||||||
// separated list of style names (case-sensitive
|
|
||||||
// "Bold" and "Italic" are supported), and
|
|
||||||
// - SIZE is an integer font size in pixels with the suffix "px".
|
|
||||||
//
|
|
||||||
// Here are examples of valid font description strings: - "Arial, Helvetica,
|
|
||||||
// Bold Italic 14px" - "Arial, 14px"
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* set_font_list_at)(struct _cef_menu_model_t* self,
|
|
||||||
int index,
|
|
||||||
const cef_string_t* font_list);
|
|
||||||
} cef_menu_model_t;
|
} cef_menu_model_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Create a new MenuModel with the specified |delegate|.
|
// Create a new MenuModel with the specified |delegate|.
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_menu_model_t* cef_menu_model_create(
|
CEF_EXPORT cef_menu_model_t* cef_menu_model_create(
|
||||||
struct _cef_menu_model_delegate_t* delegate);
|
struct _cef_menu_model_delegate_t* delegate);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,8 +33,6 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=edc411cb0447a6c2965cdeb5f709fe56c43ec2bb$
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_
|
||||||
#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_
|
#define CEF_INCLUDE_CAPI_CEF_MENU_MODEL_DELEGATE_CAPI_H_
|
||||||
@@ -57,65 +55,24 @@ typedef struct _cef_menu_model_delegate_t {
|
|||||||
///
|
///
|
||||||
// Base structure.
|
// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Perform the action associated with the specified |command_id| and optional
|
// Perform the action associated with the specified |command_id| and optional
|
||||||
// |event_flags|.
|
// |event_flags|.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* execute_command)(struct _cef_menu_model_delegate_t* self,
|
void (CEF_CALLBACK *execute_command)(struct _cef_menu_model_delegate_t* self,
|
||||||
struct _cef_menu_model_t* menu_model,
|
struct _cef_menu_model_t* menu_model, int command_id,
|
||||||
int command_id,
|
|
||||||
cef_event_flags_t event_flags);
|
cef_event_flags_t event_flags);
|
||||||
|
|
||||||
///
|
|
||||||
// Called when the user moves the mouse outside the menu and over the owning
|
|
||||||
// window.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* mouse_outside_menu)(
|
|
||||||
struct _cef_menu_model_delegate_t* self,
|
|
||||||
struct _cef_menu_model_t* menu_model,
|
|
||||||
const cef_point_t* screen_point);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called on unhandled open submenu keyboard commands. |is_rtl| will be true
|
|
||||||
// (1) if the menu is displaying a right-to-left language.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* unhandled_open_submenu)(
|
|
||||||
struct _cef_menu_model_delegate_t* self,
|
|
||||||
struct _cef_menu_model_t* menu_model,
|
|
||||||
int is_rtl);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Called on unhandled close submenu keyboard commands. |is_rtl| will be true
|
|
||||||
// (1) if the menu is displaying a right-to-left language.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* unhandled_close_submenu)(
|
|
||||||
struct _cef_menu_model_delegate_t* self,
|
|
||||||
struct _cef_menu_model_t* menu_model,
|
|
||||||
int is_rtl);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// The menu is about to show.
|
// The menu is about to show.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* menu_will_show)(struct _cef_menu_model_delegate_t* self,
|
void (CEF_CALLBACK *menu_will_show)(struct _cef_menu_model_delegate_t* self,
|
||||||
struct _cef_menu_model_t* menu_model);
|
struct _cef_menu_model_t* menu_model);
|
||||||
|
|
||||||
///
|
|
||||||
// The menu has closed.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* menu_closed)(struct _cef_menu_model_delegate_t* self,
|
|
||||||
struct _cef_menu_model_t* menu_model);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Optionally modify a menu item label. Return true (1) if |label| was
|
|
||||||
// modified.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* format_label)(struct _cef_menu_model_delegate_t* self,
|
|
||||||
struct _cef_menu_model_t* menu_model,
|
|
||||||
cef_string_t* label);
|
|
||||||
} cef_menu_model_delegate_t;
|
} cef_menu_model_delegate_t;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user