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

Side by Side Diff: chrome/browser/history/snippet.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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
« no previous file with comments | « chrome/browser/first_run/first_run_win.cc ('k') | chrome/browser/history/snippet_unittest.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 #include "chrome/browser/history/snippet.h" 5 #include "chrome/browser/history/snippet.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } // namespace 160 } // namespace
161 161
162 // static 162 // static
163 void Snippet::ExtractMatchPositions(const std::string& offsets_str, 163 void Snippet::ExtractMatchPositions(const std::string& offsets_str,
164 const std::string& column_num, 164 const std::string& column_num,
165 MatchPositions* match_positions) { 165 MatchPositions* match_positions) {
166 DCHECK(match_positions); 166 DCHECK(match_positions);
167 if (offsets_str.empty()) 167 if (offsets_str.empty())
168 return; 168 return;
169 std::vector<std::string> offsets; 169 std::vector<std::string> offsets;
170 SplitString(offsets_str, ' ', &offsets); 170 base::SplitString(offsets_str, ' ', &offsets);
171 // SQLite offsets are sets of four integers: 171 // SQLite offsets are sets of four integers:
172 // column, query term, match offset, match length 172 // column, query term, match offset, match length
173 // Matches within a string are marked by (start, end) pairs. 173 // Matches within a string are marked by (start, end) pairs.
174 for (size_t i = 0; i < offsets.size() - 3; i += 4) { 174 for (size_t i = 0; i < offsets.size() - 3; i += 4) {
175 if (offsets[i] != column_num) 175 if (offsets[i] != column_num)
176 continue; 176 continue;
177 const size_t start = atoi(offsets[i + 2].c_str()); 177 const size_t start = atoi(offsets[i + 2].c_str());
178 const size_t end = start + atoi(offsets[i + 3].c_str()); 178 const size_t end = start + atoi(offsets[i + 3].c_str());
179 // Switch to DCHECK after debugging http://crbug.com/15261. 179 // Switch to DCHECK after debugging http://crbug.com/15261.
180 CHECK(end >= start); 180 CHECK(end >= start);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 289
290 utext_close(document_utext); 290 utext_close(document_utext);
291 swap(text_, snippet); 291 swap(text_, snippet);
292 } 292 }
293 293
294 void Snippet::Swap(Snippet* other) { 294 void Snippet::Swap(Snippet* other) {
295 text_.swap(other->text_); 295 text_.swap(other->text_);
296 matches_.swap(other->matches_); 296 matches_.swap(other->matches_);
297 } 297 }
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run_win.cc ('k') | chrome/browser/history/snippet_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698