| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/threading/thread_checker.h" | 8 #include "base/threading/thread_checker.h" |
| 9 #include "base/threading/simple_thread.h" | 9 #include "base/threading/simple_thread.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 static void MethodOnDifferentThreadImpl(); | 40 static void MethodOnDifferentThreadImpl(); |
| 41 static void DetachThenCallFromDifferentThreadImpl(); | 41 static void DetachThenCallFromDifferentThreadImpl(); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(ThreadCheckerClass); | 44 DISALLOW_COPY_AND_ASSIGN(ThreadCheckerClass); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Calls ThreadCheckerClass::DoStuff on another thread. | 47 // Calls ThreadCheckerClass::DoStuff on another thread. |
| 48 class CallDoStuffOnThread : public base::SimpleThread { | 48 class CallDoStuffOnThread : public base::SimpleThread { |
| 49 public: | 49 public: |
| 50 CallDoStuffOnThread(ThreadCheckerClass* thread_checker_class) | 50 explicit CallDoStuffOnThread(ThreadCheckerClass* thread_checker_class) |
| 51 : SimpleThread("call_do_stuff_on_thread"), | 51 : SimpleThread("call_do_stuff_on_thread"), |
| 52 thread_checker_class_(thread_checker_class) { | 52 thread_checker_class_(thread_checker_class) { |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual void Run() OVERRIDE { | 55 virtual void Run() OVERRIDE { |
| 56 thread_checker_class_->DoStuff(); | 56 thread_checker_class_->DoStuff(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 ThreadCheckerClass* thread_checker_class_; | 60 ThreadCheckerClass* thread_checker_class_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(CallDoStuffOnThread); | 62 DISALLOW_COPY_AND_ASSIGN(CallDoStuffOnThread); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Deletes ThreadCheckerClass on a different thread. | 65 // Deletes ThreadCheckerClass on a different thread. |
| 66 class DeleteThreadCheckerClassOnThread : public base::SimpleThread { | 66 class DeleteThreadCheckerClassOnThread : public base::SimpleThread { |
| 67 public: | 67 public: |
| 68 DeleteThreadCheckerClassOnThread(ThreadCheckerClass* thread_checker_class) | 68 explicit DeleteThreadCheckerClassOnThread( |
| 69 ThreadCheckerClass* thread_checker_class) |
| 69 : SimpleThread("delete_thread_checker_class_on_thread"), | 70 : SimpleThread("delete_thread_checker_class_on_thread"), |
| 70 thread_checker_class_(thread_checker_class) { | 71 thread_checker_class_(thread_checker_class) { |
| 71 } | 72 } |
| 72 | 73 |
| 73 virtual void Run() OVERRIDE { | 74 virtual void Run() OVERRIDE { |
| 74 thread_checker_class_.reset(); | 75 thread_checker_class_.reset(); |
| 75 } | 76 } |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 scoped_ptr<ThreadCheckerClass> thread_checker_class_; | 79 scoped_ptr<ThreadCheckerClass> thread_checker_class_; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl(); | 174 ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl(); |
| 174 } | 175 } |
| 175 #endif // ENABLE_THREAD_CHECKER | 176 #endif // ENABLE_THREAD_CHECKER |
| 176 | 177 |
| 177 #endif // GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER | 178 #endif // GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER |
| 178 | 179 |
| 179 // Just in case we ever get lumped together with other compilation units. | 180 // Just in case we ever get lumped together with other compilation units. |
| 180 #undef ENABLE_THREAD_CHECKER | 181 #undef ENABLE_THREAD_CHECKER |
| 181 | 182 |
| 182 } // namespace base | 183 } // namespace base |
| OLD | NEW |