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

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

Issue 10004001: Add virtual and OVERRIDE to base/ implementation files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback from chromium-dev Created 8 years, 8 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) 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/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 27 matching lines...) Expand all
38 struct Derived : Base {}; 38 struct Derived : Base {};
39 39
40 struct Producer : SupportsWeakPtr<Producer> {}; 40 struct Producer : SupportsWeakPtr<Producer> {};
41 struct Consumer { WeakPtr<Producer> producer; }; 41 struct Consumer { WeakPtr<Producer> producer; };
42 42
43 // Helper class to create and destroy weak pointer copies 43 // Helper class to create and destroy weak pointer copies
44 // and delete objects on a background thread. 44 // and delete objects on a background thread.
45 class BackgroundThread : public Thread { 45 class BackgroundThread : public Thread {
46 public: 46 public:
47 BackgroundThread() 47 BackgroundThread()
48 : Thread("owner_thread") { 48 : Thread("owner_thread") {
jar (doing other things) 2012/04/05 21:11:30 nit: You may as well put this all on one line whil
49 } 49 }
50 50
51 ~BackgroundThread() { 51 virtual ~BackgroundThread() {
52 Stop(); 52 Stop();
53 } 53 }
54 54
55 void CreateConsumerFromProducer(Consumer** consumer, Producer* producer) { 55 void CreateConsumerFromProducer(Consumer** consumer, Producer* producer) {
56 WaitableEvent completion(true, false); 56 WaitableEvent completion(true, false);
57 message_loop()->PostTask( 57 message_loop()->PostTask(
58 FROM_HERE, 58 FROM_HERE,
59 base::Bind(&BackgroundThread::DoCreateFromProducer, consumer, producer, 59 base::Bind(&BackgroundThread::DoCreateFromProducer, consumer, producer,
60 &completion)); 60 &completion));
61 completion.Wait(); 61 completion.Wait();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 Base data; 339 Base data;
340 data.member = "123456"; 340 data.member = "123456";
341 WeakPtrFactory<Base> factory(&data); 341 WeakPtrFactory<Base> factory(&data);
342 WeakPtr<Base> ptr = factory.GetWeakPtr(); 342 WeakPtr<Base> ptr = factory.GetWeakPtr();
343 EXPECT_EQ(&data, ptr.get()); 343 EXPECT_EQ(&data, ptr.get());
344 EXPECT_EQ(data.member, (*ptr).member); 344 EXPECT_EQ(data.member, (*ptr).member);
345 EXPECT_EQ(data.member, ptr->member); 345 EXPECT_EQ(data.member, ptr->member);
346 } 346 }
347 347
348 } // namespace base 348 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698