| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/move.h" | 10 #include "base/macros.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 | 13 |
| 14 class CopyableType { | 14 class CopyableType { |
| 15 public: | 15 public: |
| 16 CopyableType(); | 16 CopyableType(); |
| 17 CopyableType(const CopyableType& other); | 17 CopyableType(const CopyableType& other); |
| 18 CopyableType& operator=(const CopyableType& other); | 18 CopyableType& operator=(const CopyableType& other); |
| 19 ~CopyableType(); | 19 ~CopyableType(); |
| 20 | 20 |
| 21 bool copied() const { return copied_; } | 21 bool copied() const { return copied_; } |
| 22 static size_t num_instances() { return num_instances_; } | 22 static size_t num_instances() { return num_instances_; } |
| 23 CopyableType* ptr() const { return ptr_; } | 23 CopyableType* ptr() const { return ptr_; } |
| 24 void ResetCopied() { copied_ = false; } | 24 void ResetCopied() { copied_ = false; } |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 bool copied_; | 27 bool copied_; |
| 28 static size_t num_instances_; | 28 static size_t num_instances_; |
| 29 CopyableType* ptr_; | 29 CopyableType* ptr_; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class MoveOnlyType { | 32 class MoveOnlyType { |
| 33 MOVE_ONLY_TYPE_FOR_CPP_03(MoveOnlyType); | |
| 34 public: | 33 public: |
| 35 typedef MoveOnlyType Data_; | 34 typedef MoveOnlyType Data_; |
| 36 MoveOnlyType(); | 35 MoveOnlyType(); |
| 37 MoveOnlyType(MoveOnlyType&& other); | 36 MoveOnlyType(MoveOnlyType&& other); |
| 38 MoveOnlyType& operator=(MoveOnlyType&& other); | 37 MoveOnlyType& operator=(MoveOnlyType&& other); |
| 39 ~MoveOnlyType(); | 38 ~MoveOnlyType(); |
| 40 | 39 |
| 41 bool moved() const { return moved_; } | 40 bool moved() const { return moved_; } |
| 42 static size_t num_instances() { return num_instances_; } | 41 static size_t num_instances() { return num_instances_; } |
| 43 MoveOnlyType* ptr() const { return ptr_; } | 42 MoveOnlyType* ptr() const { return ptr_; } |
| 44 void ResetMoved() { moved_ = false; } | 43 void ResetMoved() { moved_ = false; } |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 bool moved_; | 46 bool moved_; |
| 48 static size_t num_instances_; | 47 static size_t num_instances_; |
| 49 MoveOnlyType* ptr_; | 48 MoveOnlyType* ptr_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(MoveOnlyType); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 } // namespace mojo | 53 } // namespace mojo |
| 53 | 54 |
| 54 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_ | 55 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_CONTAINER_TEST_UTIL_H_ |
| OLD | NEW |