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

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

Issue 1548113002: Switch to standard integer types in components/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 11 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 <stddef.h>
8 #include <stdint.h>
9
7 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
8 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
9 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
10 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
12 #include "components/history/core/browser/history_types.h" 15 #include "components/history/core/browser/history_types.h"
13 #include "components/history/core/browser/top_sites.h" 16 #include "components/history/core/browser/top_sites.h"
14 #include "components/history/core/common/thumbnail_score.h" 17 #include "components/history/core/common/thumbnail_score.h"
15 #include "sql/connection.h" 18 #include "sql/connection.h"
16 #include "sql/recovery.h" 19 #include "sql/recovery.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void RecoverDatabaseOrRaze(sql::Connection* db, const base::FilePath& db_path) { 205 void RecoverDatabaseOrRaze(sql::Connection* db, const base::FilePath& db_path) {
203 // NOTE(shess): If the version changes, review this code. 206 // NOTE(shess): If the version changes, review this code.
204 DCHECK_EQ(3, kVersionNumber); 207 DCHECK_EQ(3, kVersionNumber);
205 208
206 // It is almost certain that some operation against |db| will fail, prevent 209 // It is almost certain that some operation against |db| will fail, prevent
207 // reentry. 210 // reentry.
208 db->reset_error_callback(); 211 db->reset_error_callback();
209 212
210 // For generating histogram stats. 213 // For generating histogram stats.
211 size_t thumbnails_recovered = 0; 214 size_t thumbnails_recovered = 0;
212 int64 original_size = 0; 215 int64_t original_size = 0;
213 base::GetFileSize(db_path, &original_size); 216 base::GetFileSize(db_path, &original_size);
214 217
215 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(db, db_path); 218 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(db, db_path);
216 if (!recovery) { 219 if (!recovery) {
217 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_SCOPER); 220 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_SCOPER);
218 return; 221 return;
219 } 222 }
220 223
221 // Setup the meta recovery table and fetch the version number from the corrupt 224 // Setup the meta recovery table and fetch the version number from the corrupt
222 // database. 225 // database.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // should be done. Add histograms to Recovered() implementation to get some 292 // should be done. Add histograms to Recovered() implementation to get some
290 // insight. 293 // insight.
291 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_COMMIT); 294 RecordRecoveryEvent(RECOVERY_EVENT_FAILED_COMMIT);
292 return; 295 return;
293 } 296 }
294 297
295 // Track the size of the recovered database relative to the size of the input 298 // Track the size of the recovered database relative to the size of the input
296 // database. The size should almost always be smaller, unless the input 299 // database. The size should almost always be smaller, unless the input
297 // database was empty to start with. If the percentage results are very low, 300 // database was empty to start with. If the percentage results are very low,
298 // something is awry. 301 // something is awry.
299 int64 final_size = 0; 302 int64_t final_size = 0;
300 if (original_size > 0 && base::GetFileSize(db_path, &final_size) && 303 if (original_size > 0 && base::GetFileSize(db_path, &final_size) &&
301 final_size > 0) { 304 final_size > 0) {
302 UMA_HISTOGRAM_PERCENTAGE("History.TopSitesRecoveredPercentage", 305 UMA_HISTOGRAM_PERCENTAGE("History.TopSitesRecoveredPercentage",
303 final_size * 100 / original_size); 306 final_size * 100 / original_size);
304 } 307 }
305 308
306 // Using 10,000 because these cases mostly care about "none recovered" and 309 // Using 10,000 because these cases mostly care about "none recovered" and
307 // "lots recovered". More than 10,000 rows recovered probably means there's 310 // "lots recovered". More than 10,000 rows recovered probably means there's
308 // something wrong with the profile. 311 // something wrong with the profile.
309 UMA_HISTOGRAM_COUNTS_10000("History.TopSitesRecoveredRowsThumbnails", 312 UMA_HISTOGRAM_COUNTS_10000("History.TopSitesRecoveredRowsThumbnails",
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 statement.BindBlob(3, thumbnail.thumbnail->front(), 544 statement.BindBlob(3, thumbnail.thumbnail->front(),
542 static_cast<int>(thumbnail.thumbnail->size())); 545 static_cast<int>(thumbnail.thumbnail->size()));
543 } 546 }
544 statement.BindString(4, GetRedirects(url)); 547 statement.BindString(4, GetRedirects(url));
545 const ThumbnailScore& score = thumbnail.thumbnail_score; 548 const ThumbnailScore& score = thumbnail.thumbnail_score;
546 statement.BindDouble(5, score.boring_score); 549 statement.BindDouble(5, score.boring_score);
547 statement.BindBool(6, score.good_clipping); 550 statement.BindBool(6, score.good_clipping);
548 statement.BindBool(7, score.at_top); 551 statement.BindBool(7, score.at_top);
549 statement.BindInt64(8, score.time_at_snapshot.ToInternalValue()); 552 statement.BindInt64(8, score.time_at_snapshot.ToInternalValue());
550 statement.BindBool(9, score.load_completed); 553 statement.BindBool(9, score.load_completed);
551 int64 last_forced = url.last_forced_time.ToInternalValue(); 554 int64_t last_forced = url.last_forced_time.ToInternalValue();
552 DCHECK((last_forced == 0) == (new_rank != kRankOfForcedURL)) 555 DCHECK((last_forced == 0) == (new_rank != kRankOfForcedURL))
553 << "Thumbnail without a forced time stamp has a forced rank, or the " 556 << "Thumbnail without a forced time stamp has a forced rank, or the "
554 << "opposite."; 557 << "opposite.";
555 statement.BindInt64(10, last_forced); 558 statement.BindInt64(10, last_forced);
556 if (!statement.Run()) 559 if (!statement.Run())
557 return; 560 return;
558 561
559 // Update rank if this is not a forced thumbnail. 562 // Update rank if this is not a forced thumbnail.
560 if (new_rank != kRankOfForcedURL) 563 if (new_rank != kRankOfForcedURL)
561 UpdatePageRankNoTransaction(url, new_rank); 564 UpdatePageRankNoTransaction(url, new_rank);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 db->set_error_callback(base::Bind(&DatabaseErrorCallback, db.get(), db_name)); 726 db->set_error_callback(base::Bind(&DatabaseErrorCallback, db.get(), db_name));
724 db->set_page_size(4096); 727 db->set_page_size(4096);
725 db->set_cache_size(32); 728 db->set_cache_size(32);
726 729
727 if (!db->Open(db_name)) 730 if (!db->Open(db_name))
728 return NULL; 731 return NULL;
729 return db.release(); 732 return db.release();
730 } 733 }
731 734
732 } // namespace history 735 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/top_sites_database.h ('k') | components/history/core/browser/top_sites_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698