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

Side by Side Diff: net/tools/balsa/simple_buffer.h

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/tools/balsa/balsa_frame.h ('k') | net/tools/dump_cache/cache_dumper.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 NET_TOOLS_BALSA_SIMPLE_BUFFER_H__ 5 #ifndef NET_TOOLS_BALSA_SIMPLE_BUFFER_H__
6 #define NET_TOOLS_BALSA_SIMPLE_BUFFER_H__ 6 #define NET_TOOLS_BALSA_SIMPLE_BUFFER_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "net/tools/balsa/buffer_interface.h" 11 #include "net/tools/balsa/buffer_interface.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 class SimpleBuffer : public BufferInterface { 15 class SimpleBuffer : public BufferInterface {
16 public: 16 public:
17 SimpleBuffer(); 17 SimpleBuffer();
18 explicit SimpleBuffer(int size); 18 explicit SimpleBuffer(int size);
19 virtual ~SimpleBuffer(); 19 ~SimpleBuffer() override;
20 20
21 std::string str() const; 21 std::string str() const;
22 22
23 typedef char * iterator; 23 typedef char * iterator;
24 typedef const char * const_iterator; 24 typedef const char * const_iterator;
25 25
26 iterator begin() { return storage_ + read_idx_; } 26 iterator begin() { return storage_ + read_idx_; }
27 const_iterator begin() const { return storage_ + read_idx_; } 27 const_iterator begin() const { return storage_ + read_idx_; }
28 28
29 iterator end() { return storage_ + write_idx_; } 29 iterator end() { return storage_ + write_idx_; }
30 const_iterator end() const { return storage_ + write_idx_; } 30 const_iterator end() const { return storage_ + write_idx_; }
31 31
32 // The following functions all override pure virtual functions 32 // The following functions all override pure virtual functions
33 // in BufferInterface. See buffer_interface.h for a description 33 // in BufferInterface. See buffer_interface.h for a description
34 // of what they do. 34 // of what they do.
35 virtual int ReadableBytes() const override; 35 int ReadableBytes() const override;
36 virtual int BufferSize() const override; 36 int BufferSize() const override;
37 virtual int BytesFree() const override; 37 int BytesFree() const override;
38 38
39 virtual bool Empty() const override; 39 bool Empty() const override;
40 virtual bool Full() const override; 40 bool Full() const override;
41 41
42 virtual int Write(const char* bytes, int size) override; 42 int Write(const char* bytes, int size) override;
43 43
44 virtual void GetWritablePtr(char **ptr, int* size) const override; 44 void GetWritablePtr(char** ptr, int* size) const override;
45 45
46 virtual void GetReadablePtr(char **ptr, int* size) const override; 46 void GetReadablePtr(char** ptr, int* size) const override;
47 47
48 virtual int Read(char* bytes, int size) override; 48 int Read(char* bytes, int size) override;
49 49
50 virtual void Clear() override; 50 void Clear() override;
51 51
52 // This can be an expensive operation: costing a new/delete, and copying of 52 // This can be an expensive operation: costing a new/delete, and copying of
53 // all existing data. Even if the existing buffer does not need to be 53 // all existing data. Even if the existing buffer does not need to be
54 // resized, unread data may still need to be non-destructively copied to 54 // resized, unread data may still need to be non-destructively copied to
55 // consolidate fragmented free space. 55 // consolidate fragmented free space.
56 virtual bool Reserve(int size) override; 56 bool Reserve(int size) override;
57 57
58 virtual void AdvanceReadablePtr(int amount_to_advance) override; 58 void AdvanceReadablePtr(int amount_to_advance) override;
59 59
60 virtual void AdvanceWritablePtr(int amount_to_advance) override; 60 void AdvanceWritablePtr(int amount_to_advance) override;
61 61
62 void Swap(SimpleBuffer* other) { 62 void Swap(SimpleBuffer* other) {
63 char* tmp = storage_; 63 char* tmp = storage_;
64 storage_ = other->storage_; 64 storage_ = other->storage_;
65 other->storage_ = tmp; 65 other->storage_ = tmp;
66 66
67 int tmp_int = write_idx_; 67 int tmp_int = write_idx_;
68 write_idx_ = other->write_idx_; 68 write_idx_ = other->write_idx_;
69 other->write_idx_ = tmp_int; 69 other->write_idx_ = tmp_int;
70 70
(...skipping 12 matching lines...) Expand all
83 int read_idx_; 83 int read_idx_;
84 int storage_size_; 84 int storage_size_;
85 85
86 private: 86 private:
87 //DISALLOW_COPY_AND_ASSIGN(SimpleBuffer); 87 //DISALLOW_COPY_AND_ASSIGN(SimpleBuffer);
88 }; 88 };
89 89
90 } // namespace net 90 } // namespace net
91 91
92 #endif // NET_TOOLS_BALSA_SIMPLE_BUFFER_H__ 92 #endif // NET_TOOLS_BALSA_SIMPLE_BUFFER_H__
OLDNEW
« no previous file with comments | « net/tools/balsa/balsa_frame.h ('k') | net/tools/dump_cache/cache_dumper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698