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

Side by Side Diff: sync/internal_api/public/util/proto_value_ptr.h

Issue 1477643002: Remove the TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03 macro. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@basepass
Patch Set: type-with-move: no-media Created 5 years 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 | « sync/api/entity_data.cc ('k') | third_party/mojo/src/mojo/edk/embedder/embedder.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 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 #ifndef SYNC_INTERNAL_API_PUBLIC_UTIL_PROTO_VALUE_PTR_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_UTIL_PROTO_VALUE_PTR_H_
6 #define SYNC_INTERNAL_API_PUBLIC_UTIL_PROTO_VALUE_PTR_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_UTIL_PROTO_VALUE_PTR_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // Copying ProtoValuePtr results in ref-counted sharing of the 46 // Copying ProtoValuePtr results in ref-counted sharing of the
47 // underlying wrapper and the value contained in the wrapper. 47 // underlying wrapper and the value contained in the wrapper.
48 // 48 //
49 // The public interface includes only immutable access to the wrapped value. 49 // The public interface includes only immutable access to the wrapped value.
50 // The only way to assign a value to ProtoValuePtr is through a 50 // The only way to assign a value to ProtoValuePtr is through a
51 // private SetValue function which is called from EntryKernel. That results 51 // private SetValue function which is called from EntryKernel. That results
52 // in stopping sharing the previous value and creating a wrapper to the new 52 // in stopping sharing the previous value and creating a wrapper to the new
53 // value. 53 // value.
54 template <typename T, typename Traits = DefaultProtoValuePtrTraits<T>> 54 template <typename T, typename Traits = DefaultProtoValuePtrTraits<T>>
55 class ProtoValuePtr { 55 class ProtoValuePtr {
56 TYPE_WITH_MOVE_CONSTRUCTOR_FOR_CPP_03(ProtoValuePtr)
57
58 private: 56 private:
59 // Immutable shareable ref-counted wrapper that embeds the value. 57 // Immutable shareable ref-counted wrapper that embeds the value.
60 class Wrapper : public base::RefCountedThreadSafe<Wrapper> { 58 class Wrapper : public base::RefCountedThreadSafe<Wrapper> {
61 public: 59 public:
62 explicit Wrapper(const T& value) { Traits::CopyValue(&value_, value); } 60 explicit Wrapper(const T& value) { Traits::CopyValue(&value_, value); }
63 explicit Wrapper(T* value) { Traits::SwapValue(&value_, value); } 61 explicit Wrapper(T* value) { Traits::SwapValue(&value_, value); }
64 62
65 const T& value() const { return value_; } 63 const T& value() const { return value_; }
66 // Create wrapper by deserializing a BLOB. 64 // Create wrapper by deserializing a BLOB.
67 static Wrapper* ParseFromBlob(const void* blob, int length) { 65 static Wrapper* ParseFromBlob(const void* blob, int length) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void load(const void* blob, int length) { 123 void load(const void* blob, int length) {
126 wrapper_ = Wrapper::ParseFromBlob(blob, length); 124 wrapper_ = Wrapper::ParseFromBlob(blob, length);
127 } 125 }
128 126
129 scoped_refptr<Wrapper> wrapper_; 127 scoped_refptr<Wrapper> wrapper_;
130 }; 128 };
131 129
132 } // namespace syncer 130 } // namespace syncer
133 131
134 #endif // SYNC_INTERNAL_API_PUBLIC_UTIL_PROTO_VALUE_PTR_H_ 132 #endif // SYNC_INTERNAL_API_PUBLIC_UTIL_PROTO_VALUE_PTR_H_
OLDNEW
« no previous file with comments | « sync/api/entity_data.cc ('k') | third_party/mojo/src/mojo/edk/embedder/embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698