| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" |    5 #include "testing/gtest/include/gtest/gtest.h" | 
|    6 #include "base/message_loop.h" |    6 #include "base/message_loop.h" | 
|    7 #include "base/thread.h" |    7 #include "base/thread.h" | 
 |    8 #include "base/scoped_ptr.h" | 
|    8 #include "base/weak_ptr.h" |    9 #include "base/weak_ptr.h" | 
|    9  |   10  | 
|   10 namespace base { |   11 namespace base { | 
|   11 namespace { |   12 namespace { | 
|   12  |   13  | 
|   13 template <class T> |   14 template <class T> | 
|   14 class OffThreadObjectCreator { |   15 class OffThreadObjectCreator { | 
|   15  public: |   16  public: | 
|   16   static T* NewObject() { |   17   static T* NewObject() { | 
|   17     T* result; |   18     T* result; | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  127   // Test that it is OK to create a class that has a WeakPtr member on one |  128   // Test that it is OK to create a class that has a WeakPtr member on one | 
|  128   // thread, but use it on another.  This tests that we do not trip runtime |  129   // thread, but use it on another.  This tests that we do not trip runtime | 
|  129   // checks that ensure that a weak reference is not used by multiple threads. |  130   // checks that ensure that a weak reference is not used by multiple threads. | 
|  130   scoped_ptr<Consumer> consumer(OffThreadObjectCreator<Consumer>::NewObject()); |  131   scoped_ptr<Consumer> consumer(OffThreadObjectCreator<Consumer>::NewObject()); | 
|  131   Producer producer; |  132   Producer producer; | 
|  132   consumer->producer = producer.AsWeakPtr(); |  133   consumer->producer = producer.AsWeakPtr(); | 
|  133   EXPECT_EQ(&producer, consumer->producer.get()); |  134   EXPECT_EQ(&producer, consumer->producer.get()); | 
|  134 } |  135 } | 
|  135  |  136  | 
|  136 }  // namespace base |  137 }  // namespace base | 
| OLD | NEW |