summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp2
-rw-r--r--base/base.gypi5
-rw-r--r--base/task.h1
-rw-r--r--base/threading/non_thread_safe.cc (renamed from base/non_thread_safe.cc)6
-rw-r--r--base/threading/non_thread_safe.h (renamed from base/non_thread_safe.h)12
-rw-r--r--base/threading/non_thread_safe_unittest.cc (renamed from base/non_thread_safe_unittest.cc)10
-rw-r--r--base/weak_ptr.h6
7 files changed, 26 insertions, 16 deletions
diff --git a/base/base.gyp b/base/base.gyp
index b1e61e2..97cb3e0 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -106,7 +106,6 @@
'metrics/field_trial_unittest.cc',
'metrics/histogram_unittest.cc',
'metrics/stats_table_unittest.cc',
- 'non_thread_safe_unittest.cc',
'object_watcher_unittest.cc',
'observer_list_unittest.cc',
'path_service_unittest.cc',
@@ -139,6 +138,7 @@
'sys_string_conversions_unittest.cc',
'task_queue_unittest.cc',
'task_unittest.cc',
+ 'threading/non_thread_safe_unittest.cc',
'threading/platform_thread_unittest.cc',
'threading/simple_thread_unittest.cc',
'threading/thread_checker_unittest.cc',
diff --git a/base/base.gypi b/base/base.gypi
index 451803a..e7ebe0d 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -151,9 +151,6 @@
'native_library_linux.cc',
'native_library_mac.mm',
'native_library_win.cc',
- 'non_thread_safe.cc',
- 'non_thread_safe.h',
- 'nullable_string16.h',
'object_watcher.cc',
'object_watcher.h',
'observer_list.h',
@@ -239,6 +236,8 @@
'task_queue.cc',
'task_queue.h',
'template_util.h',
+ 'threading/non_thread_safe.cc',
+ 'threading/non_thread_safe.h',
'threading/platform_thread.h',
'threading/platform_thread_mac.mm',
'threading/platform_thread_posix.cc',
diff --git a/base/task.h b/base/task.h
index 85c0878..fc986b2 100644
--- a/base/task.h
+++ b/base/task.h
@@ -6,7 +6,6 @@
#define BASE_TASK_H_
#pragma once
-#include "base/non_thread_safe.h"
#include "base/raw_scoped_refptr_mismatch_checker.h"
#include "base/tracked.h"
#include "base/tuple.h"
diff --git a/base/non_thread_safe.cc b/base/threading/non_thread_safe.cc
index b01ed55..8b41bc0 100644
--- a/base/non_thread_safe.cc
+++ b/base/threading/non_thread_safe.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/non_thread_safe.h"
+#include "base/threading/non_thread_safe.h"
// These checks are only done in debug builds.
#ifndef NDEBUG
#include "base/logging.h"
+namespace base {
+
NonThreadSafe::~NonThreadSafe() {
DCHECK(CalledOnValidThread());
}
@@ -21,4 +23,6 @@ void NonThreadSafe::DetachFromThread() {
thread_checker_.DetachFromThread();
}
+} // namespace base
+
#endif // NDEBUG
diff --git a/base/non_thread_safe.h b/base/threading/non_thread_safe.h
index 24a9012..868a031 100644
--- a/base/non_thread_safe.h
+++ b/base/threading/non_thread_safe.h
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_NON_THREAD_SAFE_H_
-#define BASE_NON_THREAD_SAFE_H_
+#ifndef BASE_THREADING_NON_THREAD_SAFE_H_
+#define BASE_THREADING_NON_THREAD_SAFE_H_
#pragma once
#include "base/threading/thread_checker.h"
+namespace base {
+
// A helper class used to help verify that methods of a class are
// called from the same thread. One can inherit from this class and use
// CalledOnValidThread() to verify.
@@ -16,7 +18,7 @@
// aren't. For example, a service or a singleton like the preferences system.
//
// Example:
-// class MyClass : public NonThreadSafe {
+// class MyClass : public base::NonThreadSafe {
// public:
// void Foo() {
// DCHECK(CalledOnValidThread());
@@ -42,7 +44,7 @@ class NonThreadSafe {
void DetachFromThread();
private:
- base::ThreadChecker thread_checker_;
+ ThreadChecker thread_checker_;
};
#else
// Do nothing in release mode.
@@ -57,4 +59,6 @@ class NonThreadSafe {
};
#endif // NDEBUG
+} // namespace base
+
#endif // BASE_NON_THREAD_SAFE_H_
diff --git a/base/non_thread_safe_unittest.cc b/base/threading/non_thread_safe_unittest.cc
index 98af0e1..7d158cf 100644
--- a/base/non_thread_safe_unittest.cc
+++ b/base/threading/non_thread_safe_unittest.cc
@@ -4,13 +4,15 @@
#include "base/basictypes.h"
#include "base/logging.h"
-#include "base/non_thread_safe.h"
#include "base/scoped_ptr.h"
+#include "base/threading/non_thread_safe.h"
#include "base/threading/simple_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#ifndef NDEBUG
+namespace base {
+
// Simple class to exersice the basics of NonThreadSafe.
// Both the destructor and DoStuff should verify that they were
// called on the same thread as the constructor.
@@ -32,7 +34,7 @@ class NonThreadSafeClass : public NonThreadSafe {
};
// Calls NonThreadSafeClass::DoStuff on another thread.
-class CallDoStuffOnThread : public base::SimpleThread {
+class CallDoStuffOnThread : public SimpleThread {
public:
CallDoStuffOnThread(NonThreadSafeClass* non_thread_safe_class)
: SimpleThread("call_do_stuff_on_thread"),
@@ -50,7 +52,7 @@ class CallDoStuffOnThread : public base::SimpleThread {
};
// Deletes NonThreadSafeClass on a different thread.
-class DeleteNonThreadSafeClassOnThread : public base::SimpleThread {
+class DeleteNonThreadSafeClassOnThread : public SimpleThread {
public:
DeleteNonThreadSafeClassOnThread(NonThreadSafeClass* non_thread_safe_class)
: SimpleThread("delete_non_thread_safe_class_on_thread"),
@@ -123,4 +125,6 @@ TEST(NonThreadSafeDeathTest, DestructorNotAllowedOnDifferentThread) {
#endif // GTEST_HAS_DEATH_TEST
+} // namespace base
+
#endif // NDEBUG
diff --git a/base/weak_ptr.h b/base/weak_ptr.h
index ed9ef66..6168367 100644
--- a/base/weak_ptr.h
+++ b/base/weak_ptr.h
@@ -53,8 +53,8 @@
#pragma once
#include "base/logging.h"
-#include "base/non_thread_safe.h"
#include "base/ref_counted.h"
+#include "base/threading/non_thread_safe.h"
namespace base {
@@ -64,7 +64,7 @@ namespace internal {
class WeakReference {
public:
- class Flag : public RefCounted<Flag>, public NonThreadSafe {
+ class Flag : public RefCounted<Flag>, public base::NonThreadSafe {
public:
Flag(Flag** handle);
~Flag();
@@ -74,7 +74,7 @@ class WeakReference {
void Invalidate() { handle_ = NULL; }
bool is_valid() const { return handle_ != NULL; }
- void DetachFromThread() { NonThreadSafe::DetachFromThread(); }
+ void DetachFromThread() { base::NonThreadSafe::DetachFromThread(); }
private:
Flag** handle_;