| 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 <inttypes.h> | 7 #include <inttypes.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "components/history/core/browser/download_constants.h" | 23 #include "components/history/core/browser/download_constants.h" |
| 24 #include "components/history/core/browser/download_row.h" | 24 #include "components/history/core/browser/download_row.h" |
| 25 #include "components/history/core/browser/history_types.h" | 25 #include "components/history/core/browser/history_types.h" |
| 26 #include "sql/statement.h" | 26 #include "sql/statement.h" |
| 27 | 27 |
| 28 namespace history { | 28 namespace history { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 // Reason for dropping a particular record. | 32 // Reason for dropping a particular record. Used for UMA. |
| 33 enum DroppedReason { | 33 enum DroppedReason { |
| 34 DROPPED_REASON_BAD_STATE = 0, | 34 DROPPED_REASON_BAD_STATE = 0, |
| 35 DROPPED_REASON_BAD_DANGER_TYPE = 1, | 35 DROPPED_REASON_BAD_DANGER_TYPE = 1, |
| 36 DROPPED_REASON_BAD_ID = 2, | 36 DROPPED_REASON_BAD_ID = 2, |
| 37 DROPPED_REASON_DUPLICATE_ID = 3, | 37 DROPPED_REASON_DUPLICATE_ID = 3, |
| 38 DROPPED_REASON_MAX | 38 DROPPED_REASON_MAX |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 #if defined(OS_POSIX) | 41 #if defined(OS_POSIX) |
| 42 | 42 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 return false; | 617 return false; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 { | 621 { |
| 622 sql::Statement count_urls(GetDB().GetCachedStatement(SQL_FROM_HERE, | 622 sql::Statement count_urls(GetDB().GetCachedStatement(SQL_FROM_HERE, |
| 623 "SELECT count(*) FROM downloads_url_chains WHERE id=?")); | 623 "SELECT count(*) FROM downloads_url_chains WHERE id=?")); |
| 624 count_urls.BindInt(0, info.id); | 624 count_urls.BindInt(0, info.id); |
| 625 if (count_urls.Step()) { | 625 if (count_urls.Step()) { |
| 626 bool corrupt_urls = count_urls.ColumnInt(0) > 0; | 626 bool corrupt_urls = count_urls.ColumnInt(0) > 0; |
| 627 UMA_HISTOGRAM_BOOLEAN("Download.DatabaseCorruptUrls", corrupt_urls); | |
| 628 if (corrupt_urls) { | 627 if (corrupt_urls) { |
| 629 // There should not be any URLs in downloads_url_chains for this | 628 // There should not be any URLs in downloads_url_chains for this |
| 630 // info.id. If there are, we don't want them to interfere with | 629 // info.id. If there are, we don't want them to interfere with |
| 631 // inserting the correct URLs, so just remove them. | 630 // inserting the correct URLs, so just remove them. |
| 632 RemoveDownloadURLs(info.id); | 631 RemoveDownloadURLs(info.id); |
| 633 } | 632 } |
| 634 } | 633 } |
| 635 } | 634 } |
| 636 | 635 |
| 637 sql::Statement statement_insert_chain( | 636 sql::Statement statement_insert_chain( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 size_t DownloadDatabase::CountDownloads() { | 680 size_t DownloadDatabase::CountDownloads() { |
| 682 EnsureInProgressEntriesCleanedUp(); | 681 EnsureInProgressEntriesCleanedUp(); |
| 683 | 682 |
| 684 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, | 683 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, |
| 685 "SELECT count(*) from downloads")); | 684 "SELECT count(*) from downloads")); |
| 686 statement.Step(); | 685 statement.Step(); |
| 687 return statement.ColumnInt(0); | 686 return statement.ColumnInt(0); |
| 688 } | 687 } |
| 689 | 688 |
| 690 } // namespace history | 689 } // namespace history |
| OLD | NEW |