Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / mojo / public / cpp / bindings / tests / container_test_util.cc
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
3 // found in the LICENSE file.
4
5 #include "mojo/public/cpp/bindings/tests/container_test_util.h"
6
7 namespace mojo {
8
9 size_t CopyableType::num_instances_ = 0;
10 size_t MoveOnlyType::num_instances_ = 0;
11
12 CopyableType::CopyableType() : copied_(false), ptr_(this) {
13   num_instances_++;
14 }
15
16 CopyableType::CopyableType(const CopyableType& other)
17     : copied_(true), ptr_(other.ptr()) {
18   num_instances_++;
19 }
20
21 CopyableType& CopyableType::operator=(const CopyableType& other) {
22   copied_ = true;
23   ptr_ = other.ptr();
24   return *this;
25 }
26
27 CopyableType::~CopyableType() {
28   num_instances_--;
29 }
30
31 MoveOnlyType::MoveOnlyType() : moved_(false), ptr_(this) {
32   num_instances_++;
33 }
34
35 MoveOnlyType::MoveOnlyType(RValue other)
36     : moved_(true), ptr_(other.object->ptr()) {
37   num_instances_++;
38 }
39
40 MoveOnlyType& MoveOnlyType::operator=(RValue other) {
41   moved_ = true;
42   ptr_ = other.object->ptr();
43   return *this;
44 }
45
46 MoveOnlyType::~MoveOnlyType() {
47   num_instances_--;
48 }
49
50 }  // namespace mojo