OLD | NEW |
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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "chrome/browser/history/history_types.h" | 9 #include "chrome/browser/history/history_types.h" |
10 #include "chrome/browser/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 sql::Transaction transaction(db_.get()); | 305 sql::Transaction transaction(db_.get()); |
306 transaction.Begin(); | 306 transaction.Begin(); |
307 UpdatePageRankNoTransaction(url, new_rank); | 307 UpdatePageRankNoTransaction(url, new_rank); |
308 transaction.Commit(); | 308 transaction.Commit(); |
309 } | 309 } |
310 | 310 |
311 // Caller should have a transaction open. | 311 // Caller should have a transaction open. |
312 void TopSitesDatabase::UpdatePageRankNoTransaction( | 312 void TopSitesDatabase::UpdatePageRankNoTransaction( |
313 const MostVisitedURL& url, int new_rank) { | 313 const MostVisitedURL& url, int new_rank) { |
314 DCHECK_GT(db_->transaction_nesting(), 0); | 314 DCHECK_GT(db_->transaction_nesting(), 0); |
| 315 DCHECK((url.last_forced_time.is_null()) == (new_rank != kRankOfForcedURL)) |
| 316 << "Thumbnail without a forced time stamp has a forced rank, or the " |
| 317 << "opposite."; |
315 | 318 |
316 int prev_rank = GetURLRank(url); | 319 int prev_rank = GetURLRank(url); |
317 if (prev_rank == kRankOfNonExistingURL) { | 320 if (prev_rank == kRankOfNonExistingURL) { |
318 LOG(WARNING) << "Updating rank of an unknown URL: " << url.url.spec(); | 321 LOG(WARNING) << "Updating rank of an unknown URL: " << url.url.spec(); |
319 return; | 322 return; |
320 } | 323 } |
321 | 324 |
322 // Shift the ranks. | 325 // Shift the ranks. |
323 if (prev_rank > new_rank) { | 326 if (prev_rank > new_rank) { |
324 if (new_rank == kRankOfForcedURL) { | 327 if (new_rank == kRankOfForcedURL) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 462 |
460 if (!db->Open(db_name)) { | 463 if (!db->Open(db_name)) { |
461 LOG(ERROR) << db->GetErrorMessage(); | 464 LOG(ERROR) << db->GetErrorMessage(); |
462 return NULL; | 465 return NULL; |
463 } | 466 } |
464 | 467 |
465 return db.release(); | 468 return db.release(); |
466 } | 469 } |
467 | 470 |
468 } // namespace history | 471 } // namespace history |
OLD | NEW |