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

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

Issue 2890: Include chrome/browser/SConscript in Linux build.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 3 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
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 // 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_util.h" 10 #include "base/string_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 void RangesToString(const std::vector<ChunkRange>& ranges, 55 void RangesToString(const std::vector<ChunkRange>& ranges,
56 std::string* result) { 56 std::string* result) {
57 DCHECK(result); 57 DCHECK(result);
58 result->clear(); 58 result->clear();
59 std::vector<ChunkRange>::const_iterator it = ranges.begin(); 59 std::vector<ChunkRange>::const_iterator it = ranges.begin();
60 for (; it != ranges.end(); ++it) { 60 for (; it != ranges.end(); ++it) {
61 if (!result->empty()) 61 if (!result->empty())
62 result->append(","); 62 result->append(",");
63 if (it->start() == it->stop()) { 63 if (it->start() == it->stop()) {
64 char num_buf[11]; // One 32 bit positive integer + NULL. 64 std::string num_buf = IntToString(it->start());
65 _itoa_s(it->start(), num_buf, sizeof(num_buf), 10);
66 result->append(num_buf); 65 result->append(num_buf);
67 } else { 66 } else {
68 result->append(StringPrintf("%d-%d", it->start(), it->stop())); 67 result->append(StringPrintf("%d-%d", it->start(), it->stop()));
69 } 68 }
70 } 69 }
71 } 70 }
72 71
73 bool StringToRanges(const std::string& input, 72 bool StringToRanges(const std::string& input,
74 std::vector<ChunkRange>* ranges) { 73 std::vector<ChunkRange>* ranges) {
75 DCHECK(ranges); 74 DCHECK(ranges);
(...skipping 12 matching lines...) Expand all
88 if (start == 0 || stop == 0) { 87 if (start == 0 || stop == 0) {
89 // atoi error, since chunk numbers are guaranteed to never be 0. 88 // atoi error, since chunk numbers are guaranteed to never be 0.
90 ranges->clear(); 89 ranges->clear();
91 return false; 90 return false;
92 } 91 }
93 ranges->push_back(ChunkRange(start, stop)); 92 ranges->push_back(ChunkRange(start, stop));
94 } 93 }
95 94
96 return true; 95 return true;
97 } 96 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/bloom_filter.cc ('k') | chrome/browser/safe_browsing/protocol_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698