From 6702fc573afe2c009b42edd2f7e0f2e2441bf7b5 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 11 Jul 2014 20:10:05 +0000 Subject: [PATCH] Introduce the use of Chromium types (issue #1336). - Move include/cef_build.h to include/base/cef_build.h. - Move libcef_dll/cef_macros.h to include/base/cef_macros.h. - Move include/cef_trace_event.h to include/base/cef_trace_event.h and include/internal/cef_trace_event_internal.h. - Remove the "CEF_" prefix from TRACE macros. - Add new include/base/cef_logging.h and include/internal/cef_logging_internal.h for logging support. - Add new include/wrapper/cef_helpers.h for CEF_REQUIRE_*_THREAD macros and CefScopedArgArray. - Delete the util.h headers used by tests that duplicated the above functionality. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1767 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef.gyp | 1 + cef_paths2.gypi | 15 +- include/{internal => base}/cef_build.h | 47 +- include/base/cef_logging.h | 744 ++++++++++++++++++ include/base/cef_macros.h | 123 +++ include/{ => base}/cef_trace_event.h | 247 +++--- include/capi/cef_task_capi.h | 6 +- include/cef_base.h | 2 +- include/internal/cef_export.h | 2 +- include/internal/cef_logging_internal.h | 66 ++ include/internal/cef_string_types.h | 9 +- include/internal/cef_trace_event_internal.h | 124 +++ include/internal/cef_types.h | 2 +- include/internal/cef_types_linux.h | 2 +- include/internal/cef_types_mac.h | 2 +- include/internal/cef_types_win.h | 2 +- include/wrapper/cef_byte_read_handler.h | 3 + include/wrapper/cef_helpers.h | 79 ++ include/wrapper/cef_stream_resource_handler.h | 3 + include/wrapper/cef_xml_object.h | 3 + include/wrapper/cef_zip_archive.h | 3 + libcef/browser/trace_impl.cc | 296 ------- libcef/common/base_impl.cc | 330 ++++++++ libcef/common/main_delegate.cc | 4 + libcef/renderer/browser_impl.cc | 14 - libcef_dll/base/cef_logging.cc | 257 ++++++ libcef_dll/cef_logging.h | 35 - libcef_dll/cef_macros.h | 21 - libcef_dll/cpptoc/base_cpptoc.h | 7 +- libcef_dll/cpptoc/cpptoc.h | 13 +- libcef_dll/ctocpp/base_ctocpp.h | 7 +- libcef_dll/ctocpp/command_line_ctocpp.cc | 4 +- libcef_dll/ctocpp/ctocpp.h | 7 +- libcef_dll/libcef_dll2.cc | 2 +- libcef_dll/wrapper/cef_browser_info_map.h | 7 +- libcef_dll/wrapper/cef_byte_read_handler.cc | 2 +- libcef_dll/wrapper/cef_message_router.cc | 4 +- .../wrapper/cef_stream_resource_handler.cc | 8 +- libcef_dll/wrapper/cef_xml_object.cc | 11 +- libcef_dll/wrapper/cef_zip_archive.cc | 13 +- libcef_dll/wrapper/libcef_dll_wrapper.cc | 4 +- tests/cefclient/bytes_write_handler.cpp | 8 +- tests/cefclient/cefclient.cpp | 8 +- tests/cefclient/cefclient_gtk.cpp | 4 +- .../cefclient/cefclient_osr_dragdrop_win.cpp | 8 +- tests/cefclient/cefclient_osr_widget_gtk.cpp | 16 +- tests/cefclient/cefclient_osr_widget_mac.mm | 42 +- tests/cefclient/cefclient_osr_widget_win.cpp | 14 +- tests/cefclient/cefclient_win.cpp | 6 +- tests/cefclient/client_app.cpp | 6 +- tests/cefclient/client_handler.cpp | 20 +- tests/cefclient/client_handler.h | 2 +- tests/cefclient/client_handler_gtk.cpp | 16 +- tests/cefclient/client_handler_mac.mm | 4 +- tests/cefclient/client_handler_win.cpp | 8 +- tests/cefclient/client_renderer.cpp | 2 +- tests/cefclient/dialog_test.cpp | 2 +- tests/cefclient/dom_test.cpp | 14 +- tests/cefclient/osrenderer.cpp | 10 +- tests/cefclient/performance_test_setup.h | 11 +- tests/cefclient/print_handler_gtk.cpp | 24 +- tests/cefclient/resource_util_mac.mm | 10 +- tests/cefclient/resource_util_win.cpp | 6 +- tests/cefclient/scheme_test.cpp | 14 +- tests/cefclient/util.h | 100 --- tests/cefclient/window_test.cpp | 2 +- tests/cefsimple/cefsimple_mac.mm | 2 +- tests/cefsimple/simple_app.cpp | 4 +- tests/cefsimple/simple_handler.cpp | 12 +- tests/cefsimple/simple_handler_linux.cpp | 10 +- tests/cefsimple/simple_handler_mac.mm | 4 +- tests/cefsimple/simple_handler_win.cpp | 4 +- tests/cefsimple/util.h | 37 - tests/unittests/run_all_unittests.cc | 7 +- tests/unittests/tracing_unittest.cc | 526 ++++++------- tests/unittests/urlrequest_unittest.cc | 4 +- tools/cef_api_hash.py | 5 +- tools/make_ctocpp_impl.py | 2 +- tools/make_version_header.py | 2 +- 79 files changed, 2335 insertions(+), 1172 deletions(-) rename include/{internal => base}/cef_build.h (65%) create mode 100644 include/base/cef_logging.h create mode 100644 include/base/cef_macros.h rename include/{ => base}/cef_trace_event.h (62%) create mode 100644 include/internal/cef_logging_internal.h create mode 100644 include/internal/cef_trace_event_internal.h create mode 100644 include/wrapper/cef_helpers.h create mode 100644 libcef/common/base_impl.cc create mode 100644 libcef_dll/base/cef_logging.cc delete mode 100644 libcef_dll/cef_logging.h delete mode 100644 libcef_dll/cef_macros.h delete mode 100644 tests/cefclient/util.h delete mode 100644 tests/cefsimple/util.h diff --git a/cef.gyp b/cef.gyp index 5ac20ed38..79b5b4988 100644 --- a/cef.gyp +++ b/cef.gyp @@ -985,6 +985,7 @@ 'libcef/browser/xml_reader_impl.h', 'libcef/browser/zip_reader_impl.cc', 'libcef/browser/zip_reader_impl.h', + 'libcef/common/base_impl.cc', 'libcef/common/breakpad_client.cc', 'libcef/common/breakpad_client.h', 'libcef/common/cef_message_generator.cc', diff --git a/cef_paths2.gypi b/cef_paths2.gypi index 908f711f2..e232631e8 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -9,14 +9,17 @@ ], 'variables': { 'includes_common': [ + 'include/base/cef_build.h', + 'include/base/cef_logging.h', + 'include/base/cef_macros.h', + 'include/base/cef_trace_event.h', 'include/cef_base.h', 'include/cef_pack_resources.h', 'include/cef_pack_strings.h', 'include/cef_runnable.h', - 'include/cef_trace_event.h', 'include/cef_version.h', - 'include/internal/cef_build.h', 'include/internal/cef_export.h', + 'include/internal/cef_logging_internal.h', 'include/internal/cef_ptr.h', 'include/internal/cef_string.h', 'include/internal/cef_string_list.h', @@ -25,6 +28,7 @@ 'include/internal/cef_string_types.h', 'include/internal/cef_string_wrappers.h', 'include/internal/cef_time.h', + 'include/internal/cef_trace_event_internal.h', 'include/internal/cef_tuple.h', 'include/internal/cef_types.h', 'include/internal/cef_types_wrappers.h', @@ -56,7 +60,6 @@ 'include/internal/cef_types_linux.h', ], 'libcef_sources_common': [ - 'libcef_dll/cef_logging.h', 'libcef_dll/cpptoc/cpptoc.h', 'libcef_dll/ctocpp/ctocpp.h', 'libcef_dll/libcef_dll.cc', @@ -67,8 +70,7 @@ '<@(autogen_library_side)', ], 'libcef_dll_wrapper_sources_common': [ - 'libcef_dll/cef_logging.h', - 'libcef_dll/cef_macros.h', + 'libcef_dll/base/cef_logging.cc', 'libcef_dll/cpptoc/base_cpptoc.h', 'libcef_dll/cpptoc/cpptoc.h', 'libcef_dll/ctocpp/base_ctocpp.h', @@ -131,7 +133,6 @@ 'tests/cefclient/scheme_test.h', 'tests/cefclient/string_util.cpp', 'tests/cefclient/string_util.h', - 'tests/cefclient/util.h', 'tests/cefclient/window_test.cpp', 'tests/cefclient/window_test.h', '<@(cefclient_bundle_resources_common)', @@ -189,7 +190,6 @@ 'tests/cefclient/scheme_test.h', 'tests/cefclient/string_util.cpp', 'tests/cefclient/string_util.h', - 'tests/cefclient/util.h', 'tests/cefclient/window_test.cpp', 'tests/cefclient/window_test.h', 'tests/cefclient/window_test_mac.mm', @@ -220,7 +220,6 @@ 'tests/cefsimple/simple_app.h', 'tests/cefsimple/simple_handler.cpp', 'tests/cefsimple/simple_handler.h', - 'tests/cefsimple/util.h', ], 'cefsimple_sources_win': [ 'tests/cefsimple/cefsimple.exe.manifest', diff --git a/include/internal/cef_build.h b/include/base/cef_build.h similarity index 65% rename from include/internal/cef_build.h rename to include/base/cef_build.h index 0ad86829c..934976a75 100644 --- a/include/internal/cef_build.h +++ b/include/base/cef_build.h @@ -28,15 +28,17 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ -#define CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ +#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_ +#define CEF_INCLUDE_BASE_CEF_BUILD_H_ #pragma once #if defined(BUILDING_CEF_SHARED) - +// When building CEF include the Chromium header directly. #include "base/compiler_specific.h" - #else // !BUILDING_CEF_SHARED +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. #if defined(_WIN32) #ifndef OS_WIN @@ -89,41 +91,6 @@ #define OVERRIDE #endif -#ifndef 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 - #endif // !BUILDING_CEF_SHARED -#endif // CEF_INCLUDE_INTERNAL_CEF_BUILD_H_ +#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_ diff --git a/include/base/cef_logging.h b/include/base/cef_logging.h new file mode 100644 index 000000000..677414975 --- /dev/null +++ b/include/base/cef_logging.h @@ -0,0 +1,744 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// +// WARNING: Logging macros should not be used in the main/browser process before +// calling CefInitialize or in sub-processes before calling CefExecuteProcess. +// +// Instructions +// ------------ +// +// Make a bunch of macros for logging. The way to log things is to stream +// things to LOG(). E.g., +// +// LOG(INFO) << "Found " << num_cookies << " cookies"; +// +// You can also do conditional logging: +// +// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// The CHECK(condition) macro is active in both debug and release builds and +// effectively performs a LOG(FATAL) which terminates the process and +// generates a crashdump unless a debugger is attached. +// +// There are also "debug mode" logging macros like the ones above: +// +// DLOG(INFO) << "Found cookies"; +// +// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// All "debug mode" logging is compiled away to nothing for non-debug mode +// compiles. LOG_IF and development flags also work well together +// because the code can be compiled away sometimes. +// +// We also have +// +// LOG_ASSERT(assertion); +// DLOG_ASSERT(assertion); +// +// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion; +// +// There are "verbose level" logging macros. They look like +// +// VLOG(1) << "I'm printed when you run the program with --v=1 or more"; +// VLOG(2) << "I'm printed when you run the program with --v=2 or more"; +// +// These always log at the INFO log level (when they log at all). +// The verbose logging can also be turned on module-by-module. For instance, +// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0 +// will cause: +// a. VLOG(2) and lower messages to be printed from profile.{h,cc} +// b. VLOG(1) and lower messages to be printed from icon_loader.{h,cc} +// c. VLOG(3) and lower messages to be printed from files prefixed with +// "browser" +// d. VLOG(4) and lower messages to be printed from files under a +// "chromeos" directory. +// e. VLOG(0) and lower messages to be printed from elsewhere +// +// The wildcarding functionality shown by (c) supports both '*' (match +// 0 or more characters) and '?' (match any single character) +// wildcards. Any pattern containing a forward or backward slash will +// be tested against the whole pathname and not just the module. +// E.g., "*/foo/bar/*=2" would change the logging level for all code +// in source files under a "foo/bar" directory. +// +// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as +// +// if (VLOG_IS_ON(2)) { +// // do some logging preparation and logging +// // that can't be accomplished with just VLOG(2) << ...; +// } +// +// There is also a VLOG_IF "verbose level" condition macro for sample +// cases, when some extra computation and preparation for logs is not +// needed. +// +// VLOG_IF(1, (size > 1024)) +// << "I'm printed when size is more than 1024 and when you run the " +// "program with --v=1 or more"; +// +// We also override the standard 'assert' to use 'DLOG_ASSERT'. +// +// Lastly, there is: +// +// PLOG(ERROR) << "Couldn't do foo"; +// DPLOG(ERROR) << "Couldn't do foo"; +// PLOG_IF(ERROR, cond) << "Couldn't do foo"; +// DPLOG_IF(ERROR, cond) << "Couldn't do foo"; +// PCHECK(condition) << "Couldn't do foo"; +// DPCHECK(condition) << "Couldn't do foo"; +// +// which append the last system error to the message in string form (taken from +// GetLastError() on Windows and errno on POSIX). +// +// The supported severity levels for macros that allow you to specify one +// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. +// +// Very important: logging a message at the FATAL severity level causes +// the program to terminate (after the message is logged). +// +// There is the special severity of DFATAL, which logs FATAL in debug mode, +// ERROR in normal mode. +// + +#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_ +#define CEF_INCLUDE_BASE_CEF_LOGGING_H_ +#pragma once + +#if defined(DCHECK) +// Do nothing if the macros provided by this header already exist. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(BUILDING_CEF_SHARED) +// When building CEF include the Chromium header directly. +#include "base/logging.h" +#else // !BUILDING_CEF_SHARED +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include +#include +#include +#include + +#include "include/base/cef_build.h" +#include "include/base/cef_macros.h" +#include "include/internal/cef_logging_internal.h" + +namespace cef_logging { + +// Gets the current log level. +inline int GetMinLogLevel() { + return cef_get_min_log_level(); +} + +// Gets the current vlog level for the given file (usually taken from +// __FILE__). Note that |N| is the size *with* the null terminator. +template +int GetVlogLevel(const char (&file)[N]) { + return cef_get_vlog_level(file, N); +} + +typedef int LogSeverity; +const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity +// Note: the log severities are used to index into the array of names, +// see log_severity_names. +const LogSeverity LOG_INFO = 0; +const LogSeverity LOG_WARNING = 1; +const LogSeverity LOG_ERROR = 2; +const LogSeverity LOG_FATAL = 3; +const LogSeverity LOG_NUM_SEVERITIES = 4; + +// LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode +#ifdef NDEBUG +const LogSeverity LOG_DFATAL = LOG_ERROR; +#else +const LogSeverity LOG_DFATAL = LOG_FATAL; +#endif + +// A few definitions of macros that don't generate much code. These are used +// by LOG() and LOG_IF, etc. Since these are used all over our code, it's +// better to have compact code for these operations. +#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ + cef_logging::ClassName(__FILE__, __LINE__, cef_logging::LOG_INFO , \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ + cef_logging::ClassName(__FILE__, __LINE__, cef_logging::LOG_WARNING , \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ + cef_logging::ClassName(__FILE__, __LINE__, cef_logging::LOG_ERROR , \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ + cef_logging::ClassName(__FILE__, __LINE__, cef_logging::LOG_FATAL , \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ + cef_logging::ClassName(__FILE__, __LINE__, cef_logging::LOG_DFATAL , \ + ##__VA_ARGS__) + +#define COMPACT_GOOGLE_LOG_INFO \ + COMPACT_GOOGLE_LOG_EX_INFO(LogMessage) +#define COMPACT_GOOGLE_LOG_WARNING \ + COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) +#define COMPACT_GOOGLE_LOG_ERROR \ + COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage) +#define COMPACT_GOOGLE_LOG_FATAL \ + COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage) +#define COMPACT_GOOGLE_LOG_DFATAL \ + COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage) + +#if defined(OS_WIN) +// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets +// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us +// to keep using this syntax, we define this macro to do the same thing +// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that +// the Windows SDK does for consistency. +#define ERROR 0 +#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_ERROR(ClassName , ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR +// Needed for LOG_IS_ON(ERROR). +const LogSeverity LOG_0 = LOG_ERROR; +#endif + +// As special cases, we can assume that LOG_IS_ON(FATAL) always holds. Also, +// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will +// always fire if they fail. +#define LOG_IS_ON(severity) \ + ((::cef_logging::LOG_ ## severity) >= ::cef_logging::GetMinLogLevel()) + +// We can't do any caching tricks with VLOG_IS_ON() like the +// google-glog version since it requires GCC extensions. This means +// that using the v-logging functions in conjunction with --vmodule +// may be slow. +#define VLOG_IS_ON(verboselevel) \ + ((verboselevel) <= ::cef_logging::GetVlogLevel(__FILE__)) + +// Helper macro which avoids evaluating the arguments to a stream if +// the condition doesn't hold. +#define LAZY_STREAM(stream, condition) \ + !(condition) ? (void) 0 : ::cef_logging::LogMessageVoidify() & (stream) + +// We use the preprocessor's merging operator, "##", so that, e.g., +// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny +// subtle difference between ostream member streaming functions (e.g., +// ostream::operator<<(int) and ostream non-member streaming functions +// (e.g., ::operator<<(ostream&, string&): it turns out that it's +// impossible to stream something like a string directly to an unnamed +// ostream. We employ a neat hack by calling the stream() member +// function of LogMessage which seems to avoid the problem. +#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream() + +#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity)) +#define LOG_IF(severity, condition) \ + LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) + +#define SYSLOG(severity) LOG(severity) +#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition) + +// The VLOG macros log with negative verbosities. +#define VLOG_STREAM(verbose_level) \ + cef_logging::LogMessage(__FILE__, __LINE__, -verbose_level).stream() + +#define VLOG(verbose_level) \ + LAZY_STREAM(VLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level)) + +#define VLOG_IF(verbose_level, condition) \ + LAZY_STREAM(VLOG_STREAM(verbose_level), \ + VLOG_IS_ON(verbose_level) && (condition)) + +#if defined (OS_WIN) +#define VPLOG_STREAM(verbose_level) \ + cef_logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef_logging::GetLastSystemErrorCode()).stream() +#elif defined(OS_POSIX) +#define VPLOG_STREAM(verbose_level) \ + cef_logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef_logging::GetLastSystemErrorCode()).stream() +#endif + +#define VPLOG(verbose_level) \ + LAZY_STREAM(VPLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level)) + +#define VPLOG_IF(verbose_level, condition) \ + LAZY_STREAM(VPLOG_STREAM(verbose_level), \ + VLOG_IS_ON(verbose_level) && (condition)) + +// TODO(akalin): Add more VLOG variants, e.g. VPLOG. + +#define LOG_ASSERT(condition) \ + LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " +#define SYSLOG_ASSERT(condition) \ + SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " + +#if defined(OS_WIN) +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \ + ::cef_logging::GetLastSystemErrorCode()).stream() +#elif defined(OS_POSIX) +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ + ::cef_logging::GetLastSystemErrorCode()).stream() +#endif + +#define PLOG(severity) \ + LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) + +#define PLOG_IF(severity, condition) \ + LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) + +// The actual stream used isn't important. +#define EAT_STREAM_PARAMETERS \ + true ? (void) 0 : ::cef_logging::LogMessageVoidify() & LOG_STREAM(FATAL) + +// CHECK dies with a fatal error if condition is not true. It is *not* +// controlled by NDEBUG, so the check will be executed regardless of +// compilation mode. +// +// We make sure CHECK et al. always evaluates their arguments, as +// doing CHECK(FunctionWithSideEffect()) is a common idiom. + +#define CHECK(condition) \ + LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \ + << "Check failed: " #condition ". " + +#define PCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \ + << "Check failed: " #condition ". " + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use CHECK_EQ et al below. +// +// TODO(akalin): Rewrite this so that constructs like if (...) +// CHECK_EQ(...) else { ... } work properly. +#define CHECK_OP(name, op, val1, val2) \ + if (std::string* _result = \ + cef_logging::Check##name##Impl((val1), (val2), \ + #val1 " " #op " " #val2)) \ + cef_logging::LogMessage(__FILE__, __LINE__, _result).stream() + +// Build the error message string. This is separate from the "Impl" +// function template because it is not performance critical and so can +// be out of line, while the "Impl" code should be inline. Caller +// takes ownership of the returned string. +template +std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { + std::ostringstream ss; + ss << names << " (" << v1 << " vs. " << v2 << ")"; + std::string* msg = new std::string(ss.str()); + return msg; +} + +// MSVC doesn't like complex extern templates and DLLs. +#if !defined(COMPILER_MSVC) +// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated +// in logging.cc. +extern template std::string* MakeCheckOpString( + const int&, const int&, const char* names); +extern template +std::string* MakeCheckOpString( + const unsigned long&, const unsigned long&, const char* names); +extern template +std::string* MakeCheckOpString( + const unsigned long&, const unsigned int&, const char* names); +extern template +std::string* MakeCheckOpString( + const unsigned int&, const unsigned long&, const char* names); +extern template +std::string* MakeCheckOpString( + const std::string&, const std::string&, const char* name); +#endif + +// Helper functions for CHECK_OP macro. +// The (int, int) specialization works around the issue that the compiler +// will not instantiate the template version of the function on values of +// unnamed enum type - see comment below. +#define DEFINE_CHECK_OP_IMPL(name, op) \ + template \ + inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ + const char* names) { \ + if (v1 op v2) return NULL; \ + else return MakeCheckOpString(v1, v2, names); \ + } \ + inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ + if (v1 op v2) return NULL; \ + else return MakeCheckOpString(v1, v2, names); \ + } +DEFINE_CHECK_OP_IMPL(EQ, ==) +DEFINE_CHECK_OP_IMPL(NE, !=) +DEFINE_CHECK_OP_IMPL(LE, <=) +DEFINE_CHECK_OP_IMPL(LT, < ) +DEFINE_CHECK_OP_IMPL(GE, >=) +DEFINE_CHECK_OP_IMPL(GT, > ) +#undef DEFINE_CHECK_OP_IMPL + +#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) +#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) +#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) +#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2) +#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) +#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) + +#if defined(NDEBUG) +#define ENABLE_DLOG 0 +#else +#define ENABLE_DLOG 1 +#endif + +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON 0 +#else +#define DCHECK_IS_ON 1 +#endif + +// Definitions for DLOG et al. + +#if ENABLE_DLOG + +#define DLOG_IS_ON(severity) LOG_IS_ON(severity) +#define DLOG_IF(severity, condition) LOG_IF(severity, condition) +#define DLOG_ASSERT(condition) LOG_ASSERT(condition) +#define DPLOG_IF(severity, condition) PLOG_IF(severity, condition) +#define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition) +#define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition) + +#else // ENABLE_DLOG + +// If ENABLE_DLOG is off, we want to avoid emitting any references to +// |condition| (which may reference a variable defined only if NDEBUG +// is not defined). Contrast this with DCHECK et al., which has +// different behavior. + +#define DLOG_IS_ON(severity) false +#define DLOG_IF(severity, condition) EAT_STREAM_PARAMETERS +#define DLOG_ASSERT(condition) EAT_STREAM_PARAMETERS +#define DPLOG_IF(severity, condition) EAT_STREAM_PARAMETERS +#define DVLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS +#define DVPLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS + +#endif // ENABLE_DLOG + +// DEBUG_MODE is for uses like +// if (DEBUG_MODE) foo.CheckThatFoo(); +// instead of +// #ifndef NDEBUG +// foo.CheckThatFoo(); +// #endif +// +// We tie its state to ENABLE_DLOG. +enum { DEBUG_MODE = ENABLE_DLOG }; + +#undef ENABLE_DLOG + +#define DLOG(severity) \ + LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) + +#define DPLOG(severity) \ + LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) + +#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) + +#define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) + +// Definitions for DCHECK et al. + +#if DCHECK_IS_ON + +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL +const LogSeverity LOG_DCHECK = LOG_FATAL; + +#else // DCHECK_IS_ON + +// These are just dummy values. +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO +const LogSeverity LOG_DCHECK = LOG_INFO; + +#endif // DCHECK_IS_ON + +// DCHECK et al. make sure to reference |condition| regardless of +// whether DCHECKs are enabled; this is so that we don't get unused +// variable warnings if the only use of a variable is in a DCHECK. +// This behavior is different from DLOG_IF et al. + +#define DCHECK(condition) \ + LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON && !(condition)) \ + << "Check failed: " #condition ". " + +#define DPCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON && !(condition)) \ + << "Check failed: " #condition ". " + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use DCHECK_EQ et al below. +#define DCHECK_OP(name, op, val1, val2) \ + if (DCHECK_IS_ON) \ + if (std::string* _result = \ + cef_logging::Check##name##Impl((val1), (val2), \ + #val1 " " #op " " #val2)) \ + cef_logging::LogMessage( \ + __FILE__, __LINE__, ::cef_logging::LOG_DCHECK, \ + _result).stream() + +// Equality/Inequality checks - compare two values, and log a +// LOG_DCHECK message including the two values when the result is not +// as expected. The values must have operator<<(ostream, ...) +// defined. +// +// You may append to the error message like so: +// DCHECK_NE(1, 2) << ": The world must be ending!"; +// +// We are very careful to ensure that each argument is evaluated exactly +// once, and that anything which is legal to pass as a function argument is +// legal here. In particular, the arguments may be temporary expressions +// which will end up being destroyed at the end of the apparent statement, +// for example: +// DCHECK_EQ(string("abc")[1], 'b'); +// +// WARNING: These may not compile correctly if one of the arguments is a pointer +// and the other is NULL. To work around this, simply static_cast NULL to the +// type of the desired pointer. + +#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) +#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) +#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) +#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) +#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) +#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) + +#if defined(NDEBUG) && defined(OS_CHROMEOS) +#define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \ + __FUNCTION__ << ". " +#else +#define NOTREACHED() DCHECK(false) +#endif + +// Redefine the standard assert to use our nice log files +#undef assert +#define assert(x) DLOG_ASSERT(x) + +// This class more or less represents a particular log message. You +// create an instance of LogMessage and then stream stuff to it. +// When you finish streaming to it, ~LogMessage is called and the +// full message gets streamed to the appropriate destination. +// +// You shouldn't actually use LogMessage's constructor to log things, +// though. You should use the LOG() macro (and variants thereof) +// above. +class LogMessage { + public: + // Used for LOG(severity). + LogMessage(const char* file, int line, LogSeverity severity); + + // Used for CHECK_EQ(), etc. Takes ownership of the given string. + // Implied severity = LOG_FATAL. + LogMessage(const char* file, int line, std::string* result); + + // Used for DCHECK_EQ(), etc. Takes ownership of the given string. + LogMessage(const char* file, int line, LogSeverity severity, + std::string* result); + + ~LogMessage(); + + std::ostream& stream() { return stream_; } + + private: + LogSeverity severity_; + std::ostringstream stream_; + + // The file and line information passed in to the constructor. + const char* file_; + const int line_; + +#if defined(OS_WIN) + // Stores the current value of GetLastError in the constructor and restores + // it in the destructor by calling SetLastError. + // This is useful since the LogMessage class uses a lot of Win32 calls + // that will lose the value of GLE and the code that called the log function + // will have lost the thread error value when the log call returns. + class SaveLastError { + public: + SaveLastError(); + ~SaveLastError(); + + unsigned long get_error() const { return last_error_; } + + protected: + unsigned long last_error_; + }; + + SaveLastError last_error_; +#endif + + DISALLOW_COPY_AND_ASSIGN(LogMessage); +}; + +// A non-macro interface to the log facility; (useful +// when the logging level is not a compile-time constant). +inline void LogAtLevel(int const log_level, std::string const &msg) { + LogMessage(__FILE__, __LINE__, log_level).stream() << msg; +} + +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". +class LogMessageVoidify { + public: + LogMessageVoidify() { } + // This has to be an operator with a precedence lower than << but + // higher than ?: + void operator&(std::ostream&) { } +}; + +#if defined(OS_WIN) +typedef unsigned long SystemErrorCode; +#elif defined(OS_POSIX) +typedef int SystemErrorCode; +#endif + +// Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to +// pull in windows.h just for GetLastError() and DWORD. +SystemErrorCode GetLastSystemErrorCode(); +std::string SystemErrorCodeToString(SystemErrorCode error_code); + +#if defined(OS_WIN) +// Appends a formatted system message of the GetLastError() type. +class Win32ErrorLogMessage { + public: + Win32ErrorLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err); + + // Appends the error message before destructing the encapsulated class. + ~Win32ErrorLogMessage(); + + std::ostream& stream() { return log_message_.stream(); } + + private: + SystemErrorCode err_; + LogMessage log_message_; + + DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); +}; +#elif defined(OS_POSIX) +// Appends a formatted system message of the errno type +class ErrnoLogMessage { + public: + ErrnoLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err); + + // Appends the error message before destructing the encapsulated class. + ~ErrnoLogMessage(); + + std::ostream& stream() { return log_message_.stream(); } + + private: + SystemErrorCode err_; + LogMessage log_message_; + + DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); +}; +#endif // OS_WIN + +} // namespace cef_logging + +// These functions are provided as a convenience for logging, which is where we +// use streams (it is against Google style to use streams in other places). It +// is designed to allow you to emit non-ASCII Unicode strings to the log file, +// which is normally ASCII. It is relatively slow, so try not to use it for +// common cases. Non-ASCII characters will be converted to UTF-8 by these +// operators. +std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); +inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { + return out << wstr.c_str(); +} + +// The NOTIMPLEMENTED() macro annotates codepaths which have +// not been implemented yet. +// +// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY: +// 0 -- Do nothing (stripped by compiler) +// 1 -- Warn at compile time +// 2 -- Fail at compile time +// 3 -- Fail at runtime (DCHECK) +// 4 -- [default] LOG(ERROR) at runtime +// 5 -- LOG(ERROR) at runtime, only once per call-site + +#ifndef NOTIMPLEMENTED_POLICY +#if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) +#define NOTIMPLEMENTED_POLICY 0 +#else +// Select default policy: LOG(ERROR) +#define NOTIMPLEMENTED_POLICY 4 +#endif +#endif + +#if defined(COMPILER_GCC) +// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name +// of the current function in the NOTIMPLEMENTED message. +#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ +#else +#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" +#endif + +#if NOTIMPLEMENTED_POLICY == 0 +#define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS +#elif NOTIMPLEMENTED_POLICY == 1 +// TODO, figure out how to generate a warning +#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) +#elif NOTIMPLEMENTED_POLICY == 2 +#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) +#elif NOTIMPLEMENTED_POLICY == 3 +#define NOTIMPLEMENTED() NOTREACHED() +#elif NOTIMPLEMENTED_POLICY == 4 +#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG +#elif NOTIMPLEMENTED_POLICY == 5 +#define NOTIMPLEMENTED() do {\ + static bool logged_once = false;\ + LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ + logged_once = true;\ +} while(0);\ +EAT_STREAM_PARAMETERS +#endif + +#endif // !BUILDING_CEF_SHARED + +#endif // CEF_INCLUDE_BASE_CEF_LOGGING_H_ diff --git a/include/base/cef_macros.h b/include/base/cef_macros.h new file mode 100644 index 000000000..0c874ffe1 --- /dev/null +++ b/include/base/cef_macros.h @@ -0,0 +1,123 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_MACROS_H_ +#define CEF_INCLUDE_BASE_CEF_MACROS_H_ +#pragma once + +#if defined(BUILDING_CEF_SHARED) +// When building CEF include the Chromium header directly. +#include "base/macros.h" +#else // !BUILDING_CEF_SHARED +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include // For size_t. + +#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 + +#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 +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 +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) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +#endif // !DISALLOW_COPY_AND_ASSIGN + +#endif // !BUILDING_CEF_SHARED + +#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_ diff --git a/include/cef_trace_event.h b/include/base/cef_trace_event.h similarity index 62% rename from include/cef_trace_event.h rename to include/base/cef_trace_event.h index b679433cc..a24146cd0 100644 --- a/include/cef_trace_event.h +++ b/include/base/cef_trace_event.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 Marshall A. Greenblatt. Portions copyright (c) 2012 +// 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 @@ -36,12 +36,12 @@ // // Events are issued against categories. Whereas LOG's categories are statically // defined, TRACE categories are created implicitly with a string. For example: -// CEF_TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") +// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") // // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: -// CEF_TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") +// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") // doSomethingCostly() -// CEF_TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") +// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") // Note: Our tools can't always determine the correct BEGIN/END pairs unless // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you // need them to be in separate scopes. @@ -49,13 +49,13 @@ // A common use case is to trace entire function scopes. This issues a trace // BEGIN and END automatically: // void doSomethingCostly() { -// CEF_TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly"); +// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly"); // ... // } // // Additional parameters can be associated with an event: // void doSomethingCostly2(int howMuch) { -// CEF_TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", +// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", // "howMuch", howMuch); // ... // } @@ -68,11 +68,11 @@ // [single threaded sender code] // static int send_count = 0; // ++send_count; -// CEF_TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count); +// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count); // Send(new MyMessage(send_count)); // [receive code] // void OnMyMessage(send_count) { -// CEF_TRACE_EVENT_ASYNC_END0("ipc", "message", send_count); +// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count); // } // The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs. // ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process. @@ -82,33 +82,33 @@ // class MyTracedClass { // public: // MyTracedClass() { -// CEF_TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this); +// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this); // } // ~MyTracedClass() { -// CEF_TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this); +// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this); // } // } // // The trace event also supports counters, which is a way to track a quantity // as it varies over time. Counters are created with the following macro: -// CEF_TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue); +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue); // // Counters are process-specific. The macro itself can be issued from any // thread, however. // // Sometimes, you want to track two counters at once. You can do this with two // counter macros: -// CEF_TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]); -// CEF_TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]); +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]); +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]); // Or you can do it with a combined macro: -// CEF_TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter", +// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter", // "bytesPinned", g_myCounterValue[0], // "bytesAllocated", g_myCounterValue[1]); // This indicates to the tracing UI that these counters should be displayed // in a single graph, as a summed area chart. // // Since counters are in a global namespace, you may want to disembiguate with a -// unique ID, by using the CEF_TRACE_COUNTER_ID* variations. +// unique ID, by using the TRACE_COUNTER_ID* variations. // // By default, trace collection is compiled in, but turned off at runtime. // Collecting trace data is the responsibility of the embedding application. In @@ -121,11 +121,11 @@ // in for category, name, and arg_names. Thus, the following code will cause // problems: // char* str = strdup("impprtantName"); -// CEF_TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! +// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! // free(str); // Trace system now has dangling pointer // // To avoid this issue with the |name| and |arg_name| parameters, use the -// CEF_TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime +// TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime // overhead. // Notes: The category must always be in a long-lived char* (i.e. static const). // The |arg_values|, when used, are always deep copied with the _COPY @@ -136,110 +136,37 @@ // All macros are thread safe and can be used from any process. /// -#ifndef CEF_INCLUDE_CEF_TRACE_EVENT_H_ -#define CEF_INCLUDE_CEF_TRACE_EVENT_H_ +#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ +#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ #pragma once -#include "include/internal/cef_export.h" -#include "include/internal/cef_types.h" +#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(BUILDING_CEF_SHARED) +// When building CEF include the Chromium header directly. +#include "base/debug/trace_event.h" +#else // !BUILDING_CEF_SHARED +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. -#ifdef __cplusplus -extern "C" { -#endif - -// Functions for tracing counters and functions; called from macros. -// - |category| string must have application lifetime (static or literal). They -// may not include "(quotes) chars. -// - |argX_name|, |argX_val|, |valueX_name|, |valeX_val| are optional parameters -// and represent pairs of name and values of arguments -// - |copy| is used to avoid memory scoping issues with the |name| and -// |arg_name| parameters by copying them -// - |id| is used to disambiguate counters with the same name, or match async -// trace events - -CEF_EXPORT void cef_trace_event_instant(const char* category, - const char* name, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy); -CEF_EXPORT void cef_trace_event_begin(const char* category, - const char* name, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy); -CEF_EXPORT void cef_trace_event_end(const char* category, - const char* name, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy); -CEF_EXPORT void cef_trace_counter(const char* category, - const char* name, - const char* value1_name, - uint64 value1_val, - const char* value2_name, - uint64 value2_val, - int copy); -CEF_EXPORT void cef_trace_counter_id(const char* category, - const char* name, - uint64 id, - const char* value1_name, - uint64 value1_val, - const char* value2_name, - uint64 value2_val, - int copy); -CEF_EXPORT void cef_trace_event_async_begin(const char* category, - const char* name, - uint64 id, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy); -CEF_EXPORT void cef_trace_event_async_step_into(const char* category, - const char* name, - uint64 id, - uint64 step, - const char* arg1_name, - uint64 arg1_val, - int copy); -CEF_EXPORT void cef_trace_event_async_step_past(const char* category, - const char* name, - uint64 id, - uint64 step, - const char* arg1_name, - uint64 arg1_val, - int copy); -CEF_EXPORT void cef_trace_event_async_end(const char* category, - const char* name, - uint64 id, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy); - -#ifdef __cplusplus -} -#endif +#include "include/internal/cef_trace_event_internal.h" // Records a pair of begin and end events called "name" for the current // scope, with 0, 1 or 2 associated arguments. If the category is not // enabled, then this does nothing. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define CEF_TRACE_EVENT0(category, name) \ +#define TRACE_EVENT0(category, name) \ cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \ CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) -#define CEF_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_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) -#define CEF_TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \ +#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val, false); \ @@ -257,7 +184,7 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // Implementation detail: internal macro to end end event when the scope ends. #define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \ - cef_trace_event_internal::CefTraceEndOnScopeClose \ + cef_trace_event::CefTraceEndOnScopeClose \ CEF_INTERNAL_TRACE_EVENT_UID(profileScope)(category, name) // Records a single event called "name" immediately, with 0, 1 or 2 @@ -265,19 +192,19 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // does nothing. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define CEF_TRACE_EVENT_INSTANT0(category, name) \ +#define TRACE_EVENT_INSTANT0(category, name) \ cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false) -#define CEF_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) -#define CEF_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ +#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val, false) -#define CEF_TRACE_EVENT_COPY_INSTANT0(category, name) \ +#define TRACE_EVENT_COPY_INSTANT0(category, name) \ cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true) -#define CEF_TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ +#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true) -#define CEF_TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ +#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val, true) @@ -287,19 +214,19 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // does nothing. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define CEF_TRACE_EVENT_BEGIN0(category, name) \ +#define TRACE_EVENT_BEGIN0(category, name) \ cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false) -#define CEF_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) -#define CEF_TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ +#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val, false) -#define CEF_TRACE_EVENT_COPY_BEGIN0(category, name) \ +#define TRACE_EVENT_COPY_BEGIN0(category, name) \ cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true) -#define CEF_TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ +#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true) -#define CEF_TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ +#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val, true) @@ -308,19 +235,19 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // is not enabled, then this does nothing. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define CEF_TRACE_EVENT_END0(category, name) \ +#define TRACE_EVENT_END0(category, name) \ cef_trace_event_end(category, name, NULL, 0, NULL, 0, false) -#define CEF_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) -#define CEF_TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ +#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val, false) -#define CEF_TRACE_EVENT_COPY_END0(category, name) \ +#define TRACE_EVENT_COPY_END0(category, name) \ cef_trace_event_end(category, name, NULL, 0, NULL, 0, true) -#define CEF_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) -#define CEF_TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ +#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ arg2_val, true) @@ -329,9 +256,9 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // must be representable as a 32 bit integer. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define CEF_TRACE_COUNTER1(category, name, value) \ +#define TRACE_COUNTER1(category, name, value) \ cef_trace_counter(category, name, NULL, value, NULL, 0, false) -#define CEF_TRACE_COPY_COUNTER1(category, name, value) \ +#define TRACE_COPY_COUNTER1(category, name, value) \ cef_trace_counter(category, name, NULL, value, NULL, 0, true) // Records the values of a multi-parted counter called "name" immediately. @@ -339,11 +266,11 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // values as a stacked-bar chart. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define CEF_TRACE_COUNTER2(category, name, value1_name, value1_val, \ +#define TRACE_COUNTER2(category, name, value1_name, value1_val, \ value2_name, value2_val) \ cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ value2_val, false) -#define CEF_TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ +#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ value2_name, value2_val) \ cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ value2_val, true) @@ -356,9 +283,9 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // be a pointer or an integer value up to 64 bits. If it's a pointer, the // bits will be xored with a hash of the process ID so that the same pointer // on two different processes will not collide. -#define CEF_TRACE_COUNTER_ID1(category, name, id, value) \ +#define TRACE_COUNTER_ID1(category, name, id, value) \ cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false) -#define CEF_TRACE_COPY_COUNTER_ID1(category, name, id, value) \ +#define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true) // Records the values of a multi-parted counter called "name" immediately. @@ -370,11 +297,11 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // be a pointer or an integer value up to 64 bits. If it's a pointer, the // bits will be xored with a hash of the process ID so that the same pointer // on two different processes will not collide. -#define CEF_TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ +#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ value2_name, value2_val) \ cef_trace_counter_id(category, name, id, value1_name, value1_val, \ value2_name, value2_val, false) -#define CEF_TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, \ +#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, \ value1_val, value2_name, value2_val) \ cef_trace_counter_id(category, name, id, value1_name, value1_val, \ value2_name, value2_val, true) @@ -396,22 +323,22 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // An async operation can span threads and processes, but all events in that // operation must use the same |name| and |id|. Each event can have its own // args. -#define CEF_TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ +#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false) -#define CEF_TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ +#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ 0, false) -#define CEF_TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ +#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ arg2_name, arg2_val, false) -#define CEF_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) -#define CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, \ +#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, \ arg1_val) \ cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ 0, true) -#define CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, \ +#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, \ arg1_val, arg2_name, arg2_val) \ cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ arg2_name, arg2_val, true) @@ -422,15 +349,15 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // within the async event. This should be called at the beginning of the next // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any // ASYNC_STEP_PAST events. -#define CEF_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) -#define CEF_TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, \ +#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, \ arg1_name, arg1_val) \ cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ arg1_val, false) -#define CEF_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) -#define CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, \ +#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, \ arg1_name, arg1_val) \ cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ arg1_val, true) @@ -441,44 +368,44 @@ CEF_EXPORT void cef_trace_event_async_end(const char* category, // within the async event. This should be called at the beginning of the next // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any // ASYNC_STEP_INTO events. -#define CEF_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) -#define CEF_TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, \ +#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, \ arg1_name, arg1_val) \ cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ arg1_val, false) -#define CEF_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) -#define CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, \ +#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, \ arg1_name, arg1_val) \ cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ arg1_val, true) // Records a single ASYNC_END event for "name" immediately. If the category // is not enabled, then this does nothing. -#define CEF_TRACE_EVENT_ASYNC_END0(category, name, id) \ +#define TRACE_EVENT_ASYNC_END0(category, name, id) \ cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false) -#define CEF_TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ +#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ false) -#define CEF_TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ +#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ arg2_name, arg2_val) \ cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ arg2_name, arg2_val, false) -#define CEF_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) -#define CEF_TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, \ +#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, \ arg1_val) \ cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ true) -#define CEF_TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, \ +#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, \ arg1_val, arg2_name, arg2_val) \ cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ arg2_name, arg2_val, true) -namespace cef_trace_event_internal { +namespace cef_trace_event { -// Used by CEF_TRACE_EVENTx macro. Do not use directly. +// Used by TRACE_EVENTx macro. Do not use directly. class CefTraceEndOnScopeClose { public: CefTraceEndOnScopeClose(const char* category, const char* name) @@ -493,6 +420,8 @@ class CefTraceEndOnScopeClose { const char* name_; }; -} // cef_trace_event_internal +} // cef_trace_event -#endif // CEF_INCLUDE_CEF_TRACE_EVENT_H_ +#endif // !BUILDING_CEF_SHARED + +#endif // CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ diff --git a/include/capi/cef_task_capi.h b/include/capi/cef_task_capi.h index 8551d1452..2c803348f 100644 --- a/include/capi/cef_task_capi.h +++ b/include/capi/cef_task_capi.h @@ -134,19 +134,19 @@ CEF_EXPORT cef_task_runner_t* cef_task_runner_get_for_thread( /// // Returns true (1) if called on the specified thread. Equivalent to using -// cef_task_runner_t::GetForThread(threadId)->belongs_to_current_thread(). +// cef_task_tRunner::GetForThread(threadId)->belongs_to_current_thread(). /// CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId); /// // Post a task for execution on the specified thread. Equivalent to using -// cef_task_runner_t::GetForThread(threadId)->PostTask(task). +// cef_task_tRunner::GetForThread(threadId)->PostTask(task). /// CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, cef_task_t* task); /// // Post a task for delayed execution on the specified thread. Equivalent to -// using cef_task_runner_t::GetForThread(threadId)->PostDelayedTask(task, +// using cef_task_tRunner::GetForThread(threadId)->PostDelayedTask(task, // delay_ms). /// CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, cef_task_t* task, diff --git a/include/cef_base.h b/include/cef_base.h index bc284f72e..0b6b445da 100644 --- a/include/cef_base.h +++ b/include/cef_base.h @@ -39,7 +39,7 @@ #define CEF_INCLUDE_CEF_BASE_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #include "include/internal/cef_ptr.h" #include "include/internal/cef_types_wrappers.h" diff --git a/include/internal/cef_export.h b/include/internal/cef_export.h index d333a5db8..2813253b6 100644 --- a/include/internal/cef_export.h +++ b/include/internal/cef_export.h @@ -32,7 +32,7 @@ #define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(COMPILER_MSVC) diff --git a/include/internal/cef_logging_internal.h b/include/internal/cef_logging_internal.h new file mode 100644 index 000000000..c376d0526 --- /dev/null +++ b/include/internal/cef_logging_internal.h @@ -0,0 +1,66 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_ +#define CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_ +#pragma once + +#include "include/internal/cef_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// See include/base/cef_logging.h for macros and intended usage. + +/// +// Gets the current log level. +/// +CEF_EXPORT int cef_get_min_log_level(); + +/// +// Gets the current vlog level for the given file (usually taken from +// __FILE__). Note that |N| is the size *with* the null terminator. +/// +CEF_EXPORT int cef_get_vlog_level(const char* file_start, size_t N); + +/// +// Add a log message. See the LogSeverity defines for supported |severity| +// values. +/// +CEF_EXPORT void cef_log(const char* file, + int line, + int severity, + const char* message); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // CEF_INCLUDE_INTERNAL_CEF_LOGGING_INTERNAL_H_ diff --git a/include/internal/cef_string_types.h b/include/internal/cef_string_types.h index 7ab6671cb..493dc7e65 100644 --- a/include/internal/cef_string_types.h +++ b/include/internal/cef_string_types.h @@ -36,14 +36,15 @@ // modification. It is the user's responsibility to provide synchronization if // modifying CEF strings from multiple threads. +#include + +#include "include/base/cef_build.h" +#include "include/internal/cef_export.h" + #ifdef __cplusplus extern "C" { #endif -#include "include/internal/cef_build.h" -#include "include/internal/cef_export.h" -#include - // CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on // most other platforms. diff --git a/include/internal/cef_trace_event_internal.h b/include/internal/cef_trace_event_internal.h new file mode 100644 index 000000000..6df870717 --- /dev/null +++ b/include/internal/cef_trace_event_internal.h @@ -0,0 +1,124 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_ +#define CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_ +#pragma once + +#include "include/internal/cef_export.h" +#include "include/internal/cef_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// See include/base/cef_trace_event.h for macros and intended usage. + +// Functions for tracing counters and functions; called from macros. +// - |category| string must have application lifetime (static or literal). They +// may not include "(quotes) chars. +// - |argX_name|, |argX_val|, |valueX_name|, |valeX_val| are optional parameters +// and represent pairs of name and values of arguments +// - |copy| is used to avoid memory scoping issues with the |name| and +// |arg_name| parameters by copying them +// - |id| is used to disambiguate counters with the same name, or match async +// trace events + +CEF_EXPORT void cef_trace_event_instant(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_begin(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_end(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_counter(const char* category, + const char* name, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy); +CEF_EXPORT void cef_trace_counter_id(const char* category, + const char* name, + uint64 id, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy); +CEF_EXPORT void cef_trace_event_async_begin(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); +CEF_EXPORT void cef_trace_event_async_step_into(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy); +CEF_EXPORT void cef_trace_event_async_step_past(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy); +CEF_EXPORT void cef_trace_event_async_end(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // CEF_INCLUDE_INTERNAL_CEF_TRACE_EVENT_INTERNAL_H_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index f15a45c5e..4f636eeaa 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -32,7 +32,7 @@ #define CEF_INCLUDE_INTERNAL_CEF_TYPES_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #include "include/internal/cef_string.h" #include "include/internal/cef_string_list.h" #include "include/internal/cef_time.h" diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h index 190f3d6bb..3fb896dd0 100644 --- a/include/internal/cef_types_linux.h +++ b/include/internal/cef_types_linux.h @@ -32,7 +32,7 @@ #define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(OS_LINUX) diff --git a/include/internal/cef_types_mac.h b/include/internal/cef_types_mac.h index 69c64fdb3..9603fc60a 100644 --- a/include/internal/cef_types_mac.h +++ b/include/internal/cef_types_mac.h @@ -32,7 +32,7 @@ #define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(OS_MACOSX) #include "include/internal/cef_string.h" diff --git a/include/internal/cef_types_win.h b/include/internal/cef_types_win.h index 708dd58ea..27bf6053b 100644 --- a/include/internal/cef_types_win.h +++ b/include/internal/cef_types_win.h @@ -32,7 +32,7 @@ #define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_ #pragma once -#include "include/internal/cef_build.h" +#include "include/base/cef_build.h" #if defined(OS_WIN) #include diff --git a/include/wrapper/cef_byte_read_handler.h b/include/wrapper/cef_byte_read_handler.h index 2954264d8..5060541f5 100644 --- a/include/wrapper/cef_byte_read_handler.h +++ b/include/wrapper/cef_byte_read_handler.h @@ -37,6 +37,7 @@ #define CEF_INCLUDE_WRAPPER_CEF_BYTE_READ_HANDLER_H_ #pragma once +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/cef_stream.h" @@ -70,6 +71,8 @@ class CefByteReadHandler : public CefReadHandler { IMPLEMENT_REFCOUNTING(CefByteReadHandler); IMPLEMENT_LOCKING(CefByteReadHandler); + + DISALLOW_COPY_AND_ASSIGN(CefByteReadHandler); }; #endif // CEF_INCLUDE_WRAPPER_CEF_BYTE_READ_HANDLER_H_ diff --git a/include/wrapper/cef_helpers.h b/include/wrapper/cef_helpers.h new file mode 100644 index 000000000..352eb3f59 --- /dev/null +++ b/include/wrapper/cef_helpers.h @@ -0,0 +1,79 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// + +#ifndef CEF_INCLUDE_WRAPPER_CEF_HELPERS_H_ +#define CEF_INCLUDE_WRAPPER_CEF_HELPERS_H_ +#pragma once + +#include +#include +#include + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/cef_task.h" + +#define CEF_REQUIRE_UI_THREAD() DCHECK(CefCurrentlyOn(TID_UI)); +#define CEF_REQUIRE_IO_THREAD() DCHECK(CefCurrentlyOn(TID_IO)); +#define CEF_REQUIRE_FILE_THREAD() DCHECK(CefCurrentlyOn(TID_FILE)); +#define CEF_REQUIRE_RENDERER_THREAD() DCHECK(CefCurrentlyOn(TID_RENDERER)); + +// Helper class to manage a scoped copy of |argv|. +class CefScopedArgArray { + public: + CefScopedArgArray(int argc, char* argv[]) { + array_ = new char*[argc]; + for (int i = 0; i < argc; ++i) { + values_.push_back(argv[i]); + array_[i] = const_cast(values_[i].c_str()); + } + } + ~CefScopedArgArray() { + delete [] array_; + } + + char** array() const { return array_; } + + private: + char** array_; + + // Keep values in a vector separate from |array_| because various users may + // modify |array_| and we still want to clean up memory properly. + std::vector values_; + + DISALLOW_COPY_AND_ASSIGN(CefScopedArgArray); +}; + +#endif // CEF_INCLUDE_WRAPPER_CEF_HELPERS_H_ diff --git a/include/wrapper/cef_stream_resource_handler.h b/include/wrapper/cef_stream_resource_handler.h index e6d09c074..8718c7f1b 100644 --- a/include/wrapper/cef_stream_resource_handler.h +++ b/include/wrapper/cef_stream_resource_handler.h @@ -37,6 +37,7 @@ #define CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_ #pragma once +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/cef_resource_handler.h" #include "include/cef_response.h" @@ -96,6 +97,8 @@ class CefStreamResourceHandler : public CefResourceHandler { #endif IMPLEMENT_REFCOUNTING(CefStreamResourceHandler); + + DISALLOW_COPY_AND_ASSIGN(CefStreamResourceHandler); }; #endif // CEF_INCLUDE_WRAPPER_CEF_STREAM_RESOURCE_HANDLER_H_ diff --git a/include/wrapper/cef_xml_object.h b/include/wrapper/cef_xml_object.h index d9f706fde..21f54700f 100644 --- a/include/wrapper/cef_xml_object.h +++ b/include/wrapper/cef_xml_object.h @@ -37,6 +37,7 @@ #define CEF_INCLUDE_WRAPPER_CEF_XML_OBJECT_H_ #pragma once +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/cef_xml_reader.h" #include @@ -183,6 +184,8 @@ class CefXmlObject : public CefBase { IMPLEMENT_REFCOUNTING(CefXmlObject); IMPLEMENT_LOCKING(CefXmlObject); + + DISALLOW_COPY_AND_ASSIGN(CefXmlObject); }; #endif // CEF_INCLUDE_WRAPPER_CEF_XML_OBJECT_H_ diff --git a/include/wrapper/cef_zip_archive.h b/include/wrapper/cef_zip_archive.h index 4e37d69a0..1d8233839 100644 --- a/include/wrapper/cef_zip_archive.h +++ b/include/wrapper/cef_zip_archive.h @@ -37,6 +37,7 @@ #define CEF_INCLUDE_WRAPPER_CEF_ZIP_ARCHIVE_H_ #pragma once +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include @@ -130,6 +131,8 @@ class CefZipArchive : public CefBase { IMPLEMENT_REFCOUNTING(CefZipArchive); IMPLEMENT_LOCKING(CefZipArchive); + + DISALLOW_COPY_AND_ASSIGN(CefZipArchive); }; #endif // CEF_INCLUDE_WRAPPER_CEF_ZIP_ARCHIVE_H_ diff --git a/libcef/browser/trace_impl.cc b/libcef/browser/trace_impl.cc index 017ed6213..580fee688 100644 --- a/libcef/browser/trace_impl.cc +++ b/libcef/browser/trace_impl.cc @@ -3,12 +3,10 @@ // be found in the LICENSE file. #include "include/cef_trace.h" -#include "include/cef_trace_event.h" #include "libcef/browser/trace_subscriber.h" #include "libcef/browser/context.h" #include "libcef/browser/thread_util.h" -#include "base/debug/trace_event.h" #include "base/time/time.h" bool CefBeginTracing(const CefString& categories, @@ -52,297 +50,3 @@ bool CefEndTracing(const CefString& tracing_file, int64 CefNowFromSystemTraceTime() { return base::TimeTicks::NowFromSystemTraceTime().ToInternalValue(); } - -// The below functions can be called from any process. - -CEF_EXPORT void cef_trace_event_instant(const char* category, - const char* name, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_COPY_INSTANT0(category, name, TRACE_EVENT_SCOPE_THREAD); - } else if (arg2_name == NULL) { - TRACE_EVENT_COPY_INSTANT1(category, name, TRACE_EVENT_SCOPE_THREAD, - arg1_name, arg1_val); - } else { - TRACE_EVENT_COPY_INSTANT2(category, name, TRACE_EVENT_SCOPE_THREAD, - arg1_name, arg1_val, arg2_name, arg2_val); - } - } else { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_INSTANT0(category, name, TRACE_EVENT_SCOPE_THREAD); - } else if (arg2_name == NULL) { - TRACE_EVENT_INSTANT1(category, name, TRACE_EVENT_SCOPE_THREAD, - arg1_name, arg1_val); - } else { - TRACE_EVENT_INSTANT2(category, name, TRACE_EVENT_SCOPE_THREAD, - arg1_name, arg1_val, arg2_name, arg2_val); - } - } -} - -CEF_EXPORT void cef_trace_event_begin(const char* category, - const char* name, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_COPY_BEGIN0(category, name); - } else if (arg2_name == NULL) { - TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val); - } else { - TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, - arg2_name, arg2_val); - } - } else { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_BEGIN0(category, name); - } else if (arg2_name == NULL) { - TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val); - } else { - TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, - arg2_name, arg2_val); - } - } -} - -CEF_EXPORT void cef_trace_event_end(const char* category, - const char* name, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_COPY_END0(category, name); - } else if (arg2_name == NULL) { - TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val); - } else { - TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, - arg2_name, arg2_val); - } - } else { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_END0(category, name); - } else if (arg2_name == NULL) { - TRACE_EVENT_END1(category, name, arg1_name, arg1_val); - } else { - TRACE_EVENT_END2(category, name, arg1_name, arg1_val, - arg2_name, arg2_val); - } - } -} - -CEF_EXPORT void cef_trace_counter(const char* category, - const char* name, - const char* value1_name, - uint64 value1_val, - const char* value2_name, - uint64 value2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (value1_name == NULL && value2_name == NULL) { - TRACE_COPY_COUNTER1(category, name, value1_val); - } else { - TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, - value2_name, value2_val); - } - } else { - if (value1_name == NULL && value2_name == NULL) { - TRACE_COUNTER1(category, name, value1_val); - } else { - TRACE_COUNTER2(category, name, value1_name, value1_val, - value2_name, value2_val); - } - } -} - -CEF_EXPORT void cef_trace_counter_id(const char* category, - const char* name, - uint64 id, - const char* value1_name, - uint64 value1_val, - const char* value2_name, - uint64 value2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (value1_name == NULL && value2_name == NULL) { - TRACE_COPY_COUNTER_ID1(category, name, id, value1_val); - } else { - TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, - value1_val, value2_name, value2_val); - } - } else { - if (value1_name == NULL && value2_name == NULL) { - TRACE_COUNTER_ID1(category, name, id, value1_val); - } else { - TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, - value2_name, value2_val); - } - } -} - -CEF_EXPORT void cef_trace_event_async_begin(const char* category, - const char* name, - uint64 id, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id); - } else if (arg2_name == NULL) { - TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val); - } else { - TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, - arg2_name, arg2_val); - } - } else { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_ASYNC_BEGIN0(category, name, id); - } else if (arg2_name == NULL) { - TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val); - } else { - TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, - arg2_name, arg2_val); - } - } -} - -CEF_EXPORT void cef_trace_event_async_step_into(const char* category, - const char* name, - uint64 id, - uint64 step, - const char* arg1_name, - uint64 arg1_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL) { - INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, - category, name, id, TRACE_EVENT_FLAG_COPY, "step", step); - } else { - INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, - category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, - arg1_name, arg1_val); - } - } else { - if (arg1_name == NULL) { - TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step); - } else { - TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, - arg1_name, arg1_val); - } - } -} - -CEF_EXPORT void cef_trace_event_async_step_past(const char* category, - const char* name, - uint64 id, - uint64 step, - const char* arg1_name, - uint64 arg1_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL) { - INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, - category, name, id, TRACE_EVENT_FLAG_COPY, "step", step); - } else { - INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, - category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, - arg1_name, arg1_val); - } - } else { - if (arg1_name == NULL) { - TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step); - } else { - TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, - arg1_name, arg1_val); - } - } -} - -CEF_EXPORT void cef_trace_event_async_end(const char* category, - const char* name, - uint64 id, - const char* arg1_name, - uint64 arg1_val, - const char* arg2_name, - uint64 arg2_val, - int copy) { - DCHECK(category); - DCHECK(name); - if (!category || !name) - return; - - if (copy) { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_COPY_ASYNC_END0(category, name, id); - } else if (arg2_name == NULL) { - TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, - arg1_val); - } else { - TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, - arg1_val, arg2_name, arg2_val); - } - } else { - if (arg1_name == NULL && arg2_name == NULL) { - TRACE_EVENT_ASYNC_END0(category, name, id); - } else if (arg2_name == NULL) { - TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, - arg1_val); - } else { - TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, - arg1_val, arg2_name, arg2_val); - } - } -} diff --git a/libcef/common/base_impl.cc b/libcef/common/base_impl.cc new file mode 100644 index 000000000..a3b980f64 --- /dev/null +++ b/libcef/common/base_impl.cc @@ -0,0 +1,330 @@ +// Copyright (c) 2014 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 "include/internal/cef_trace_event_internal.h" +#include "include/internal/cef_logging_internal.h" + +#include "base/debug/trace_event.h" +#include "base/logging.h" + +// The contents of this file are a compilation unit that is not called by other +// functions in the the library. Consiquently MSVS will exclude it during the +// linker stage if we don't call a stub function. +#if defined(COMPILER_MSVC) +#pragma optimize("", off) +#endif + +void base_impl_stub() {} + +#if defined(COMPILER_MSVC) +#pragma optimize("", on) +#endif + + +CEF_EXPORT void cef_trace_event_instant(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_INSTANT0(category, name, TRACE_EVENT_SCOPE_THREAD); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_INSTANT1(category, name, TRACE_EVENT_SCOPE_THREAD, + arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_INSTANT2(category, name, TRACE_EVENT_SCOPE_THREAD, + arg1_name, arg1_val, arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_INSTANT0(category, name, TRACE_EVENT_SCOPE_THREAD); + } else if (arg2_name == NULL) { + TRACE_EVENT_INSTANT1(category, name, TRACE_EVENT_SCOPE_THREAD, + arg1_name, arg1_val); + } else { + TRACE_EVENT_INSTANT2(category, name, TRACE_EVENT_SCOPE_THREAD, + arg1_name, arg1_val, arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_begin(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_BEGIN0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_BEGIN0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_end(const char* category, + const char* name, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_END0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_END0(category, name); + } else if (arg2_name == NULL) { + TRACE_EVENT_END1(category, name, arg1_name, arg1_val); + } else { + TRACE_EVENT_END2(category, name, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_counter(const char* category, + const char* name, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COPY_COUNTER1(category, name, value1_val); + } else { + TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, + value2_name, value2_val); + } + } else { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COUNTER1(category, name, value1_val); + } else { + TRACE_COUNTER2(category, name, value1_name, value1_val, + value2_name, value2_val); + } + } +} + +CEF_EXPORT void cef_trace_counter_id(const char* category, + const char* name, + uint64 id, + const char* value1_name, + uint64 value1_val, + const char* value2_name, + uint64 value2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COPY_COUNTER_ID1(category, name, id, value1_val); + } else { + TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, + value1_val, value2_name, value2_val); + } + } else { + if (value1_name == NULL && value2_name == NULL) { + TRACE_COUNTER_ID1(category, name, id, value1_val); + } else { + TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, + value2_name, value2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_begin(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val); + } else { + TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_ASYNC_BEGIN0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val); + } else { + TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, + arg2_name, arg2_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_step_into(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL) { + INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, + category, name, id, TRACE_EVENT_FLAG_COPY, "step", step); + } else { + INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, + category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, + arg1_name, arg1_val); + } + } else { + if (arg1_name == NULL) { + TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step); + } else { + TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, + arg1_name, arg1_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_step_past(const char* category, + const char* name, + uint64 id, + uint64 step, + const char* arg1_name, + uint64 arg1_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL) { + INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, + category, name, id, TRACE_EVENT_FLAG_COPY, "step", step); + } else { + INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, + category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, + arg1_name, arg1_val); + } + } else { + if (arg1_name == NULL) { + TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step); + } else { + TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, + arg1_name, arg1_val); + } + } +} + +CEF_EXPORT void cef_trace_event_async_end(const char* category, + const char* name, + uint64 id, + const char* arg1_name, + uint64 arg1_val, + const char* arg2_name, + uint64 arg2_val, + int copy) { + DCHECK(category); + DCHECK(name); + if (!category || !name) + return; + + if (copy) { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_END0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, + arg1_val); + } else { + TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, + arg1_val, arg2_name, arg2_val); + } + } else { + if (arg1_name == NULL && arg2_name == NULL) { + TRACE_EVENT_ASYNC_END0(category, name, id); + } else if (arg2_name == NULL) { + TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, + arg1_val); + } else { + TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, + arg1_val, arg2_name, arg2_val); + } + } +} + +CEF_EXPORT int cef_get_min_log_level() { + return logging::GetMinLogLevel(); +} + +CEF_EXPORT int cef_get_vlog_level(const char* file_start, size_t N) { + return logging::GetVlogLevelHelper(file_start, N); +} + +CEF_EXPORT void cef_log(const char* file, + int line, + int severity, + const char* message) { + logging::LogMessage(file, line, severity).stream() << message; +} diff --git a/libcef/common/main_delegate.cc b/libcef/common/main_delegate.cc index 40f0b7521..2d8aa112c 100644 --- a/libcef/common/main_delegate.cc +++ b/libcef/common/main_delegate.cc @@ -185,6 +185,10 @@ class CefUIThread : public base::Thread { CefMainDelegate::CefMainDelegate(CefRefPtr application) : content_client_(application) { + // Necessary so that exported functions from base_impl.cc will be included + // in the binary. + extern void base_impl_stub(); + base_impl_stub(); } CefMainDelegate::~CefMainDelegate() { diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index f3cee43fa..d9eca19df 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -45,20 +45,6 @@ using blink::WebString; using blink::WebURL; using blink::WebView; -namespace { - -blink::WebString FilePathStringToWebString( - const base::FilePath::StringType& str) { -#if defined(OS_POSIX) - return base::WideToUTF16(base::SysNativeMBToWide(str)); -#elif defined(OS_WIN) - return base::WideToUTF16(str); -#endif -} - -} // namespace - - // CefBrowserImpl static methods. // ----------------------------------------------------------------------------- diff --git a/libcef_dll/base/cef_logging.cc b/libcef_dll/base/cef_logging.cc new file mode 100644 index 000000000..7904633e2 --- /dev/null +++ b/libcef_dll/base/cef_logging.cc @@ -0,0 +1,257 @@ +// Copyright (c) 2014 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 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. + +#include "include/base/cef_logging.h" + +#if defined(OS_WIN) +#include +#include +#include +#elif defined(OS_POSIX) +#include +#include +#include +#endif + +#include "include/internal/cef_string_types.h" + +namespace cef_logging { + +namespace { + +#if defined(OS_POSIX) +// From base/safe_strerror_posix.cc. + +#define USE_HISTORICAL_STRERRO_R (defined(__GLIBC__) || defined(OS_NACL)) + +#if USE_HISTORICAL_STRERRO_R && defined(__GNUC__) +// GCC will complain about the unused second wrap function unless we tell it +// that we meant for them to be potentially unused, which is exactly what this +// attribute is for. +#define POSSIBLY_UNUSED __attribute__((unused)) +#else +#define POSSIBLY_UNUSED +#endif + +#if USE_HISTORICAL_STRERRO_R +// glibc has two strerror_r functions: a historical GNU-specific one that +// returns type char *, and a POSIX.1-2001 compliant one available since 2.3.4 +// that returns int. This wraps the GNU-specific one. +static void POSSIBLY_UNUSED wrap_posix_strerror_r( + char *(*strerror_r_ptr)(int, char *, size_t), + int err, + char *buf, + size_t len) { + // GNU version. + char *rc = (*strerror_r_ptr)(err, buf, len); + if (rc != buf) { + // glibc did not use buf and returned a static string instead. Copy it + // into buf. + buf[0] = '\0'; + strncat(buf, rc, len - 1); + } + // The GNU version never fails. Unknown errors get an "unknown error" message. + // The result is always null terminated. +} +#endif // USE_HISTORICAL_STRERRO_R + +// Wrapper for strerror_r functions that implement the POSIX interface. POSIX +// does not define the behaviour for some of the edge cases, so we wrap it to +// guarantee that they are handled. This is compiled on all POSIX platforms, but +// it will only be used on Linux if the POSIX strerror_r implementation is +// being used (see below). +static void POSSIBLY_UNUSED wrap_posix_strerror_r( + int (*strerror_r_ptr)(int, char *, size_t), + int err, + char *buf, + size_t len) { + int old_errno = errno; + // Have to cast since otherwise we get an error if this is the GNU version + // (but in such a scenario this function is never called). Sadly we can't use + // C++-style casts because the appropriate one is reinterpret_cast but it's + // considered illegal to reinterpret_cast a type to itself, so we get an + // error in the opposite case. + int result = (*strerror_r_ptr)(err, buf, len); + if (result == 0) { + // POSIX is vague about whether the string will be terminated, although + // it indirectly implies that typically ERANGE will be returned, instead + // of truncating the string. We play it safe by always terminating the + // string explicitly. + buf[len - 1] = '\0'; + } else { + // Error. POSIX is vague about whether the return value is itself a system + // error code or something else. On Linux currently it is -1 and errno is + // set. On BSD-derived systems it is a system error and errno is unchanged. + // We try and detect which case it is so as to put as much useful info as + // we can into our message. + int strerror_error; // The error encountered in strerror + int new_errno = errno; + if (new_errno != old_errno) { + // errno was changed, so probably the return value is just -1 or something + // else that doesn't provide any info, and errno is the error. + strerror_error = new_errno; + } else { + // Either the error from strerror_r was the same as the previous value, or + // errno wasn't used. Assume the latter. + strerror_error = result; + } + // snprintf truncates and always null-terminates. + snprintf(buf, + len, + "Error %d while retrieving error %d", + strerror_error, + err); + } + errno = old_errno; +} + +void safe_strerror_r(int err, char *buf, size_t len) { + if (buf == NULL || len <= 0) { + return; + } + // If using glibc (i.e., Linux), the compiler will automatically select the + // appropriate overloaded function based on the function type of strerror_r. + // The other one will be elided from the translation unit since both are + // static. + wrap_posix_strerror_r(&strerror_r, err, buf, len); +} + +std::string safe_strerror(int err) { + const int buffer_size = 256; + char buf[buffer_size]; + safe_strerror_r(err, buf, sizeof(buf)); + return std::string(buf); +} +#endif // defined(OS_POSIX) + +} // namespace + +// MSVC doesn't like complex extern templates and DLLs. +#if !defined(COMPILER_MSVC) +// Explicit instantiations for commonly used comparisons. +template std::string* MakeCheckOpString( + const int&, const int&, const char* names); +template std::string* MakeCheckOpString( + const unsigned long&, const unsigned long&, const char* names); +template std::string* MakeCheckOpString( + const unsigned long&, const unsigned int&, const char* names); +template std::string* MakeCheckOpString( + const unsigned int&, const unsigned long&, const char* names); +template std::string* MakeCheckOpString( + const std::string&, const std::string&, const char* name); +#endif + +#if defined(OS_WIN) +LogMessage::SaveLastError::SaveLastError() : last_error_(::GetLastError()) { +} + +LogMessage::SaveLastError::~SaveLastError() { + ::SetLastError(last_error_); +} +#endif // defined(OS_WIN) + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity) + : severity_(severity), file_(file), line_(line) { +} + +LogMessage::LogMessage(const char* file, int line, std::string* result) + : severity_(LOG_FATAL), file_(file), line_(line) { + stream_ << "Check failed: " << *result; + delete result; +} + +LogMessage::LogMessage(const char* file, int line, LogSeverity severity, + std::string* result) + : severity_(severity), file_(file), line_(line) { + stream_ << "Check failed: " << *result; + delete result; +} + +LogMessage::~LogMessage() { + stream_ << std::endl; + std::string str_newline(stream_.str()); + cef_log(file_, line_, severity_, str_newline.c_str()); +} + +#if defined(OS_WIN) +// This has already been defined in the header, but defining it again as DWORD +// ensures that the type used in the header is equivalent to DWORD. If not, +// the redefinition is a compile error. +typedef DWORD SystemErrorCode; +#endif + +SystemErrorCode GetLastSystemErrorCode() { +#if defined(OS_WIN) + return ::GetLastError(); +#elif defined(OS_POSIX) + return errno; +#else +#error Not implemented +#endif +} + +#if defined(OS_WIN) +std::string SystemErrorCodeToString(SystemErrorCode error_code) { + const int error_message_buffer_size = 256; + char msgbuf[error_message_buffer_size]; + DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + DWORD len = FormatMessageA(flags, NULL, error_code, 0, msgbuf, + arraysize(msgbuf), NULL); + std::stringstream ss; + if (len) { + std::string s(msgbuf); + // Messages returned by system end with line breaks. + s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end()); + ss << s << " (0x" << std::hex << error_code << ")"; + } else { + ss << "Error (0x" << std::hex << GetLastError() << + ") while retrieving error. (0x" << error_code << ")"; + } + return ss.str(); +} +#elif defined(OS_POSIX) +std::string SystemErrorCodeToString(SystemErrorCode error_code) { + return safe_strerror(error_code); +} +#else +#error Not implemented +#endif + +#if defined(OS_WIN) +Win32ErrorLogMessage::Win32ErrorLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err) + : err_(err), + log_message_(file, line, severity) { +} + +Win32ErrorLogMessage::~Win32ErrorLogMessage() { + stream() << ": " << SystemErrorCodeToString(err_); +} +#elif defined(OS_POSIX) +ErrnoLogMessage::ErrnoLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err) + : err_(err), + log_message_(file, line, severity) { +} + +ErrnoLogMessage::~ErrnoLogMessage() { + stream() << ": " << SystemErrorCodeToString(err_); +} +#endif // OS_WIN + +std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { + cef_string_utf8_t str = {0}; + std::wstring tmp_str(wstr); + cef_string_wide_to_utf8(wstr, tmp_str.size(), &str); + out << str.str; + cef_string_utf8_clear(&str); + return out; +} + +} // namespace cef_logging diff --git a/libcef_dll/cef_logging.h b/libcef_dll/cef_logging.h deleted file mode 100644 index 55a0fa6e9..000000000 --- a/libcef_dll/cef_logging.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014 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. - -#ifndef CEF_LIBCEF_DLL_CEF_LOGGING_H_ -#define CEF_LIBCEF_DLL_CEF_LOGGING_H_ -#pragma once - -#include "include/cef_task.h" - -#ifdef BUILDING_CEF_SHARED -#include "base/logging.h" -#else // !BUILDING_CEF_SHARED -#include // NOLINT(build/include_order) - -#ifndef NDEBUG -#define DCHECK(condition) assert(condition) -#else -#define DCHECK(condition) ((void)0) -#endif - -#define DCHECK_EQ(val1, val2) DCHECK(val1 == val2) -#define DCHECK_NE(val1, val2) DCHECK(val1 != val2) -#define DCHECK_LE(val1, val2) DCHECK(val1 <= val2) -#define DCHECK_LT(val1, val2) DCHECK(val1 < val2) -#define DCHECK_GE(val1, val2) DCHECK(val1 >= val2) -#define DCHECK_GT(val1, val2) DCHECK(val1 > val2) -#endif // !BUILDING_CEF_SHARED - -#define CEF_REQUIRE_UI_THREAD() DCHECK(CefCurrentlyOn(TID_UI)); -#define CEF_REQUIRE_IO_THREAD() DCHECK(CefCurrentlyOn(TID_IO)); -#define CEF_REQUIRE_FILE_THREAD() DCHECK(CefCurrentlyOn(TID_FILE)); -#define CEF_REQUIRE_RENDERER_THREAD() DCHECK(CefCurrentlyOn(TID_RENDERER)); - -#endif // CEF_LIBCEF_DLL_CEF_LOGGING_H_ diff --git a/libcef_dll/cef_macros.h b/libcef_dll/cef_macros.h deleted file mode 100644 index 8152be890..000000000 --- a/libcef_dll/cef_macros.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2014 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. - -#ifndef CEF_LIBCEF_DLL_CEF_MACROS_H_ -#define CEF_LIBCEF_DLL_CEF_MACROS_H_ -#pragma once - -#ifdef BUILDING_CEF_SHARED -#include "base/macros.h" -#else // !BUILDING_CEF_SHARED - -// 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) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) - -#endif // !BUILDING_CEF_SHARED - -#endif // CEF_LIBCEF_DLL_CEF_MACROS_H_ diff --git a/libcef_dll/cpptoc/base_cpptoc.h b/libcef_dll/cpptoc/base_cpptoc.h index 1184d718a..5712de12c 100644 --- a/libcef_dll/cpptoc/base_cpptoc.h +++ b/libcef_dll/cpptoc/base_cpptoc.h @@ -6,10 +6,10 @@ #define CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ #pragma once +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/capi/cef_base_capi.h" -#include "libcef_dll/cef_logging.h" - // CefCppToC implementation for CefBase. class CefBaseCppToC : public CefBase { @@ -137,10 +137,11 @@ class CefBaseCppToC : public CefBase { return impl->class_->GetRefCt(); } - protected: CefRefCount refct_; Struct struct_; CefBase* class_; + + DISALLOW_COPY_AND_ASSIGN(CefBaseCppToC); }; #endif // CEF_LIBCEF_DLL_CPPTOC_BASE_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/cpptoc.h b/libcef_dll/cpptoc/cpptoc.h index 3449264f9..2fdda7302 100644 --- a/libcef_dll/cpptoc/cpptoc.h +++ b/libcef_dll/cpptoc/cpptoc.h @@ -6,9 +6,10 @@ #define CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_ #pragma once +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/capi/cef_base_capi.h" -#include "libcef_dll/cef_logging.h" // Wrap a C++ class with a C structure. This is used when the class @@ -123,6 +124,11 @@ class CefCppToC : public CefBase { static long DebugObjCt; // NOLINT(runtime/int) #endif + protected: + CefRefCount refct_; + Struct struct_; + BaseName* class_; + private: static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) { DCHECK(base); @@ -151,10 +157,7 @@ class CefCppToC : public CefBase { return impl->class_->GetRefCt(); } - protected: - CefRefCount refct_; - Struct struct_; - BaseName* class_; + DISALLOW_COPY_AND_ASSIGN(CefCppToC); }; #endif // CEF_LIBCEF_DLL_CPPTOC_CPPTOC_H_ diff --git a/libcef_dll/ctocpp/base_ctocpp.h b/libcef_dll/ctocpp/base_ctocpp.h index 650c08e33..e2fb00b2c 100644 --- a/libcef_dll/ctocpp/base_ctocpp.h +++ b/libcef_dll/ctocpp/base_ctocpp.h @@ -6,9 +6,10 @@ #define CEF_LIBCEF_DLL_CTOCPP_BASE_CTOCPP_H_ #pragma once +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/capi/cef_base_capi.h" -#include "libcef_dll/cef_logging.h" // CefCToCpp implementation for CefBase. @@ -89,9 +90,11 @@ class CefBaseCToCpp : public CefBase { return struct_->get_refct(struct_); } - protected: + private: CefRefCount refct_; cef_base_t* struct_; + + DISALLOW_COPY_AND_ASSIGN(CefBaseCToCpp); }; diff --git a/libcef_dll/ctocpp/command_line_ctocpp.cc b/libcef_dll/ctocpp/command_line_ctocpp.cc index ff1177732..0767de840 100644 --- a/libcef_dll/ctocpp/command_line_ctocpp.cc +++ b/libcef_dll/ctocpp/command_line_ctocpp.cc @@ -21,7 +21,7 @@ CefRefPtr CefCommandLine::CreateCommandLine() { const char* api_hash = cef_api_hash(0); if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { // The libcef API hash does not match the current header API hash. - DCHECK(false); + NOTREACHED(); return NULL; } @@ -38,7 +38,7 @@ CefRefPtr CefCommandLine::GetGlobalCommandLine() { const char* api_hash = cef_api_hash(0); if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { // The libcef API hash does not match the current header API hash. - DCHECK(false); + NOTREACHED(); return NULL; } diff --git a/libcef_dll/ctocpp/ctocpp.h b/libcef_dll/ctocpp/ctocpp.h index 3697647c4..4f96fabf5 100644 --- a/libcef_dll/ctocpp/ctocpp.h +++ b/libcef_dll/ctocpp/ctocpp.h @@ -6,10 +6,10 @@ #define CEF_LIBCEF_DLL_CTOCPP_CTOCPP_H_ #pragma once +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" #include "include/cef_base.h" #include "include/capi/cef_base_capi.h" -#include "libcef_dll/cef_logging.h" - // Wrap a C structure with a C++ class. This is used when the implementation // exists on the other side of the DLL boundary but will have methods called on @@ -108,6 +108,9 @@ class CefCToCpp : public BaseName { protected: CefRefCount refct_; StructName* struct_; + + private: + DISALLOW_COPY_AND_ASSIGN(CefCToCpp); }; #endif // CEF_LIBCEF_DLL_CTOCPP_CTOCPP_H_ diff --git a/libcef_dll/libcef_dll2.cc b/libcef_dll/libcef_dll2.cc index 20ceb5d89..1a5172313 100644 --- a/libcef_dll/libcef_dll2.cc +++ b/libcef_dll/libcef_dll2.cc @@ -4,7 +4,7 @@ // #include "include/cef_version.h" -#include "cef_logging.h" +#include CEF_EXPORT int cef_build_revision() { return CEF_REVISION; diff --git a/libcef_dll/wrapper/cef_browser_info_map.h b/libcef_dll/wrapper/cef_browser_info_map.h index c8048e946..c2a82d6c3 100644 --- a/libcef_dll/wrapper/cef_browser_info_map.h +++ b/libcef_dll/wrapper/cef_browser_info_map.h @@ -7,8 +7,9 @@ #pragma once #include -#include "libcef_dll/cef_logging.h" -#include "libcef_dll/cef_macros.h" + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" // Default traits for CefBrowserInfoMap. Override to provide different object // destruction behavior. @@ -61,7 +62,7 @@ class CefBrowserInfoMap { } else { info_map = it_browser->second; // The specified ID should not already exist in the map. - DCHECK_EQ(info_map->find(info_id), info_map->end()); + DCHECK(info_map->find(info_id) == info_map->end()); } info_map->insert(std::make_pair(info_id, info)); diff --git a/libcef_dll/wrapper/cef_byte_read_handler.cc b/libcef_dll/wrapper/cef_byte_read_handler.cc index bf00587b8..0af1aa348 100644 --- a/libcef_dll/wrapper/cef_byte_read_handler.cc +++ b/libcef_dll/wrapper/cef_byte_read_handler.cc @@ -3,10 +3,10 @@ // can be found in the LICENSE file. #include "include/wrapper/cef_byte_read_handler.h" + #include #include #include -#include "libcef_dll/cef_logging.h" CefByteReadHandler::CefByteReadHandler(const unsigned char* bytes, size_t size, CefRefPtr source) diff --git a/libcef_dll/wrapper/cef_message_router.cc b/libcef_dll/wrapper/cef_message_router.cc index 0833d8793..5f28f9979 100644 --- a/libcef_dll/wrapper/cef_message_router.cc +++ b/libcef_dll/wrapper/cef_message_router.cc @@ -7,10 +7,10 @@ #include #include +#include "include/base/cef_macros.h" #include "include/cef_runnable.h" #include "include/cef_task.h" -#include "libcef_dll/cef_logging.h" -#include "libcef_dll/cef_macros.h" +#include "include/wrapper/cef_helpers.h" #include "libcef_dll/wrapper/cef_browser_info_map.h" namespace { diff --git a/libcef_dll/wrapper/cef_stream_resource_handler.cc b/libcef_dll/wrapper/cef_stream_resource_handler.cc index 68912e1d1..2d5391277 100644 --- a/libcef_dll/wrapper/cef_stream_resource_handler.cc +++ b/libcef_dll/wrapper/cef_stream_resource_handler.cc @@ -3,12 +3,16 @@ // can be found in the LICENSE file. #include "include/wrapper/cef_stream_resource_handler.h" + #include + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" #include "include/cef_callback.h" #include "include/cef_request.h" #include "include/cef_runnable.h" #include "include/cef_stream.h" -#include "libcef_dll/cef_logging.h" +#include "include/wrapper/cef_helpers.h" // Class that represents a readable/writable character buffer. class CefStreamResourceHandler::Buffer { @@ -77,6 +81,8 @@ class CefStreamResourceHandler::Buffer { int bytes_requested_; int bytes_written_; int bytes_read_; + + DISALLOW_COPY_AND_ASSIGN(Buffer); }; CefStreamResourceHandler::CefStreamResourceHandler( diff --git a/libcef_dll/wrapper/cef_xml_object.cc b/libcef_dll/wrapper/cef_xml_object.cc index 49b1ff586..5db0b1b35 100644 --- a/libcef_dll/wrapper/cef_xml_object.cc +++ b/libcef_dll/wrapper/cef_xml_object.cc @@ -3,10 +3,13 @@ // can be found in the LICENSE file. #include "include/wrapper/cef_xml_object.h" -#include "include/cef_stream.h" -#include "libcef_dll/cef_logging.h" + #include +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/cef_stream.h" + namespace { class CefXmlObjectLoader { @@ -102,7 +105,7 @@ class CefXmlObjectLoader { cur_object->GetName() != reader->GetQualifiedName()) { // Open tag without close tag or close tag without open tag should // never occur (the parser catches this error). - DCHECK(false); + NOTREACHED(); std::stringstream ss; ss << "Mismatched end tag for " << std::string(cur_object->GetName()) << @@ -149,6 +152,8 @@ class CefXmlObjectLoader { private: CefString load_error_; CefRefPtr root_object_; + + DISALLOW_COPY_AND_ASSIGN(CefXmlObjectLoader); }; } // namespace diff --git a/libcef_dll/wrapper/cef_zip_archive.cc b/libcef_dll/wrapper/cef_zip_archive.cc index 4f5c45b3b..10479eff5 100644 --- a/libcef_dll/wrapper/cef_zip_archive.cc +++ b/libcef_dll/wrapper/cef_zip_archive.cc @@ -2,17 +2,20 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. -#if defined(__linux__) -#include -#endif +#include "include/wrapper/cef_zip_archive.h" #include #include -#include "include/wrapper/cef_zip_archive.h" + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" #include "include/cef_stream.h" #include "include/cef_zip_reader.h" #include "include/wrapper/cef_byte_read_handler.h" -#include "libcef_dll/cef_logging.h" + +#if defined(OS_LINUX) +#include +#endif namespace { diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index e331d1e48..ecf7bf42c 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -122,7 +122,7 @@ CEF_GLOBAL int CefExecuteProcess(const CefMainArgs& args, const char* api_hash = cef_api_hash(0); if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { // The libcef API hash does not match the current header API hash. - DCHECK(false); + NOTREACHED(); return 0; } @@ -146,7 +146,7 @@ CEF_GLOBAL bool CefInitialize(const CefMainArgs& args, const char* api_hash = cef_api_hash(0); if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) { // The libcef API hash does not match the current header API hash. - DCHECK(false); + NOTREACHED(); return false; } diff --git a/tests/cefclient/bytes_write_handler.cpp b/tests/cefclient/bytes_write_handler.cpp index 7b0692d22..ed3f48f8f 100644 --- a/tests/cefclient/bytes_write_handler.cpp +++ b/tests/cefclient/bytes_write_handler.cpp @@ -7,15 +7,15 @@ #include #include -#include "cefclient/util.h" +#include "include/wrapper/cef_helpers.h" BytesWriteHandler::BytesWriteHandler(size_t grow) : grow_(grow), datasize_(grow), offset_(0) { - ASSERT(grow > 0); // NOLINT(readability/check) + DCHECK_GT(grow, 0U); data_ = malloc(grow); - ASSERT(data_ != NULL); + DCHECK(data_ != NULL); } BytesWriteHandler::~BytesWriteHandler() { @@ -82,7 +82,7 @@ size_t BytesWriteHandler::Grow(size_t size) { size_t rv; size_t s = (size > grow_ ? size : grow_); void* tmp = realloc(data_, datasize_ + s); - ASSERT(tmp != NULL); + DCHECK(tmp != NULL); if (tmp) { data_ = tmp; datasize_ += s; diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 39fa16acf..3af814568 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -13,10 +13,10 @@ #include "include/cef_frame.h" #include "include/cef_runnable.h" #include "include/cef_web_plugin.h" +#include "include/wrapper/cef_helpers.h" #include "cefclient/client_handler.h" #include "cefclient/client_switches.h" #include "cefclient/string_util.h" -#include "cefclient/util.h" CefRefPtr g_handler; CefRefPtr g_command_line; @@ -49,7 +49,7 @@ CefRefPtr AppGetCommandLine() { // Returns the application settings based on command line arguments. void AppGetSettings(CefSettings& settings) { - ASSERT(g_command_line.get()); + DCHECK(g_command_line.get()); if (!g_command_line.get()) return; @@ -68,7 +68,7 @@ void AppGetSettings(CefSettings& settings) { } void AppGetBrowserSettings(CefBrowserSettings& settings) { - ASSERT(g_command_line.get()); + DCHECK(g_command_line.get()); if (!g_command_line.get()) return; @@ -79,7 +79,7 @@ void AppGetBrowserSettings(CefBrowserSettings& settings) { } bool AppIsOffScreenRenderingEnabled() { - ASSERT(g_command_line.get()); + DCHECK(g_command_line.get()); if (!g_command_line.get()) return false; diff --git a/tests/cefclient/cefclient_gtk.cpp b/tests/cefclient/cefclient_gtk.cpp index ea104b4fa..165eed079 100644 --- a/tests/cefclient/cefclient_gtk.cpp +++ b/tests/cefclient/cefclient_gtk.cpp @@ -19,12 +19,12 @@ #include "include/cef_browser.h" #include "include/cef_frame.h" #include "include/cef_runnable.h" +#include "include/wrapper/cef_helpers.h" #include "cefclient/cefclient_osr_widget_gtk.h" #include "cefclient/client_handler.h" #include "cefclient/client_switches.h" #include "cefclient/scheme_test.h" #include "cefclient/string_util.h" -#include "cefclient/util.h" // The global ClientHandler reference. extern CefRefPtr g_handler; @@ -318,7 +318,7 @@ GtkWidget* CreateMenuBar() { int main(int argc, char* argv[]) { // Create a copy of |argv| on Linux because Chromium mangles the value // internally (see issue #620). - ScopedArgArray scoped_arg_array(argc, argv); + CefScopedArgArray scoped_arg_array(argc, argv); char** argv_copy = scoped_arg_array.array(); CefMainArgs main_args(argc, argv); diff --git a/tests/cefclient/cefclient_osr_dragdrop_win.cpp b/tests/cefclient/cefclient_osr_dragdrop_win.cpp index a8bdcd0b9..5bc224083 100644 --- a/tests/cefclient/cefclient_osr_dragdrop_win.cpp +++ b/tests/cefclient/cefclient_osr_dragdrop_win.cpp @@ -12,10 +12,10 @@ #include #include "include/cef_runnable.h" +#include "include/wrapper/cef_helpers.h" #include "cefclient/bytes_write_handler.h" #include "cefclient/cefclient_osr_widget_win.h" #include "cefclient/resource.h" -#include "cefclient/util.h" namespace { @@ -71,7 +71,7 @@ void GetStorageForString(STGMEDIUM* stgmed, const std::basic_string& data) { void GetStorageForFileDescriptor(STGMEDIUM* storage, const std::wstring& file_name) { - ASSERT(!file_name.empty()); + DCHECK(!file_name.empty()); HANDLE hdata = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR)); FILEGROUPDESCRIPTOR* descriptor = @@ -252,7 +252,7 @@ bool DragDataToDataObject(CefRefPtr drag_data, CefRefPtr writer = CefStreamWriter::CreateForHandler(handler.get()); drag_data->GetFileContents(writer); - ASSERT(handler->GetDataSize() == static_cast(bufferSize)); + DCHECK_EQ(handler->GetDataSize(), static_cast(bufferSize)); CefString fileName = drag_data->GetFileName(); GetStorageForFileDescriptor(&stgmeds[curr_index], fileName.ToWString()); fmtetc.cfFormat = file_desc_format; @@ -264,7 +264,7 @@ bool DragDataToDataObject(CefRefPtr drag_data, fmtetcs[curr_index] = fmtetc; curr_index++; } - ASSERT(curr_index < kMaxDataObjects); + DCHECK_LT(curr_index, kMaxDataObjects); CComPtr obj = DataObjectWin::Create(fmtetcs, stgmeds, curr_index); diff --git a/tests/cefclient/cefclient_osr_widget_gtk.cpp b/tests/cefclient/cefclient_osr_widget_gtk.cpp index f1c229d0a..5bdf44c3e 100644 --- a/tests/cefclient/cefclient_osr_widget_gtk.cpp +++ b/tests/cefclient/cefclient_osr_widget_gtk.cpp @@ -18,7 +18,7 @@ #include #include "include/cef_runnable.h" -#include "cefclient/util.h" +#include "include/wrapper/cef_helpers.h" namespace { @@ -1102,7 +1102,7 @@ class ScopedGLContext { CefRefPtr OSRWindow::Create(OSRBrowserProvider* browser_provider, bool transparent, ClientWindowHandle parentView) { - ASSERT(browser_provider); + DCHECK(browser_provider); if (!browser_provider) return NULL; @@ -1198,7 +1198,7 @@ void OSRWindow::OnCursorChange(CefRefPtr browser, // Retrieve the X11 display shared with Chromium. ::Display* xdisplay = cef_get_xdisplay(); - ASSERT(xdisplay); + DCHECK(xdisplay); // Retrieve the X11 window handle for OSR widget. ::Window xwindow = GDK_WINDOW_XID(gtk_widget_get_window(glarea_)); @@ -1257,13 +1257,13 @@ OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, painting_popup_(false), render_task_pending_(false) { glarea_ = gtk_drawing_area_new(); - ASSERT(glarea_); + DCHECK(glarea_); GdkGLConfig* glconfig = gdk_gl_config_new_by_mode( static_cast(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); - ASSERT(glconfig); + DCHECK(glconfig); gtk_widget_set_gl_capability(glarea_, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); @@ -1312,7 +1312,7 @@ OSRWindow::~OSRWindow() { } void OSRWindow::Render() { - ASSERT(CefCurrentlyOn(TID_UI)); + CEF_REQUIRE_UI_THREAD(); if (render_task_pending_) render_task_pending_ = false; @@ -1327,7 +1327,7 @@ void OSRWindow::Render() { } void OSRWindow::EnableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); + CEF_REQUIRE_UI_THREAD(); if (gl_enabled_) return; @@ -1341,7 +1341,7 @@ void OSRWindow::EnableGL() { } void OSRWindow::DisableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); + CEF_REQUIRE_UI_THREAD(); if (!gl_enabled_) return; diff --git a/tests/cefclient/cefclient_osr_widget_mac.mm b/tests/cefclient/cefclient_osr_widget_mac.mm index abe48f553..b51d96fa5 100644 --- a/tests/cefclient/cefclient_osr_widget_mac.mm +++ b/tests/cefclient/cefclient_osr_widget_mac.mm @@ -14,11 +14,11 @@ #include "include/cef_browser.h" #include "include/cef_client.h" #include "include/cef_url.h" +#include "include/wrapper/cef_helpers.h" #include "cefclient/bytes_write_handler.h" #include "cefclient/cefclient.h" #include "cefclient/osrenderer.h" #include "cefclient/resource_util.h" -#include "cefclient/util.h" // This method will return YES for OS X versions 10.7.3 and later, and NO // otherwise. @@ -127,7 +127,7 @@ void ClientOSRHandler::OnBeforeClose(CefRefPtr browser) { bool ClientOSRHandler::GetViewRect(CefRefPtr browser, CefRect& rect) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return false; @@ -146,7 +146,7 @@ bool ClientOSRHandler::GetScreenPoint(CefRefPtr browser, int viewY, int& screenX, int& screenY) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return false; @@ -163,7 +163,7 @@ bool ClientOSRHandler::GetScreenPoint(CefRefPtr browser, bool ClientOSRHandler::GetScreenInfo(CefRefPtr browser, CefScreenInfo& screen_info) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return false; @@ -192,7 +192,7 @@ bool ClientOSRHandler::GetScreenInfo(CefRefPtr browser, void ClientOSRHandler::OnPopupShow(CefRefPtr browser, bool show) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return; @@ -209,7 +209,7 @@ void ClientOSRHandler::OnPopupShow(CefRefPtr browser, void ClientOSRHandler::OnPopupSize(CefRefPtr browser, const CefRect& rect) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return; @@ -222,7 +222,7 @@ void ClientOSRHandler::OnPaint(CefRefPtr browser, const RectList& dirtyRects, const void* buffer, int width, int height) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return; @@ -253,7 +253,7 @@ void ClientOSRHandler::OnPaint(CefRefPtr browser, void ClientOSRHandler::OnCursorChange(CefRefPtr browser, CefCursorHandle cursor) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); [cursor set]; } @@ -261,7 +261,7 @@ bool ClientOSRHandler::StartDragging(CefRefPtr browser, CefRefPtr drag_data, CefRenderHandler::DragOperationsMask allowed_ops, int x, int y) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return false; return [view_ startDragging:drag_data @@ -271,7 +271,7 @@ bool ClientOSRHandler::StartDragging(CefRefPtr browser, void ClientOSRHandler::UpdateDragCursor(CefRefPtr browser, CefRenderHandler::DragOperation operation) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!view_) return; view_->current_drag_op_ = operation; @@ -542,7 +542,7 @@ void ClientOSRHandler::SetLoading(bool isLoading) { return; CGEventRef cgEvent = [event CGEvent]; - ASSERT(cgEvent); + DCHECK(cgEvent); int deltaX = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2); @@ -817,9 +817,9 @@ void ClientOSRHandler::SetLoading(bool isLoading) { - (BOOL)startDragging:(CefRefPtr)drag_data allowed_ops:(NSDragOperation)ops point:(NSPoint)position { - ASSERT(!pasteboard_); - ASSERT(!fileUTI_); - ASSERT(!current_drag_data_.get()); + DCHECK(!pasteboard_); + DCHECK(!fileUTI_); + DCHECK(!current_drag_data_.get()); [self resetDragDrop]; @@ -982,7 +982,7 @@ void ClientOSRHandler::SetLoading(bool isLoading) { // URL. if ([type isEqualToString:NSURLPboardType]) { - ASSERT(current_drag_data_->IsLink()); + DCHECK(current_drag_data_->IsLink()); NSString* strUrl = [NSString stringWithUTF8String: current_drag_data_->GetLinkURL().ToString().c_str()]; NSURL* url = [NSURL URLWithString:strUrl]; @@ -996,12 +996,12 @@ void ClientOSRHandler::SetLoading(bool isLoading) { // File contents. } else if ([type isEqualToString:(NSString*)fileUTI_]) { size_t size = current_drag_data_->GetFileContents(NULL); - ASSERT(size > 0); + DCHECK_GT(size, 0U); CefRefPtr handler = new BytesWriteHandler(size); CefRefPtr writer = CefStreamWriter::CreateForHandler(handler.get()); current_drag_data_->GetFileContents(writer); - ASSERT(handler->GetDataSize() == static_cast(size)); + DCHECK_EQ(handler->GetDataSize(), static_cast(size)); [pboard setData:[NSData dataWithBytes:handler->GetData() length:handler->GetDataSize()] @@ -1038,7 +1038,7 @@ void ClientOSRHandler::SetLoading(bool isLoading) { } - (void)fillPasteboard { - ASSERT(!pasteboard_); + DCHECK(!pasteboard_); pasteboard_ = [[NSPasteboard pasteboardWithName:NSDragPboard] retain]; [pasteboard_ declareTypes:@[ kCEFDragDummyPboardType ] @@ -1090,9 +1090,9 @@ void ClientOSRHandler::SetLoading(bool isLoading) { - (void)populateDropData:(CefRefPtr)data fromPasteboard:(NSPasteboard*)pboard { - ASSERT(data); - ASSERT(pboard); - ASSERT(data && !data->IsReadOnly()); + DCHECK(data); + DCHECK(pboard); + DCHECK(data && !data->IsReadOnly()); NSArray* types = [pboard types]; // Get plain text. diff --git a/tests/cefclient/cefclient_osr_widget_win.cpp b/tests/cefclient/cefclient_osr_widget_win.cpp index 1f4220ef4..b22561778 100644 --- a/tests/cefclient/cefclient_osr_widget_win.cpp +++ b/tests/cefclient/cefclient_osr_widget_win.cpp @@ -7,13 +7,13 @@ #include #include "include/cef_runnable.h" +#include "include/wrapper/cef_helpers.h" #include "cefclient/resource.h" -#include "cefclient/util.h" // static CefRefPtr OSRWindow::Create(OSRBrowserProvider* browser_provider, bool transparent) { - ASSERT(browser_provider); + DCHECK(browser_provider); if (!browser_provider) return NULL; @@ -28,7 +28,7 @@ CefRefPtr OSRWindow::From( bool OSRWindow::CreateWidget(HWND hWndParent, const RECT& rect, HINSTANCE hInst, LPCTSTR className) { - ASSERT(hWnd_ == NULL && hDC_ == NULL && hRC_ == NULL); + DCHECK(hWnd_ == NULL && hDC_ == NULL && hRC_ == NULL); RegisterOSRClass(hInst, className); hWnd_ = ::CreateWindow(className, 0, @@ -46,7 +46,7 @@ bool OSRWindow::CreateWidget(HWND hWndParent, const RECT& rect, drop_target_ = DropTargetWin::Create(this, hWnd_); HRESULT register_res = RegisterDragDrop(hWnd_, drop_target_); - ASSERT(register_res == S_OK); + DCHECK_EQ(register_res, S_OK); return true; } @@ -236,7 +236,7 @@ OSRWindow::~OSRWindow() { } void OSRWindow::Render() { - ASSERT(CefCurrentlyOn(TID_UI)); + CEF_REQUIRE_UI_THREAD(); if (render_task_pending_) render_task_pending_ = false; @@ -249,7 +249,7 @@ void OSRWindow::Render() { } void OSRWindow::EnableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); + CEF_REQUIRE_UI_THREAD(); PIXELFORMATDESCRIPTOR pfd; int format; @@ -277,7 +277,7 @@ void OSRWindow::EnableGL() { } void OSRWindow::DisableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); + CEF_REQUIRE_UI_THREAD(); if (!hDC_) return; diff --git a/tests/cefclient/cefclient_win.cpp b/tests/cefclient/cefclient_win.cpp index b93bcf5ca..7cd8372c9 100644 --- a/tests/cefclient/cefclient_win.cpp +++ b/tests/cefclient/cefclient_win.cpp @@ -110,7 +110,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, // Populate the settings based on command line arguments. AppGetSettings(settings); - + // Initialize CEF. CefInitialize(main_args, settings, app.get(), sandbox_info); @@ -143,7 +143,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, } else { // Create a hidden window for message processing. hMessageWnd = CreateMessageWindow(hInstance); - ASSERT(hMessageWnd); + DCHECK(hMessageWnd); MSG msg; @@ -692,7 +692,7 @@ void AppQuitMessageLoop() { if (command_line->HasSwitch(cefclient::kMultiThreadedMessageLoop)) { // Running in multi-threaded message loop mode. Need to execute // PostQuitMessage on the main application thread. - ASSERT(hMessageWnd); + DCHECK(hMessageWnd); PostMessage(hMessageWnd, WM_COMMAND, ID_QUIT, 0); } else { CefQuitMessageLoop(); diff --git a/tests/cefclient/client_app.cpp b/tests/cefclient/client_app.cpp index 419794028..3943220b8 100644 --- a/tests/cefclient/client_app.cpp +++ b/tests/cefclient/client_app.cpp @@ -12,7 +12,7 @@ #include "include/cef_process_message.h" #include "include/cef_task.h" #include "include/cef_v8.h" -#include "util.h" // NOLINT(build/include) +#include "include/wrapper/cef_helpers.h" ClientApp::ClientApp() { } @@ -31,7 +31,7 @@ void ClientApp::OnContextInitialized() { // Register cookieable schemes with the global cookie manager. CefRefPtr manager = CefCookieManager::GetGlobalManager(); - ASSERT(manager.get()); + DCHECK(manager.get()); manager->SetSupportedSchemes(cookieable_schemes_); print_handler_ = CreatePrintHandler(); @@ -146,7 +146,7 @@ bool ClientApp::OnProcessMessageReceived( CefRefPtr browser, CefProcessId source_process, CefRefPtr message) { - ASSERT(source_process == PID_BROWSER); + DCHECK_EQ(source_process, PID_BROWSER); bool handled = false; diff --git a/tests/cefclient/client_handler.cpp b/tests/cefclient/client_handler.cpp index 5cfe0b752..0ba607b2e 100644 --- a/tests/cefclient/client_handler.cpp +++ b/tests/cefclient/client_handler.cpp @@ -195,7 +195,7 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); bool first_message; std::string logFile; @@ -239,7 +239,7 @@ void ClientHandler::OnBeforeDownload( CefRefPtr download_item, const CefString& suggested_name, CefRefPtr callback) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Continue the download and show the "Save As" dialog. callback->Continue(GetDownloadPath(suggested_name), true); } @@ -248,7 +248,7 @@ void ClientHandler::OnDownloadUpdated( CefRefPtr browser, CefRefPtr download_item, CefRefPtr callback) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (download_item->IsComplete()) { SetLastDownloadFile(download_item->GetFullPath()); SendNotification(NOTIFY_DOWNLOAD_COMPLETE); @@ -258,7 +258,7 @@ void ClientHandler::OnDownloadUpdated( bool ClientHandler::OnDragEnter(CefRefPtr browser, CefRefPtr dragData, CefDragHandler::DragOperationsMask mask) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Forbid dragging of link URLs. if (mask & DRAG_OPERATION_LINK) @@ -340,7 +340,7 @@ bool ClientHandler::OnBeforePopup(CefRefPtr browser, } void ClientHandler::OnAfterCreated(CefRefPtr browser) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (!message_router_) { // Create the browser-side router for query handling. @@ -378,7 +378,7 @@ void ClientHandler::OnAfterCreated(CefRefPtr browser) { } bool ClientHandler::DoClose(CefRefPtr browser) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Closing the main window requires special handling. See the DoClose() // documentation in the CEF header for a detailed destription of this @@ -394,7 +394,7 @@ bool ClientHandler::DoClose(CefRefPtr browser) { } void ClientHandler::OnBeforeClose(CefRefPtr browser) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); message_router_->OnBeforeClose(browser); @@ -437,7 +437,7 @@ void ClientHandler::OnLoadingStateChange(CefRefPtr browser, bool isLoading, bool canGoBack, bool canGoForward) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); SetLoading(isLoading); SetNavState(canGoBack, canGoForward); @@ -454,7 +454,7 @@ void ClientHandler::OnLoadError(CefRefPtr browser, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Don't display an error for downloaded files. if (errorCode == ERR_ABORTED) @@ -504,7 +504,7 @@ CefRefPtr ClientHandler::GetResourceHandler( CefStreamReader::CreateForData( static_cast(const_cast(str.c_str())), str.size()); - ASSERT(stream.get()); + DCHECK(stream.get()); return new CefStreamResourceHandler("text/html", stream); } else { // Load the resource from file. diff --git a/tests/cefclient/client_handler.h b/tests/cefclient/client_handler.h index 6b3b23c88..1d27d2a79 100644 --- a/tests/cefclient/client_handler.h +++ b/tests/cefclient/client_handler.h @@ -11,8 +11,8 @@ #include #include #include "include/cef_client.h" +#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_message_router.h" -#include "cefclient/util.h" #if defined(OS_LINUX) // The Linux client uses GTK instead of the underlying platform type (X11). diff --git a/tests/cefclient/client_handler_gtk.cpp b/tests/cefclient/client_handler_gtk.cpp index 2247eac96..35794a8a4 100644 --- a/tests/cefclient/client_handler_gtk.cpp +++ b/tests/cefclient/client_handler_gtk.cpp @@ -127,7 +127,7 @@ bool ClientHandler::OnFileDialog(CefRefPtr browser, action = GTK_FILE_CHOOSER_ACTION_SAVE; accept_button = GTK_STOCK_SAVE; } else { - ASSERT(false); // Not reached + NOTREACHED(); return false; } @@ -216,7 +216,7 @@ bool ClientHandler::OnFileDialog(CefRefPtr browser, void ClientHandler::OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { // Set the edit window text @@ -227,7 +227,7 @@ void ClientHandler::OnAddressChange(CefRefPtr browser, void ClientHandler::OnTitleChange(CefRefPtr browser, const CefString& title) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); std::string titleStr(title); @@ -239,11 +239,11 @@ void ClientHandler::OnTitleChange(CefRefPtr browser, } else { // Retrieve the X11 display shared with Chromium. ::Display* display = cef_get_xdisplay(); - ASSERT(display); + DCHECK(display); // Retrieve the X11 window handle for the browser. ::Window window = browser->GetHost()->GetWindowHandle(); - ASSERT(window != kNullWindowHandle); + DCHECK_NE(window, kNullWindowHandle); // Retrieve the atoms required by the below XChangeProperty call. const char* kAtoms[] = { @@ -254,7 +254,7 @@ void ClientHandler::OnTitleChange(CefRefPtr browser, int result = XInternAtoms(display, const_cast(kAtoms), 2, false, atoms); if (!result) - ASSERT(false); + NOTREACHED(); // Set the window title. XChangeProperty(display, @@ -379,7 +379,7 @@ void ClientHandler::OnResetDialogState(CefRefPtr browser) { void ClientHandler::OnDialogResponse(GtkDialog* dialog, gint response_id, ClientHandler* handler) { - ASSERT(dialog == GTK_DIALOG(handler->gtk_dialog_)); + DCHECK_EQ(dialog, GTK_DIALOG(handler->gtk_dialog_)); switch (response_id) { case GTK_RESPONSE_OK: handler->js_dialog_callback_->Continue(true, GetPromptText(dialog)); @@ -389,7 +389,7 @@ void ClientHandler::OnDialogResponse(GtkDialog* dialog, handler->js_dialog_callback_->Continue(false, CefString()); break; default: - ASSERT(false); // Not reached + NOTREACHED(); } handler->OnResetDialogState(NULL); diff --git a/tests/cefclient/client_handler_mac.mm b/tests/cefclient/client_handler_mac.mm index 0a6f91a40..7bf5c41f2 100644 --- a/tests/cefclient/client_handler_mac.mm +++ b/tests/cefclient/client_handler_mac.mm @@ -12,7 +12,7 @@ void ClientHandler::OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { // Set the edit window text @@ -25,7 +25,7 @@ void ClientHandler::OnAddressChange(CefRefPtr browser, void ClientHandler::OnTitleChange(CefRefPtr browser, const CefString& title) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Set the frame window title bar NSView* view = (NSView*)browser->GetHost()->GetWindowHandle(); diff --git a/tests/cefclient/client_handler_win.cpp b/tests/cefclient/client_handler_win.cpp index 99bde8d47..b45f0a7fa 100644 --- a/tests/cefclient/client_handler_win.cpp +++ b/tests/cefclient/client_handler_win.cpp @@ -15,7 +15,7 @@ void ClientHandler::OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { // Set the edit window text @@ -25,7 +25,7 @@ void ClientHandler::OnAddressChange(CefRefPtr browser, void ClientHandler::OnTitleChange(CefRefPtr browser, const CefString& title) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Set the frame window title bar CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle(); @@ -55,14 +55,14 @@ void ClientHandler::SendNotification(NotificationType type) { } void ClientHandler::SetLoading(bool isLoading) { - ASSERT(m_EditHwnd != NULL && m_ReloadHwnd != NULL && m_StopHwnd != NULL); + DCHECK(m_EditHwnd != NULL && m_ReloadHwnd != NULL && m_StopHwnd != NULL); EnableWindow(m_EditHwnd, TRUE); EnableWindow(m_ReloadHwnd, !isLoading); EnableWindow(m_StopHwnd, isLoading); } void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) { - ASSERT(m_BackHwnd != NULL && m_ForwardHwnd != NULL); + DCHECK(m_BackHwnd != NULL && m_ForwardHwnd != NULL); EnableWindow(m_BackHwnd, canGoBack); EnableWindow(m_ForwardHwnd, canGoForward); } diff --git a/tests/cefclient/client_renderer.cpp b/tests/cefclient/client_renderer.cpp index 2e0584c9b..9c98db8f4 100644 --- a/tests/cefclient/client_renderer.cpp +++ b/tests/cefclient/client_renderer.cpp @@ -8,8 +8,8 @@ #include #include "include/cef_dom.h" +#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_message_router.h" -#include "cefclient/util.h" namespace client_renderer { diff --git a/tests/cefclient/dialog_test.cpp b/tests/cefclient/dialog_test.cpp index 8701d3e63..723c74172 100644 --- a/tests/cefclient/dialog_test.cpp +++ b/tests/cefclient/dialog_test.cpp @@ -82,7 +82,7 @@ class Handler : public CefMessageRouterBrowserSide::Handler { browser->GetHost()->RunFileDialog(FILE_DIALOG_SAVE, "My Save Dialog", "test.txt", file_types, dialog_callback.get()); } else { - ASSERT(false); // Not reached. + NOTREACHED(); } return true; diff --git a/tests/cefclient/dom_test.cpp b/tests/cefclient/dom_test.cpp index 0dad68675..9fe216980 100644 --- a/tests/cefclient/dom_test.cpp +++ b/tests/cefclient/dom_test.cpp @@ -8,7 +8,7 @@ #include #include "include/cef_dom.h" -#include "cefclient/util.h" +#include "include/wrapper/cef_helpers.h" namespace dom_test { @@ -25,12 +25,12 @@ class ClientDOMEventListener : public CefDOMEventListener { virtual void HandleEvent(CefRefPtr event) OVERRIDE { CefRefPtr document = event->GetDocument(); - ASSERT(document.get()); + DCHECK(document.get()); std::stringstream ss; CefRefPtr button = event->GetTarget(); - ASSERT(button.get()); + DCHECK(button.get()); std::string buttonValue = button->GetElementAttribute("value"); ss << "You clicked the " << buttonValue.c_str() << " button. "; @@ -71,10 +71,10 @@ class ClientDOMEventListener : public CefDOMEventListener { // Update the description. CefRefPtr desc = document->GetElementById("description"); - ASSERT(desc.get()); + DCHECK(desc.get()); CefRefPtr text = desc->GetFirstChild(); - ASSERT(text.get()); - ASSERT(text->IsText()); + DCHECK(text.get()); + DCHECK(text->IsText()); text->SetValue(ss.str()); } @@ -89,7 +89,7 @@ class ClientDOMVisitor : public CefDOMVisitor { virtual void Visit(CefRefPtr document) OVERRIDE { // Register a click listener for the button. CefRefPtr button = document->GetElementById("button"); - ASSERT(button.get()); + DCHECK(button.get()); button->AddEventListener("click", new ClientDOMEventListener(), false); } diff --git a/tests/cefclient/osrenderer.cpp b/tests/cefclient/osrenderer.cpp index a8c0dda3e..6aaa96f13 100644 --- a/tests/cefclient/osrenderer.cpp +++ b/tests/cefclient/osrenderer.cpp @@ -16,7 +16,7 @@ #error Platform is not supported. #endif -#include "cefclient/util.h" +#include "include/wrapper/cef_helpers.h" #ifndef GL_BGR #define GL_BGR 0x80E0 @@ -56,7 +56,7 @@ void ClientOSRenderer::Initialize() { // Create the texture. glGenTextures(1, &texture_id_); - ASSERT(texture_id_ != 0); + DCHECK_NE(texture_id_, 0U); glBindTexture(GL_TEXTURE_2D, texture_id_); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -75,7 +75,7 @@ void ClientOSRenderer::Render() { if (view_width_ == 0 || view_height_ == 0) return; - ASSERT(initialized_); + DCHECK(initialized_); struct { float tu, tv; @@ -128,7 +128,7 @@ void ClientOSRenderer::Render() { glEnable(GL_TEXTURE_2D); // Draw the facets with the texture. - ASSERT(texture_id_ != 0); + DCHECK_NE(texture_id_, 0U); glBindTexture(GL_TEXTURE_2D, texture_id_); glInterleavedArrays(GL_T2F_V3F, 0, vertices); glDrawArrays(GL_QUADS, 0, 4); @@ -198,7 +198,7 @@ void ClientOSRenderer::OnPaint(CefRefPtr browser, // Enable 2D textures. glEnable(GL_TEXTURE_2D); - ASSERT(texture_id_ != 0); + DCHECK_NE(texture_id_, 0U); glBindTexture(GL_TEXTURE_2D, texture_id_); if (type == PET_VIEW) { diff --git a/tests/cefclient/performance_test_setup.h b/tests/cefclient/performance_test_setup.h index 8a8301a5a..cbe3e813e 100644 --- a/tests/cefclient/performance_test_setup.h +++ b/tests/cefclient/performance_test_setup.h @@ -6,7 +6,8 @@ #define CEF_TESTS_CEFCLIENT_PERFORMANCE_TEST_SETUP_H_ #pragma once -#include "cefclient/util.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_logging.h" namespace performance_test { @@ -39,19 +40,19 @@ class CefTimer { bool IsRunning() { return running_; } void Start() { - ASSERT(!running_); + DCHECK(!running_); running_ = true; start_.Now(); } void Stop() { stop_.Now(); - ASSERT(running_); + DCHECK(running_); running_ = false; } int64 Delta() { - ASSERT(!running_); + DCHECK(!running_); return start_.Delta(stop_); } @@ -59,6 +60,8 @@ class CefTimer { bool running_; CefTime start_; CefTime stop_; + + DISALLOW_COPY_AND_ASSIGN(CefTimer); }; // Peform test iterations using a user-provided timing result variable. diff --git a/tests/cefclient/print_handler_gtk.cpp b/tests/cefclient/print_handler_gtk.cpp index 97ce69cd9..99ba43f3b 100644 --- a/tests/cefclient/print_handler_gtk.cpp +++ b/tests/cefclient/print_handler_gtk.cpp @@ -7,7 +7,9 @@ #include -#include "cefclient/util.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/wrapper/cef_helpers.h" namespace { @@ -57,7 +59,7 @@ class StickyPrintSettingGtk { StickyPrintSettingGtk() : last_used_settings_(gtk_print_settings_new()) { } ~StickyPrintSettingGtk() { - ASSERT(false); // Not reached; the instance is leaked. + NOTREACHED(); // The instance is intentionally leaked. } GtkPrintSettings* settings() { @@ -65,7 +67,7 @@ class StickyPrintSettingGtk { } void SetLastUsedSettings(GtkPrintSettings* settings) { - ASSERT(last_used_settings_); + DCHECK(last_used_settings_); g_object_unref(last_used_settings_); last_used_settings_ = gtk_print_settings_copy(settings); } @@ -215,8 +217,8 @@ void GetColorModelForMode(CefPrintSettings::ColorModel color_mode, void InitPrintSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup, CefRefPtr print_settings) { - ASSERT(settings); - ASSERT(page_setup); + DCHECK(settings); + DCHECK(page_setup); std::string device_name; const gchar* name = gtk_print_settings_get_printer(settings); @@ -283,8 +285,8 @@ void ClientPrintHandlerGtk::OnPrintSettings( CefRefPtr settings, bool get_defaults) { if (get_defaults) { - ASSERT(!page_setup_); - ASSERT(!printer_); + DCHECK(!page_setup_); + DCHECK(!printer_); // |gtk_settings_| is a new copy. gtk_settings_ = @@ -330,7 +332,7 @@ void ClientPrintHandlerGtk::OnPrintSettings( cups_duplex_mode = kDuplexNone; break; default: // UNKNOWN_DUPLEX_MODE - ASSERT(false); // Not reached + NOTREACHED(); break; } gtk_print_settings_set(gtk_settings_, kCUPSDuplex, cups_duplex_mode); @@ -441,7 +443,7 @@ void ClientPrintHandlerGtk::OnDialogResponse(GtkDialog *dialog, gint response_id) { int num_matched_handlers = g_signal_handlers_disconnect_by_func( dialog_, reinterpret_cast(&OnDialogResponseThunk), this); - ASSERT(1 == num_matched_handlers); + DCHECK_EQ(1, num_matched_handlers); gtk_widget_hide(dialog_); @@ -489,7 +491,7 @@ void ClientPrintHandlerGtk::OnDialogResponse(GtkDialog *dialog, break; case GTK_PRINT_PAGES_CURRENT: default: - ASSERT(false); // Not reached. + NOTREACHED(); break; } @@ -509,7 +511,7 @@ void ClientPrintHandlerGtk::OnDialogResponse(GtkDialog *dialog, } case GTK_RESPONSE_APPLY: default: { - ASSERT(false); // Not reached. + NOTREACHED(); } } } diff --git a/tests/cefclient/resource_util_mac.mm b/tests/cefclient/resource_util_mac.mm index 1d53639cd..7bf6d882e 100644 --- a/tests/cefclient/resource_util_mac.mm +++ b/tests/cefclient/resource_util_mac.mm @@ -4,10 +4,12 @@ // found in the LICENSE file. #include "cefclient/resource_util.h" + #import #include #include -#include "cefclient/util.h" + +#include "include/base/cef_logging.h" namespace { @@ -18,7 +20,7 @@ bool AmIBundled() { FSRef fsref; OSStatus pbErr; if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { - ASSERT(false); + NOTREACHED(); return false; } @@ -26,7 +28,7 @@ bool AmIBundled() { OSErr fsErr; if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, NULL, NULL, NULL)) != noErr) { - ASSERT(false); + NOTREACHED(); return false; } @@ -53,7 +55,7 @@ bool GetResourceDir(std::string& dir) { return true; } else { // TODO: Provide unbundled path - ASSERT(false); + NOTIMPLEMENTED(); return false; } } diff --git a/tests/cefclient/resource_util_win.cpp b/tests/cefclient/resource_util_win.cpp index 114ca4bc3..a5a640760 100644 --- a/tests/cefclient/resource_util_win.cpp +++ b/tests/cefclient/resource_util_win.cpp @@ -3,10 +3,10 @@ // can be found in the LICENSE file. #include "cefclient/resource_util.h" +#include "include/base/cef_logging.h" #include "include/cef_stream.h" #include "include/wrapper/cef_byte_read_handler.h" #include "cefclient/resource.h" -#include "cefclient/util.h" namespace { @@ -70,7 +70,7 @@ bool LoadBinaryResource(const char* resource_name, std::string& resource_data) { return true; } - ASSERT(FALSE); // The resource should be found. + NOTREACHED(); // The resource should be found. return false; } @@ -87,6 +87,6 @@ CefRefPtr GetBinaryResourceReader(const char* resource_name) { new CefByteReadHandler(pBytes, dwSize, NULL)); } - ASSERT(FALSE); // The resource should be found. + NOTREACHED(); // The resource should be found. return NULL; } diff --git a/tests/cefclient/scheme_test.cpp b/tests/cefclient/scheme_test.cpp index 8c0a84475..4fd45bf17 100644 --- a/tests/cefclient/scheme_test.cpp +++ b/tests/cefclient/scheme_test.cpp @@ -12,9 +12,9 @@ #include "include/cef_response.h" #include "include/cef_request.h" #include "include/cef_scheme.h" +#include "include/wrapper/cef_helpers.h" #include "cefclient/resource_util.h" #include "cefclient/string_util.h" -#include "cefclient/util.h" #if defined(OS_WIN) #include "cefclient/resource.h" @@ -32,7 +32,7 @@ class ClientSchemeHandler : public CefResourceHandler { virtual bool ProcessRequest(CefRefPtr request, CefRefPtr callback) OVERRIDE { - REQUIRE_IO_THREAD(); + CEF_REQUIRE_IO_THREAD(); bool handled = false; @@ -85,9 +85,9 @@ class ClientSchemeHandler : public CefResourceHandler { virtual void GetResponseHeaders(CefRefPtr response, int64& response_length, CefString& redirectUrl) OVERRIDE { - REQUIRE_IO_THREAD(); + CEF_REQUIRE_IO_THREAD(); - ASSERT(!data_.empty()); + DCHECK(!data_.empty()); response->SetMimeType(mime_type_); response->SetStatus(200); @@ -97,7 +97,7 @@ class ClientSchemeHandler : public CefResourceHandler { } virtual void Cancel() OVERRIDE { - REQUIRE_IO_THREAD(); + CEF_REQUIRE_IO_THREAD(); } virtual bool ReadResponse(void* data_out, @@ -105,7 +105,7 @@ class ClientSchemeHandler : public CefResourceHandler { int& bytes_read, CefRefPtr callback) OVERRIDE { - REQUIRE_IO_THREAD(); + CEF_REQUIRE_IO_THREAD(); bool has_data = false; bytes_read = 0; @@ -144,7 +144,7 @@ class ClientSchemeHandlerFactory : public CefSchemeHandlerFactory { const CefString& scheme_name, CefRefPtr request) OVERRIDE { - REQUIRE_IO_THREAD(); + CEF_REQUIRE_IO_THREAD(); return new ClientSchemeHandler(); } diff --git a/tests/cefclient/util.h b/tests/cefclient/util.h deleted file mode 100644 index 38ade76f6..000000000 --- a/tests/cefclient/util.h +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CEF_TESTS_CEFCLIENT_UTIL_H_ -#define CEF_TESTS_CEFCLIENT_UTIL_H_ -#pragma once - -#include -#include -#include - -#include "include/cef_task.h" - -#if defined(OS_WIN) - -#include // NOLINT(build/include_order) - -#ifndef NDEBUG -#define ASSERT(condition) if (!(condition)) { DebugBreak(); } -#else -#define ASSERT(condition) ((void)0) -#endif - -#else // !OS_WIN - -#include // NOLINT(build/include_order) - -#ifndef NDEBUG -#define ASSERT(condition) if (!(condition)) { assert(false); } -#else -#define ASSERT(condition) ((void)0) -#endif - -#endif // !OS_WIN - -#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI)); -#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO)); -#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE)); - -// Helper class to manage a scoped copy of |argv|. -class ScopedArgArray { - public: - ScopedArgArray(int argc, char* argv[]) { - array_ = new char*[argc]; - for (int i = 0; i < argc; ++i) { - values_.push_back(argv[i]); - array_[i] = const_cast(values_[i].c_str()); - } - } - ~ScopedArgArray() { - delete [] array_; - } - - char** array() const { return array_; } - - private: - char** array_; - - // Keep values in a vector separate from |array_| because various users may - // modify |array_| and we still want to clean up memory properly. - std::vector values_; -}; - - -// 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 -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 -char (&ArraySizeHelper(const T (&array)[N]))[N]; -#endif - -#define arraysize(array) (sizeof(ArraySizeHelper(array))) - - -// 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) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) - -#endif // CEF_TESTS_CEFCLIENT_UTIL_H_ diff --git a/tests/cefclient/window_test.cpp b/tests/cefclient/window_test.cpp index d360fac31..2a86842bf 100644 --- a/tests/cefclient/window_test.cpp +++ b/tests/cefclient/window_test.cpp @@ -63,7 +63,7 @@ class Handler : public CefMessageRouterBrowserSide::Handler { } else if (message_name == kMessageRestoreName) { Restore(browser->GetHost()->GetWindowHandle()); } else { - ASSERT(false); // Not reached. + NOTREACHED(); } callback->Success(""); diff --git a/tests/cefsimple/cefsimple_mac.mm b/tests/cefsimple/cefsimple_mac.mm index f8fabce70..d4052fa3a 100644 --- a/tests/cefsimple/cefsimple_mac.mm +++ b/tests/cefsimple/cefsimple_mac.mm @@ -7,8 +7,8 @@ #include "cefsimple/simple_app.h" #include "cefsimple/simple_handler.h" -#include "cefsimple/util.h" #include "include/cef_application_mac.h" +#include "include/wrapper/cef_helpers.h" // Receives notifications from the application. @interface SimpleAppDelegate : NSObject diff --git a/tests/cefsimple/simple_app.cpp b/tests/cefsimple/simple_app.cpp index cb8357050..f09ee8ab7 100644 --- a/tests/cefsimple/simple_app.cpp +++ b/tests/cefsimple/simple_app.cpp @@ -7,15 +7,15 @@ #include #include "cefsimple/simple_handler.h" -#include "cefsimple/util.h" #include "include/cef_browser.h" #include "include/cef_command_line.h" +#include "include/wrapper/cef_helpers.h" SimpleApp::SimpleApp() { } void SimpleApp::OnContextInitialized() { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Information used when creating the native window. CefWindowInfo window_info; diff --git a/tests/cefsimple/simple_handler.cpp b/tests/cefsimple/simple_handler.cpp index 218e30ede..e17b7473c 100644 --- a/tests/cefsimple/simple_handler.cpp +++ b/tests/cefsimple/simple_handler.cpp @@ -7,9 +7,9 @@ #include #include -#include "cefsimple/util.h" #include "include/cef_app.h" #include "include/cef_runnable.h" +#include "include/wrapper/cef_helpers.h" namespace { @@ -19,7 +19,7 @@ SimpleHandler* g_instance = NULL; SimpleHandler::SimpleHandler() : is_closing_(false) { - ASSERT(!g_instance); + DCHECK(!g_instance); g_instance = this; } @@ -33,14 +33,14 @@ SimpleHandler* SimpleHandler::GetInstance() { } void SimpleHandler::OnAfterCreated(CefRefPtr browser) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Add to the list of existing browsers. browser_list_.push_back(browser); } bool SimpleHandler::DoClose(CefRefPtr browser) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Closing the main window requires special handling. See the DoClose() // documentation in the CEF header for a detailed destription of this @@ -56,7 +56,7 @@ bool SimpleHandler::DoClose(CefRefPtr browser) { } void SimpleHandler::OnBeforeClose(CefRefPtr browser) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Remove from the list of existing browsers. BrowserList::iterator bit = browser_list_.begin(); @@ -78,7 +78,7 @@ void SimpleHandler::OnLoadError(CefRefPtr browser, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); // Don't display an error for downloaded files. if (errorCode == ERR_ABORTED) diff --git a/tests/cefsimple/simple_handler_linux.cpp b/tests/cefsimple/simple_handler_linux.cpp index dc944d2d3..a1e04e15e 100644 --- a/tests/cefsimple/simple_handler_linux.cpp +++ b/tests/cefsimple/simple_handler_linux.cpp @@ -8,21 +8,21 @@ #include #include -#include "cefsimple/util.h" #include "include/cef_browser.h" +#include "include/wrapper/cef_helpers.h" void SimpleHandler::OnTitleChange(CefRefPtr browser, const CefString& title) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); std::string titleStr(title); // Retrieve the X11 display shared with Chromium. ::Display* display = cef_get_xdisplay(); - ASSERT(display); + DCHECK(display); // Retrieve the X11 window handle for the browser. ::Window window = browser->GetHost()->GetWindowHandle(); - ASSERT(window != kNullWindowHandle); + DCHECK_NE(window, kNullWindowHandle); // Retrieve the atoms required by the below XChangeProperty call. const char* kAtoms[] = { @@ -33,7 +33,7 @@ void SimpleHandler::OnTitleChange(CefRefPtr browser, int result = XInternAtoms(display, const_cast(kAtoms), 2, false, atoms); if (!result) - ASSERT(false); + NOTREACHED(); // Set the window title. XChangeProperty(display, diff --git a/tests/cefsimple/simple_handler_mac.mm b/tests/cefsimple/simple_handler_mac.mm index 57de1f61e..696959a5c 100644 --- a/tests/cefsimple/simple_handler_mac.mm +++ b/tests/cefsimple/simple_handler_mac.mm @@ -6,12 +6,12 @@ #import -#include "cefsimple/util.h" #include "include/cef_browser.h" +#include "include/wrapper/cef_helpers.h" void SimpleHandler::OnTitleChange(CefRefPtr browser, const CefString& title) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); NSView* view = (NSView*)browser->GetHost()->GetWindowHandle(); NSWindow* window = [view window]; diff --git a/tests/cefsimple/simple_handler_win.cpp b/tests/cefsimple/simple_handler_win.cpp index 03b932e54..32fc1c008 100644 --- a/tests/cefsimple/simple_handler_win.cpp +++ b/tests/cefsimple/simple_handler_win.cpp @@ -7,12 +7,12 @@ #include #include -#include "cefsimple/util.h" #include "include/cef_browser.h" +#include "include/wrapper/cef_helpers.h" void SimpleHandler::OnTitleChange(CefRefPtr browser, const CefString& title) { - REQUIRE_UI_THREAD(); + CEF_REQUIRE_UI_THREAD(); CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle(); SetWindowText(hwnd, std::wstring(title).c_str()); diff --git a/tests/cefsimple/util.h b/tests/cefsimple/util.h deleted file mode 100644 index ba0305c1c..000000000 --- a/tests/cefsimple/util.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CEF_TESTS_CEFCLIENT_UTIL_H_ -#define CEF_TESTS_CEFCLIENT_UTIL_H_ -#pragma once - -#include "include/cef_task.h" - -#if defined(OS_WIN) - -#include // NOLINT(build/include_order) - -#ifndef NDEBUG -#define ASSERT(condition) if (!(condition)) { DebugBreak(); } -#else -#define ASSERT(condition) ((void)0) -#endif - -#else // !OS_WIN - -#include // NOLINT(build/include_order) - -#ifndef NDEBUG -#define ASSERT(condition) if (!(condition)) { assert(false); } -#else -#define ASSERT(condition) ((void)0) -#endif - -#endif // !OS_WIN - -#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI)); -#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO)); -#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE)); - -#endif // CEF_TESTS_CEFCLIENT_UTIL_H_ diff --git a/tests/unittests/run_all_unittests.cc b/tests/unittests/run_all_unittests.cc index 9a0ae364b..c5f09f19f 100644 --- a/tests/unittests/run_all_unittests.cc +++ b/tests/unittests/run_all_unittests.cc @@ -2,10 +2,13 @@ // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. +// Include this first to avoid conflicts with base/cef_logging.h. +#include "base/logging.h" + #include "include/cef_app.h" #include "include/cef_task.h" +#include "include/wrapper/cef_helpers.h" #include "tests/cefclient/client_app.h" -#include "tests/cefclient/util.h" #include "tests/unittests/test_handler.h" #include "tests/unittests/test_suite.h" #include "base/bind.h" @@ -62,7 +65,7 @@ int main(int argc, char* argv[]) { #if defined(OS_LINUX) // Create a copy of |argv| on Linux because Chromium mangles the value // internally (see issue #620). - ScopedArgArray scoped_arg_array(argc, argv); + CefScopedArgArray scoped_arg_array(argc, argv); char** argv_copy = scoped_arg_array.array(); #else char** argv_copy = argv; diff --git a/tests/unittests/tracing_unittest.cc b/tests/unittests/tracing_unittest.cc index 2848e50c2..1b298af24 100644 --- a/tests/unittests/tracing_unittest.cc +++ b/tests/unittests/tracing_unittest.cc @@ -7,60 +7,60 @@ #include "include/cef_runnable.h" #include "include/cef_task.h" #include "include/cef_trace.h" -#include "include/cef_trace_event.h" +#include "include/base/cef_trace_event.h" #include "tests/unittests/test_handler.h" #include "testing/gtest/include/gtest/gtest.h" enum TracingTestType { - CEF_TRACE_EVENT0, - CEF_TRACE_EVENT1, - CEF_TRACE_EVENT2, - CEF_TRACE_EVENT_INSTANT0, - CEF_TRACE_EVENT_INSTANT1, - CEF_TRACE_EVENT_INSTANT2, - CEF_TRACE_EVENT_COPY_INSTANT0, - CEF_TRACE_EVENT_COPY_INSTANT1, - CEF_TRACE_EVENT_COPY_INSTANT2, - CEF_TRACE_EVENT_BEGIN0, - CEF_TRACE_EVENT_BEGIN1, - CEF_TRACE_EVENT_BEGIN2, - CEF_TRACE_EVENT_COPY_BEGIN0, - CEF_TRACE_EVENT_COPY_BEGIN1, - CEF_TRACE_EVENT_COPY_BEGIN2, - CEF_TRACE_EVENT_END0, - CEF_TRACE_EVENT_END1, - CEF_TRACE_EVENT_END2, - CEF_TRACE_EVENT_COPY_END0, - CEF_TRACE_EVENT_COPY_END1, - CEF_TRACE_EVENT_COPY_END2, - CEF_TRACE_COUNTER1, - CEF_TRACE_COPY_COUNTER1, - CEF_TRACE_COUNTER2, - CEF_TRACE_COPY_COUNTER2, - CEF_TRACE_COUNTER_ID1, - CEF_TRACE_COPY_COUNTER_ID1, - CEF_TRACE_COUNTER_ID2, - CEF_TRACE_COPY_COUNTER_ID2, - CEF_TRACE_EVENT_ASYNC_BEGIN0, - CEF_TRACE_EVENT_ASYNC_BEGIN1, - CEF_TRACE_EVENT_ASYNC_BEGIN2, - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN0, - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1, - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2, - CEF_TRACE_EVENT_ASYNC_STEP_INTO0, - CEF_TRACE_EVENT_ASYNC_STEP_INTO1, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO0, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO1, - CEF_TRACE_EVENT_ASYNC_STEP_PAST0, - CEF_TRACE_EVENT_ASYNC_STEP_PAST1, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST0, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST1, - CEF_TRACE_EVENT_ASYNC_END0, - CEF_TRACE_EVENT_ASYNC_END1, - CEF_TRACE_EVENT_ASYNC_END2, - CEF_TRACE_EVENT_COPY_ASYNC_END0, - CEF_TRACE_EVENT_COPY_ASYNC_END1, - CEF_TRACE_EVENT_COPY_ASYNC_END2 + TT_TRACE_EVENT0, + TT_TRACE_EVENT1, + TT_TRACE_EVENT2, + TT_TRACE_EVENT_INSTANT0, + TT_TRACE_EVENT_INSTANT1, + TT_TRACE_EVENT_INSTANT2, + TT_TRACE_EVENT_COPY_INSTANT0, + TT_TRACE_EVENT_COPY_INSTANT1, + TT_TRACE_EVENT_COPY_INSTANT2, + TT_TRACE_EVENT_BEGIN0, + TT_TRACE_EVENT_BEGIN1, + TT_TRACE_EVENT_BEGIN2, + TT_TRACE_EVENT_COPY_BEGIN0, + TT_TRACE_EVENT_COPY_BEGIN1, + TT_TRACE_EVENT_COPY_BEGIN2, + TT_TRACE_EVENT_END0, + TT_TRACE_EVENT_END1, + TT_TRACE_EVENT_END2, + TT_TRACE_EVENT_COPY_END0, + TT_TRACE_EVENT_COPY_END1, + TT_TRACE_EVENT_COPY_END2, + TT_TRACE_COUNTER1, + TT_TRACE_COPY_COUNTER1, + TT_TRACE_COUNTER2, + TT_TRACE_COPY_COUNTER2, + TT_TRACE_COUNTER_ID1, + TT_TRACE_COPY_COUNTER_ID1, + TT_TRACE_COUNTER_ID2, + TT_TRACE_COPY_COUNTER_ID2, + TT_TRACE_EVENT_ASYNC_BEGIN0, + TT_TRACE_EVENT_ASYNC_BEGIN1, + TT_TRACE_EVENT_ASYNC_BEGIN2, + TT_TRACE_EVENT_COPY_ASYNC_BEGIN0, + TT_TRACE_EVENT_COPY_ASYNC_BEGIN1, + TT_TRACE_EVENT_COPY_ASYNC_BEGIN2, + TT_TRACE_EVENT_ASYNC_STEP_INTO0, + TT_TRACE_EVENT_ASYNC_STEP_INTO1, + TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0, + TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1, + TT_TRACE_EVENT_ASYNC_STEP_PAST0, + TT_TRACE_EVENT_ASYNC_STEP_PAST1, + TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0, + TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1, + TT_TRACE_EVENT_ASYNC_END0, + TT_TRACE_EVENT_ASYNC_END1, + TT_TRACE_EVENT_ASYNC_END2, + TT_TRACE_EVENT_COPY_ASYNC_END0, + TT_TRACE_EVENT_COPY_ASYNC_END1, + TT_TRACE_EVENT_COPY_ASYNC_END2 }; const char kTraceTestCategory[] = "test_category"; @@ -104,217 +104,213 @@ class TracingTestHandler : public CefEndTracingCallback, EXPECT_UI_THREAD(); switch (type_) { - case CEF_TRACE_EVENT0: { - CEF_TRACE_EVENT0(kTraceTestCategory, "CEF_TRACE_EVENT0"); + case TT_TRACE_EVENT0: { + TRACE_EVENT0(kTraceTestCategory, "TT_TRACE_EVENT0"); } break; - case CEF_TRACE_EVENT1: { - CEF_TRACE_EVENT1(kTraceTestCategory, "CEF_TRACE_EVENT1", "arg1", 1); + case TT_TRACE_EVENT1: { + TRACE_EVENT1(kTraceTestCategory, "TT_TRACE_EVENT1", "arg1", 1); } break; - case CEF_TRACE_EVENT2: { - CEF_TRACE_EVENT2(kTraceTestCategory, "CEF_TRACE_EVENT2", "arg1", 1, - "arg2", 2); + case TT_TRACE_EVENT2: { + TRACE_EVENT2(kTraceTestCategory, "TT_TRACE_EVENT2", "arg1", 1, + "arg2", 2); } break; - case CEF_TRACE_EVENT_INSTANT0: - CEF_TRACE_EVENT_INSTANT0(kTraceTestCategory, - "CEF_TRACE_EVENT_INSTANT0"); + case TT_TRACE_EVENT_INSTANT0: + TRACE_EVENT_INSTANT0(kTraceTestCategory, + "TT_TRACE_EVENT_INSTANT0"); break; - case CEF_TRACE_EVENT_INSTANT1: - CEF_TRACE_EVENT_INSTANT1(kTraceTestCategory, "CEF_TRACE_EVENT_INSTANT1", - "arg1", 1); - break; - case CEF_TRACE_EVENT_INSTANT2: - CEF_TRACE_EVENT_INSTANT2(kTraceTestCategory, "CEF_TRACE_EVENT_INSTANT2", - "arg1", 1, "arg2", 2); - break; - case CEF_TRACE_EVENT_COPY_INSTANT0: - CEF_TRACE_EVENT_COPY_INSTANT0(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_INSTANT0"); - break; - case CEF_TRACE_EVENT_COPY_INSTANT1: - CEF_TRACE_EVENT_COPY_INSTANT1(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_INSTANT1", - "arg1", 1); - break; - case CEF_TRACE_EVENT_COPY_INSTANT2: - CEF_TRACE_EVENT_COPY_INSTANT2(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_INSTANT2", - "arg1", 1, "arg2", 2); - break; - case CEF_TRACE_EVENT_BEGIN0: - CEF_TRACE_EVENT_BEGIN0(kTraceTestCategory, "CEF_TRACE_EVENT_BEGIN0"); - break; - case CEF_TRACE_EVENT_BEGIN1: - CEF_TRACE_EVENT_BEGIN1(kTraceTestCategory, "CEF_TRACE_EVENT_BEGIN1", - "arg1", 1); - break; - case CEF_TRACE_EVENT_BEGIN2: - CEF_TRACE_EVENT_BEGIN2(kTraceTestCategory, "CEF_TRACE_EVENT_BEGIN2", - "arg1", 1, "arg2", 2); - break; - case CEF_TRACE_EVENT_COPY_BEGIN0: - CEF_TRACE_EVENT_COPY_BEGIN0(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_BEGIN0"); - break; - case CEF_TRACE_EVENT_COPY_BEGIN1: - CEF_TRACE_EVENT_COPY_BEGIN1(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_BEGIN1", - "arg1", 1); - break; - case CEF_TRACE_EVENT_COPY_BEGIN2: - CEF_TRACE_EVENT_COPY_BEGIN2(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_BEGIN2", - "arg1", 1, "arg2", 2); - break; - case CEF_TRACE_EVENT_END0: - CEF_TRACE_EVENT_END0(kTraceTestCategory, "CEF_TRACE_EVENT_END0"); - break; - case CEF_TRACE_EVENT_END1: - CEF_TRACE_EVENT_END1(kTraceTestCategory, "CEF_TRACE_EVENT_END1", + case TT_TRACE_EVENT_INSTANT1: + TRACE_EVENT_INSTANT1(kTraceTestCategory, "TT_TRACE_EVENT_INSTANT1", "arg1", 1); break; - case CEF_TRACE_EVENT_END2: - CEF_TRACE_EVENT_END2(kTraceTestCategory, "CEF_TRACE_EVENT_END2", + case TT_TRACE_EVENT_INSTANT2: + TRACE_EVENT_INSTANT2(kTraceTestCategory, "TT_TRACE_EVENT_INSTANT2", "arg1", 1, "arg2", 2); break; - case CEF_TRACE_EVENT_COPY_END0: - CEF_TRACE_EVENT_COPY_END0(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_END0"); + case TT_TRACE_EVENT_COPY_INSTANT0: + TRACE_EVENT_COPY_INSTANT0(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_INSTANT0"); break; - case CEF_TRACE_EVENT_COPY_END1: - CEF_TRACE_EVENT_COPY_END1(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_END1", "arg1", 1); + case TT_TRACE_EVENT_COPY_INSTANT1: + TRACE_EVENT_COPY_INSTANT1(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_INSTANT1", + "arg1", 1); break; - case CEF_TRACE_EVENT_COPY_END2: - CEF_TRACE_EVENT_COPY_END2(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_END2", "arg1", 1, - "arg2", 2); + case TT_TRACE_EVENT_COPY_INSTANT2: + TRACE_EVENT_COPY_INSTANT2(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_INSTANT2", + "arg1", 1, "arg2", 2); break; - case CEF_TRACE_COUNTER1: - CEF_TRACE_COUNTER1(kTraceTestCategory, "CEF_TRACE_COUNTER1", 5); + case TT_TRACE_EVENT_BEGIN0: + TRACE_EVENT_BEGIN0(kTraceTestCategory, "TT_TRACE_EVENT_BEGIN0"); break; - case CEF_TRACE_COPY_COUNTER1: - CEF_TRACE_COPY_COUNTER1(kTraceTestCategory, "CEF_TRACE_COPY_COUNTER1", - 5); + case TT_TRACE_EVENT_BEGIN1: + TRACE_EVENT_BEGIN1(kTraceTestCategory, "TT_TRACE_EVENT_BEGIN1", + "arg1", 1); break; - case CEF_TRACE_COUNTER2: - CEF_TRACE_COUNTER2(kTraceTestCategory, "CEF_TRACE_COUNTER2", "val1", 5, - "val2", 10); + case TT_TRACE_EVENT_BEGIN2: + TRACE_EVENT_BEGIN2(kTraceTestCategory, "TT_TRACE_EVENT_BEGIN2", + "arg1", 1, "arg2", 2); break; - case CEF_TRACE_COPY_COUNTER2: - CEF_TRACE_COPY_COUNTER2(kTraceTestCategory, "CEF_TRACE_COPY_COUNTER2", - "val1", 5, "val2", 10); + case TT_TRACE_EVENT_COPY_BEGIN0: + TRACE_EVENT_COPY_BEGIN0(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_BEGIN0"); break; - case CEF_TRACE_COUNTER_ID1: - CEF_TRACE_COUNTER_ID1(kTraceTestCategory, "CEF_TRACE_COUNTER_ID1", 100, - 5); + case TT_TRACE_EVENT_COPY_BEGIN1: + TRACE_EVENT_COPY_BEGIN1(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_BEGIN1", + "arg1", 1); break; - case CEF_TRACE_COPY_COUNTER_ID1: - CEF_TRACE_COPY_COUNTER_ID1(kTraceTestCategory, - "CEF_TRACE_COPY_COUNTER_ID1", 100, 5); + case TT_TRACE_EVENT_COPY_BEGIN2: + TRACE_EVENT_COPY_BEGIN2(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_BEGIN2", + "arg1", 1, "arg2", 2); break; - case CEF_TRACE_COUNTER_ID2: - CEF_TRACE_COUNTER_ID2(kTraceTestCategory, "CEF_TRACE_COUNTER_ID2", 100, - "val1", 5, "val2", 10); + case TT_TRACE_EVENT_END0: + TRACE_EVENT_END0(kTraceTestCategory, "TT_TRACE_EVENT_END0"); break; - case CEF_TRACE_COPY_COUNTER_ID2: - CEF_TRACE_COPY_COUNTER_ID2(kTraceTestCategory, - "CEF_TRACE_COPY_COUNTER_ID2", 100, - "val1", 5, "val2", 10); + case TT_TRACE_EVENT_END1: + TRACE_EVENT_END1(kTraceTestCategory, "TT_TRACE_EVENT_END1", + "arg1", 1); break; - case CEF_TRACE_EVENT_ASYNC_BEGIN0: - CEF_TRACE_EVENT_ASYNC_BEGIN0(kTraceTestCategory, - "CEF_TRACE_EVENT_ASYNC_BEGIN0", 100); + case TT_TRACE_EVENT_END2: + TRACE_EVENT_END2(kTraceTestCategory, "TT_TRACE_EVENT_END2", + "arg1", 1, "arg2", 2); break; - case CEF_TRACE_EVENT_ASYNC_BEGIN1: - CEF_TRACE_EVENT_ASYNC_BEGIN1(kTraceTestCategory, - "CEF_TRACE_EVENT_ASYNC_BEGIN1", 100, - "arg1", 1); + case TT_TRACE_EVENT_COPY_END0: + TRACE_EVENT_COPY_END0(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_END0"); break; - case CEF_TRACE_EVENT_ASYNC_BEGIN2: - CEF_TRACE_EVENT_ASYNC_BEGIN2(kTraceTestCategory, - "CEF_TRACE_EVENT_ASYNC_BEGIN2", - 100, "arg1", 1, "arg2", 2); + case TT_TRACE_EVENT_COPY_END1: + TRACE_EVENT_COPY_END1(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_END1", "arg1", 1); break; - case CEF_TRACE_EVENT_COPY_ASYNC_BEGIN0: - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN0(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_ASYNC_BEGIN0", - 100); + case TT_TRACE_EVENT_COPY_END2: + TRACE_EVENT_COPY_END2(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_END2", "arg1", 1, "arg2", 2); break; - case CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1: - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1", - 100, "arg1", 1); + case TT_TRACE_COUNTER1: + TRACE_COUNTER1(kTraceTestCategory, "TT_TRACE_COUNTER1", 5); break; - case CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2: - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2", - 100, "arg1", 1, "arg2", 2); + case TT_TRACE_COPY_COUNTER1: + TRACE_COPY_COUNTER1(kTraceTestCategory, "TT_TRACE_COPY_COUNTER1", 5); break; - case CEF_TRACE_EVENT_ASYNC_STEP_INTO0: - CEF_TRACE_EVENT_ASYNC_STEP_INTO0( - kTraceTestCategory, "CEF_TRACE_EVENT_ASYNC_STEP_INTO0", 100, 1000); + case TT_TRACE_COUNTER2: + TRACE_COUNTER2(kTraceTestCategory, "TT_TRACE_COUNTER2", "val1", 5, + "val2", 10); break; - case CEF_TRACE_EVENT_ASYNC_STEP_INTO1: - CEF_TRACE_EVENT_ASYNC_STEP_INTO1( - kTraceTestCategory, "CEF_TRACE_EVENT_ASYNC_STEP_INTO1", 100, 1000, + case TT_TRACE_COPY_COUNTER2: + TRACE_COPY_COUNTER2(kTraceTestCategory, "TT_TRACE_COPY_COUNTER2", + "val1", 5, "val2", 10); + break; + case TT_TRACE_COUNTER_ID1: + TRACE_COUNTER_ID1(kTraceTestCategory, "TT_TRACE_COUNTER_ID1", 100, 5); + break; + case TT_TRACE_COPY_COUNTER_ID1: + TRACE_COPY_COUNTER_ID1(kTraceTestCategory, + "TT_TRACE_COPY_COUNTER_ID1", 100, 5); + break; + case TT_TRACE_COUNTER_ID2: + TRACE_COUNTER_ID2(kTraceTestCategory, "TT_TRACE_COUNTER_ID2", 100, + "val1", 5, "val2", 10); + break; + case TT_TRACE_COPY_COUNTER_ID2: + TRACE_COPY_COUNTER_ID2(kTraceTestCategory, + "TT_TRACE_COPY_COUNTER_ID2", 100, + "val1", 5, "val2", 10); + break; + case TT_TRACE_EVENT_ASYNC_BEGIN0: + TRACE_EVENT_ASYNC_BEGIN0(kTraceTestCategory, + "TT_TRACE_EVENT_ASYNC_BEGIN0", 100); + break; + case TT_TRACE_EVENT_ASYNC_BEGIN1: + TRACE_EVENT_ASYNC_BEGIN1(kTraceTestCategory, + "TT_TRACE_EVENT_ASYNC_BEGIN1", 100, "arg1", 1); + break; + case TT_TRACE_EVENT_ASYNC_BEGIN2: + TRACE_EVENT_ASYNC_BEGIN2(kTraceTestCategory, + "TT_TRACE_EVENT_ASYNC_BEGIN2", + 100, "arg1", 1, "arg2", 2); + break; + case TT_TRACE_EVENT_COPY_ASYNC_BEGIN0: + TRACE_EVENT_COPY_ASYNC_BEGIN0(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_ASYNC_BEGIN0", + 100); + break; + case TT_TRACE_EVENT_COPY_ASYNC_BEGIN1: + TRACE_EVENT_COPY_ASYNC_BEGIN1(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_ASYNC_BEGIN1", + 100, "arg1", 1); + break; + case TT_TRACE_EVENT_COPY_ASYNC_BEGIN2: + TRACE_EVENT_COPY_ASYNC_BEGIN2(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_ASYNC_BEGIN2", + 100, "arg1", 1, "arg2", 2); + break; + case TT_TRACE_EVENT_ASYNC_STEP_INTO0: + TRACE_EVENT_ASYNC_STEP_INTO0( + kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_INTO0", 100, 1000); + break; + case TT_TRACE_EVENT_ASYNC_STEP_INTO1: + TRACE_EVENT_ASYNC_STEP_INTO1( + kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_INTO1", 100, 1000, "arg1", 1); break; - case CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO0: - CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO0( - kTraceTestCategory, "CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO0", 100, + case TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0: + TRACE_EVENT_COPY_ASYNC_STEP_INTO0( + kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0", 100, 1000); break; - case CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO1: - CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO1( - kTraceTestCategory, "CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO1", 100, + case TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1: + TRACE_EVENT_COPY_ASYNC_STEP_INTO1( + kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1", 100, 1000, "arg1", 1); break; - case CEF_TRACE_EVENT_ASYNC_STEP_PAST0: - CEF_TRACE_EVENT_ASYNC_STEP_PAST0( - kTraceTestCategory, "CEF_TRACE_EVENT_ASYNC_STEP_PAST0", 100, 1000); + case TT_TRACE_EVENT_ASYNC_STEP_PAST0: + TRACE_EVENT_ASYNC_STEP_PAST0( + kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_PAST0", 100, 1000); break; - case CEF_TRACE_EVENT_ASYNC_STEP_PAST1: - CEF_TRACE_EVENT_ASYNC_STEP_PAST1( - kTraceTestCategory, "CEF_TRACE_EVENT_ASYNC_STEP_PAST1", 100, 1000, + case TT_TRACE_EVENT_ASYNC_STEP_PAST1: + TRACE_EVENT_ASYNC_STEP_PAST1( + kTraceTestCategory, "TT_TRACE_EVENT_ASYNC_STEP_PAST1", 100, 1000, "arg1", 1); break; - case CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST0: - CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST0( - kTraceTestCategory, "CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST0", 100, + case TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0: + TRACE_EVENT_COPY_ASYNC_STEP_PAST0( + kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0", 100, 1000); break; - case CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST1: - CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST1( - kTraceTestCategory, "CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST1", 100, + case TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1: + TRACE_EVENT_COPY_ASYNC_STEP_PAST1( + kTraceTestCategory, "TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1", 100, 1000, "arg1", 1); break; - case CEF_TRACE_EVENT_ASYNC_END0: - CEF_TRACE_EVENT_ASYNC_END0(kTraceTestCategory, - "CEF_TRACE_EVENT_ASYNC_END0", 100); + case TT_TRACE_EVENT_ASYNC_END0: + TRACE_EVENT_ASYNC_END0(kTraceTestCategory, + "TT_TRACE_EVENT_ASYNC_END0", 100); break; - case CEF_TRACE_EVENT_ASYNC_END1: - CEF_TRACE_EVENT_ASYNC_END1(kTraceTestCategory, - "CEF_TRACE_EVENT_ASYNC_END1", 100, - "arg1", 1); + case TT_TRACE_EVENT_ASYNC_END1: + TRACE_EVENT_ASYNC_END1(kTraceTestCategory, + "TT_TRACE_EVENT_ASYNC_END1", 100, + "arg1", 1); break; - case CEF_TRACE_EVENT_ASYNC_END2: - CEF_TRACE_EVENT_ASYNC_END2(kTraceTestCategory, - "CEF_TRACE_EVENT_ASYNC_END2", 100, - "arg1", 1, "arg2", 2); - case CEF_TRACE_EVENT_COPY_ASYNC_END0: - CEF_TRACE_EVENT_COPY_ASYNC_END0(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_ASYNC_END0", - 100); + case TT_TRACE_EVENT_ASYNC_END2: + TRACE_EVENT_ASYNC_END2(kTraceTestCategory, + "TT_TRACE_EVENT_ASYNC_END2", 100, + "arg1", 1, "arg2", 2); + case TT_TRACE_EVENT_COPY_ASYNC_END0: + TRACE_EVENT_COPY_ASYNC_END0(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_ASYNC_END0", + 100); break; - case CEF_TRACE_EVENT_COPY_ASYNC_END1: - CEF_TRACE_EVENT_COPY_ASYNC_END1(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_ASYNC_END1", - 100, "arg1", 1); + case TT_TRACE_EVENT_COPY_ASYNC_END1: + TRACE_EVENT_COPY_ASYNC_END1(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_ASYNC_END1", + 100, "arg1", 1); break; - case CEF_TRACE_EVENT_COPY_ASYNC_END2: - CEF_TRACE_EVENT_COPY_ASYNC_END2(kTraceTestCategory, - "CEF_TRACE_EVENT_COPY_ASYNC_END2", - 100, "arg1", 1, "arg2", 2); + case TT_TRACE_EVENT_COPY_ASYNC_END2: + TRACE_EVENT_COPY_ASYNC_END2(kTraceTestCategory, + "TT_TRACE_EVENT_COPY_ASYNC_END2", + 100, "arg1", 1, "arg2", 2); break; } @@ -358,64 +354,64 @@ class TracingTestHandler : public CefEndTracingCallback, } // Define the tests. -TRACING_TEST(TraceEvent0, CEF_TRACE_EVENT0); -TRACING_TEST(TraceEvent1, CEF_TRACE_EVENT1); -TRACING_TEST(TraceEvent2, CEF_TRACE_EVENT2); -TRACING_TEST(TraceEventInstant0, CEF_TRACE_EVENT_INSTANT0); -TRACING_TEST(TraceEventInstant1, CEF_TRACE_EVENT_INSTANT1); -TRACING_TEST(TraceEventInstant2, CEF_TRACE_EVENT_INSTANT2); -TRACING_TEST(TraceEventCopyInstant0, CEF_TRACE_EVENT_COPY_INSTANT0); -TRACING_TEST(TraceEventCopyInstant1, CEF_TRACE_EVENT_COPY_INSTANT1); -TRACING_TEST(TraceEventCopyInstant2, CEF_TRACE_EVENT_COPY_INSTANT2); -TRACING_TEST(TraceEventBegin0, CEF_TRACE_EVENT_BEGIN0); -TRACING_TEST(TraceEventBegin1, CEF_TRACE_EVENT_BEGIN1); -TRACING_TEST(TraceEventBegin2, CEF_TRACE_EVENT_BEGIN2); -TRACING_TEST(TraceEventCopyBegin0, CEF_TRACE_EVENT_COPY_BEGIN0); -TRACING_TEST(TraceEventCopyBegin1, CEF_TRACE_EVENT_COPY_BEGIN1); -TRACING_TEST(TraceEventCopyBegin2, CEF_TRACE_EVENT_COPY_BEGIN2); -TRACING_TEST(TraceEventEnd0, CEF_TRACE_EVENT_END0); -TRACING_TEST(TraceEventEnd1, CEF_TRACE_EVENT_END1); -TRACING_TEST(TraceEventEnd2, CEF_TRACE_EVENT_END2); -TRACING_TEST(TraceEventCopyEnd0, CEF_TRACE_EVENT_COPY_END0); -TRACING_TEST(TraceEventCopyEnd1, CEF_TRACE_EVENT_COPY_END1); -TRACING_TEST(TraceEventCopyEnd2, CEF_TRACE_EVENT_COPY_END1); -TRACING_TEST(TraceCounter1, CEF_TRACE_COUNTER1); -TRACING_TEST(TraceCopyCounter1, CEF_TRACE_COPY_COUNTER1); -TRACING_TEST(TraceCounter2, CEF_TRACE_COUNTER2); -TRACING_TEST(TraceCopyCounter2, CEF_TRACE_COPY_COUNTER2); -TRACING_TEST(TraceCounterId1, CEF_TRACE_COUNTER_ID1); -TRACING_TEST(TraceCopyCounterId1, CEF_TRACE_COPY_COUNTER_ID1); -TRACING_TEST(TraceCounterId2, CEF_TRACE_COUNTER_ID2); -TRACING_TEST(TraceCopyCounterId2, CEF_TRACE_COPY_COUNTER_ID1); -TRACING_TEST(TraceEventAsyncBegin0, CEF_TRACE_EVENT_ASYNC_BEGIN0); -TRACING_TEST(TraceEventAsyncBegin1, CEF_TRACE_EVENT_ASYNC_BEGIN1); -TRACING_TEST(TraceEventAsyncBegin2, CEF_TRACE_EVENT_ASYNC_BEGIN2); +TRACING_TEST(TraceEvent0, TT_TRACE_EVENT0); +TRACING_TEST(TraceEvent1, TT_TRACE_EVENT1); +TRACING_TEST(TraceEvent2, TT_TRACE_EVENT2); +TRACING_TEST(TraceEventInstant0, TT_TRACE_EVENT_INSTANT0); +TRACING_TEST(TraceEventInstant1, TT_TRACE_EVENT_INSTANT1); +TRACING_TEST(TraceEventInstant2, TT_TRACE_EVENT_INSTANT2); +TRACING_TEST(TraceEventCopyInstant0, TT_TRACE_EVENT_COPY_INSTANT0); +TRACING_TEST(TraceEventCopyInstant1, TT_TRACE_EVENT_COPY_INSTANT1); +TRACING_TEST(TraceEventCopyInstant2, TT_TRACE_EVENT_COPY_INSTANT2); +TRACING_TEST(TraceEventBegin0, TT_TRACE_EVENT_BEGIN0); +TRACING_TEST(TraceEventBegin1, TT_TRACE_EVENT_BEGIN1); +TRACING_TEST(TraceEventBegin2, TT_TRACE_EVENT_BEGIN2); +TRACING_TEST(TraceEventCopyBegin0, TT_TRACE_EVENT_COPY_BEGIN0); +TRACING_TEST(TraceEventCopyBegin1, TT_TRACE_EVENT_COPY_BEGIN1); +TRACING_TEST(TraceEventCopyBegin2, TT_TRACE_EVENT_COPY_BEGIN2); +TRACING_TEST(TraceEventEnd0, TT_TRACE_EVENT_END0); +TRACING_TEST(TraceEventEnd1, TT_TRACE_EVENT_END1); +TRACING_TEST(TraceEventEnd2, TT_TRACE_EVENT_END2); +TRACING_TEST(TraceEventCopyEnd0, TT_TRACE_EVENT_COPY_END0); +TRACING_TEST(TraceEventCopyEnd1, TT_TRACE_EVENT_COPY_END1); +TRACING_TEST(TraceEventCopyEnd2, TT_TRACE_EVENT_COPY_END1); +TRACING_TEST(TraceCounter1, TT_TRACE_COUNTER1); +TRACING_TEST(TraceCopyCounter1, TT_TRACE_COPY_COUNTER1); +TRACING_TEST(TraceCounter2, TT_TRACE_COUNTER2); +TRACING_TEST(TraceCopyCounter2, TT_TRACE_COPY_COUNTER2); +TRACING_TEST(TraceCounterId1, TT_TRACE_COUNTER_ID1); +TRACING_TEST(TraceCopyCounterId1, TT_TRACE_COPY_COUNTER_ID1); +TRACING_TEST(TraceCounterId2, TT_TRACE_COUNTER_ID2); +TRACING_TEST(TraceCopyCounterId2, TT_TRACE_COPY_COUNTER_ID1); +TRACING_TEST(TraceEventAsyncBegin0, TT_TRACE_EVENT_ASYNC_BEGIN0); +TRACING_TEST(TraceEventAsyncBegin1, TT_TRACE_EVENT_ASYNC_BEGIN1); +TRACING_TEST(TraceEventAsyncBegin2, TT_TRACE_EVENT_ASYNC_BEGIN2); TRACING_TEST(TraceEventCopyAsyncBegin0, - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN0); + TT_TRACE_EVENT_COPY_ASYNC_BEGIN0); TRACING_TEST(TraceEventCopyAsyncBegin1, - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN1); + TT_TRACE_EVENT_COPY_ASYNC_BEGIN1); TRACING_TEST(TraceEventCopyAsyncBegin2, - CEF_TRACE_EVENT_COPY_ASYNC_BEGIN2); + TT_TRACE_EVENT_COPY_ASYNC_BEGIN2); TRACING_TEST(TraceEventAsyncStepInto0, - CEF_TRACE_EVENT_ASYNC_STEP_INTO0); + TT_TRACE_EVENT_ASYNC_STEP_INTO0); TRACING_TEST(TraceEventAsyncStepInto1, - CEF_TRACE_EVENT_ASYNC_STEP_INTO1); + TT_TRACE_EVENT_ASYNC_STEP_INTO1); TRACING_TEST(TraceEventCopyAsyncStepInto0, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO0); + TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO0); TRACING_TEST(TraceEventCopyAsyncStepInto1, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_INTO1); + TT_TRACE_EVENT_COPY_ASYNC_STEP_INTO1); TRACING_TEST(TraceEventAsyncStepPast0, - CEF_TRACE_EVENT_ASYNC_STEP_PAST0); + TT_TRACE_EVENT_ASYNC_STEP_PAST0); TRACING_TEST(TraceEventAsyncStepPast1, - CEF_TRACE_EVENT_ASYNC_STEP_PAST1); + TT_TRACE_EVENT_ASYNC_STEP_PAST1); TRACING_TEST(TraceEventCopyAsyncStepPast0, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST0); + TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST0); TRACING_TEST(TraceEventCopyAsyncStepPast1, - CEF_TRACE_EVENT_COPY_ASYNC_STEP_PAST1); -TRACING_TEST(TraceEventAsyncEnd0, CEF_TRACE_EVENT_ASYNC_END0); -TRACING_TEST(TraceEventAsyncEnd1, CEF_TRACE_EVENT_ASYNC_END1); -TRACING_TEST(TraceEventAsyncEnd2, CEF_TRACE_EVENT_ASYNC_END2); -TRACING_TEST(TraceEventCopyAsyncEnd0, CEF_TRACE_EVENT_COPY_ASYNC_END0); + TT_TRACE_EVENT_COPY_ASYNC_STEP_PAST1); +TRACING_TEST(TraceEventAsyncEnd0, TT_TRACE_EVENT_ASYNC_END0); +TRACING_TEST(TraceEventAsyncEnd1, TT_TRACE_EVENT_ASYNC_END1); +TRACING_TEST(TraceEventAsyncEnd2, TT_TRACE_EVENT_ASYNC_END2); +TRACING_TEST(TraceEventCopyAsyncEnd0, TT_TRACE_EVENT_COPY_ASYNC_END0); TEST(TracingTest, NowFromSystemTraceTime) { diff --git a/tests/unittests/urlrequest_unittest.cc b/tests/unittests/urlrequest_unittest.cc index 26cc66f93..1cafbd17c 100644 --- a/tests/unittests/urlrequest_unittest.cc +++ b/tests/unittests/urlrequest_unittest.cc @@ -848,7 +848,7 @@ class RequestRendererTest : public ClientApp::RenderDelegate, public RequestTestRunner::Delegate { public: RequestRendererTest() - : ALLOW_THIS_IN_INITIALIZER_LIST(test_runner_(this, false)) { + : test_runner_(this, false) { } virtual bool OnProcessMessageReceived( @@ -913,7 +913,7 @@ class RequestTestHandler : public TestHandler, : test_mode_(test_mode), test_in_browser_(test_in_browser), test_url_(test_url), - ALLOW_THIS_IN_INITIALIZER_LIST(test_runner_(this, true)) { + test_runner_(this, true) { } virtual void RunTest() OVERRIDE { diff --git a/tools/cef_api_hash.py b/tools/cef_api_hash.py index 36c71010a..df5c13505 100644 --- a/tools/cef_api_hash.py +++ b/tools/cef_api_hash.py @@ -30,18 +30,17 @@ class cef_api_hash: self.platform_files = { "windows": [ - "internal/cef_types_win.h" + "internal/cef_types_win.h", ], "macosx": [ "internal/cef_types_mac.h", ], "linux": [ - "internal/cef_types_linux.h" + "internal/cef_types_linux.h", ] }; self.included_files = [ - "cef_trace_event.h" ]; self.excluded_files = [ diff --git a/tools/make_ctocpp_impl.py b/tools/make_ctocpp_impl.py index 4cae75010..197ea6d77 100644 --- a/tools/make_ctocpp_impl.py +++ b/tools/make_ctocpp_impl.py @@ -65,7 +65,7 @@ def make_ctocpp_function_impl_new(clsname, name, func): result += '\n const char* api_hash = cef_api_hash(0);'\ '\n if (strcmp(api_hash, CEF_API_HASH_PLATFORM)) {'\ '\n // The libcef API hash does not match the current header API hash.'\ - '\n DCHECK(false);'\ + '\n NOTREACHED();'\ '\n return'+retval_default+';'\ '\n }\n' diff --git a/tools/make_version_header.py b/tools/make_version_header.py index 88fb57087..84d49f52a 100644 --- a/tools/make_version_header.py +++ b/tools/make_version_header.py @@ -116,10 +116,10 @@ def write_svn_header(header, chrome_version, cef_version, cpp_header_dir): '#define DO_MAKE_STRING(p) #p\n'+\ '#define MAKE_STRING(p) DO_MAKE_STRING(p)\n\n'+\ '#ifndef APSTUDIO_HIDDEN_SYMBOLS\n\n'\ + '#include "include/internal/cef_export.h"\n\n'+\ '#ifdef __cplusplus\n'+\ 'extern "C" {\n'+\ '#endif\n\n'+\ - '#include "internal/cef_export.h"\n\n'+\ '// The API hash is created by analyzing CEF header files for C API type\n'+\ '// definitions. The hash value will change when header files are modified\n'+\ '// in a way that may cause binary incompatibility with other builds. The\n'+\