summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2015-12-04 12:12:27 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-04 20:13:42 +0000
commit4b041ab3706e1c26bf105617750353ec111cf18b (patch)
treef4147c384802594c5701d3b8770cb0c243ea010a /skia
parent14d1b99388647b719bc02be6f282b989d6ee19d5 (diff)
downloadchromium_src-4b041ab3706e1c26bf105617750353ec111cf18b.zip
chromium_src-4b041ab3706e1c26bf105617750353ec111cf18b.tar.gz
chromium_src-4b041ab3706e1c26bf105617750353ec111cf18b.tar.bz2
Remove the TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 macro.
This macro existed only to add a Pass() method on scoped_refptr and skia::RefPtr. We can just use std::move() now, so replace callsites to Pass() with std::move() and kill the macro. R=thakis@chromium.org BUG=557422 Review URL: https://codereview.chromium.org/1477643002 Cr-Commit-Position: refs/heads/master@{#363281}
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/refptr.h16
-rw-r--r--skia/ext/refptr_unittest.cc13
2 files changed, 13 insertions, 16 deletions
diff --git a/skia/ext/refptr.h b/skia/ext/refptr.h
index a7ba7ff..93f1220 100644
--- a/skia/ext/refptr.h
+++ b/skia/ext/refptr.h
@@ -6,8 +6,8 @@
#define SKIA_EXT_REFPTR_H_
#include <algorithm>
+#include <cstddef>
-#include "base/move.h"
#include "third_party/skia/include/core/SkRefCnt.h"
namespace skia {
@@ -52,23 +52,29 @@ namespace skia {
// for you.
template<typename T>
class RefPtr {
- TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(RefPtr)
public:
RefPtr() : ptr_(nullptr) {}
- RefPtr(decltype(nullptr)) : ptr_(nullptr) {}
+ RefPtr(std::nullptr_t) : ptr_(nullptr) {}
+ // Copy constructor.
RefPtr(const RefPtr& other)
: ptr_(other.get()) {
SkSafeRef(ptr_);
}
+ // Copy conversion constructor.
template<typename U>
RefPtr(const RefPtr<U>& other)
: ptr_(other.get()) {
SkSafeRef(ptr_);
}
+ // Move constructor. This is required in addition to the conversion
+ // constructor below in order for clang to warn about pessimizing moves.
+ RefPtr(RefPtr&& other) : ptr_(other.get()) { other.ptr_ = nullptr; }
+
+ // Move conversion constructor.
template <typename U>
RefPtr(RefPtr<U>&& other)
: ptr_(other.get()) {
@@ -79,7 +85,7 @@ class RefPtr {
clear();
}
- RefPtr& operator=(decltype(nullptr)) {
+ RefPtr& operator=(std::nullptr_t) {
clear();
return *this;
}
@@ -97,7 +103,7 @@ class RefPtr {
template <typename U>
RefPtr& operator=(RefPtr<U>&& other) {
- RefPtr<T> temp(other.Pass());
+ RefPtr<T> temp(std::move(other));
std::swap(ptr_, temp.ptr_);
return *this;
}
diff --git a/skia/ext/refptr_unittest.cc b/skia/ext/refptr_unittest.cc
index a356a64..237f439 100644
--- a/skia/ext/refptr_unittest.cc
+++ b/skia/ext/refptr_unittest.cc
@@ -180,11 +180,11 @@ TEST(RefPtrTest, AssignmentFromTemporary) {
TEST(RefPtrTest, PassIntoArguments) {
// No ref count changes when passing an argument with Pass().
RefPtr<RefCountCounter> object = skia::AdoptRef(new RefCountCounter);
- RefPtr<RefCountCounter> object2 = object.Pass();
+ RefPtr<RefCountCounter> object2 = std::move(object);
auto lambda = [](RefPtr<RefCountCounter> arg) {
EXPECT_EQ(0, arg->ref_count_changes());
};
- lambda(object2.Pass());
+ lambda(std::move(object2));
}
class DestructionNotifier : public SkRefCnt {
@@ -196,15 +196,6 @@ class DestructionNotifier : public SkRefCnt {
bool* flag_;
};
-TEST(RefPtrTest, PassIntoSelf) {
- bool is_destroyed = false;
- RefPtr<DestructionNotifier> object =
- skia::AdoptRef(new DestructionNotifier(&is_destroyed));
- object = object.Pass();
- ASSERT_FALSE(is_destroyed);
- EXPECT_TRUE(object->unique());
-}
-
TEST(RefPtrTest, Nullptr) {
RefPtr<SkRefCnt> null(nullptr);
EXPECT_FALSE(null);