diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gypi | 2 | ||||
-rw-r--r-- | base/command_line.cc | 7 | ||||
-rw-r--r-- | base/command_line.h | 3 | ||||
-rw-r--r-- | base/env_var.cc | 6 | ||||
-rw-r--r-- | base/env_var.h | 7 | ||||
-rw-r--r-- | base/message_loop.cc | 11 | ||||
-rw-r--r-- | base/message_loop.h | 6 | ||||
-rw-r--r-- | base/task.cc | 17 | ||||
-rw-r--r-- | base/task.h | 7 | ||||
-rw-r--r-- | base/tracked.cc | 14 | ||||
-rw-r--r-- | base/tracked.h | 10 | ||||
-rw-r--r-- | base/values.cc | 25 | ||||
-rw-r--r-- | base/values.h | 17 | ||||
-rw-r--r-- | base/weak_ptr.cc | 65 | ||||
-rw-r--r-- | base/weak_ptr.h | 54 |
15 files changed, 182 insertions, 69 deletions
diff --git a/base/base.gypi b/base/base.gypi index d590df0..ff05d2a 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -235,6 +235,7 @@ 'sys_string_conversions_linux.cc', 'sys_string_conversions_mac.mm', 'sys_string_conversions_win.cc', + 'task.cc', 'task.h', 'template_util.h', 'thread.cc', @@ -277,6 +278,7 @@ 'waitable_event_win.cc', 'watchdog.cc', 'watchdog.h', + 'weak_ptr.cc', 'weak_ptr.h', 'win_util.cc', 'win_util.h', diff --git a/base/command_line.cc b/base/command_line.cc index 2c6ef0b..2a7824d 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -55,6 +55,9 @@ static void Lowercase(std::string* parameter) { } #endif +CommandLine::~CommandLine() { +} + #if defined(OS_WIN) CommandLine::CommandLine(ArgumentsOnly args_only) { } @@ -437,3 +440,7 @@ void CommandLine::PrependWrapper(const std::wstring& wrapper_wide) { } #endif + +// private +CommandLine::CommandLine() { +} diff --git a/base/command_line.h b/base/command_line.h index b2b4185..c68711a 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -35,6 +35,7 @@ class CommandLine { // A constructor for CommandLines that are used only to carry arguments. enum ArgumentsOnly { ARGUMENTS_ONLY }; explicit CommandLine(ArgumentsOnly args_only); + ~CommandLine(); #if defined(OS_WIN) // The type of native command line arguments. @@ -203,7 +204,7 @@ class CommandLine { private: friend class InProcessBrowserTest; - CommandLine() {} + CommandLine(); // Used by InProcessBrowserTest. static CommandLine* ForCurrentProcessMutable() { diff --git a/base/env_var.cc b/base/env_var.cc index 8d32c02..bcdadb9 100644 --- a/base/env_var.cc +++ b/base/env_var.cc @@ -85,6 +85,12 @@ class EnvVarGetterImpl : public base::EnvVarGetter { namespace base { +EnvVarGetter::~EnvVarGetter() {} + +bool EnvVarGetter::HasEnv(const char* variable_name) { + return GetEnv(variable_name, NULL); +} + // static EnvVarGetter* EnvVarGetter::Create() { return new EnvVarGetterImpl(); diff --git a/base/env_var.h b/base/env_var.h index 6888353..3cc2399 100644 --- a/base/env_var.h +++ b/base/env_var.h @@ -14,15 +14,14 @@ namespace base { // These are used to derive mocks for unittests. class EnvVarGetter { public: - virtual ~EnvVarGetter() {} + virtual ~EnvVarGetter(); + // Gets an environment variable's value and stores it in |result|. // Returns false if the key is unset. virtual bool GetEnv(const char* variable_name, std::string* result) = 0; // Syntactic sugar for GetEnv(variable_name, NULL); - virtual bool HasEnv(const char* variable_name) { - return GetEnv(variable_name, NULL); - } + virtual bool HasEnv(const char* variable_name); virtual void SetEnv(const char* variable_name, const std::string& new_value) = 0; diff --git a/base/message_loop.cc b/base/message_loop.cc index 218ff26..1d86f79 100644 --- a/base/message_loop.cc +++ b/base/message_loop.cc @@ -100,6 +100,17 @@ static LPTOP_LEVEL_EXCEPTION_FILTER GetTopSEHFilter() { //------------------------------------------------------------------------------ +MessageLoop::TaskObserver::TaskObserver() { +} + +MessageLoop::TaskObserver::~TaskObserver() { +} + +MessageLoop::DestructionObserver::~DestructionObserver() { +} + +//------------------------------------------------------------------------------ + // static MessageLoop* MessageLoop::current() { // TODO(darin): sadly, we cannot enable this yet since people call us even diff --git a/base/message_loop.h b/base/message_loop.h index 35b2651..62da3dd 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -66,7 +66,7 @@ class MessageLoop : public base::MessagePump::Delegate { // NOTE: A TaskObserver implementation should be extremely fast! class TaskObserver { public: - TaskObserver() {} + TaskObserver(); // This method is called before processing a task. virtual void WillProcessTask(base::TimeTicks birth_time) = 0; @@ -75,7 +75,7 @@ class MessageLoop : public base::MessagePump::Delegate { virtual void DidProcessTask() = 0; protected: - virtual ~TaskObserver() {} + virtual ~TaskObserver(); }; static void EnableHistogrammer(bool enable_histogrammer); @@ -90,7 +90,7 @@ class MessageLoop : public base::MessagePump::Delegate { // class DestructionObserver { public: - virtual ~DestructionObserver() {} + virtual ~DestructionObserver(); virtual void WillDestroyCurrentMessageLoop() = 0; }; diff --git a/base/task.cc b/base/task.cc new file mode 100644 index 0000000..d33f3e1 --- /dev/null +++ b/base/task.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2010 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/task.h" + +Task::Task() { +} + +Task::~Task() { +} + +CancelableTask::CancelableTask() { +} + +CancelableTask::~CancelableTask() { +} diff --git a/base/task.h b/base/task.h index 1425546..64b10f3 100644 --- a/base/task.h +++ b/base/task.h @@ -18,8 +18,8 @@ class Task : public tracked_objects::Tracked { public: - Task() {} - virtual ~Task() {} + Task(); + virtual ~Task(); // Tasks are automatically deleted after Run is called. virtual void Run() = 0; @@ -27,6 +27,9 @@ class Task : public tracked_objects::Tracked { class CancelableTask : public Task { public: + CancelableTask(); + virtual ~CancelableTask(); + // Not all tasks support cancellation. virtual void Cancel() = 0; }; diff --git a/base/tracked.cc b/base/tracked.cc index fdac6d3..a9d6ad7 100644 --- a/base/tracked.cc +++ b/base/tracked.cc @@ -12,6 +12,20 @@ using base::TimeTicks; namespace tracked_objects { //------------------------------------------------------------------------------ + +Location::Location(const char* function_name, const char* file_name, + int line_number) + : function_name_(function_name), + file_name_(file_name), + line_number_(line_number) { +} + +Location::Location() + : function_name_("Unknown"), + file_name_("Unknown"), + line_number_(-1) { +} + void Location::Write(bool display_filename, bool display_function_name, std::string* output) const { StringAppendF(output, "%s[%d] ", diff --git a/base/tracked.h b/base/tracked.h index 3622d1c..af904c1 100644 --- a/base/tracked.h +++ b/base/tracked.h @@ -39,16 +39,10 @@ class Location { // Constructor should be called with a long-lived char*, such as __FILE__. // It assumes the provided value will persist as a global constant, and it // will not make a copy of it. - Location(const char* function_name, const char* file_name, int line_number) - : function_name_(function_name), - file_name_(file_name), - line_number_(line_number) { } + Location(const char* function_name, const char* file_name, int line_number); // Provide a default constructor for easy of debugging. - Location() - : function_name_("Unknown"), - file_name_("Unknown"), - line_number_(-1) { } + Location(); // Comparison operator for insertion into a std::map<> hash tables. // All we need is *some* (any) hashing distinction. Strings should already diff --git a/base/values.cc b/base/values.cc index 507646c..58a91f1 100644 --- a/base/values.cc +++ b/base/values.cc @@ -142,8 +142,23 @@ bool Value::Equals(const Value* other) const { return other->IsType(TYPE_NULL); } +Value::Value(ValueType type) : type_(type) { +} + ///////////////////// FundamentalValue //////////////////// +FundamentalValue::FundamentalValue(bool in_value) + : Value(TYPE_BOOLEAN), boolean_value_(in_value) { +} + +FundamentalValue::FundamentalValue(int in_value) + : Value(TYPE_INTEGER), integer_value_(in_value) { +} + +FundamentalValue::FundamentalValue(double in_value) + : Value(TYPE_REAL), real_value_(in_value) { +} + FundamentalValue::~FundamentalValue() { } @@ -307,6 +322,10 @@ bool BinaryValue::Equals(const Value* other) const { ///////////////////// DictionaryValue //////////////////// +DictionaryValue::DictionaryValue() + : Value(TYPE_DICTIONARY) { +} + DictionaryValue::~DictionaryValue() { Clear(); } @@ -696,6 +715,9 @@ void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { ///////////////////// ListValue //////////////////// +ListValue::ListValue() : Value(TYPE_LIST) { +} + ListValue::~ListValue() { Clear(); } @@ -898,3 +920,6 @@ bool ListValue::Equals(const Value* other) const { return true; } + +ValueSerializer::~ValueSerializer() { +} diff --git a/base/values.h b/base/values.h index 5c0ea33..ea8a3ca 100644 --- a/base/values.h +++ b/base/values.h @@ -104,7 +104,7 @@ class Value { protected: // This isn't safe for end-users (they should use the Create*Value() // static methods above), but it's useful for subclasses. - explicit Value(ValueType type) : type_(type) {} + explicit Value(ValueType type); private: Value(); @@ -117,12 +117,9 @@ class Value { // FundamentalValue represents the simple fundamental types of values. class FundamentalValue : public Value { public: - explicit FundamentalValue(bool in_value) - : Value(TYPE_BOOLEAN), boolean_value_(in_value) {} - explicit FundamentalValue(int in_value) - : Value(TYPE_INTEGER), integer_value_(in_value) {} - explicit FundamentalValue(double in_value) - : Value(TYPE_REAL), real_value_(in_value) {} + explicit FundamentalValue(bool in_value); + explicit FundamentalValue(int in_value); + explicit FundamentalValue(double in_value); ~FundamentalValue(); // Subclassed methods @@ -206,7 +203,7 @@ class BinaryValue: public Value { class DictionaryValue : public Value { public: - DictionaryValue() : Value(TYPE_DICTIONARY) {} + DictionaryValue(); ~DictionaryValue(); // Subclassed methods @@ -352,7 +349,7 @@ class DictionaryValue : public Value { // This type of Value represents a list of other Value values. class ListValue : public Value { public: - ListValue() : Value(TYPE_LIST) {} + ListValue(); ~ListValue(); // Subclassed methods @@ -435,7 +432,7 @@ class ListValue : public Value { // deserialize Value objects. class ValueSerializer { public: - virtual ~ValueSerializer() {} + virtual ~ValueSerializer(); virtual bool Serialize(const Value& root) = 0; diff --git a/base/weak_ptr.cc b/base/weak_ptr.cc new file mode 100644 index 0000000..2c8f5aa --- /dev/null +++ b/base/weak_ptr.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2010 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/weak_ptr.h" + +namespace base { +namespace internal { + +WeakReference::Flag::Flag(Flag** handle) : handle_(handle) { +} + +WeakReference::Flag::~Flag() { + if (handle_) + *handle_ = NULL; +} + +void WeakReference::Flag::AddRef() { + DCHECK(CalledOnValidThread()); + RefCounted<Flag>::AddRef(); +} + +void WeakReference::Flag::Release() { + DCHECK(CalledOnValidThread()); + RefCounted<Flag>::Release(); +} + +WeakReference::WeakReference() { +} + +WeakReference::WeakReference(Flag* flag) : flag_(flag) { +} + +bool WeakReference::is_valid() const { + return flag_ && flag_->is_valid(); +} + +WeakReferenceOwner::WeakReferenceOwner() : flag_(NULL) { +} + +WeakReferenceOwner::~WeakReferenceOwner() { + Invalidate(); +} + +WeakReference WeakReferenceOwner::GetRef() const { + if (!flag_) + flag_ = new WeakReference::Flag(&flag_); + return WeakReference(flag_); +} + +void WeakReferenceOwner::Invalidate() { + if (flag_) { + flag_->Invalidate(); + flag_ = NULL; + } +} + +WeakPtrBase::WeakPtrBase() { +} + +WeakPtrBase::WeakPtrBase(const WeakReference& ref) : ref_(ref) { +} + +} // namespace internal +} // namespace base diff --git a/base/weak_ptr.h b/base/weak_ptr.h index 1bc963e..85a26d16 100644 --- a/base/weak_ptr.h +++ b/base/weak_ptr.h @@ -65,24 +65,11 @@ class WeakReference { public: class Flag : public RefCounted<Flag>, public NonThreadSafe { public: - Flag(Flag** handle) : handle_(handle) { - } - - ~Flag() { - if (handle_) - *handle_ = NULL; - } - - void AddRef() { - DCHECK(CalledOnValidThread()); - RefCounted<Flag>::AddRef(); - } - - void Release() { - DCHECK(CalledOnValidThread()); - RefCounted<Flag>::Release(); - } + Flag(Flag** handle); + ~Flag(); + void AddRef(); + void Release(); void Invalidate() { handle_ = NULL; } bool is_valid() const { return handle_ != NULL; } @@ -90,10 +77,10 @@ class WeakReference { Flag** handle_; }; - WeakReference() {} - WeakReference(Flag* flag) : flag_(flag) {} + WeakReference(); + WeakReference(Flag* flag); - bool is_valid() const { return flag_ && flag_->is_valid(); } + bool is_valid() const; private: scoped_refptr<Flag> flag_; @@ -101,29 +88,16 @@ class WeakReference { class WeakReferenceOwner { public: - WeakReferenceOwner() : flag_(NULL) { - } - - ~WeakReferenceOwner() { - Invalidate(); - } + WeakReferenceOwner(); + ~WeakReferenceOwner(); - WeakReference GetRef() const { - if (!flag_) - flag_ = new WeakReference::Flag(&flag_); - return WeakReference(flag_); - } + WeakReference GetRef() const; bool HasRefs() const { return flag_ != NULL; } - void Invalidate() { - if (flag_) { - flag_->Invalidate(); - flag_ = NULL; - } - } + void Invalidate(); private: mutable WeakReference::Flag* flag_; @@ -135,12 +109,10 @@ class WeakReferenceOwner { // base class gives us a way to access ref_ in a protected fashion. class WeakPtrBase { public: - WeakPtrBase() { - } + WeakPtrBase(); protected: - WeakPtrBase(const WeakReference& ref) : ref_(ref) { - } + WeakPtrBase(const WeakReference& ref); WeakReference ref_; }; |