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

Side by Side Diff: remoting/base/typed_buffer.h

Issue 2038273002: Remove base/move.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: is_constructible Created 4 years, 6 months 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 | « net/base/file_stream_context.h ('k') | storage/browser/blob/scoped_file.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 REMOTING_BASE_TYPED_BUFFER_H_ 5 #ifndef REMOTING_BASE_TYPED_BUFFER_H_
6 #define REMOTING_BASE_TYPED_BUFFER_H_ 6 #define REMOTING_BASE_TYPED_BUFFER_H_
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/move.h" 14 #include "base/macros.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 // A scoper for a variable-length structure such as SID, SECURITY_DESCRIPTOR and 18 // A scoper for a variable-length structure such as SID, SECURITY_DESCRIPTOR and
19 // similar. These structures typically consist of a header followed by variable- 19 // similar. These structures typically consist of a header followed by variable-
20 // length data, so the size may not match sizeof(T). The class supports 20 // length data, so the size may not match sizeof(T). The class supports
21 // move-only semantics and typed buffer getters. 21 // move-only semantics and typed buffer getters.
22 template <typename T> 22 template <typename T>
23 class TypedBuffer { 23 class TypedBuffer {
24 MOVE_ONLY_TYPE_FOR_CPP_03(TypedBuffer)
25
26 public: 24 public:
27 TypedBuffer() : TypedBuffer(0) {} 25 TypedBuffer() : TypedBuffer(0) {}
28 26
29 // Creates an instance of the object allocating a buffer of the given size. 27 // Creates an instance of the object allocating a buffer of the given size.
30 explicit TypedBuffer(uint32_t length) : buffer_(NULL), length_(length) { 28 explicit TypedBuffer(uint32_t length) : buffer_(NULL), length_(length) {
31 if (length_ > 0) 29 if (length_ > 0)
32 buffer_ = reinterpret_cast<T*>(new uint8_t[length_]); 30 buffer_ = reinterpret_cast<T*>(new uint8_t[length_]);
33 } 31 }
34 32
35 TypedBuffer(TypedBuffer&& rvalue) : TypedBuffer() { Swap(rvalue); } 33 TypedBuffer(TypedBuffer&& rvalue) : TypedBuffer() { Swap(rvalue); }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 std::swap(buffer_, other.buffer_); 74 std::swap(buffer_, other.buffer_);
77 std::swap(length_, other.length_); 75 std::swap(length_, other.length_);
78 } 76 }
79 77
80 private: 78 private:
81 // Points to the owned buffer. 79 // Points to the owned buffer.
82 T* buffer_; 80 T* buffer_;
83 81
84 // Length of the owned buffer in bytes. 82 // Length of the owned buffer in bytes.
85 uint32_t length_; 83 uint32_t length_;
84
85 DISALLOW_COPY_AND_ASSIGN(TypedBuffer);
86 }; 86 };
87 87
88 } // namespace remoting 88 } // namespace remoting
89 89
90 #endif // REMOTING_BASE_TYPED_BUFFER_H_ 90 #endif // REMOTING_BASE_TYPED_BUFFER_H_
OLDNEW
« no previous file with comments | « net/base/file_stream_context.h ('k') | storage/browser/blob/scoped_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698