diff options
27 files changed, 51 insertions, 47 deletions
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc index 1d808a6..5ca67e9 100644 --- a/base/bind_unittest.cc +++ b/base/bind_unittest.cc @@ -106,7 +106,7 @@ class CopyCounter { } // Probing for copies from coercion. - CopyCounter(const DerivedCopyCounter& other) + explicit CopyCounter(const DerivedCopyCounter& other) : copies_(other.copies_), assigns_(other.assigns_) { (*copies_)++; @@ -766,7 +766,7 @@ TEST_F(BindTest, ArgumentCopies) { DerivedCopyCounter dervied(&copies, &assigns); Callback<void(CopyCounter)> coerce_cb = Bind(&VoidPolymorphic1<CopyCounter>); - coerce_cb.Run(dervied); + coerce_cb.Run(CopyCounter(dervied)); EXPECT_GE(2, copies); EXPECT_EQ(0, assigns); } diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc index 2c2bef1a..6103b2e 100644 --- a/base/callback_unittest.cc +++ b/base/callback_unittest.cc @@ -148,7 +148,7 @@ TEST_F(CallbackTest, ResetAndReturn) { class CallbackOwner : public base::RefCounted<CallbackOwner> { public: - CallbackOwner(bool* deleted) { + explicit CallbackOwner(bool* deleted) { callback_ = Bind(&CallbackOwner::Unused, this); deleted_ = deleted; } diff --git a/base/containers/small_map_unittest.cc b/base/containers/small_map_unittest.cc index d1c8680..c90a303 100644 --- a/base/containers/small_map_unittest.cc +++ b/base/containers/small_map_unittest.cc @@ -424,7 +424,8 @@ namespace { class hash_map_add_item : public hash_map<int, int> { public: hash_map_add_item() : hash_map<int, int>() {} - hash_map_add_item(const std::pair<int, int>& item) : hash_map<int, int>() { + explicit hash_map_add_item(const std::pair<int, int>& item) + : hash_map<int, int>() { insert(item); } }; diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc index 7930a40..e1e006e 100644 --- a/base/debug/stack_trace_posix.cc +++ b/base/debug/stack_trace_posix.cc @@ -323,7 +323,7 @@ class PrintBacktraceOutputHandler : public BacktraceOutputHandler { class StreamBacktraceOutputHandler : public BacktraceOutputHandler { public: - StreamBacktraceOutputHandler(std::ostream* os) : os_(os) { + explicit StreamBacktraceOutputHandler(std::ostream* os) : os_(os) { } virtual void HandleOutput(const char* output) { diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h index 58bd023..fc8897e 100644 --- a/base/debug/trace_event.h +++ b/base/debug/trace_event.h @@ -719,33 +719,33 @@ class TraceID { unsigned long long data_; }; - explicit TraceID(const void* id, unsigned char* flags) + TraceID(const void* id, unsigned char* flags) : data_(static_cast<unsigned long long>( reinterpret_cast<unsigned long>(id))) { *flags |= TRACE_EVENT_FLAG_MANGLE_ID; } - explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) { + TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) { *flags |= TRACE_EVENT_FLAG_MANGLE_ID; } - explicit TraceID(unsigned long long id, unsigned char* flags) + TraceID(unsigned long long id, unsigned char* flags) : data_(id) { (void)flags; } - explicit TraceID(unsigned long id, unsigned char* flags) + TraceID(unsigned long id, unsigned char* flags) : data_(id) { (void)flags; } - explicit TraceID(unsigned int id, unsigned char* flags) + TraceID(unsigned int id, unsigned char* flags) : data_(id) { (void)flags; } - explicit TraceID(unsigned short id, unsigned char* flags) + TraceID(unsigned short id, unsigned char* flags) : data_(id) { (void)flags; } - explicit TraceID(unsigned char id, unsigned char* flags) + TraceID(unsigned char id, unsigned char* flags) : data_(id) { (void)flags; } - explicit TraceID(long long id, unsigned char* flags) + TraceID(long long id, unsigned char* flags) : data_(static_cast<unsigned long long>(id)) { (void)flags; } - explicit TraceID(long id, unsigned char* flags) + TraceID(long id, unsigned char* flags) : data_(static_cast<unsigned long long>(id)) { (void)flags; } - explicit TraceID(int id, unsigned char* flags) + TraceID(int id, unsigned char* flags) : data_(static_cast<unsigned long long>(id)) { (void)flags; } - explicit TraceID(short id, unsigned char* flags) + TraceID(short id, unsigned char* flags) : data_(static_cast<unsigned long long>(id)) { (void)flags; } - explicit TraceID(signed char id, unsigned char* flags) + TraceID(signed char id, unsigned char* flags) : data_(static_cast<unsigned long long>(id)) { (void)flags; } unsigned long long data() const { return data_; } diff --git a/base/event_recorder.h b/base/event_recorder.h index 32e1124..979e806 100644 --- a/base/event_recorder.h +++ b/base/event_recorder.h @@ -74,7 +74,7 @@ class BASE_EXPORT EventRecorder { // Create a new EventRecorder. Events are saved to the file filename. // If the file already exists, it will be deleted before recording // starts. - explicit EventRecorder() + EventRecorder() : is_recording_(false), is_playing_(false), #if defined(OS_WIN) diff --git a/base/i18n/char_iterator.h b/base/i18n/char_iterator.h index 431e350..25bcf9a 100644 --- a/base/i18n/char_iterator.h +++ b/base/i18n/char_iterator.h @@ -30,7 +30,7 @@ namespace i18n { class BASE_I18N_EXPORT UTF8CharIterator { public: // Requires |str| to live as long as the UTF8CharIterator does. - UTF8CharIterator(const std::string* str); + explicit UTF8CharIterator(const std::string* str); ~UTF8CharIterator(); // Return the starting array index of the current character within the @@ -76,7 +76,7 @@ class BASE_I18N_EXPORT UTF8CharIterator { class BASE_I18N_EXPORT UTF16CharIterator { public: // Requires |str| to live as long as the UTF16CharIterator does. - UTF16CharIterator(const string16* str); + explicit UTF16CharIterator(const string16* str); UTF16CharIterator(const char16* str, size_t str_len); ~UTF16CharIterator(); diff --git a/base/memory/ref_counted_memory.h b/base/memory/ref_counted_memory.h index b99871b..fd5e8a0 100644 --- a/base/memory/ref_counted_memory.h +++ b/base/memory/ref_counted_memory.h @@ -65,7 +65,7 @@ class BASE_EXPORT RefCountedBytes : public RefCountedMemory { RefCountedBytes(); // Constructs a RefCountedBytes object by _copying_ from |initializer|. - RefCountedBytes(const std::vector<unsigned char>& initializer); + explicit RefCountedBytes(const std::vector<unsigned char>& initializer); // Constructs a RefCountedBytes object by performing a swap. (To non // destructively build a RefCountedBytes, use the constructor that takes a diff --git a/base/message_pump_libevent_unittest.cc b/base/message_pump_libevent_unittest.cc index 3e06478..c7d908e 100644 --- a/base/message_pump_libevent_unittest.cc +++ b/base/message_pump_libevent_unittest.cc @@ -85,7 +85,7 @@ TEST_F(MessagePumpLibeventTest, TestWatchingFromBadThread) { class BaseWatcher : public MessagePumpLibevent::Watcher { public: - BaseWatcher(MessagePumpLibevent::FileDescriptorWatcher* controller) + explicit BaseWatcher(MessagePumpLibevent::FileDescriptorWatcher* controller) : controller_(controller) { DCHECK(controller_); } diff --git a/base/metrics/bucket_ranges.h b/base/metrics/bucket_ranges.h index 90b9047..210b9a7 100644 --- a/base/metrics/bucket_ranges.h +++ b/base/metrics/bucket_ranges.h @@ -30,7 +30,7 @@ class BASE_EXPORT BucketRanges { public: typedef std::vector<HistogramBase::Sample> Ranges; - BucketRanges(size_t num_ranges); + explicit BucketRanges(size_t num_ranges); ~BucketRanges(); size_t size() const { return ranges_.size(); } diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h index 69e1437..949e864 100644 --- a/base/metrics/histogram_base.h +++ b/base/metrics/histogram_base.h @@ -69,7 +69,7 @@ class BASE_EXPORT HistogramBase { kHexRangePrintingFlag = 0x8000, }; - HistogramBase(const std::string& name); + explicit HistogramBase(const std::string& name); virtual ~HistogramBase(); std::string histogram_name() const { return histogram_name_; } diff --git a/base/metrics/histogram_samples.cc b/base/metrics/histogram_samples.cc index e375952..0e0eeb4 100644 --- a/base/metrics/histogram_samples.cc +++ b/base/metrics/histogram_samples.cc @@ -13,7 +13,7 @@ namespace { class SampleCountPickleIterator : public SampleCountIterator { public: - SampleCountPickleIterator(PickleIterator* iter); + explicit SampleCountPickleIterator(PickleIterator* iter); virtual bool Done() const OVERRIDE; virtual void Next() OVERRIDE; diff --git a/base/metrics/sample_map.h b/base/metrics/sample_map.h index 22c391bb..cdd1138 100644 --- a/base/metrics/sample_map.h +++ b/base/metrics/sample_map.h @@ -46,7 +46,7 @@ class BASE_EXPORT_PRIVATE SampleMapIterator : public SampleCountIterator { typedef std::map<HistogramBase::Sample, HistogramBase::Count> SampleToCountMap; - SampleMapIterator(const SampleToCountMap& sample_counts); + explicit SampleMapIterator(const SampleToCountMap& sample_counts); virtual ~SampleMapIterator(); // SampleCountIterator implementation: diff --git a/base/metrics/sparse_histogram.h b/base/metrics/sparse_histogram.h index 346ffeb..ae4530a 100644 --- a/base/metrics/sparse_histogram.h +++ b/base/metrics/sparse_histogram.h @@ -46,7 +46,7 @@ class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { private: // Clients should always use FactoryGet to create SparseHistogram. - SparseHistogram(const std::string& name); + explicit SparseHistogram(const std::string& name); friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( PickleIterator* iter); diff --git a/base/synchronization/condition_variable_unittest.cc b/base/synchronization/condition_variable_unittest.cc index 4162d4f..a6426cf 100644 --- a/base/synchronization/condition_variable_unittest.cc +++ b/base/synchronization/condition_variable_unittest.cc @@ -35,7 +35,7 @@ class ConditionVariableTest : public PlatformTest { const TimeDelta kSixtyMs; const TimeDelta kOneHundredMs; - explicit ConditionVariableTest() + ConditionVariableTest() : kZeroMs(TimeDelta::FromMilliseconds(0)), kTenMs(TimeDelta::FromMilliseconds(10)), kThirtyMs(TimeDelta::FromMilliseconds(30)), diff --git a/base/synchronization/lock_unittest.cc b/base/synchronization/lock_unittest.cc index a048f85..e87571d 100644 --- a/base/synchronization/lock_unittest.cc +++ b/base/synchronization/lock_unittest.cc @@ -16,7 +16,7 @@ namespace base { class BasicLockTestThread : public PlatformThread::Delegate { public: - BasicLockTestThread(Lock* lock) : lock_(lock), acquired_(0) {} + explicit BasicLockTestThread(Lock* lock) : lock_(lock), acquired_(0) {} virtual void ThreadMain() OVERRIDE { for (int i = 0; i < 10; i++) { @@ -91,7 +91,7 @@ TEST(LockTest, Basic) { class TryLockTestThread : public PlatformThread::Delegate { public: - TryLockTestThread(Lock* lock) : lock_(lock), got_lock_(false) {} + explicit TryLockTestThread(Lock* lock) : lock_(lock), got_lock_(false) {} virtual void ThreadMain() OVERRIDE { got_lock_ = lock_->Try(); diff --git a/base/task_runner.cc b/base/task_runner.cc index b0563d4..5860f28 100644 --- a/base/task_runner.cc +++ b/base/task_runner.cc @@ -17,7 +17,7 @@ namespace { // possible to merge the two. class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl { public: - PostTaskAndReplyTaskRunner(TaskRunner* destination); + explicit PostTaskAndReplyTaskRunner(TaskRunner* destination); private: virtual bool PostTask(const tracked_objects::Location& from_here, diff --git a/base/test/trace_event_analyzer.h b/base/test/trace_event_analyzer.h index a472639..e2bb7de 100644 --- a/base/test/trace_event_analyzer.h +++ b/base/test/trace_event_analyzer.h @@ -352,7 +352,7 @@ class Query { // Find BEGIN events of given |name| which also have associated END events. static Query MatchBeginName(const std::string& name) { - return (Query(EVENT_NAME) == name) && MatchBeginWithEnd(); + return (Query(EVENT_NAME) == Query(name)) && MatchBeginWithEnd(); } // Match given Process ID and Thread ID. @@ -452,16 +452,16 @@ class Query { }; // Compare with the given member. - Query(TraceEventMember member); + explicit Query(TraceEventMember member); // Compare with the given member argument value. Query(TraceEventMember member, const std::string& arg_name); // Compare with the given string. - Query(const std::string& str); + explicit Query(const std::string& str); // Compare with the given number. - Query(double num); + explicit Query(double num); // Construct a boolean Query that returns (left <binary_op> right). Query(const Query& left, const Query& right, Operator binary_op); diff --git a/base/thread_task_runner_handle.h b/base/thread_task_runner_handle.h index 599d15b..348c071 100644 --- a/base/thread_task_runner_handle.h +++ b/base/thread_task_runner_handle.h @@ -22,7 +22,7 @@ class BASE_EXPORT ThreadTaskRunnerHandle { // Gets the SingleThreadTaskRunner for the current thread. static scoped_refptr<SingleThreadTaskRunner> Get(); - ThreadTaskRunnerHandle( + explicit ThreadTaskRunnerHandle( const scoped_refptr<SingleThreadTaskRunner>& task_runner); ~ThreadTaskRunnerHandle(); diff --git a/base/threading/non_thread_safe_unittest.cc b/base/threading/non_thread_safe_unittest.cc index ee31701..8a82a63 100644 --- a/base/threading/non_thread_safe_unittest.cc +++ b/base/threading/non_thread_safe_unittest.cc @@ -47,7 +47,7 @@ class NonThreadSafeClass : public NonThreadSafe { // Calls NonThreadSafeClass::DoStuff on another thread. class CallDoStuffOnThread : public SimpleThread { public: - CallDoStuffOnThread(NonThreadSafeClass* non_thread_safe_class) + explicit CallDoStuffOnThread(NonThreadSafeClass* non_thread_safe_class) : SimpleThread("call_do_stuff_on_thread"), non_thread_safe_class_(non_thread_safe_class) { } @@ -65,7 +65,8 @@ class CallDoStuffOnThread : public SimpleThread { // Deletes NonThreadSafeClass on a different thread. class DeleteNonThreadSafeClassOnThread : public SimpleThread { public: - DeleteNonThreadSafeClassOnThread(NonThreadSafeClass* non_thread_safe_class) + explicit DeleteNonThreadSafeClassOnThread( + NonThreadSafeClass* non_thread_safe_class) : SimpleThread("delete_non_thread_safe_class_on_thread"), non_thread_safe_class_(non_thread_safe_class) { } diff --git a/base/threading/thread_checker_unittest.cc b/base/threading/thread_checker_unittest.cc index 026cfd9..ae96923 100644 --- a/base/threading/thread_checker_unittest.cc +++ b/base/threading/thread_checker_unittest.cc @@ -47,7 +47,7 @@ class ThreadCheckerClass : public ThreadChecker { // Calls ThreadCheckerClass::DoStuff on another thread. class CallDoStuffOnThread : public base::SimpleThread { public: - CallDoStuffOnThread(ThreadCheckerClass* thread_checker_class) + explicit CallDoStuffOnThread(ThreadCheckerClass* thread_checker_class) : SimpleThread("call_do_stuff_on_thread"), thread_checker_class_(thread_checker_class) { } @@ -65,7 +65,8 @@ class CallDoStuffOnThread : public base::SimpleThread { // Deletes ThreadCheckerClass on a different thread. class DeleteThreadCheckerClassOnThread : public base::SimpleThread { public: - DeleteThreadCheckerClassOnThread(ThreadCheckerClass* thread_checker_class) + explicit DeleteThreadCheckerClassOnThread( + ThreadCheckerClass* thread_checker_class) : SimpleThread("delete_thread_checker_class_on_thread"), thread_checker_class_(thread_checker_class) { } diff --git a/base/threading/thread_collision_warner.h b/base/threading/thread_collision_warner.h index 2181cbd..d509a58 100644 --- a/base/threading/thread_collision_warner.h +++ b/base/threading/thread_collision_warner.h @@ -144,7 +144,7 @@ struct BASE_EXPORT DCheckAsserter : public AsserterBase { class BASE_EXPORT ThreadCollisionWarner { public: // The parameter asserter is there only for test purpose - ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter()) + explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter()) : valid_thread_id_(0), counter_(0), asserter_(asserter) {} diff --git a/base/threading/worker_pool.cc b/base/threading/worker_pool.cc index 16cc061..9e45f8c 100644 --- a/base/threading/worker_pool.cc +++ b/base/threading/worker_pool.cc @@ -17,7 +17,8 @@ namespace { class PostTaskAndReplyWorkerPool : public internal::PostTaskAndReplyImpl { public: - PostTaskAndReplyWorkerPool(bool task_is_slow) : task_is_slow_(task_is_slow) { + explicit PostTaskAndReplyWorkerPool(bool task_is_slow) + : task_is_slow_(task_is_slow) { } private: @@ -36,7 +37,7 @@ class PostTaskAndReplyWorkerPool : public internal::PostTaskAndReplyImpl { // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). class WorkerPoolTaskRunner : public TaskRunner { public: - WorkerPoolTaskRunner(bool tasks_are_slow); + explicit WorkerPoolTaskRunner(bool tasks_are_slow); // TaskRunner implementation virtual bool PostDelayedTask(const tracked_objects::Location& from_here, diff --git a/base/time.h b/base/time.h index 78d7456..9c20b54 100644 --- a/base/time.h +++ b/base/time.h @@ -241,7 +241,7 @@ class BASE_EXPORT Time { }; // Contains the NULL time. Use Time::Now() to get the current time. - explicit Time() : us_(0) { + Time() : us_(0) { } // Returns true if the time object has not been initialized. diff --git a/base/timer.cc b/base/timer.cc index 410d1b7..c7dcce0 100644 --- a/base/timer.cc +++ b/base/timer.cc @@ -18,7 +18,7 @@ namespace base { // - abandoned (orphaned) by Timer. class BaseTimerTaskInternal { public: - BaseTimerTaskInternal(Timer* timer) + explicit BaseTimerTaskInternal(Timer* timer) : timer_(timer) { } diff --git a/base/timer_unittest.cc b/base/timer_unittest.cc index 6fb89ad..1751a38 100644 --- a/base/timer_unittest.cc +++ b/base/timer_unittest.cc @@ -24,7 +24,7 @@ const int kNumTestingMessageLoops = arraysize(testing_message_loops); class OneShotTimerTester { public: - OneShotTimerTester(bool* did_run, unsigned milliseconds = 10) + explicit OneShotTimerTester(bool* did_run, unsigned milliseconds = 10) : did_run_(did_run), delay_ms_(milliseconds) { } diff --git a/base/values.cc b/base/values.cc index 7a21709..4c8968f 100644 --- a/base/values.cc +++ b/base/values.cc @@ -68,7 +68,7 @@ class ValueEquals { // Pass the value against which all consecutive calls of the () operator will // compare their argument to. This Value object must not be destroyed while // the ValueEquals is in use. - ValueEquals(const Value* first) : first_(first) { } + explicit ValueEquals(const Value* first) : first_(first) { } bool operator ()(const Value* second) const { return first_->Equals(second); |