| OLD | NEW |
| 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 |
| 11 // class is a simple and compact mechanism for storing a continuous list of | 11 // class is a simple and compact mechanism for storing a continuous list of |
| 12 // chunk numbers. | 12 // chunk numbers. |
| 13 | 13 |
| 14 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H__ | 14 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H_ |
| 15 #define CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H__ | 15 #define CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H_ |
| 16 | 16 |
| 17 #include <string> | 17 #include <string> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 // ChunkRange ------------------------------------------------------------------ | 20 // ChunkRange ------------------------------------------------------------------ |
| 21 // Each ChunkRange represents a continuous range of chunk numbers [start, stop]. | 21 // Each ChunkRange represents a continuous range of chunk numbers [start, stop]. |
| 22 | 22 |
| 23 class ChunkRange { | 23 class ChunkRange { |
| 24 public: | 24 public: |
| 25 ChunkRange(int start); | 25 ChunkRange(int start); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 void RangesToString(const std::vector<ChunkRange>& ranges, | 54 void RangesToString(const std::vector<ChunkRange>& ranges, |
| 55 std::string* result); | 55 std::string* result); |
| 56 | 56 |
| 57 // Returns 'true' if the string was successfully converted to ChunkRanges, | 57 // Returns 'true' if the string was successfully converted to ChunkRanges, |
| 58 // 'false' if the input was malformed. | 58 // 'false' if the input was malformed. |
| 59 // The string must be in the form: "1-100,398,415,1138-2001,2019". | 59 // The string must be in the form: "1-100,398,415,1138-2001,2019". |
| 60 bool StringToRanges(const std::string& input, | 60 bool StringToRanges(const std::string& input, |
| 61 std::vector<ChunkRange>* ranges); | 61 std::vector<ChunkRange>* ranges); |
| 62 | 62 |
| 63 | 63 |
| 64 #endif // CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H__ | 64 #endif // CHROME_BROWSER_SAFE_BROWSING_CHUNK_RANGE_H_ |
| OLD | NEW |