Cleanup dead code in base/ as found by Scythe.

Some parts just needed to be ifdefed.

Review URL: https://codereview.chromium.org/853903003

Cr-Commit-Position: refs/heads/master@{#312576}


CrOS-Libchrome-Original-Commit: 88c7b3339b207cd3424f5478b5e672485617ca44
diff --git a/base/base.gyp b/base/base.gyp
index f070cbd..114cad6 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -230,15 +230,10 @@
         }],
       ],
       'sources': [
-        'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
-        'third_party/xdg_user_dirs/xdg_user_dir_lookup.h',
         'async_socket_io_handler.h',
         'async_socket_io_handler_posix.cc',
         'async_socket_io_handler_win.cc',
         'auto_reset.h',
-        'event_recorder.h',
-        'event_recorder_stubs.cc',
-        'event_recorder_win.cc',
         'linux_util.cc',
         'linux_util.h',
         'message_loop/message_pump_android.cc',
@@ -256,8 +251,10 @@
         'posix/file_descriptor_shuffle.cc',
         'posix/file_descriptor_shuffle.h',
         'sync_socket.h',
-        'sync_socket_win.cc',
         'sync_socket_posix.cc',
+        'sync_socket_win.cc',
+        'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
+        'third_party/xdg_user_dirs/xdg_user_dir_lookup.h',
       ],
       'includes': [
         '../build/android/increase_size_for_speed.gypi',
@@ -1166,15 +1163,10 @@
             4267,
           ],
           'sources': [
-            'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
-            'third_party/xdg_user_dirs/xdg_user_dir_lookup.h',
             'async_socket_io_handler.h',
             'async_socket_io_handler_posix.cc',
             'async_socket_io_handler_win.cc',
             'auto_reset.h',
-            'event_recorder.h',
-            'event_recorder_stubs.cc',
-            'event_recorder_win.cc',
             'linux_util.cc',
             'linux_util.h',
             'md5.cc',
@@ -1186,8 +1178,10 @@
             'posix/file_descriptor_shuffle.cc',
             'posix/file_descriptor_shuffle.h',
             'sync_socket.h',
-            'sync_socket_win.cc',
             'sync_socket_posix.cc',
+            'sync_socket_win.cc',
+            'third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
+            'third_party/xdg_user_dirs/xdg_user_dir_lookup.h',
           ],
         },
         {
diff --git a/base/base.gypi b/base/base.gypi
index c1c5f2b..0c6ee7e 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -929,7 +929,6 @@
               '<(DEPTH)/third_party/wtl/include',
             ],
             'sources!': [
-              'event_recorder_stubs.cc',
               'files/file_path_watcher_fsevents.cc',
               'files/file_path_watcher_fsevents.h',
               'files/file_path_watcher_kqueue.cc',
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index c80826c..1b1fce3 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -745,7 +745,6 @@
   // This lock protects accesses to thread_names_, thread_event_start_times_
   // and thread_colors_.
   Lock thread_info_lock_;
-  int locked_line_;
   Mode mode_;
   int num_traces_recorded_;
   scoped_ptr<TraceBuffer> logged_events_;
diff --git a/base/event_recorder.h b/base/event_recorder.h
deleted file mode 100644
index bff87ed..0000000
--- a/base/event_recorder.h
+++ /dev/null
@@ -1,109 +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.
-
-#ifndef BASE_EVENT_RECORDER_H_
-#define BASE_EVENT_RECORDER_H_
-
-#include "base/base_export.h"
-#include "base/basictypes.h"
-#include "build/build_config.h"
-
-#if defined(OS_WIN)
-#include <stdio.h>
-#include <string.h>
-#include <windows.h>
-#endif
-
-namespace base {
-
-class FilePath;
-
-// A class for recording and playing back keyboard and mouse input events.
-//
-// Note - if you record events, and the playback with the windows in
-//        different sizes or positions, the playback will fail.  When
-//        recording and playing, you should move the relevant windows
-//        to constant sizes and locations.
-// TODO(mbelshe) For now this is a singleton.  I believe that this class
-//        could be easily modified to:
-//             support two simultaneous recorders
-//             be playing back events while already recording events.
-//        Why?  Imagine if the product had a "record a macro" feature.
-//        You might be recording globally, while recording or playing back
-//        a macro.  I don't think two playbacks make sense.
-class BASE_EXPORT EventRecorder {
- public:
-  // Get the singleton EventRecorder.
-  // We can only handle one recorder/player at a time.
-  static EventRecorder* current() {
-    if (!current_)
-      current_ = new EventRecorder();
-    return current_;
-  }
-
-  // Starts recording events.
-  // Will clobber the file if it already exists.
-  // Returns true on success, or false if an error occurred.
-  bool StartRecording(const FilePath& filename);
-
-  // Stops recording.
-  void StopRecording();
-
-  // Is the EventRecorder currently recording.
-  bool is_recording() const { return is_recording_; }
-
-  // Plays events previously recorded.
-  // Returns true on success, or false if an error occurred.
-  bool StartPlayback(const FilePath& filename);
-
-  // Stops playback.
-  void StopPlayback();
-
-  // Is the EventRecorder currently playing.
-  bool is_playing() const { return is_playing_; }
-
-#if defined(OS_WIN)
-  // C-style callbacks for the EventRecorder.
-  // Used for internal purposes only.
-  LRESULT RecordWndProc(int nCode, WPARAM wParam, LPARAM lParam);
-  LRESULT PlaybackWndProc(int nCode, WPARAM wParam, LPARAM lParam);
-#endif
-
- private:
-  // Create a new EventRecorder.  Events are saved to the file filename.
-  // If the file already exists, it will be deleted before recording
-  // starts.
-  EventRecorder()
-      : is_recording_(false),
-        is_playing_(false),
-#if defined(OS_WIN)
-        journal_hook_(NULL),
-        file_(NULL),
-#endif
-        playback_first_msg_time_(0),
-        playback_start_time_(0) {
-#if defined(OS_WIN)
-    memset(&playback_msg_, 0, sizeof(playback_msg_));
-#endif
-  }
-  ~EventRecorder();
-
-  static EventRecorder* current_;  // Our singleton.
-
-  bool is_recording_;
-  bool is_playing_;
-#if defined(OS_WIN)
-  HHOOK journal_hook_;
-  FILE* file_;
-  EVENTMSG playback_msg_;
-#endif
-  int playback_first_msg_time_;
-  int playback_start_time_;
-
-  DISALLOW_COPY_AND_ASSIGN(EventRecorder);
-};
-
-}  // namespace base
-
-#endif // BASE_EVENT_RECORDER_H_
diff --git a/base/event_recorder_stubs.cc b/base/event_recorder_stubs.cc
deleted file mode 100644
index 91f2e07..0000000
--- a/base/event_recorder_stubs.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2009 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/event_recorder.h"
-
-// This file implements a link stub for EventRecorder that can be used on
-// platforms that don't have a working EventRecorder implementation.
-
-namespace base {
-
-EventRecorder* EventRecorder::current_;  // Our singleton.
-
-bool EventRecorder::StartRecording(const FilePath& filename) {
-  return true;
-}
-
-void EventRecorder::StopRecording() {
-}
-
-bool EventRecorder::StartPlayback(const FilePath& filename) {
-  return false;
-}
-
-void EventRecorder::StopPlayback() {
-}
-
-}  // namespace
diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc
index 17bbba8..5eb6819 100644
--- a/base/files/file_util_proxy_unittest.cc
+++ b/base/files/file_util_proxy_unittest.cc
@@ -19,8 +19,6 @@
   FileUtilProxyTest()
       : file_thread_("FileUtilProxyTestFileThread"),
         error_(File::FILE_OK),
-        created_(false),
-        bytes_written_(-1),
         weak_factory_(this) {}
 
   void SetUp() override {
@@ -52,11 +50,9 @@
 
   ScopedTempDir dir_;
   File::Error error_;
-  bool created_;
   FilePath path_;
   File::Info file_info_;
   std::vector<char> buffer_;
-  int bytes_written_;
   WeakPtrFactory<FileUtilProxyTest> weak_factory_;
 };
 
diff --git a/base/i18n/i18n_constants.cc b/base/i18n/i18n_constants.cc
index 9b8c571..7d2f5fc 100644
--- a/base/i18n/i18n_constants.cc
+++ b/base/i18n/i18n_constants.cc
@@ -8,8 +8,6 @@
 
 const char kCodepageLatin1[] = "ISO-8859-1";
 const char kCodepageUTF8[] = "UTF-8";
-const char kCodepageUTF16BE[] = "UTF-16BE";
-const char kCodepageUTF16LE[] = "UTF-16LE";
 
 }  // namespace base
 
diff --git a/base/i18n/i18n_constants.h b/base/i18n/i18n_constants.h
index c2de842..c1bd87d 100644
--- a/base/i18n/i18n_constants.h
+++ b/base/i18n/i18n_constants.h
@@ -12,8 +12,9 @@
 // Names of codepages (charsets) understood by icu.
 BASE_I18N_EXPORT extern const char kCodepageLatin1[];  // a.k.a. ISO 8859-1
 BASE_I18N_EXPORT extern const char kCodepageUTF8[];
-BASE_I18N_EXPORT extern const char kCodepageUTF16BE[];
-BASE_I18N_EXPORT extern const char kCodepageUTF16LE[];
+
+// The other possible options are UTF-16BE and UTF-16LE, but they are unused in
+// Chromium as of this writing.
 
 }  // namespace base
 
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index 8180733..86771e4 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -117,8 +117,10 @@
 
 MessageLoop::MessageLoop(Type type)
     : type_(type),
+#if defined(OS_WIN)
       pending_high_res_tasks_(0),
       in_high_res_mode_(false),
+#endif
       nestable_tasks_allowed_(true),
 #if defined(OS_WIN)
       os_modal_loop_(false),
@@ -133,8 +135,10 @@
 MessageLoop::MessageLoop(scoped_ptr<MessagePump> pump)
     : pump_(pump.Pass()),
       type_(TYPE_CUSTOM),
+#if defined(OS_WIN)
       pending_high_res_tasks_(0),
       in_high_res_mode_(false),
+#endif
       nestable_tasks_allowed_(true),
 #if defined(OS_WIN)
       os_modal_loop_(false),
@@ -422,10 +426,13 @@
 void MessageLoop::RunTask(const PendingTask& pending_task) {
   DCHECK(nestable_tasks_allowed_);
 
+#if defined(OS_WIN)
   if (pending_task.is_high_res) {
     pending_high_res_tasks_--;
-    CHECK(pending_high_res_tasks_ >= 0);
+    CHECK_GE(pending_high_res_tasks_, 0);
   }
+#endif
+
   // Execute the task and assume the worst: It is probably not reentrant.
   nestable_tasks_allowed_ = false;
 
@@ -495,8 +502,12 @@
   // load. That reduces the number of locks-per-task significantly when our
   // queues get large.
   if (work_queue_.empty()) {
+#if defined(OS_WIN)
     pending_high_res_tasks_ +=
         incoming_task_queue_->ReloadWorkQueue(&work_queue_);
+#else
+    incoming_task_queue_->ReloadWorkQueue(&work_queue_);
+#endif
   }
 }
 
@@ -692,8 +703,8 @@
 bool MessageLoopForIO::WatchFileDescriptor(int fd,
                                            bool persistent,
                                            Mode mode,
-                                           FileDescriptorWatcher *controller,
-                                           Watcher *delegate) {
+                                           FileDescriptorWatcher* controller,
+                                           Watcher* delegate) {
   return ToPumpIO(pump_.get())->WatchFileDescriptor(
       fd,
       persistent,
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 32e826d..7c76616 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -106,7 +106,7 @@
     TYPE_IO,
 #if defined(OS_ANDROID)
     TYPE_JAVA,
-#endif // defined(OS_ANDROID)
+#endif  // defined(OS_ANDROID)
   };
 
   // Normally, it is not necessary to instantiate a MessageLoop.  Instead, it
@@ -452,6 +452,7 @@
   // this queue is only accessed (push/pop) by our current thread.
   TaskQueue work_queue_;
 
+#if defined(OS_WIN)
   // How many high resolution tasks are in the pending task queue. This value
   // increases by N every time we call ReloadWorkQueue() and decreases by 1
   // every time we call RunTask() if the task needs a high resolution timer.
@@ -459,6 +460,7 @@
   // Tracks if we have requested high resolution timers. Its only use is to
   // turn off the high resolution timer upon loop destruction.
   bool in_high_res_mode_;
+#endif
 
   // Contains delayed tasks, sorted by their 'delayed_run_time' property.
   DelayedTaskQueue delayed_work_queue_;
@@ -639,8 +641,8 @@
   bool WatchFileDescriptor(int fd,
                            bool persistent,
                            Mode mode,
-                           FileDescriptorWatcher *controller,
-                           Watcher *delegate);
+                           FileDescriptorWatcher* controller,
+                           Watcher* delegate);
 #endif  // defined(OS_IOS) || defined(OS_POSIX)
 #endif  // !defined(OS_NACL_SFI)
 };
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h
index d06e018..d011958 100644
--- a/base/process/process_metrics.h
+++ b/base/process/process_metrics.h
@@ -85,17 +85,6 @@
   size_t image;
 };
 
-// Free memory (Megabytes marked as free) in the 2G process address space.
-// total : total amount in megabytes marked as free. Maximum value is 2048.
-// largest : size of the largest contiguous amount of memory found. It is
-//   always smaller or equal to FreeMBytes::total.
-// largest_ptr: starting address of the largest memory block.
-struct FreeMBytes {
-  size_t total;
-  size_t largest;
-  void* largest_ptr;
-};
-
 // Convert a POSIX timeval to microseconds.
 BASE_EXPORT int64 TimeValToMicroseconds(const struct timeval& tv);