summaryrefslogtreecommitdiffstats
path: root/base/non_thread_safe.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-01 04:48:49 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-01 04:48:49 +0000
commitc91775096768e4a75b23a910ddc1e33d9412a3be (patch)
treecb807f9b28d88b4950e41d32fbe73a5c81a94c40 /base/non_thread_safe.h
parente0eb450f398ae888aa0fbdb7fd3abc072d5846a2 (diff)
downloadchromium_src-c91775096768e4a75b23a910ddc1e33d9412a3be.zip
chromium_src-c91775096768e4a75b23a910ddc1e33d9412a3be.tar.gz
chromium_src-c91775096768e4a75b23a910ddc1e33d9412a3be.tar.bz2
Move non_thread_safe from base to base/threading and into the base namespace.
TEST=it compiles BUG=none Review URL: http://codereview.chromium.org/6005010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/non_thread_safe.h')
-rw-r--r--base/non_thread_safe.h60
1 files changed, 0 insertions, 60 deletions
diff --git a/base/non_thread_safe.h b/base/non_thread_safe.h
deleted file mode 100644
index 24a9012..0000000
--- a/base/non_thread_safe.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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.
-
-#ifndef BASE_NON_THREAD_SAFE_H_
-#define BASE_NON_THREAD_SAFE_H_
-#pragma once
-
-#include "base/threading/thread_checker.h"
-
-// 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.
-//
-// This is intended to be used with classes that appear to be thread safe, but
-// aren't. For example, a service or a singleton like the preferences system.
-//
-// Example:
-// class MyClass : public NonThreadSafe {
-// public:
-// void Foo() {
-// DCHECK(CalledOnValidThread());
-// ... (do stuff) ...
-// }
-// }
-//
-// In Release mode, CalledOnValidThread will always return true.
-//
-#ifndef NDEBUG
-class NonThreadSafe {
- public:
- ~NonThreadSafe();
-
- bool CalledOnValidThread() const;
-
- protected:
- // Changes the thread that is checked for in CalledOnValidThread. The next
- // call to CalledOnValidThread will attach this class to a new thread. It is
- // up to the NonThreadSafe derived class to decide to expose this or not.
- // This may be useful when an object may be created on one thread and then
- // used exclusively on another thread.
- void DetachFromThread();
-
- private:
- base::ThreadChecker thread_checker_;
-};
-#else
-// Do nothing in release mode.
-class NonThreadSafe {
- public:
- bool CalledOnValidThread() const {
- return true;
- }
-
- protected:
- void DetachFromThread() {}
-};
-#endif // NDEBUG
-
-#endif // BASE_NON_THREAD_SAFE_H_