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

Side by Side Diff: chrome/renderer/net/predictor_queue.h

Issue 6674006: Coverity Fixlets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit squash. Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | chrome/renderer/net/predictor_queue.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // DnsQueue is implemented as an almost FIFO circular buffer for text 5 // DnsQueue is implemented as an almost FIFO circular buffer for text
6 // strings that don't have embedded nulls ('\0'). The "almost" element is that 6 // strings that don't have embedded nulls ('\0'). The "almost" element is that
7 // some duplicate strings may be removed (i.e., the string won't really be 7 // some duplicate strings may be removed (i.e., the string won't really be
8 // pushed *if* the class happens to notice that a duplicate is already in the 8 // pushed *if* the class happens to notice that a duplicate is already in the
9 // queue). 9 // queue).
10 // The buffers internal format is null terminated character strings 10 // The buffers internal format is null terminated character strings
(...skipping 30 matching lines...) Expand all
41 // to hold at most one string of that length, or "many" 41 // to hold at most one string of that length, or "many"
42 // strings of considerably shorter length. Note that strings 42 // strings of considerably shorter length. Note that strings
43 // are padded internally with a terminal '\0" while stored, 43 // are padded internally with a terminal '\0" while stored,
44 // so if you are trying to be precise and get N strings of 44 // so if you are trying to be precise and get N strings of
45 // length K to fit, you should actually construct a buffer with 45 // length K to fit, you should actually construct a buffer with
46 // an internal size of N*(K+1). 46 // an internal size of N*(K+1).
47 explicit DnsQueue(BufferSize size); 47 explicit DnsQueue(BufferSize size);
48 ~DnsQueue(void); 48 ~DnsQueue(void);
49 49
50 size_t Size() const { return size_; } 50 size_t Size() const { return size_; }
51 void Clear() { 51 void Clear();
52 size_ = 0;
53 readable_ = writeable_;
54 Validate();
55 }
56 52
57 // Push takes an unterminated string of the given length 53 // Push takes an unterminated string of the given length
58 // and inserts it into the queue for later 54 // and inserts it into the queue for later
59 // extraction by read. For each successful push(), there 55 // extraction by read. For each successful push(), there
60 // can later be a corresponding read() to extracted the text. 56 // can later be a corresponding read() to extracted the text.
61 // The string must not contain an embedded null terminator 57 // The string must not contain an embedded null terminator
62 // Exactly length chars are written, or the push fails (where 58 // Exactly length chars are written, or the push fails (where
63 // "fails" means nothing is written). 59 // "fails" means nothing is written).
64 // Returns true for success, false for failure (nothing written). 60 // Returns true for success, false for failure (nothing written).
65 PushResult Push(const char* source, const size_t length); 61 PushResult Push(const char* source, const size_t length);
(...skipping 17 matching lines...) Expand all
83 BufferSize readable_; // Next readable char in buffer_. 79 BufferSize readable_; // Next readable char in buffer_.
84 BufferSize writeable_; // The next space in buffer_ to push. 80 BufferSize writeable_; // The next space in buffer_ to push.
85 81
86 // Number of queued strings 82 // Number of queued strings
87 size_t size_; 83 size_t size_;
88 84
89 DISALLOW_COPY_AND_ASSIGN(DnsQueue); 85 DISALLOW_COPY_AND_ASSIGN(DnsQueue);
90 }; // class DnsQueue 86 }; // class DnsQueue
91 87
92 #endif // CHROME_RENDERER_NET_PREDICTOR_QUEUE_H__ 88 #endif // CHROME_RENDERER_NET_PREDICTOR_QUEUE_H__
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | chrome/renderer/net/predictor_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698