Remove barrier_closure, big_ending, os_compat_*
Change-Id: If2566a32c2802c4050993cdc97106e9b81d55c32
Reviewed-on: https://gn-review.googlesource.com/1543
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/base/PRESUBMIT.py b/base/PRESUBMIT.py
deleted file mode 100644
index 7fc8107..0000000
--- a/base/PRESUBMIT.py
+++ /dev/null
@@ -1,49 +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.
-
-"""Chromium presubmit script for src/base.
-
-See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
-for more details on the presubmit API built into depot_tools.
-"""
-
-def _CheckNoInterfacesInBase(input_api, output_api):
- """Checks to make sure no files in libbase.a have |@interface|."""
- pattern = input_api.re.compile(r'^\s*@interface', input_api.re.MULTILINE)
- files = []
- for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
- if (f.LocalPath().startswith('base/') and
- not "/ios/" in f.LocalPath() and
- not "/test/" in f.LocalPath() and
- not f.LocalPath().endswith('_unittest.mm') and
- not f.LocalPath().endswith('mac/sdk_forward_declarations.h')):
- contents = input_api.ReadFile(f)
- if pattern.search(contents):
- files.append(f)
-
- if len(files):
- return [ output_api.PresubmitError(
- 'Objective-C interfaces or categories are forbidden in libbase. ' +
- 'See http://groups.google.com/a/chromium.org/group/chromium-dev/' +
- 'browse_thread/thread/efb28c10435987fd',
- files) ]
- return []
-
-
-def _CommonChecks(input_api, output_api):
- """Checks common to both upload and commit."""
- results = []
- results.extend(_CheckNoInterfacesInBase(input_api, output_api))
- return results
-
-def CheckChangeOnUpload(input_api, output_api):
- results = []
- results.extend(_CommonChecks(input_api, output_api))
- return results
-
-
-def CheckChangeOnCommit(input_api, output_api):
- results = []
- results.extend(_CommonChecks(input_api, output_api))
- return results
diff --git a/base/barrier_closure.cc b/base/barrier_closure.cc
deleted file mode 100644
index 4426bb9..0000000
--- a/base/barrier_closure.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2013 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/barrier_closure.h"
-
-#include <utility>
-
-#include "base/atomic_ref_count.h"
-#include "base/bind.h"
-#include "base/memory/ptr_util.h"
-
-namespace base {
-namespace {
-
-// Maintains state for a BarrierClosure.
-class BarrierInfo {
- public:
- BarrierInfo(int num_callbacks_left, OnceClosure done_closure);
- void Run();
-
- private:
- AtomicRefCount num_callbacks_left_;
- OnceClosure done_closure_;
-};
-
-BarrierInfo::BarrierInfo(int num_callbacks, OnceClosure done_closure)
- : num_callbacks_left_(num_callbacks),
- done_closure_(std::move(done_closure)) {}
-
-void BarrierInfo::Run() {
- DCHECK(!num_callbacks_left_.IsZero());
- if (!num_callbacks_left_.Decrement())
- std::move(done_closure_).Run();
-}
-
-} // namespace
-
-RepeatingClosure BarrierClosure(int num_callbacks_left,
- OnceClosure done_closure) {
- DCHECK_GE(num_callbacks_left, 0);
-
- if (num_callbacks_left == 0)
- std::move(done_closure).Run();
-
- return BindRepeating(
- &BarrierInfo::Run,
- Owned(new BarrierInfo(num_callbacks_left, std::move(done_closure))));
-}
-
-} // namespace base
diff --git a/base/barrier_closure.h b/base/barrier_closure.h
deleted file mode 100644
index 282aa39..0000000
--- a/base/barrier_closure.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2013 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_BARRIER_CLOSURE_H_
-#define BASE_BARRIER_CLOSURE_H_
-
-#include "base/base_export.h"
-#include "base/callback.h"
-
-namespace base {
-
-// BarrierClosure executes |done_closure| after it has been invoked
-// |num_closures| times.
-//
-// If |num_closures| is 0, |done_closure| is executed immediately.
-//
-// BarrierClosure is thread-safe - the count of remaining closures is
-// maintained as a base::AtomicRefCount. |done_closure| will be run on
-// the thread that calls the final Run() on the returned closures.
-//
-// |done_closure| is also cleared on the final calling thread.
-BASE_EXPORT RepeatingClosure BarrierClosure(int num_closures,
- OnceClosure done_closure);
-
-} // namespace base
-
-#endif // BASE_BARRIER_CLOSURE_H_
diff --git a/base/big_endian.cc b/base/big_endian.cc
deleted file mode 100644
index 514581f..0000000
--- a/base/big_endian.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/big_endian.h"
-
-#include "base/strings/string_piece.h"
-
-namespace base {
-
-BigEndianReader::BigEndianReader(const char* buf, size_t len)
- : ptr_(buf), end_(ptr_ + len) {}
-
-bool BigEndianReader::Skip(size_t len) {
- if (ptr_ + len > end_)
- return false;
- ptr_ += len;
- return true;
-}
-
-bool BigEndianReader::ReadBytes(void* out, size_t len) {
- if (ptr_ + len > end_)
- return false;
- memcpy(out, ptr_, len);
- ptr_ += len;
- return true;
-}
-
-bool BigEndianReader::ReadPiece(base::StringPiece* out, size_t len) {
- if (ptr_ + len > end_)
- return false;
- *out = base::StringPiece(ptr_, len);
- ptr_ += len;
- return true;
-}
-
-template<typename T>
-bool BigEndianReader::Read(T* value) {
- if (ptr_ + sizeof(T) > end_)
- return false;
- ReadBigEndian<T>(ptr_, value);
- ptr_ += sizeof(T);
- return true;
-}
-
-bool BigEndianReader::ReadU8(uint8_t* value) {
- return Read(value);
-}
-
-bool BigEndianReader::ReadU16(uint16_t* value) {
- return Read(value);
-}
-
-bool BigEndianReader::ReadU32(uint32_t* value) {
- return Read(value);
-}
-
-bool BigEndianReader::ReadU64(uint64_t* value) {
- return Read(value);
-}
-
-BigEndianWriter::BigEndianWriter(char* buf, size_t len)
- : ptr_(buf), end_(ptr_ + len) {}
-
-bool BigEndianWriter::Skip(size_t len) {
- if (ptr_ + len > end_)
- return false;
- ptr_ += len;
- return true;
-}
-
-bool BigEndianWriter::WriteBytes(const void* buf, size_t len) {
- if (ptr_ + len > end_)
- return false;
- memcpy(ptr_, buf, len);
- ptr_ += len;
- return true;
-}
-
-template<typename T>
-bool BigEndianWriter::Write(T value) {
- if (ptr_ + sizeof(T) > end_)
- return false;
- WriteBigEndian<T>(ptr_, value);
- ptr_ += sizeof(T);
- return true;
-}
-
-bool BigEndianWriter::WriteU8(uint8_t value) {
- return Write(value);
-}
-
-bool BigEndianWriter::WriteU16(uint16_t value) {
- return Write(value);
-}
-
-bool BigEndianWriter::WriteU32(uint32_t value) {
- return Write(value);
-}
-
-bool BigEndianWriter::WriteU64(uint64_t value) {
- return Write(value);
-}
-
-} // namespace base
diff --git a/base/big_endian.h b/base/big_endian.h
deleted file mode 100644
index 5684c67..0000000
--- a/base/big_endian.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_BIG_ENDIAN_H_
-#define BASE_BIG_ENDIAN_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "base/base_export.h"
-#include "base/strings/string_piece.h"
-
-namespace base {
-
-// Read an integer (signed or unsigned) from |buf| in Big Endian order.
-// Note: this loop is unrolled with -O1 and above.
-// NOTE(szym): glibc dns-canon.c use ntohs(*(uint16_t*)ptr) which is
-// potentially unaligned.
-// This would cause SIGBUS on ARMv5 or earlier and ARMv6-M.
-template<typename T>
-inline void ReadBigEndian(const char buf[], T* out) {
- *out = buf[0];
- for (size_t i = 1; i < sizeof(T); ++i) {
- *out <<= 8;
- // Must cast to uint8_t to avoid clobbering by sign extension.
- *out |= static_cast<uint8_t>(buf[i]);
- }
-}
-
-// Write an integer (signed or unsigned) |val| to |buf| in Big Endian order.
-// Note: this loop is unrolled with -O1 and above.
-template<typename T>
-inline void WriteBigEndian(char buf[], T val) {
- for (size_t i = 0; i < sizeof(T); ++i) {
- buf[sizeof(T)-i-1] = static_cast<char>(val & 0xFF);
- val >>= 8;
- }
-}
-
-// Specializations to make clang happy about the (dead code) shifts above.
-template <>
-inline void ReadBigEndian<uint8_t>(const char buf[], uint8_t* out) {
- *out = buf[0];
-}
-
-template <>
-inline void WriteBigEndian<uint8_t>(char buf[], uint8_t val) {
- buf[0] = static_cast<char>(val);
-}
-
-// Allows reading integers in network order (big endian) while iterating over
-// an underlying buffer. All the reading functions advance the internal pointer.
-class BASE_EXPORT BigEndianReader {
- public:
- BigEndianReader(const char* buf, size_t len);
-
- const char* ptr() const { return ptr_; }
- int remaining() const { return end_ - ptr_; }
-
- bool Skip(size_t len);
- bool ReadBytes(void* out, size_t len);
- // Creates a StringPiece in |out| that points to the underlying buffer.
- bool ReadPiece(base::StringPiece* out, size_t len);
- bool ReadU8(uint8_t* value);
- bool ReadU16(uint16_t* value);
- bool ReadU32(uint32_t* value);
- bool ReadU64(uint64_t* value);
-
- private:
- // Hidden to promote type safety.
- template<typename T>
- bool Read(T* v);
-
- const char* ptr_;
- const char* end_;
-};
-
-// Allows writing integers in network order (big endian) while iterating over
-// an underlying buffer. All the writing functions advance the internal pointer.
-class BASE_EXPORT BigEndianWriter {
- public:
- BigEndianWriter(char* buf, size_t len);
-
- char* ptr() const { return ptr_; }
- int remaining() const { return end_ - ptr_; }
-
- bool Skip(size_t len);
- bool WriteBytes(const void* buf, size_t len);
- bool WriteU8(uint8_t value);
- bool WriteU16(uint16_t value);
- bool WriteU32(uint32_t value);
- bool WriteU64(uint64_t value);
-
- private:
- // Hidden to promote type safety.
- template<typename T>
- bool Write(T v);
-
- char* ptr_;
- char* end_;
-};
-
-} // namespace base
-
-#endif // BASE_BIG_ENDIAN_H_
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 9f6ae16..b7a3e9d 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -16,10 +16,6 @@
#include "base/threading/thread_restrictions.h"
#include "build_config.h"
-#if defined(OS_ANDROID)
-#include "base/os_compat_android.h"
-#endif
-
namespace base {
// Make sure our Whence mappings match the system headers.
diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
index 37fb015..1892baf 100644
--- a/base/files/file_util_posix.cc
+++ b/base/files/file_util_posix.cc
@@ -49,11 +49,6 @@
#include "base/mac/foundation_util.h"
#endif
-#if defined(OS_ANDROID)
-#include "base/android/content_uri_utils.h"
-#include "base/os_compat_android.h"
-#endif
-
#if !defined(OS_IOS)
#include <grp.h>
#endif
diff --git a/base/os_compat_nacl.cc b/base/os_compat_nacl.cc
deleted file mode 100644
index 58fe93e..0000000
--- a/base/os_compat_nacl.cc
+++ /dev/null
@@ -1,30 +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/os_compat_nacl.h"
-
-#include <stdlib.h>
-#include <time.h>
-
-#if !defined (__GLIBC__)
-
-extern "C" {
-// Native Client has no timegm().
-time_t timegm(struct tm* tm) {
- time_t ret;
- char* tz;
- tz = getenv("TZ");
- setenv("TZ", "", 1);
- tzset();
- ret = mktime(tm);
- if (tz)
- setenv("TZ", tz, 1);
- else
- unsetenv("TZ");
- tzset();
- return ret;
-}
-} // extern "C"
-
-#endif // !defined (__GLIBC__)
diff --git a/base/os_compat_nacl.h b/base/os_compat_nacl.h
deleted file mode 100644
index 13e0e3f..0000000
--- a/base/os_compat_nacl.h
+++ /dev/null
@@ -1,16 +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_OS_COMPAT_NACL_H_
-#define BASE_OS_COMPAT_NACL_H_
-
-#include <sys/types.h>
-
-#if !defined (__GLIBC__)
-// NaCl has no timegm().
-extern "C" time_t timegm(struct tm* const t);
-#endif // !defined (__GLIBC__)
-
-#endif // BASE_OS_COMPAT_NACL_H_
-
diff --git a/base/time/time_exploded_posix.cc b/base/time/time_exploded_posix.cc
index ad95167..26eaed9 100644
--- a/base/time/time_exploded_posix.cc
+++ b/base/time/time_exploded_posix.cc
@@ -18,12 +18,6 @@
#include "base/synchronization/lock.h"
#include "build_config.h"
-#if defined(OS_ANDROID)
-#include "base/os_compat_android.h"
-#elif defined(OS_NACL)
-#include "base/os_compat_nacl.h"
-#endif
-
#if defined(OS_MACOSX)
static_assert(sizeof(time_t) >= 8, "Y2038 problem!");
#endif
diff --git a/tools/gn/command_gen.cc b/tools/gn/command_gen.cc
index ca65877..44bf922 100644
--- a/tools/gn/command_gen.cc
+++ b/tools/gn/command_gen.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/atomicops.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"