| 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 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ |
| 6 #define COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
| 13 #include "components/history/core/browser/download_types.h" | 13 #include "components/history/core/browser/download_types.h" |
| 14 #include "sql/meta_table.h" | 14 #include "sql/meta_table.h" |
| 15 | 15 |
| 16 namespace sql { | 16 namespace sql { |
| 17 class Connection; | 17 class Connection; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace history { | 20 namespace history { |
| 21 | 21 |
| 22 struct DownloadRow; | 22 struct DownloadRow; |
| 23 | 23 |
| 24 // Maintains a table of downloads. | 24 // Maintains a table of downloads. |
| 25 class DownloadDatabase { | 25 class DownloadDatabase { |
| 26 public: | 26 public: |
| 27 // Must call InitDownloadTable before using any other functions. | 27 // Must call InitDownloadTable before using any other functions. |
| 28 DownloadDatabase(DownloadInterruptReason download_interrupt_no_reason, | 28 DownloadDatabase(DownloadInterruptReason download_interrupt_reason_none, |
| 29 DownloadInterruptReason download_interrupt_crash); | 29 DownloadInterruptReason download_interrupt_reason_crash); |
| 30 virtual ~DownloadDatabase(); | 30 virtual ~DownloadDatabase(); |
| 31 | 31 |
| 32 uint32 GetNextDownloadId(); | 32 uint32 GetNextDownloadId(); |
| 33 | 33 |
| 34 // Get all the downloads from the database. | 34 // Get all the downloads from the database. |
| 35 void QueryDownloads(std::vector<DownloadRow>* results); | 35 void QueryDownloads(std::vector<DownloadRow>* results); |
| 36 | 36 |
| 37 // Update the state of one download. Returns true if successful. | 37 // Update the state of one download. Returns true if successful. |
| 38 // Does not update |url|, |start_time|; uses |id| only | 38 // Does not update |url|, |start_time|; uses |id| only |
| 39 // to select the row in the database table to update. | 39 // to select the row in the database table to update. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // Initialized to false on construction, and checked in all functional | 104 // Initialized to false on construction, and checked in all functional |
| 105 // routines post-migration in the database for a possible call to | 105 // routines post-migration in the database for a possible call to |
| 106 // CleanUpInProgressEntries(). This allows us to avoid | 106 // CleanUpInProgressEntries(). This allows us to avoid |
| 107 // doing the cleanup until after any DB migration and unless we are | 107 // doing the cleanup until after any DB migration and unless we are |
| 108 // actually use the downloads database. | 108 // actually use the downloads database. |
| 109 bool in_progress_entry_cleanup_completed_; | 109 bool in_progress_entry_cleanup_completed_; |
| 110 | 110 |
| 111 // Those constants are defined in the embedder and injected into the | 111 // Those constants are defined in the embedder and injected into the |
| 112 // database in the constructor. They represent the interrupt reason | 112 // database in the constructor. They represent the interrupt reason |
| 113 // to use for respectively an undefined value and in case of a crash. | 113 // to use for respectively an undefined value and in case of a crash. |
| 114 DownloadInterruptReason download_interrupt_no_reason_; | 114 DownloadInterruptReason download_interrupt_reason_none_; |
| 115 DownloadInterruptReason download_interrupt_crash_; | 115 DownloadInterruptReason download_interrupt_reason_crash_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); | 117 DISALLOW_COPY_AND_ASSIGN(DownloadDatabase); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace history | 120 } // namespace history |
| 121 | 121 |
| 122 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ | 122 #endif // COMPONENTS_HISTORY_CORE_BROWSER_DOWNLOAD_DATABASE_H_ |
| OLD | NEW |