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

Side by Side Diff: base/weak_ptr_unittest.cc

Issue 593084: Fix up some style guide violations wrt aligning function arguments. (Closed)
Patch Set: Created 10 years, 10 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/tracked_objects.cc ('k') | chrome/browser/browser.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/thread.h" 6 #include "base/thread.h"
7 #include "base/weak_ptr.h" 7 #include "base/weak_ptr.h"
8 8
9 namespace base { 9 namespace base {
10 namespace { 10 namespace {
11 11
12 template <class T> 12 template <class T>
13 class OffThreadObjectCreator { 13 class OffThreadObjectCreator {
14 public: 14 public:
15 static T* NewObject() { 15 static T* NewObject() {
16 T* result; 16 T* result;
17 { 17 {
18 Thread creator_thread("creator_thread"); 18 Thread creator_thread("creator_thread");
19 creator_thread.Start(); 19 creator_thread.Start();
20 creator_thread.message_loop()->PostTask(FROM_HERE, 20 creator_thread.message_loop()->PostTask(
21 FROM_HERE,
21 NewRunnableFunction(OffThreadObjectCreator::CreateObject, &result)); 22 NewRunnableFunction(OffThreadObjectCreator::CreateObject, &result));
22 } 23 }
23 DCHECK(result); // We synchronized on thread destruction above. 24 DCHECK(result); // We synchronized on thread destruction above.
24 return result; 25 return result;
25 } 26 }
26 private: 27 private:
27 static void CreateObject(T** result) { 28 static void CreateObject(T** result) {
28 *result = new T; 29 *result = new T;
29 } 30 }
30 }; 31 };
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // Test that it is OK to create a class that has a WeakPtr member on one 126 // Test that it is OK to create a class that has a WeakPtr member on one
126 // thread, but use it on another. This tests that we do not trip runtime 127 // thread, but use it on another. This tests that we do not trip runtime
127 // checks that ensure that a weak reference is not used by multiple threads. 128 // checks that ensure that a weak reference is not used by multiple threads.
128 scoped_ptr<Consumer> consumer(OffThreadObjectCreator<Consumer>::NewObject()); 129 scoped_ptr<Consumer> consumer(OffThreadObjectCreator<Consumer>::NewObject());
129 Producer producer; 130 Producer producer;
130 consumer->producer = producer.AsWeakPtr(); 131 consumer->producer = producer.AsWeakPtr();
131 EXPECT_EQ(&producer, consumer->producer.get()); 132 EXPECT_EQ(&producer, consumer->producer.get());
132 } 133 }
133 134
134 } // namespace base 135 } // namespace base
OLDNEW
« no previous file with comments | « base/tracked_objects.cc ('k') | chrome/browser/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698