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 // Implementation of ChunkRange class. | 5 // Implementation of ChunkRange class. |
6 | 6 |
7 #include "chrome/browser/safe_browsing/chunk_range.h" | 7 #include "chrome/browser/safe_browsing/chunk_range.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 | 12 |
12 ChunkRange::ChunkRange(int start) : start_(start), stop_(start) { | 13 ChunkRange::ChunkRange(int start) : start_(start), stop_(start) { |
13 } | 14 } |
14 | 15 |
15 ChunkRange::ChunkRange(int start, int stop) : start_(start), stop_(stop) { | 16 ChunkRange::ChunkRange(int start, int stop) : start_(start), stop_(stop) { |
16 } | 17 } |
17 | 18 |
18 ChunkRange::ChunkRange(const ChunkRange& rhs) | 19 ChunkRange::ChunkRange(const ChunkRange& rhs) |
19 : start_(rhs.start()), stop_(rhs.stop()) { | 20 : start_(rhs.start()), stop_(rhs.stop()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 55 |
55 void RangesToString(const std::vector<ChunkRange>& ranges, | 56 void RangesToString(const std::vector<ChunkRange>& ranges, |
56 std::string* result) { | 57 std::string* result) { |
57 DCHECK(result); | 58 DCHECK(result); |
58 result->clear(); | 59 result->clear(); |
59 std::vector<ChunkRange>::const_iterator it = ranges.begin(); | 60 std::vector<ChunkRange>::const_iterator it = ranges.begin(); |
60 for (; it != ranges.end(); ++it) { | 61 for (; it != ranges.end(); ++it) { |
61 if (!result->empty()) | 62 if (!result->empty()) |
62 result->append(","); | 63 result->append(","); |
63 if (it->start() == it->stop()) { | 64 if (it->start() == it->stop()) { |
64 std::string num_buf = IntToString(it->start()); | 65 std::string num_buf = base::IntToString(it->start()); |
65 result->append(num_buf); | 66 result->append(num_buf); |
66 } else { | 67 } else { |
67 result->append(StringPrintf("%d-%d", it->start(), it->stop())); | 68 result->append(StringPrintf("%d-%d", it->start(), it->stop())); |
68 } | 69 } |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 bool StringToRanges(const std::string& input, | 73 bool StringToRanges(const std::string& input, |
73 std::vector<ChunkRange>* ranges) { | 74 std::vector<ChunkRange>* ranges) { |
74 DCHECK(ranges); | 75 DCHECK(ranges); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 114 |
114 // Adjust our mid point. | 115 // Adjust our mid point. |
115 if (chunk.stop() < chunk_number) | 116 if (chunk.stop() < chunk_number) |
116 low = mid + 1; | 117 low = mid + 1; |
117 else | 118 else |
118 high = mid - 1; | 119 high = mid - 1; |
119 } | 120 } |
120 | 121 |
121 return false; | 122 return false; |
122 } | 123 } |
OLD | NEW |