summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 17:25:28 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-28 17:25:28 +0000
commit5d91c9e739630685fbff5341abdbd1259f0e63ff (patch)
tree04e82f352e32cfa77985b707c55f661a8f733268 /base
parent37e658bd7bcf3e6a6d474f1826b5b03c4485afcb (diff)
downloadchromium_src-5d91c9e739630685fbff5341abdbd1259f0e63ff.zip
chromium_src-5d91c9e739630685fbff5341abdbd1259f0e63ff.tar.gz
chromium_src-5d91c9e739630685fbff5341abdbd1259f0e63ff.tar.bz2
base/ header cleanup. Forward declaration instead of including.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3068004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53969 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/command_line.cc43
-rw-r--r--base/command_line.h43
-rw-r--r--base/command_line_unittest.cc1
-rw-r--r--base/data_pack.cc1
-rw-r--r--base/data_pack.h2
-rw-r--r--base/histogram.cc45
-rw-r--r--base/histogram.h31
-rw-r--r--base/process_posix.cc1
-rw-r--r--base/process_util.h5
-rw-r--r--base/process_util_posix.cc2
-rw-r--r--base/process_util_win.cc1
-rw-r--r--base/test/test_suite.h1
12 files changed, 121 insertions, 55 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index c046125..b11902b 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -104,6 +104,13 @@ void CommandLine::ParseFromString(const std::wstring& command_line) {
LocalFree(args);
}
+// static
+CommandLine CommandLine::FromString(const std::wstring& command_line) {
+ CommandLine cmd;
+ cmd.ParseFromString(command_line);
+ return cmd;
+}
+
CommandLine::CommandLine(const FilePath& program) {
if (!program.empty()) {
program_ = program.value();
@@ -117,6 +124,14 @@ CommandLine::CommandLine(ArgumentsOnly args_only) {
argv_.push_back("");
}
+CommandLine::CommandLine(int argc, const char* const* argv) {
+ InitFromArgv(argc, argv);
+}
+
+CommandLine::CommandLine(const std::vector<std::string>& argv) {
+ InitFromArgv(argv);
+}
+
void CommandLine::InitFromArgv(int argc, const char* const* argv) {
for (int i = 0; i < argc; ++i)
argv_.push_back(argv[i]);
@@ -265,6 +280,20 @@ bool CommandLine::HasSwitch(const std::string& switch_string) const {
return switches_.find(lowercased_switch) != switches_.end();
}
+bool CommandLine::HasSwitch(const std::wstring& switch_string) const {
+ return HasSwitch(WideToASCII(switch_string));
+}
+
+std::string CommandLine::GetSwitchValueASCII(
+ const std::string& switch_string) const {
+ return WideToASCII(GetSwitchValue(switch_string));
+}
+
+FilePath CommandLine::GetSwitchValuePath(
+ const std::string& switch_string) const {
+ return FilePath::FromWStringHack(GetSwitchValue(switch_string));
+}
+
std::wstring CommandLine::GetSwitchValue(
const std::string& switch_string) const {
std::string lowercased_switch(switch_string);
@@ -286,6 +315,15 @@ std::wstring CommandLine::GetSwitchValue(
}
}
+std::wstring CommandLine::GetSwitchValue(
+ const std::wstring& switch_string) const {
+ return GetSwitchValue(WideToASCII(switch_string));
+}
+
+FilePath CommandLine::GetProgram() const {
+ return FilePath::FromWStringHack(program());
+}
+
#if defined(OS_WIN)
std::wstring CommandLine::program() const {
return program_;
@@ -432,6 +470,11 @@ void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) {
#endif
+void CommandLine::AppendSwitchWithValue(const std::string& switch_string,
+ const std::string& value_string) {
+ AppendSwitchWithValue(switch_string, ASCIIToWide(value_string));
+}
+
// private
CommandLine::CommandLine() {
}
diff --git a/base/command_line.h b/base/command_line.h
index b7f01f3..7ef83bc 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -24,10 +24,9 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/file_path.h"
#include "base/logging.h"
-#include "base/string_util.h"
+class FilePath;
class InProcessBrowserTest;
class CommandLine {
@@ -44,11 +43,7 @@ class CommandLine {
// Initialize by parsing the given command-line string.
// The program name is assumed to be the first item in the string.
void ParseFromString(const std::wstring& command_line);
- static CommandLine FromString(const std::wstring& command_line) {
- CommandLine cmd;
- cmd.ParseFromString(command_line);
- return cmd;
- }
+ static CommandLine FromString(const std::wstring& command_line);
#elif defined(OS_POSIX)
// The type of native command line arguments.
typedef std::string StringType;
@@ -57,12 +52,8 @@ class CommandLine {
void InitFromArgv(int argc, const char* const* argv);
void InitFromArgv(const std::vector<std::string>& argv);
- CommandLine(int argc, const char* const* argv) {
- InitFromArgv(argc, argv);
- }
- explicit CommandLine(const std::vector<std::string>& argv) {
- InitFromArgv(argv);
- }
+ CommandLine(int argc, const char* const* argv);
+ explicit CommandLine(const std::vector<std::string>& argv);
#endif
// Construct a new, empty command line.
@@ -105,27 +96,19 @@ class CommandLine {
bool HasSwitch(const std::string& switch_string) const;
// Deprecated version of the above.
- bool HasSwitch(const std::wstring& switch_string) const {
- return HasSwitch(WideToASCII(switch_string));
- }
+ bool HasSwitch(const std::wstring& switch_string) const;
// Returns the value associated with the given switch. If the
// switch has no value or isn't present, this method returns
// the empty string.
// TODO(evanm): move these into command_line.cpp once we've fixed the
// wstringness.
- std::string GetSwitchValueASCII(const std::string& switch_string) const {
- return WideToASCII(GetSwitchValue(switch_string));
- }
- FilePath GetSwitchValuePath(const std::string& switch_string) const {
- return FilePath::FromWStringHack(GetSwitchValue(switch_string));
- }
+ std::string GetSwitchValueASCII(const std::string& switch_string) const;
+ FilePath GetSwitchValuePath(const std::string& switch_string) const;
// Deprecated versions of the above.
std::wstring GetSwitchValue(const std::string& switch_string) const;
- std::wstring GetSwitchValue(const std::wstring& switch_string) const {
- return GetSwitchValue(WideToASCII(switch_string));
- }
+ std::wstring GetSwitchValue(const std::wstring& switch_string) const;
// Get the number of switches in this process.
size_t GetSwitchCount() const { return switches_.size(); }
@@ -134,7 +117,7 @@ class CommandLine {
typedef std::map<std::string, StringType> SwitchMap;
// Get a copy of all switches, along with their values
- SwitchMap GetSwitches() const {
+ const SwitchMap& GetSwitches() const {
return switches_;
}
@@ -157,9 +140,7 @@ class CommandLine {
#endif
// Returns the program part of the command line string (the first item).
- FilePath GetProgram() const {
- return FilePath::FromWStringHack(program());
- }
+ FilePath GetProgram() const;
// Returns the program part of the command line string (the first item).
// Deprecated version of the above.
@@ -184,9 +165,7 @@ class CommandLine {
void AppendSwitchWithValue(const std::string& switch_string,
const std::wstring& value_string);
void AppendSwitchWithValue(const std::string& switch_string,
- const std::string& value_string) {
- AppendSwitchWithValue(switch_string, ASCIIToWide(value_string));
- }
+ const std::string& value_string);
// Append a loose value to the command line.
void AppendLooseValue(const std::wstring& value);
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 8f3c7c0..c3fb04c 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/string_util.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/base/data_pack.cc b/base/data_pack.cc
index 06f2308..c130031 100644
--- a/base/data_pack.cc
+++ b/base/data_pack.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/ref_counted_memory.h"
#include "base/string_piece.h"
// For details of the file layout, see
diff --git a/base/data_pack.h b/base/data_pack.h
index 33f8b0f..2836715 100644
--- a/base/data_pack.h
+++ b/base/data_pack.h
@@ -13,13 +13,13 @@
#include <map>
#include "base/basictypes.h"
-#include "base/ref_counted_memory.h"
#include "base/scoped_ptr.h"
namespace file_util {
class MemoryMappedFile;
}
class FilePath;
+class RefCountedStaticMemory;
namespace base {
diff --git a/base/histogram.cc b/base/histogram.cc
index 2206756..31cc6a5 100644
--- a/base/histogram.cc
+++ b/base/histogram.cc
@@ -84,6 +84,10 @@ Histogram::~Histogram() {
DCHECK(ValidateBucketRanges());
}
+bool Histogram::PrintEmptyBucket(size_t index) const {
+ return true;
+}
+
void Histogram::Add(int value) {
if (value >= kSampleType_MAX)
value = kSampleType_MAX - 1;
@@ -95,10 +99,18 @@ void Histogram::Add(int value) {
Accumulate(value, 1, index);
}
+void Histogram::AddBoolean(bool value) {
+ DCHECK(false);
+}
+
void Histogram::AddSampleSet(const SampleSet& sample) {
sample_.Add(sample);
}
+void Histogram::SetRangeDescriptions(const DescriptionPair descriptions[]) {
+ DCHECK(false);
+}
+
// The following methods provide a graphical histogram display.
void Histogram::WriteHTMLGraph(std::string* output) const {
// TBD(jar) Write a nice HTML bar chart, with divs an mouse-overs etc.
@@ -290,6 +302,20 @@ void Histogram::SnapshotSample(SampleSet* sample) const {
*sample = sample_;
}
+bool Histogram::HasConstructorArguments(Sample minimum, Sample maximum,
+ size_t bucket_count) {
+ return ((minimum == declared_min_) && (maximum == declared_max_) &&
+ (bucket_count == bucket_count_));
+}
+
+bool Histogram::HasConstructorTimeDeltaArguments(base::TimeDelta minimum,
+ base::TimeDelta maximum,
+ size_t bucket_count) {
+ return ((minimum.InMilliseconds() == declared_min_) &&
+ (maximum.InMilliseconds() == declared_max_) &&
+ (bucket_count == bucket_count_));
+}
+
//------------------------------------------------------------------------------
// Accessor methods
@@ -613,6 +639,10 @@ LinearHistogram::LinearHistogram(const std::string& name,
DCHECK(ValidateBucketRanges());
}
+Histogram::ClassType LinearHistogram::histogram_type() const {
+ return LINEAR_HISTOGRAM;
+}
+
void LinearHistogram::SetRangeDescriptions(
const DescriptionPair descriptions[]) {
for (int i =0; descriptions[i].description; ++i) {
@@ -671,6 +701,17 @@ scoped_refptr<Histogram> BooleanHistogram::FactoryGet(const std::string& name,
return histogram;
}
+Histogram::ClassType BooleanHistogram::histogram_type() const {
+ return BOOLEAN_HISTOGRAM;
+}
+
+void BooleanHistogram::AddBoolean(bool value) {
+ Add(value ? 1 : 0);
+}
+
+BooleanHistogram::BooleanHistogram(const std::string& name)
+ : LinearHistogram(name, 1, 2, 3) {
+}
//------------------------------------------------------------------------------
// CustomHistogram:
@@ -706,6 +747,10 @@ scoped_refptr<Histogram> CustomHistogram::FactoryGet(
return histogram;
}
+Histogram::ClassType CustomHistogram::histogram_type() const {
+ return CUSTOM_HISTOGRAM;
+}
+
CustomHistogram::CustomHistogram(const std::string& name,
const std::vector<int>& custom_ranges)
: Histogram(name, custom_ranges[1], custom_ranges.back(),
diff --git a/base/histogram.h b/base/histogram.h
index 441507b..1d13544 100644
--- a/base/histogram.h
+++ b/base/histogram.h
@@ -319,7 +319,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> {
void Add(int value);
// This method is an interface, used only by BooleanHistogram.
- virtual void AddBoolean(bool value) { DCHECK(false); }
+ virtual void AddBoolean(bool value);
// Accept a TimeDelta to increment.
void AddTime(base::TimeDelta time) {
@@ -329,8 +329,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> {
void AddSampleSet(const SampleSet& sample);
// This method is an interface, used only by LinearHistogram.
- virtual void SetRangeDescriptions(const DescriptionPair descriptions[])
- { DCHECK(false); }
+ virtual void SetRangeDescriptions(const DescriptionPair descriptions[]);
// The following methods provide graphical histogram displays.
void WriteHTMLGraph(std::string* output) const;
@@ -373,17 +372,11 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> {
virtual void SnapshotSample(SampleSet* sample) const;
virtual bool HasConstructorArguments(Sample minimum, Sample maximum,
- size_t bucket_count) {
- return ((minimum == declared_min_) && (maximum == declared_max_) &&
- (bucket_count == bucket_count_));
- }
+ size_t bucket_count);
virtual bool HasConstructorTimeDeltaArguments(base::TimeDelta minimum,
- base::TimeDelta maximum, size_t bucket_count) {
- return ((minimum.InMilliseconds() == declared_min_) &&
- (maximum.InMilliseconds() == declared_max_) &&
- (bucket_count == bucket_count_));
- }
+ base::TimeDelta maximum,
+ size_t bucket_count);
protected:
friend class base::RefCountedThreadSafe<Histogram>;
@@ -395,7 +388,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> {
virtual ~Histogram();
// Method to override to skip the display of the i'th bucket if it's empty.
- virtual bool PrintEmptyBucket(size_t index) const { return true; }
+ virtual bool PrintEmptyBucket(size_t index) const;
//----------------------------------------------------------------------------
// Methods to override to create histogram with different bucket widths.
@@ -488,7 +481,7 @@ class Histogram : public base::RefCountedThreadSafe<Histogram> {
// buckets.
class LinearHistogram : public Histogram {
public:
- virtual ClassType histogram_type() const { return LINEAR_HISTOGRAM; }
+ virtual ClassType histogram_type() const;
// Store a list of number/text values for use in rendering the histogram.
// The last element in the array has a null in its "description" slot.
@@ -539,14 +532,12 @@ class BooleanHistogram : public LinearHistogram {
static scoped_refptr<Histogram> FactoryGet(const std::string& name,
Flags flags);
- virtual ClassType histogram_type() const { return BOOLEAN_HISTOGRAM; }
+ virtual ClassType histogram_type() const;
- virtual void AddBoolean(bool value) { Add(value ? 1 : 0); }
+ virtual void AddBoolean(bool value);
private:
- explicit BooleanHistogram(const std::string& name)
- : LinearHistogram(name, 1, 2, 3) {
- }
+ explicit BooleanHistogram(const std::string& name);
DISALLOW_COPY_AND_ASSIGN(BooleanHistogram);
};
@@ -556,7 +547,7 @@ class BooleanHistogram : public LinearHistogram {
// CustomHistogram is a histogram for a set of custom integers.
class CustomHistogram : public Histogram {
public:
- virtual ClassType histogram_type() const { return CUSTOM_HISTOGRAM; }
+ virtual ClassType histogram_type() const;
static scoped_refptr<Histogram> FactoryGet(const std::string& name,
const std::vector<int>& custom_ranges, Flags flags);
diff --git a/base/process_posix.cc b/base/process_posix.cc
index 904884a..ee70e5a 100644
--- a/base/process_posix.cc
+++ b/base/process_posix.cc
@@ -9,6 +9,7 @@
#include <sys/resource.h>
#include "base/process_util.h"
+#include "base/logging.h"
namespace base {
diff --git a/base/process_util.h b/base/process_util.h
index d7ff940..4cb954b 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -33,9 +33,7 @@ typedef struct _malloc_zone_t malloc_zone_t;
#include <utility>
#include <vector>
-#include "base/command_line.h"
#include "base/file_descriptor_shuffle.h"
-#include "base/file_path.h"
#include "base/process.h"
#ifndef NAME_MAX // Solaris and some BSDs have no NAME_MAX
@@ -46,6 +44,9 @@ typedef struct _malloc_zone_t malloc_zone_t;
#endif
#endif
+class CommandLine;
+class FilePath;
+
namespace base {
#if defined(OS_WIN)
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index cae70a5..3455a43 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -16,6 +16,7 @@
#include <limits>
#include <set>
+#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/debug_util.h"
#include "base/dir_reader_posix.h"
@@ -25,6 +26,7 @@
#include "base/process_util.h"
#include "base/rand_util.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
#include "base/time.h"
#include "base/waitable_event.h"
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 2eb73ca..428fe25 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -12,6 +12,7 @@
#include <ios>
+#include "base/command_line.h"
#include "base/debug_util.h"
#include "base/histogram.h"
#include "base/logging.h"
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index ce40d9a..3c40fd1 100644
--- a/base/test/test_suite.h
+++ b/base/test/test_suite.h
@@ -14,6 +14,7 @@
#include "base/base_paths.h"
#include "base/debug_on_start.h"
#include "base/debug_util.h"
+#include "base/file_path.h"
#include "base/i18n/icu_util.h"
#include "base/multiprocess_test.h"
#include "base/nss_util.h"