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

Side by Side Diff: components/history/core/browser/top_sites_database.cc

Issue 1234973004: Update SplitString calls in components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/history/core/browser/top_sites_database.h" 5 #include "components/history/core/browser/top_sites_database.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Encodes redirects into a string. 83 // Encodes redirects into a string.
84 std::string GetRedirects(const MostVisitedURL& url) { 84 std::string GetRedirects(const MostVisitedURL& url) {
85 std::vector<std::string> redirects; 85 std::vector<std::string> redirects;
86 for (size_t i = 0; i < url.redirects.size(); i++) 86 for (size_t i = 0; i < url.redirects.size(); i++)
87 redirects.push_back(url.redirects[i].spec()); 87 redirects.push_back(url.redirects[i].spec());
88 return base::JoinString(redirects, " "); 88 return base::JoinString(redirects, " ");
89 } 89 }
90 90
91 // Decodes redirects from a string and sets them for the url. 91 // Decodes redirects from a string and sets them for the url.
92 void SetRedirects(const std::string& redirects, MostVisitedURL* url) { 92 void SetRedirects(const std::string& redirects, MostVisitedURL* url) {
93 std::vector<std::string> redirects_vector; 93 for (const std::string& redirect : base::SplitString(
94 base::SplitStringAlongWhitespace(redirects, &redirects_vector); 94 redirects, base::kWhitespaceASCII,
95 for (size_t i = 0; i < redirects_vector.size(); ++i) { 95 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
96 GURL redirects_url(redirects_vector[i]); 96 GURL redirect_url(redirect);
97 if (redirects_url.is_valid()) 97 if (redirect_url.is_valid())
98 url->redirects.push_back(redirects_url); 98 url->redirects.push_back(redirect_url);
99 } 99 }
100 } 100 }
101 101
102 // Track various failure (and success) cases in recovery code. 102 // Track various failure (and success) cases in recovery code.
103 // 103 //
104 // TODO(shess): The recovery code is complete, but by nature runs in challenging 104 // TODO(shess): The recovery code is complete, but by nature runs in challenging
105 // circumstances, so initially the default error response is to leave the 105 // circumstances, so initially the default error response is to leave the
106 // existing database in place. This histogram is intended to expose the 106 // existing database in place. This histogram is intended to expose the
107 // failures seen in the fleet. Frequent failure cases can be explored more 107 // failures seen in the fleet. Frequent failure cases can be explored more
108 // deeply to see if the complexity to fix them is warranted. Infrequent failure 108 // deeply to see if the complexity to fix them is warranted. Infrequent failure
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 db->set_error_callback(base::Bind(&DatabaseErrorCallback, db.get(), db_name)); 723 db->set_error_callback(base::Bind(&DatabaseErrorCallback, db.get(), db_name));
724 db->set_page_size(4096); 724 db->set_page_size(4096);
725 db->set_cache_size(32); 725 db->set_cache_size(32);
726 726
727 if (!db->Open(db_name)) 727 if (!db->Open(db_name))
728 return NULL; 728 return NULL;
729 return db.release(); 729 return db.release();
730 } 730 }
731 731
732 } // namespace history 732 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698