| 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 "components/history/core/browser/download_database.h" | 5 #include "components/history/core/browser/download_database.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // DB corruption case in production code. | 352 // DB corruption case in production code. |
| 353 | 353 |
| 354 // Confirm the id has already been seen--if it hasn't, discard the | 354 // Confirm the id has already been seen--if it hasn't, discard the |
| 355 // record. | 355 // record. |
| 356 DCHECK(ContainsKey(info_map, id)); | 356 DCHECK(ContainsKey(info_map, id)); |
| 357 if (!ContainsKey(info_map, id)) | 357 if (!ContainsKey(info_map, id)) |
| 358 continue; | 358 continue; |
| 359 | 359 |
| 360 // Confirm all previous URLs in the chain have already been seen; | 360 // Confirm all previous URLs in the chain have already been seen; |
| 361 // if not, fill in with null or discard record. | 361 // if not, fill in with null or discard record. |
| 362 int current_chain_size = info_map[id]->url_chain.size(); | 362 int current_chain_size = static_cast<int>(info_map[id]->url_chain.size()); |
| 363 std::vector<GURL>* url_chain(&info_map[id]->url_chain); | 363 std::vector<GURL>* url_chain(&info_map[id]->url_chain); |
| 364 DCHECK_EQ(chain_index, current_chain_size); | 364 DCHECK_EQ(chain_index, current_chain_size); |
| 365 while (current_chain_size < chain_index) { | 365 while (current_chain_size < chain_index) { |
| 366 url_chain->push_back(GURL()); | 366 url_chain->push_back(GURL()); |
| 367 current_chain_size++; | 367 current_chain_size++; |
| 368 } | 368 } |
| 369 if (current_chain_size > chain_index) | 369 if (current_chain_size > chain_index) |
| 370 continue; | 370 continue; |
| 371 | 371 |
| 372 // Save the record. | 372 // Save the record. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 sql::Statement statement_insert_chain( | 524 sql::Statement statement_insert_chain( |
| 525 GetDB().GetCachedStatement(SQL_FROM_HERE, | 525 GetDB().GetCachedStatement(SQL_FROM_HERE, |
| 526 "INSERT INTO downloads_url_chains " | 526 "INSERT INTO downloads_url_chains " |
| 527 "(id, chain_index, url) " | 527 "(id, chain_index, url) " |
| 528 "VALUES (?, ?, ?)")); | 528 "VALUES (?, ?, ?)")); |
| 529 for (size_t i = 0; i < info.url_chain.size(); ++i) { | 529 for (size_t i = 0; i < info.url_chain.size(); ++i) { |
| 530 statement_insert_chain.BindInt(0, info.id); | 530 statement_insert_chain.BindInt(0, info.id); |
| 531 statement_insert_chain.BindInt(1, i); | 531 statement_insert_chain.BindInt(1, static_cast<int>(i)); |
| 532 statement_insert_chain.BindString(2, info.url_chain[i].spec()); | 532 statement_insert_chain.BindString(2, info.url_chain[i].spec()); |
| 533 if (!statement_insert_chain.Run()) { | 533 if (!statement_insert_chain.Run()) { |
| 534 UMA_HISTOGRAM_ENUMERATION("Download.DatabaseURLChainInsertError", | 534 UMA_HISTOGRAM_ENUMERATION("Download.DatabaseURLChainInsertError", |
| 535 GetDB().GetErrorCode() & 0xff, 50); | 535 GetDB().GetErrorCode() & 0xff, 50); |
| 536 RemoveDownload(info.id); | 536 RemoveDownload(info.id); |
| 537 return false; | 537 return false; |
| 538 } | 538 } |
| 539 statement_insert_chain.Reset(true); | 539 statement_insert_chain.Reset(true); |
| 540 } | 540 } |
| 541 return true; | 541 return true; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 568 size_t DownloadDatabase::CountDownloads() { | 568 size_t DownloadDatabase::CountDownloads() { |
| 569 EnsureInProgressEntriesCleanedUp(); | 569 EnsureInProgressEntriesCleanedUp(); |
| 570 | 570 |
| 571 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 571 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
| 572 "SELECT count(*) from downloads")); | 572 "SELECT count(*) from downloads")); |
| 573 statement.Step(); | 573 statement.Step(); |
| 574 return statement.ColumnInt(0); | 574 return statement.ColumnInt(0); |
| 575 } | 575 } |
| 576 | 576 |
| 577 } // namespace history | 577 } // namespace history |
| OLD | NEW |