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

Side by Side Diff: mojo/edk/util/ref_counted_unittest.cc

Issue 1423713009: EDK: Move ref counting classes to mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojo/edk/util/ref_counted_perftest.cc ('k') | mojo/edk/util/ref_ptr.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file tests both ref_counted.h and ref_ptr.h (which the former includes). 5 // This file tests both ref_counted.h and ref_ptr.h (which the former includes).
6 // TODO(vtl): Possibly we could separate these tests out better, since a lot of 6 // TODO(vtl): Possibly we could separate these tests out better, since a lot of
7 // it is actually testing |RefPtr|. 7 // it is actually testing |RefPtr|.
8 8
9 #include "mojo/edk/system/ref_counted.h" 9 #include "mojo/edk/util/ref_counted.h"
10 10
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "mojo/public/cpp/system/macros.h" 12 #include "mojo/public/cpp/system/macros.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #if defined(__clang__) 15 #if defined(__clang__)
16 #define ALLOW_PESSIMIZING_MOVE(code_line) \ 16 #define ALLOW_PESSIMIZING_MOVE(code_line) \
17 _Pragma("clang diagnostic push") \ 17 _Pragma("clang diagnostic push") \
18 _Pragma("clang diagnostic ignored \"-Wpessimizing-move\"") code_line; \ 18 _Pragma("clang diagnostic ignored \"-Wpessimizing-move\"") code_line; \
19 _Pragma("clang diagnostic pop") 19 _Pragma("clang diagnostic pop")
20 #else 20 #else
21 #define ALLOW_PESSIMIZING_MOVE(code_line) code_line; 21 #define ALLOW_PESSIMIZING_MOVE(code_line) code_line;
22 #endif 22 #endif
23 23
24 #if defined(__clang__) 24 #if defined(__clang__)
25 #define ALLOW_SELF_MOVE(code_line) \ 25 #define ALLOW_SELF_MOVE(code_line) \
26 _Pragma("clang diagnostic push") \ 26 _Pragma("clang diagnostic push") \
27 _Pragma("clang diagnostic ignored \"-Wself-move\"") code_line; \ 27 _Pragma("clang diagnostic ignored \"-Wself-move\"") code_line; \
28 _Pragma("clang diagnostic pop") 28 _Pragma("clang diagnostic pop")
29 #else 29 #else
30 #define ALLOW_SELF_MOVE(code_line) code_line; 30 #define ALLOW_SELF_MOVE(code_line) code_line;
31 #endif 31 #endif
32 32
33 namespace mojo { 33 namespace mojo {
34 namespace system { 34 namespace util {
35 namespace { 35 namespace {
36 36
37 class MyClass : public RefCountedThreadSafe<MyClass> { 37 class MyClass : public RefCountedThreadSafe<MyClass> {
38 protected: 38 protected:
39 MyClass(MyClass** created, bool* was_destroyed) 39 MyClass(MyClass** created, bool* was_destroyed)
40 : was_destroyed_(was_destroyed) { 40 : was_destroyed_(was_destroyed) {
41 if (created) 41 if (created)
42 *created = this; 42 *created = this;
43 } 43 }
44 virtual ~MyClass() { 44 virtual ~MyClass() {
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 { 599 {
600 RefPtr<MyPublicClass> r(MakeRefCounted<MyPublicClass>()); 600 RefPtr<MyPublicClass> r(MakeRefCounted<MyPublicClass>());
601 EXPECT_DEATH_IF_SUPPORTED(delete r.get(), "destruction_started_"); 601 EXPECT_DEATH_IF_SUPPORTED(delete r.get(), "destruction_started_");
602 } 602 }
603 } 603 }
604 #endif 604 #endif
605 605
606 // TODO(vtl): Add (threaded) stress tests. 606 // TODO(vtl): Add (threaded) stress tests.
607 607
608 } // namespace 608 } // namespace
609 } // namespace system 609 } // namespace util
610 } // namespace mojo 610 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/util/ref_counted_perftest.cc ('k') | mojo/edk/util/ref_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698