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

Side by Side Diff: chrome/browser/safe_browsing/chunk_range.h

Issue 4588001: Cleanup converting safe-browsing chunks to range list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lei comments. Created 10 years, 1 month 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 | « no previous file | chrome/browser/safe_browsing/chunk_range.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Class for parsing lists of integers into ranges. 5 // Class for parsing lists of integers into ranges.
6 // 6 //
7 // The anti-phishing and anti-malware protocol sends ASCII strings of numbers 7 // The anti-phishing and anti-malware protocol sends ASCII strings of numbers
8 // and ranges of numbers corresponding to chunks of whitelists and blacklists. 8 // and ranges of numbers corresponding to chunks of whitelists and blacklists.
9 // Clients of this protocol need to be able to convert back and forth between 9 // Clients of this protocol need to be able to convert back and forth between
10 // this representation, and individual integer chunk numbers. The ChunkRange 10 // this representation, and individual integer chunk numbers. The ChunkRange
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 private: 37 private:
38 int start_; 38 int start_;
39 int stop_; 39 int stop_;
40 }; 40 };
41 41
42 42
43 // Helper functions ------------------------------------------------------------ 43 // Helper functions ------------------------------------------------------------
44 44
45 // Convert a series of chunk numbers into a more compact range representation.
46 // The 'chunks' vector must be sorted in ascending order.
47 void ChunksToRanges(const std::vector<int>& chunks,
48 std::vector<ChunkRange>* ranges);
49
50 // Convert a set of ranges into individual chunk numbers. 45 // Convert a set of ranges into individual chunk numbers.
51 void RangesToChunks(const std::vector<ChunkRange>& ranges, 46 void RangesToChunks(const std::vector<ChunkRange>& ranges,
52 std::vector<int>* chunks); 47 std::vector<int>* chunks);
53 48
54 // Convert a series of chunk ranges into a string in protocol format.
55 void RangesToString(const std::vector<ChunkRange>& ranges,
56 std::string* result);
57
58 // Returns 'true' if the string was successfully converted to ChunkRanges, 49 // Returns 'true' if the string was successfully converted to ChunkRanges,
59 // 'false' if the input was malformed. 50 // 'false' if the input was malformed.
60 // The string must be in the form: "1-100,398,415,1138-2001,2019". 51 // The string must be in the form: "1-100,398,415,1138-2001,2019".
61 bool StringToRanges(const std::string& input, 52 bool StringToRanges(const std::string& input,
62 std::vector<ChunkRange>* ranges); 53 std::vector<ChunkRange>* ranges);
63 54
55 // Convenience for going from a list of chunks to a string in protocol
56 // format.
57 void ChunksToRangeString(const std::vector<int>& chunks, std::string* result);
58
64 // Tests if a chunk number is contained a sorted vector of ChunkRanges. 59 // Tests if a chunk number is contained a sorted vector of ChunkRanges.
65 bool IsChunkInRange(int chunk_number, const std::vector<ChunkRange>& ranges); 60 bool IsChunkInRange(int chunk_number, const std::vector<ChunkRange>& ranges);
66 61
67 #endif // CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H_ 62 #endif // CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/chunk_range.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698