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

Side by Side Diff: content/browser/speech/chunked_byte_buffer.h

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « content/browser/speech/audio_encoder.cc ('k') | content/browser/speech/chunked_byte_buffer.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 (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 CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ 5 #ifndef CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_
6 #define CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ 6 #define CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 // Models a chunk-oriented byte buffer. The term chunk is herein defined as an 21 // Models a chunk-oriented byte buffer. The term chunk is herein defined as an
22 // arbitrary sequence of bytes that is preceeded by N header bytes, indicating 22 // arbitrary sequence of bytes that is preceeded by N header bytes, indicating
23 // its size. Data may be appended to the buffer with no particular respect of 23 // its size. Data may be appended to the buffer with no particular respect of
24 // chunks boundaries. However, chunks can be extracted (FIFO) only when their 24 // chunks boundaries. However, chunks can be extracted (FIFO) only when their
25 // content (according to their header) is fully available in the buffer. 25 // content (according to their header) is fully available in the buffer.
(...skipping 11 matching lines...) Expand all
37 void Append(const uint8_t* start, size_t length); 37 void Append(const uint8_t* start, size_t length);
38 38
39 // Appends bytes contained in the |string| to the buffer. 39 // Appends bytes contained in the |string| to the buffer.
40 void Append(const std::string& string); 40 void Append(const std::string& string);
41 41
42 // Checks whether one or more complete chunks are available in the buffer. 42 // Checks whether one or more complete chunks are available in the buffer.
43 bool HasChunks() const; 43 bool HasChunks() const;
44 44
45 // If enough data is available, reads and removes the first complete chunk 45 // If enough data is available, reads and removes the first complete chunk
46 // from the buffer. Returns a NULL pointer if no complete chunk is available. 46 // from the buffer. Returns a NULL pointer if no complete chunk is available.
47 scoped_ptr<std::vector<uint8_t>> PopChunk(); 47 std::unique_ptr<std::vector<uint8_t>> PopChunk();
48 48
49 // Clears all the content of the buffer. 49 // Clears all the content of the buffer.
50 void Clear(); 50 void Clear();
51 51
52 // Returns the number of raw bytes (including headers) present. 52 // Returns the number of raw bytes (including headers) present.
53 size_t GetTotalLength() const { return total_bytes_stored_; } 53 size_t GetTotalLength() const { return total_bytes_stored_; }
54 54
55 private: 55 private:
56 struct Chunk { 56 struct Chunk {
57 Chunk(); 57 Chunk();
58 ~Chunk(); 58 ~Chunk();
59 59
60 std::vector<uint8_t> header; 60 std::vector<uint8_t> header;
61 scoped_ptr<std::vector<uint8_t>> content; 61 std::unique_ptr<std::vector<uint8_t>> content;
62 size_t ExpectedContentLength() const; 62 size_t ExpectedContentLength() const;
63 63
64 private: 64 private:
65 DISALLOW_COPY_AND_ASSIGN(Chunk); 65 DISALLOW_COPY_AND_ASSIGN(Chunk);
66 }; 66 };
67 67
68 ScopedVector<Chunk> chunks_; 68 ScopedVector<Chunk> chunks_;
69 scoped_ptr<Chunk> partial_chunk_; 69 std::unique_ptr<Chunk> partial_chunk_;
70 size_t total_bytes_stored_; 70 size_t total_bytes_stored_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer); 72 DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer);
73 }; 73 };
74 74
75 75
76 } // namespace content 76 } // namespace content
77 77
78 #endif // CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ 78 #endif // CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_
OLDNEW
« no previous file with comments | « content/browser/speech/audio_encoder.cc ('k') | content/browser/speech/chunked_byte_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698