Bug 1415543 - Remove some Chromium unused files (platform_file_*.cc thread_local_storage_*.cc) r=jld
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 07 Nov 2017 14:54:51 +0100
changeset 444572 741841a69b8758aae99e311a2ae8bfb34cd902f6
parent 444571 e9a687531a09b73edc201a4c7c95fecb6d537d43
child 444573 e74c96a287cec01c2441ef6aab4b71cd8a1d28be
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1415543
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415543 - Remove some Chromium unused files (platform_file_*.cc thread_local_storage_*.cc) r=jld MozReview-Commit-ID: FY6YZ7TqfjG
ipc/chromium/moz.build
ipc/chromium/src/base/platform_file_posix.cc
ipc/chromium/src/base/platform_file_win.cc
ipc/chromium/src/base/thread_local_storage_posix.cc
ipc/chromium/src/base/thread_local_storage_win.cc
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -35,24 +35,22 @@ UNIFIED_SOURCES += [
 if os_win:
     SOURCES += [
         'src/base/condition_variable_win.cc',
         'src/base/cpu.cc',
         'src/base/file_util_win.cc',
         'src/base/lock_impl_win.cc',
         'src/base/message_pump_win.cc',
         'src/base/object_watcher.cc',
-        'src/base/platform_file_win.cc',
         'src/base/platform_thread_win.cc',
         'src/base/process_util_win.cc',
         'src/base/rand_util_win.cc',
         'src/base/shared_memory_win.cc',
         'src/base/sys_info_win.cc',
         'src/base/sys_string_conversions_win.cc',
-        'src/base/thread_local_storage_win.cc',
         'src/base/thread_local_win.cc',
         'src/base/time_win.cc',
         'src/base/waitable_event_win.cc',
         'src/base/win_util.cc',
         'src/chrome/common/ipc_channel_win.cc',
         'src/chrome/common/process_watcher_win.cc',
         'src/chrome/common/transport_dib_win.cc',
     ]
@@ -62,25 +60,23 @@ elif not CONFIG['MOZ_SYSTEM_LIBEVENT']:
 
 if os_posix:
     UNIFIED_SOURCES += [
         'src/base/condition_variable_posix.cc',
         'src/base/file_descriptor_shuffle.cc',
         'src/base/file_util_posix.cc',
         'src/base/lock_impl_posix.cc',
         'src/base/message_pump_libevent.cc',
-        'src/base/platform_file_posix.cc',
         'src/base/platform_thread_posix.cc',
         'src/base/process_util_posix.cc',
         'src/base/rand_util_posix.cc',
         'src/base/shared_memory_posix.cc',
         'src/base/string16.cc',
         'src/base/sys_info_posix.cc',
         'src/base/thread_local_posix.cc',
-        'src/base/thread_local_storage_posix.cc',
         'src/base/waitable_event_posix.cc',
         'src/chrome/common/file_descriptor_set_posix.cc',
         'src/chrome/common/ipc_channel_posix.cc',
         'src/chrome/common/process_watcher_posix_sigchld.cc',
     ]
 
 if os_macosx:
     UNIFIED_SOURCES += [
deleted file mode 100644
--- a/ipc/chromium/src/base/platform_file_posix.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2006-2008 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/platform_file.h"
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#ifdef ANDROID
-#include <linux/stat.h>
-#endif
-
-#include "base/logging.h"
-#include "base/string_util.h"
-
-namespace base {
-
-// TODO(erikkay): does it make sense to support PLATFORM_FILE_EXCLUSIVE_* here?
-PlatformFile CreatePlatformFile(const std::wstring& name,
-                                int flags,
-                                bool* created) {
-  int open_flags = 0;
-  if (flags & PLATFORM_FILE_CREATE)
-    open_flags = O_CREAT | O_EXCL;
-
-  if (flags & PLATFORM_FILE_CREATE_ALWAYS) {
-    DCHECK(!open_flags);
-    open_flags = O_CREAT | O_TRUNC;
-  }
-
-  if (!open_flags && !(flags & PLATFORM_FILE_OPEN) &&
-      !(flags & PLATFORM_FILE_OPEN_ALWAYS)) {
-    NOTREACHED();
-    errno = ENOTSUP;
-    return kInvalidPlatformFileValue;
-  }
-
-  if (flags & PLATFORM_FILE_WRITE && flags & PLATFORM_FILE_READ) {
-    open_flags |= O_RDWR;
-  } else if (flags & PLATFORM_FILE_WRITE) {
-    open_flags |= O_WRONLY;
-  } else if (!(flags & PLATFORM_FILE_READ)) {
-    NOTREACHED();
-  }
-
-  DCHECK(O_RDONLY == 0);
-
-  int descriptor = open(WideToUTF8(name).c_str(), open_flags,
-                        S_IRUSR | S_IWUSR);
-
-  if (flags & PLATFORM_FILE_OPEN_ALWAYS) {
-    if (descriptor > 0) {
-      if (created)
-        *created = false;
-    } else {
-      open_flags |= O_CREAT;
-      descriptor = open(WideToUTF8(name).c_str(), open_flags,
-                        S_IRUSR | S_IWUSR);
-      if (created && descriptor > 0)
-        *created = true;
-    }
-  }
-
-  return descriptor;
-}
-
-}  // namespace base
deleted file mode 100644
--- a/ipc/chromium/src/base/platform_file_win.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2006-2008 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/platform_file.h"
-
-#include "base/logging.h"
-
-namespace base {
-
-PlatformFile CreatePlatformFile(const std::wstring& name,
-                                int flags,
-                                bool* created) {
-  DWORD disposition = 0;
-
-  if (flags & PLATFORM_FILE_OPEN)
-    disposition = OPEN_EXISTING;
-
-  if (flags & PLATFORM_FILE_CREATE) {
-    DCHECK(!disposition);
-    disposition = CREATE_NEW;
-  }
-
-  if (flags & PLATFORM_FILE_OPEN_ALWAYS) {
-    DCHECK(!disposition);
-    disposition = OPEN_ALWAYS;
-  }
-
-  if (flags & PLATFORM_FILE_CREATE_ALWAYS) {
-    DCHECK(!disposition);
-    disposition = CREATE_ALWAYS;
-  }
-
-  if (!disposition) {
-    NOTREACHED();
-    return NULL;
-  }
-
-  DWORD access = (flags & PLATFORM_FILE_READ) ? GENERIC_READ : 0;
-  if (flags & PLATFORM_FILE_WRITE)
-    access |= GENERIC_WRITE;
-
-  DWORD sharing = (flags & PLATFORM_FILE_EXCLUSIVE_READ) ? 0 : FILE_SHARE_READ;
-  if (!(flags & PLATFORM_FILE_EXCLUSIVE_WRITE))
-    sharing |= FILE_SHARE_WRITE;
-
-  DWORD create_flags = 0;
-  if (flags & PLATFORM_FILE_ASYNC)
-    create_flags |= FILE_FLAG_OVERLAPPED;
-
-  HANDLE file = CreateFile(name.c_str(), access, sharing, NULL, disposition,
-                           create_flags, NULL);
-
-  if ((flags & PLATFORM_FILE_OPEN_ALWAYS) && created &&
-      INVALID_HANDLE_VALUE != file) {
-    *created = (ERROR_ALREADY_EXISTS != GetLastError());
-  }
-
-  return file;
-}
-
-}  // namespace disk_cache
deleted file mode 100644
--- a/ipc/chromium/src/base/thread_local_storage_posix.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2006-2008 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/thread_local_storage.h"
-
-#include "base/logging.h"
-
-ThreadLocalStorage::Slot::Slot(TLSDestructorFunc destructor)
-    : initialized_(false) {
-  Initialize(destructor);
-}
-
-bool ThreadLocalStorage::Slot::Initialize(TLSDestructorFunc destructor) {
-  DCHECK(!initialized_);
-  int error = pthread_key_create(&key_, destructor);
-  if (error) {
-    NOTREACHED();
-    return false;
-  }
-
-  initialized_ = true;
-  return true;
-}
-
-void ThreadLocalStorage::Slot::Free() {
-  DCHECK(initialized_);
-  int error = pthread_key_delete(key_);
-  if (error)
-    NOTREACHED();
-  initialized_ = false;
-}
-
-void* ThreadLocalStorage::Slot::Get() const {
-  DCHECK(initialized_);
-  return pthread_getspecific(key_);
-}
-
-void ThreadLocalStorage::Slot::Set(void* value) {
-  DCHECK(initialized_);
-  int error = pthread_setspecific(key_, value);
-  if (error)
-    NOTREACHED();
-}
deleted file mode 100644
--- a/ipc/chromium/src/base/thread_local_storage_win.cc
+++ /dev/null
@@ -1,188 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-// Copyright (c) 2006-2008 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/thread_local_storage.h"
-
-#include <windows.h>
-
-#include "base/logging.h"
-
-// In order to make TLS destructors work, we need to keep function
-// pointers to the destructor for each TLS that we allocate.
-// We make this work by allocating a single OS-level TLS, which
-// contains an array of slots for the application to use.  In
-// parallel, we also allocate an array of destructors, which we
-// keep track of and call when threads terminate.
-
-// tls_key_ is the one native TLS that we use.  It stores our
-// table.
-long ThreadLocalStorage::tls_key_ = TLS_OUT_OF_INDEXES;
-
-// tls_max_ is the high-water-mark of allocated thread local storage.
-// We intentionally skip 0 so that it is not confused with an
-// unallocated TLS slot.
-long ThreadLocalStorage::tls_max_ = 1;
-
-// An array of destructor function pointers for the slots.  If
-// a slot has a destructor, it will be stored in its corresponding
-// entry in this array.
-ThreadLocalStorage::TLSDestructorFunc
-  ThreadLocalStorage::tls_destructors_[kThreadLocalStorageSize];
-
-void** ThreadLocalStorage::Initialize() {
-  if (tls_key_ == TLS_OUT_OF_INDEXES) {
-    long value = TlsAlloc();
-    DCHECK(value != TLS_OUT_OF_INDEXES);
-
-    // Atomically test-and-set the tls_key.  If the key is TLS_OUT_OF_INDEXES,
-    // go ahead and set it.  Otherwise, do nothing, as another
-    // thread already did our dirty work.
-    if (InterlockedCompareExchange(&tls_key_, value, TLS_OUT_OF_INDEXES) !=
-            TLS_OUT_OF_INDEXES) {
-      // We've been shortcut. Another thread replaced tls_key_ first so we need
-      // to destroy our index and use the one the other thread got first.
-      TlsFree(value);
-    }
-  }
-  DCHECK(TlsGetValue(tls_key_) == NULL);
-
-  // Create an array to store our data.
-  void** tls_data = new void*[kThreadLocalStorageSize];
-  memset(tls_data, 0, sizeof(void*[kThreadLocalStorageSize]));
-  TlsSetValue(tls_key_, tls_data);
-  return tls_data;
-}
-
-ThreadLocalStorage::Slot::Slot(TLSDestructorFunc destructor)
-    : initialized_(false) {
-  Initialize(destructor);
-}
-
-bool ThreadLocalStorage::Slot::Initialize(TLSDestructorFunc destructor) {
-  if (tls_key_ == TLS_OUT_OF_INDEXES || !TlsGetValue(tls_key_))
-    ThreadLocalStorage::Initialize();
-
-  // Grab a new slot.
-  slot_ = InterlockedIncrement(&tls_max_) - 1;
-  if (slot_ >= kThreadLocalStorageSize) {
-    NOTREACHED();
-    return false;
-  }
-
-  // Setup our destructor.
-  tls_destructors_[slot_] = destructor;
-  initialized_ = true;
-  return true;
-}
-
-void ThreadLocalStorage::Slot::Free() {
-  // At this time, we don't reclaim old indices for TLS slots.
-  // So all we need to do is wipe the destructor.
-  tls_destructors_[slot_] = NULL;
-  initialized_ = false;
-}
-
-void* ThreadLocalStorage::Slot::Get() const {
-  void** tls_data = static_cast<void**>(TlsGetValue(tls_key_));
-  if (!tls_data)
-    tls_data = ThreadLocalStorage::Initialize();
-  DCHECK(slot_ >= 0 && slot_ < kThreadLocalStorageSize);
-  return tls_data[slot_];
-}
-
-void ThreadLocalStorage::Slot::Set(void* value) {
-  void** tls_data = static_cast<void**>(TlsGetValue(tls_key_));
-  if (!tls_data)
-    tls_data = ThreadLocalStorage::Initialize();
-  DCHECK(slot_ >= 0 && slot_ < kThreadLocalStorageSize);
-  tls_data[slot_] = value;
-}
-
-void ThreadLocalStorage::ThreadExit() {
-  if (tls_key_ == TLS_OUT_OF_INDEXES)
-    return;
-
-  void** tls_data = static_cast<void**>(TlsGetValue(tls_key_));
-
-  // Maybe we have never initialized TLS for this thread.
-  if (!tls_data)
-    return;
-
-  for (int slot = 0; slot < tls_max_; slot++) {
-    if (tls_destructors_[slot] != NULL) {
-      void* value = tls_data[slot];
-      tls_destructors_[slot](value);
-    }
-  }
-
-  delete[] tls_data;
-
-  // In case there are other "onexit" handlers...
-  TlsSetValue(tls_key_, NULL);
-}
-
-// Thread Termination Callbacks.
-// Windows doesn't support a per-thread destructor with its
-// TLS primitives.  So, we build it manually by inserting a
-// function to be called on each thread's exit.
-// This magic is from http://www.codeproject.com/threads/tls.asp
-// and it works for VC++ 7.0 and later.
-
-#ifdef _WIN64
-
-// This makes the linker create the TLS directory if it's not already
-// there.  (e.g. if __declspec(thread) is not used).
-#pragma comment(linker, "/INCLUDE:_tls_used")
-
-#else  // _WIN64
-
-// This makes the linker create the TLS directory if it's not already
-// there.  (e.g. if __declspec(thread) is not used).
-#pragma comment(linker, "/INCLUDE:__tls_used")
-
-#endif  // _WIN64
-
-// Static callback function to call with each thread termination.
-void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved)
-{
-  // On XP SP0 & SP1, the DLL_PROCESS_ATTACH is never seen. It is sent on SP2+
-  // and on W2K and W2K3. So don't assume it is sent.
-  if (DLL_THREAD_DETACH == reason || DLL_PROCESS_DETACH == reason)
-    ThreadLocalStorage::ThreadExit();
-}
-
-// .CRT$XLA to .CRT$XLZ is an array of PIMAGE_TLS_CALLBACK pointers that are
-// called automatically by the OS loader code (not the CRT) when the module is
-// loaded and on thread creation. They are NOT called if the module has been
-// loaded by a LoadLibrary() call. It must have implicitly been loaded at
-// process startup.
-// By implicitly loaded, I mean that it is directly referenced by the main EXE
-// or by one of its dependent DLLs. Delay-loaded DLL doesn't count as being
-// implicitly loaded.
-//
-// See VC\crt\src\tlssup.c for reference.
-#ifdef _WIN64
-
-// .CRT section is merged with .rdata on x64 so it must be constant data.
-#pragma const_seg(".CRT$XLB")
-// When defining a const variable, it must have external linkage to be sure the
-// linker doesn't discard it. If this value is discarded, the OnThreadExit
-// function will never be called.
-extern const PIMAGE_TLS_CALLBACK p_thread_callback;
-const PIMAGE_TLS_CALLBACK p_thread_callback = OnThreadExit;
-
-// Reset the default section.
-#pragma const_seg()
-
-#else  // _WIN64
-
-#pragma data_seg(".CRT$XLB")
-PIMAGE_TLS_CALLBACK p_thread_callback = OnThreadExit;
-
-// Reset the default section.
-#pragma data_seg()
-
-#endif  // _WIN64