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

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

Issue 896093004: Cleanup usage of history namespace in components/history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "components/history/core/browser/history_types.h" 12 #include "components/history/core/browser/history_types.h"
13 #include "components/history/core/browser/top_sites.h" 13 #include "components/history/core/browser/top_sites.h"
14 #include "components/history/core/common/thumbnail_score.h" 14 #include "components/history/core/common/thumbnail_score.h"
15 #include "sql/connection.h" 15 #include "sql/connection.h"
16 #include "sql/recovery.h" 16 #include "sql/recovery.h"
17 #include "sql/statement.h" 17 #include "sql/statement.h"
18 #include "sql/transaction.h" 18 #include "sql/transaction.h"
19 #include "third_party/sqlite/sqlite3.h" 19 #include "third_party/sqlite/sqlite3.h"
20 20
21 namespace history {
22
21 // Description of database table: 23 // Description of database table:
22 // 24 //
23 // thumbnails 25 // thumbnails
24 // url URL of the sites for which we have a thumbnail. 26 // url URL of the sites for which we have a thumbnail.
25 // url_rank Index of the URL in that thumbnail, 0-based. The thumbnail 27 // url_rank Index of the URL in that thumbnail, 0-based. The thumbnail
26 // with the highest rank will be the next one evicted. Forced 28 // with the highest rank will be the next one evicted. Forced
27 // thumbnails have a rank of -1. 29 // thumbnails have a rank of -1.
28 // title The title to display under that thumbnail. 30 // title The title to display under that thumbnail.
29 // redirects A space separated list of URLs that are known to redirect 31 // redirects A space separated list of URLs that are known to redirect
30 // to this url. 32 // to this url.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 "boring_score DOUBLE DEFAULT 1.0," 74 "boring_score DOUBLE DEFAULT 1.0,"
73 "good_clipping INTEGER DEFAULT 0," 75 "good_clipping INTEGER DEFAULT 0,"
74 "at_top INTEGER DEFAULT 0," 76 "at_top INTEGER DEFAULT 0,"
75 "last_updated INTEGER DEFAULT 0," 77 "last_updated INTEGER DEFAULT 0,"
76 "load_completed INTEGER DEFAULT 0," 78 "load_completed INTEGER DEFAULT 0,"
77 "last_forced INTEGER DEFAULT 0)"; 79 "last_forced INTEGER DEFAULT 0)";
78 return db->Execute(kThumbnailsSql); 80 return db->Execute(kThumbnailsSql);
79 } 81 }
80 82
81 // Encodes redirects into a string. 83 // Encodes redirects into a string.
82 std::string GetRedirects(const history::MostVisitedURL& url) { 84 std::string GetRedirects(const MostVisitedURL& url) {
83 std::vector<std::string> redirects; 85 std::vector<std::string> redirects;
84 for (size_t i = 0; i < url.redirects.size(); i++) 86 for (size_t i = 0; i < url.redirects.size(); i++)
85 redirects.push_back(url.redirects[i].spec()); 87 redirects.push_back(url.redirects[i].spec());
86 return JoinString(redirects, ' '); 88 return JoinString(redirects, ' ');
87 } 89 }
88 90
89 // Decodes redirects from a string and sets them for the url. 91 // Decodes redirects from a string and sets them for the url.
90 void SetRedirects(const std::string& redirects, history::MostVisitedURL* url) { 92 void SetRedirects(const std::string& redirects, MostVisitedURL* url) {
91 std::vector<std::string> redirects_vector; 93 std::vector<std::string> redirects_vector;
92 base::SplitStringAlongWhitespace(redirects, &redirects_vector); 94 base::SplitStringAlongWhitespace(redirects, &redirects_vector);
93 for (size_t i = 0; i < redirects_vector.size(); ++i) { 95 for (size_t i = 0; i < redirects_vector.size(); ++i) {
94 GURL redirects_url(redirects_vector[i]); 96 GURL redirects_url(redirects_vector[i]);
95 if (redirects_url.is_valid()) 97 if (redirects_url.is_valid())
96 url->redirects.push_back(redirects_url); 98 url->redirects.push_back(redirects_url);
97 } 99 }
98 } 100 }
99 101
100 // Track various failure (and success) cases in recovery code. 102 // Track various failure (and success) cases in recovery code.
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // possible that running recovery would be a reasonable default when errors 341 // possible that running recovery would be a reasonable default when errors
340 // are seen. 342 // are seen.
341 343
342 // The default handling is to assert on debug and to ignore on release. 344 // The default handling is to assert on debug and to ignore on release.
343 if (!sql::Connection::ShouldIgnoreSqliteError(extended_error)) 345 if (!sql::Connection::ShouldIgnoreSqliteError(extended_error))
344 DLOG(FATAL) << db->GetErrorMessage(); 346 DLOG(FATAL) << db->GetErrorMessage();
345 } 347 }
346 348
347 } // namespace 349 } // namespace
348 350
349 namespace history {
350
351 // static 351 // static
352 const int TopSitesDatabase::kRankOfForcedURL = -1; 352 const int TopSitesDatabase::kRankOfForcedURL = -1;
353 353
354 // static 354 // static
355 const int TopSitesDatabase::kRankOfNonExistingURL = -2; 355 const int TopSitesDatabase::kRankOfNonExistingURL = -2;
356 356
357 TopSitesDatabase::TopSitesDatabase() { 357 TopSitesDatabase::TopSitesDatabase() {
358 } 358 }
359 359
360 TopSitesDatabase::~TopSitesDatabase() { 360 TopSitesDatabase::~TopSitesDatabase() {
(...skipping 362 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
« no previous file with comments | « components/history/core/browser/thumbnail_database.cc ('k') | components/history/core/browser/top_sites_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698