Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: base/memory/weak_ptr_unittest.cc

Issue 6714032: Move some files in base to base/memory. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: only base Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/threading/thread.h" 7 #include "base/threading/thread.h"
8 #include "base/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 10
11 namespace base { 11 namespace base {
12 namespace { 12 namespace {
13 13
14 template <class T> 14 template <class T>
15 class OffThreadObjectCreator { 15 class OffThreadObjectCreator {
16 public: 16 public:
17 static T* NewObject() { 17 static T* NewObject() {
18 T* result; 18 T* result;
19 { 19 {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // 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
129 // 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
130 // 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.
131 scoped_ptr<Consumer> consumer(OffThreadObjectCreator<Consumer>::NewObject()); 131 scoped_ptr<Consumer> consumer(OffThreadObjectCreator<Consumer>::NewObject());
132 Producer producer; 132 Producer producer;
133 consumer->producer = producer.AsWeakPtr(); 133 consumer->producer = producer.AsWeakPtr();
134 EXPECT_EQ(&producer, consumer->producer.get()); 134 EXPECT_EQ(&producer, consumer->producer.get());
135 } 135 }
136 136
137 } // namespace base 137 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698