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

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

Issue 562993002: [Top Sites] Validating URLs for "redirects" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | 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) 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 "chrome/browser/history/top_sites_database.h" 5 #include "chrome/browser/history/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 std::vector<std::string> redirects; 83 std::vector<std::string> redirects;
84 for (size_t i = 0; i < url.redirects.size(); i++) 84 for (size_t i = 0; i < url.redirects.size(); i++)
85 redirects.push_back(url.redirects[i].spec()); 85 redirects.push_back(url.redirects[i].spec());
86 return JoinString(redirects, ' '); 86 return JoinString(redirects, ' ');
87 } 87 }
88 88
89 // Decodes redirects from a string and sets them for the url. 89 // Decodes redirects from a string and sets them for the url.
90 void SetRedirects(const std::string& redirects, history::MostVisitedURL* url) { 90 void SetRedirects(const std::string& redirects, history::MostVisitedURL* url) {
91 std::vector<std::string> redirects_vector; 91 std::vector<std::string> redirects_vector;
92 base::SplitStringAlongWhitespace(redirects, &redirects_vector); 92 base::SplitStringAlongWhitespace(redirects, &redirects_vector);
93 for (size_t i = 0; i < redirects_vector.size(); ++i) 93 for (size_t i = 0; i < redirects_vector.size(); ++i) {
94 url->redirects.push_back(GURL(redirects_vector[i])); 94 GURL redirects_url(redirects_vector[i]);
95 if (redirects_url.is_valid())
96 url->redirects.push_back(redirects_url);
97 }
95 } 98 }
96 99
97 // Track various failure (and success) cases in recovery code. 100 // Track various failure (and success) cases in recovery code.
98 // 101 //
99 // TODO(shess): The recovery code is complete, but by nature runs in challenging 102 // TODO(shess): The recovery code is complete, but by nature runs in challenging
100 // circumstances, so initially the default error response is to leave the 103 // circumstances, so initially the default error response is to leave the
101 // existing database in place. This histogram is intended to expose the 104 // existing database in place. This histogram is intended to expose the
102 // failures seen in the fleet. Frequent failure cases can be explored more 105 // failures seen in the fleet. Frequent failure cases can be explored more
103 // deeply to see if the complexity to fix them is warranted. Infrequent failure 106 // deeply to see if the complexity to fix them is warranted. Infrequent failure
104 // cases can be resolved by marking the database unrecoverable (which will 107 // cases can be resolved by marking the database unrecoverable (which will
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 db.get(), db_name)); 727 db.get(), db_name));
725 db->set_page_size(4096); 728 db->set_page_size(4096);
726 db->set_cache_size(32); 729 db->set_cache_size(32);
727 730
728 if (!db->Open(db_name)) 731 if (!db->Open(db_name))
729 return NULL; 732 return NULL;
730 return db.release(); 733 return db.release();
731 } 734 }
732 735
733 } // namespace history 736 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698