Remove redundant base::ElapsedTimer command_gen.cc was the only caller of base::ElapsedTimer (and already used ::ElapsedTimer from util/ticks.h elsewhere in the same file). Switch the remaining 4 uses to ElapsedTimer from util/ticks.h, mark ElapsedTimer::Elapsed() const, and delete src/base/timer/. Bug: None Test: ninja -C out run_tests Change-Id: I954131a520986cbb2373c4b572715ae97bcbe610 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/29681 Reviewed-by: David Turner <digit@google.com> Commit-Queue: Takuto Ikuta <tikuta@google.com>
diff --git a/build/gen.py b/build/gen.py index 9bbf3d4..4163a60 100755 --- a/build/gen.py +++ b/build/gen.py
@@ -710,7 +710,6 @@ 'src/base/strings/stringprintf.cc', 'src/base/strings/utf_string_conversion_utils.cc', 'src/base/strings/utf_string_conversions.cc', - 'src/base/timer/elapsed_timer.cc', 'src/base/value_iterators.cc', 'src/base/values.cc', ]
diff --git a/src/base/timer/elapsed_timer.cc b/src/base/timer/elapsed_timer.cc deleted file mode 100644 index 68992f4..0000000 --- a/src/base/timer/elapsed_timer.cc +++ /dev/null
@@ -1,25 +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/timer/elapsed_timer.h" - -namespace base { - -ElapsedTimer::ElapsedTimer() { - begin_ = TicksNow(); -} - -ElapsedTimer::ElapsedTimer(ElapsedTimer&& other) { - begin_ = other.begin_; -} - -void ElapsedTimer::operator=(ElapsedTimer&& other) { - begin_ = other.begin_; -} - -TickDelta ElapsedTimer::Elapsed() const { - return TicksDelta(TicksNow(), begin_); -} - -} // namespace base
diff --git a/src/base/timer/elapsed_timer.h b/src/base/timer/elapsed_timer.h deleted file mode 100644 index 4c26b6d..0000000 --- a/src/base/timer/elapsed_timer.h +++ /dev/null
@@ -1,32 +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_TIMER_ELAPSED_TIMER_H_ -#define BASE_TIMER_ELAPSED_TIMER_H_ - -#include "util/ticks.h" - -namespace base { - -// A simple wrapper around TicksNow(). -class ElapsedTimer { - public: - ElapsedTimer(); - ElapsedTimer(ElapsedTimer&& other); - - void operator=(ElapsedTimer&& other); - - // Returns the time elapsed since object construction. - TickDelta Elapsed() const; - - private: - Ticks begin_; - - ElapsedTimer(const ElapsedTimer&) = delete; - ElapsedTimer& operator=(const ElapsedTimer&) = delete; -}; - -} // namespace base - -#endif // BASE_TIMER_ELAPSED_TIMER_H_
diff --git a/src/gn/command_gen.cc b/src/gn/command_gen.cc index 8d94c0b..cfde3a3 100644 --- a/src/gn/command_gen.cc +++ b/src/gn/command_gen.cc
@@ -16,7 +16,6 @@ #include "base/files/file_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" -#include "base/timer/elapsed_timer.h" #include "gn/build_settings.h" #include "gn/commands.h" #include "gn/compile_commands_writer.h" @@ -40,6 +39,7 @@ #include "gn/target.h" #include "gn/visual_studio_writer.h" #include "gn/xcode_writer.h" +#include "util/ticks.h" namespace commands { @@ -361,7 +361,7 @@ const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); bool quiet = command_line->HasSwitch(switches::kQuiet); - base::ElapsedTimer timer; + ElapsedTimer timer; if (ide == kSwitchIdeValueEclipse) { bool res = EclipseWriter::RunAndWriteFile(build_settings, builder, err); @@ -498,7 +498,7 @@ const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); bool quiet = command_line->HasSwitch(switches::kQuiet); - base::ElapsedTimer timer; + ElapsedTimer timer; std::string file_name = "rust-project.json"; bool res = RustProjectWriter::RunAndWriteFiles(build_settings, builder, @@ -524,7 +524,7 @@ return true; // No compilation database needs to be written. bool quiet = command_line->HasSwitch(switches::kQuiet); - base::ElapsedTimer timer; + ElapsedTimer timer; // The compilation database file goes in the build directory. SourceFile output_file = @@ -880,7 +880,7 @@ )"; int RunGen(const std::vector<std::string>& args) { - base::ElapsedTimer timer; + ElapsedTimer timer; if (args.size() != 1) { Err(Location(), "Need exactly one build directory to generate.",
diff --git a/src/util/ticks.h b/src/util/ticks.h index fcbde05..5d111e6 100644 --- a/src/util/ticks.h +++ b/src/util/ticks.h
@@ -36,7 +36,7 @@ class ElapsedTimer { public: ElapsedTimer() : start_(TicksNow()) {} - TickDelta Elapsed() { return TicksDelta(TicksNow(), start_); } + TickDelta Elapsed() const { return TicksDelta(TicksNow(), start_); } private: Ticks start_;