Remove base/guid and unused example files Change-Id: I7d4ce104918fd9148d49917cc4d6033b9a38fd38 Reviewed-on: https://gn-review.googlesource.com/1524 Commit-Queue: Scott Graham <scottmg@chromium.org> Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/base/check_example.cc b/base/check_example.cc deleted file mode 100644 index 7b9d8e6..0000000 --- a/base/check_example.cc +++ /dev/null
@@ -1,37 +0,0 @@ -// 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. - -// This file is meant for analyzing the code generated by the CHECK -// macros in a small executable file that's easy to disassemble. - -#include "base/compiler_specific.h" -#include "base/logging.h" - -// An official build shouldn't generate code to print out messages for -// the CHECK* macros, nor should it have the strings in the -// executable. It is also important that the CHECK() function collapse to the -// same implementation as RELEASE_ASSERT(), in particular on Windows x86. -// Historically, the stream eating caused additional unnecessary instructions. -// See https://crbug.com/672699. - -#define BLINK_RELEASE_ASSERT_EQUIVALENT(assertion) \ - (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0) - -void DoCheck(bool b) { - CHECK(b) << "DoCheck " << b; -} - -void DoBlinkReleaseAssert(bool b) { - BLINK_RELEASE_ASSERT_EQUIVALENT(b); -} - -void DoCheckEq(int x, int y) { - CHECK_EQ(x, y); -} - -int main(int argc, const char* argv[]) { - DoCheck(argc > 1); - DoCheckEq(argc, 1); - DoBlinkReleaseAssert(argc > 1); -}
diff --git a/base/export_template.h b/base/export_template.h deleted file mode 100644 index aac8b7c..0000000 --- a/base/export_template.h +++ /dev/null
@@ -1,163 +0,0 @@ -// Copyright 2015 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. - -#ifndef BASE_EXPORT_TEMPLATE_H_ -#define BASE_EXPORT_TEMPLATE_H_ - -// Synopsis -// -// This header provides macros for using FOO_EXPORT macros with explicit -// template instantiation declarations and definitions. -// Generally, the FOO_EXPORT macros are used at declarations, -// and GCC requires them to be used at explicit instantiation declarations, -// but MSVC requires __declspec(dllexport) to be used at the explicit -// instantiation definitions instead. - -// Usage -// -// In a header file, write: -// -// extern template class EXPORT_TEMPLATE_DECLARE(FOO_EXPORT) foo<bar>; -// -// In a source file, write: -// -// template class EXPORT_TEMPLATE_DEFINE(FOO_EXPORT) foo<bar>; - -// Implementation notes -// -// The implementation of this header uses some subtle macro semantics to -// detect what the provided FOO_EXPORT value was defined as and then -// to dispatch to appropriate macro definitions. Unfortunately, -// MSVC's C preprocessor is rather non-compliant and requires special -// care to make it work. -// -// Issue 1. -// -// #define F(x) -// F() -// -// MSVC emits warning C4003 ("not enough actual parameters for macro -// 'F'), even though it's a valid macro invocation. This affects the -// macros below that take just an "export" parameter, because export -// may be empty. -// -// As a workaround, we can add a dummy parameter and arguments: -// -// #define F(x,_) -// F(,) -// -// Issue 2. -// -// #define F(x) G##x -// #define Gj() ok -// F(j()) -// -// The correct replacement for "F(j())" is "ok", but MSVC replaces it -// with "Gj()". As a workaround, we can pass the result to an -// identity macro to force MSVC to look for replacements again. (This -// is why EXPORT_TEMPLATE_STYLE_3 exists.) - -#define EXPORT_TEMPLATE_DECLARE(export) \ - EXPORT_TEMPLATE_INVOKE(DECLARE, EXPORT_TEMPLATE_STYLE(export, ), export) -#define EXPORT_TEMPLATE_DEFINE(export) \ - EXPORT_TEMPLATE_INVOKE(DEFINE, EXPORT_TEMPLATE_STYLE(export, ), export) - -// INVOKE is an internal helper macro to perform parameter replacements -// and token pasting to chain invoke another macro. E.g., -// EXPORT_TEMPLATE_INVOKE(DECLARE, DEFAULT, FOO_EXPORT) -// will export to call -// EXPORT_TEMPLATE_DECLARE_DEFAULT(FOO_EXPORT, ) -// (but with FOO_EXPORT expanded too). -#define EXPORT_TEMPLATE_INVOKE(which, style, export) \ - EXPORT_TEMPLATE_INVOKE_2(which, style, export) -#define EXPORT_TEMPLATE_INVOKE_2(which, style, export) \ - EXPORT_TEMPLATE_##which##_##style(export, ) - -// Default style is to apply the FOO_EXPORT macro at declaration sites. -#define EXPORT_TEMPLATE_DECLARE_DEFAULT(export, _) export -#define EXPORT_TEMPLATE_DEFINE_DEFAULT(export, _) - -// The "MSVC hack" style is used when FOO_EXPORT is defined -// as __declspec(dllexport), which MSVC requires to be used at -// definition sites instead. -#define EXPORT_TEMPLATE_DECLARE_MSVC_HACK(export, _) -#define EXPORT_TEMPLATE_DEFINE_MSVC_HACK(export, _) export - -// EXPORT_TEMPLATE_STYLE is an internal helper macro that identifies which -// export style needs to be used for the provided FOO_EXPORT macro definition. -// "", "__attribute__(...)", and "__declspec(dllimport)" are mapped -// to "DEFAULT"; while "__declspec(dllexport)" is mapped to "MSVC_HACK". -// -// It's implemented with token pasting to transform the __attribute__ and -// __declspec annotations into macro invocations. E.g., if FOO_EXPORT is -// defined as "__declspec(dllimport)", it undergoes the following sequence of -// macro substitutions: -// EXPORT_TEMPLATE_STYLE(FOO_EXPORT, ) -// EXPORT_TEMPLATE_STYLE_2(__declspec(dllimport), ) -// EXPORT_TEMPLATE_STYLE_3(EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport)) -// EXPORT_TEMPLATE_STYLE_MATCH__declspec(dllimport) -// EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport -// DEFAULT -#define EXPORT_TEMPLATE_STYLE(export, _) EXPORT_TEMPLATE_STYLE_2(export, ) -#define EXPORT_TEMPLATE_STYLE_2(export, _) \ - EXPORT_TEMPLATE_STYLE_3( \ - EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA##export) -#define EXPORT_TEMPLATE_STYLE_3(style) style - -// Internal helper macros for EXPORT_TEMPLATE_STYLE. -// -// XXX: C++ reserves all identifiers containing "__" for the implementation, -// but "__attribute__" and "__declspec" already contain "__" and the token-paste -// operator can only add characters; not remove them. To minimize the risk of -// conflict with implementations, we include "foj3FJo5StF0OvIzl7oMxA" (a random -// 128-bit string, encoded in Base64) in the macro name. -#define EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA DEFAULT -#define EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__attribute__(...) \ - DEFAULT -#define EXPORT_TEMPLATE_STYLE_MATCH_foj3FJo5StF0OvIzl7oMxA__declspec(arg) \ - EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_##arg - -// Internal helper macros for EXPORT_TEMPLATE_STYLE. -#define EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllexport MSVC_HACK -#define EXPORT_TEMPLATE_STYLE_MATCH_DECLSPEC_dllimport DEFAULT - -// Sanity checks. -// -// EXPORT_TEMPLATE_TEST uses the same macro invocation pattern as -// EXPORT_TEMPLATE_DECLARE and EXPORT_TEMPLATE_DEFINE do to check that they're -// working correctly. When they're working correctly, the sequence of macro -// replacements should go something like: -// -// EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); -// -// static_assert(EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT, -// EXPORT_TEMPLATE_STYLE(__declspec(dllimport), ), -// __declspec(dllimport)), "__declspec(dllimport)"); -// -// static_assert(EXPORT_TEMPLATE_INVOKE(TEST_DEFAULT, -// DEFAULT, __declspec(dllimport)), "__declspec(dllimport)"); -// -// static_assert(EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT( -// __declspec(dllimport)), "__declspec(dllimport)"); -// -// static_assert(true, "__declspec(dllimport)"); -// -// When they're not working correctly, a syntax error should occur instead. -#define EXPORT_TEMPLATE_TEST(want, export) \ - static_assert(EXPORT_TEMPLATE_INVOKE( \ - TEST_##want, EXPORT_TEMPLATE_STYLE(export, ), export), \ - #export) -#define EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT(...) true -#define EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK(...) true - -EXPORT_TEMPLATE_TEST(DEFAULT, ); -EXPORT_TEMPLATE_TEST(DEFAULT, __attribute__((visibility("default")))); -EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport)); -EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); - -#undef EXPORT_TEMPLATE_TEST -#undef EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT -#undef EXPORT_TEMPLATE_TEST_MSVC_HACK_MSVC_HACK - -#endif // BASE_EXPORT_TEMPLATE_H_
diff --git a/base/guid.cc b/base/guid.cc deleted file mode 100644 index 2a23658..0000000 --- a/base/guid.cc +++ /dev/null
@@ -1,82 +0,0 @@ -// Copyright (c) 2012 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 "base/guid.h" - -#include <stddef.h> -#include <stdint.h> - -#include "base/rand_util.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" - -namespace base { - -namespace { - -bool IsLowerHexDigit(char c) { - return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'); -} - -bool IsValidGUIDInternal(const base::StringPiece& guid, bool strict) { - const size_t kGUIDLength = 36U; - if (guid.length() != kGUIDLength) - return false; - - for (size_t i = 0; i < guid.length(); ++i) { - char current = guid[i]; - if (i == 8 || i == 13 || i == 18 || i == 23) { - if (current != '-') - return false; - } else { - if ((strict && !IsLowerHexDigit(current)) || !IsHexDigit(current)) - return false; - } - } - - return true; -} - -} // namespace - -std::string GenerateGUID() { - uint64_t sixteen_bytes[2]; - // Use base::RandBytes instead of crypto::RandBytes, because crypto calls the - // base version directly, and to prevent the dependency from base/ to crypto/. - base::RandBytes(&sixteen_bytes, sizeof(sixteen_bytes)); - - // Set the GUID to version 4 as described in RFC 4122, section 4.4. - // The format of GUID version 4 must be xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, - // where y is one of [8, 9, A, B]. - - // Clear the version bits and set the version to 4: - sixteen_bytes[0] &= 0xffffffff'ffff0fffULL; - sixteen_bytes[0] |= 0x00000000'00004000ULL; - - // Set the two most significant bits (bits 6 and 7) of the - // clock_seq_hi_and_reserved to zero and one, respectively: - sixteen_bytes[1] &= 0x3fffffff'ffffffffULL; - sixteen_bytes[1] |= 0x80000000'00000000ULL; - - return RandomDataToGUIDString(sixteen_bytes); -} - -bool IsValidGUID(const base::StringPiece& guid) { - return IsValidGUIDInternal(guid, false /* strict */); -} - -bool IsValidGUIDOutputString(const base::StringPiece& guid) { - return IsValidGUIDInternal(guid, true /* strict */); -} - -std::string RandomDataToGUIDString(const uint64_t bytes[2]) { - return StringPrintf("%08x-%04x-%04x-%04x-%012llx", - static_cast<unsigned int>(bytes[0] >> 32), - static_cast<unsigned int>((bytes[0] >> 16) & 0x0000ffff), - static_cast<unsigned int>(bytes[0] & 0x0000ffff), - static_cast<unsigned int>(bytes[1] >> 48), - bytes[1] & 0x0000ffff'ffffffffULL); -} - -} // namespace base
diff --git a/base/guid.h b/base/guid.h deleted file mode 100644 index 9b0eb28..0000000 --- a/base/guid.h +++ /dev/null
@@ -1,45 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef BASE_GUID_H_ -#define BASE_GUID_H_ - -#include <stdint.h> - -#include <string> - -#include "base/base_export.h" -#include "base/strings/string_piece.h" -#include "build_config.h" - -namespace base { - -// Generate a 128-bit random GUID in the form of version 4 as described in -// RFC 4122, section 4.4. -// The format of GUID version 4 must be xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, -// where y is one of [8, 9, A, B]. -// The hexadecimal values "a" through "f" are output as lower case characters. -// -// A cryptographically secure random source will be used, but consider using -// UnguessableToken for greater type-safety if GUID format is unnecessary. -BASE_EXPORT std::string GenerateGUID(); - -// Returns true if the input string conforms to the version 4 GUID format. -// Note that this does NOT check if the hexadecimal values "a" through "f" -// are in lower case characters, as Version 4 RFC says onput they're -// case insensitive. (Use IsValidGUIDOutputString for checking if the -// given string is valid output string) -BASE_EXPORT bool IsValidGUID(const base::StringPiece& guid); - -// Returns true if the input string is valid version 4 GUID output string. -// This also checks if the hexadecimal values "a" through "f" are in lower -// case characters. -BASE_EXPORT bool IsValidGUIDOutputString(const base::StringPiece& guid); - -// For unit testing purposes only. Do not use outside of tests. -BASE_EXPORT std::string RandomDataToGUIDString(const uint64_t bytes[2]); - -} // namespace base - -#endif // BASE_GUID_H_
diff --git a/build/gen.py b/build/gen.py index 01fe35f..3bf6fac 100755 --- a/build/gen.py +++ b/build/gen.py
@@ -688,7 +688,6 @@ 'base/files/file_util_win.cc', 'base/files/file_win.cc', 'base/files/memory_mapped_file_win.cc', - 'base/guid.cc', 'base/logging_win.cc', 'base/message_loop/message_pump_win.cc', 'base/native_library_win.cc',