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

Side by Side Diff: base/weak_ptr_unittest.cc

Issue 2965015: Attempt four at landing the "histogram.h removed from message_loop.h" patch. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: win build fixes Created 10 years, 5 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
« no previous file with comments | « base/observer_list_threadsafe.h ('k') | chrome/browser/autocomplete/autocomplete_edit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
OLDNEW
« no previous file with comments | « base/observer_list_threadsafe.h ('k') | chrome/browser/autocomplete/autocomplete_edit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698