Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download struct used for informing and querying the download system's | 5 // Download struct used for informing and querying the download system's |
| 6 // persitent store. | 6 // persitent store. |
| 7 | 7 |
| 8 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_PERSISTENT_STORE_INFO_H_ | 8 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_PERSISTENT_STORE_INFO_H_ |
| 9 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_PERSISTENT_STORE_INFO_H_ | 9 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_PERSISTENT_STORE_INFO_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <string> | |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "content/browser/download/interrupt_reasons.h" | |
| 16 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 17 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 18 | 20 |
| 19 class DownloadItem; | 21 class DownloadItem; |
| 20 | 22 |
| 21 // Contains the information that is stored in the download system's persistent | 23 // Contains the information that is stored in the download system's persistent |
| 22 // store (or refers to it). Managed by the DownloadItem. When used to create a | 24 // store (or refers to it). Managed by the DownloadItem. When used to create a |
| 23 // history entry, all fields except for |db_handle| are set by DownloadItem and | 25 // history entry, all fields except for |db_handle| are set by DownloadItem and |
| 24 // read by DownloadDatabase. When used to update a history entry, DownloadItem | 26 // read by DownloadDatabase. When used to update a history entry, DownloadItem |
| 25 // sets all fields, but DownloadDatabase only reads |end_time|, | 27 // sets all fields, but DownloadDatabase only reads |end_time|, |
| 26 // |received_bytes|, |state|, and |opened|, and uses |db_handle| to select the | 28 // |received_bytes|, |state|, and |opened|, and uses |db_handle| to select the |
| 27 // row in the database table to update. When used to load DownloadItems from | 29 // row in the database table to update. When used to load DownloadItems from |
| 28 // the history, all fields except |referrer_url| are set by the DownloadDatabase | 30 // the history, all fields except |referrer_url| are set by the DownloadDatabase |
| 29 // and read by the DownloadItem. | 31 // and read by the DownloadItem. |
| 30 struct CONTENT_EXPORT DownloadPersistentStoreInfo { | 32 struct CONTENT_EXPORT DownloadPersistentStoreInfo { |
| 31 // TODO(ahendrickson) -- Reduce the number of constructors. | |
| 32 DownloadPersistentStoreInfo(); | 33 DownloadPersistentStoreInfo(); |
| 33 DownloadPersistentStoreInfo(const FilePath& path, | 34 DownloadPersistentStoreInfo(const FilePath& path, |
| 34 const GURL& url, | 35 const GURL& url, |
| 35 const GURL& referrer, | 36 const GURL& referrer, |
| 36 const base::Time& start, | 37 const base::Time& start, |
| 37 const base::Time& end, | 38 const base::Time& end, |
| 38 int64 received, | 39 int64 received, |
| 39 int64 total, | 40 int64 total, |
| 40 int32 download_state, | 41 int32 download_state, |
| 41 int64 handle, | 42 int64 handle, |
| 42 bool download_opened); | 43 bool download_opened, |
| 44 int32 local_id, | |
| 45 const std::string& hash, | |
| 46 const std::string& last_modified, | |
| 47 const std::string& etag, | |
| 48 InterruptReason reason); | |
| 43 ~DownloadPersistentStoreInfo(); // For linux-clang. | 49 ~DownloadPersistentStoreInfo(); // For linux-clang. |
| 44 | 50 |
| 45 // The final path where the download is saved. | 51 // The final path where the download is saved. |
| 46 FilePath path; | 52 FilePath path; |
| 47 | 53 |
| 48 // The URL from which we are downloading. This is the final URL after any | 54 // The URL from which we are downloading. This is the final URL after any |
| 49 // redirection by the server for |url_chain|. Is not changed by UpdateEntry(). | 55 // redirection by the server for |url_chain|. Is not changed by UpdateEntry(). |
| 50 GURL url; | 56 GURL url; |
| 51 | 57 |
| 52 // The URL that referred us. | 58 // The URL that referred us. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 66 | 72 |
| 67 // The current state of the download. | 73 // The current state of the download. |
| 68 int32 state; | 74 int32 state; |
| 69 | 75 |
| 70 // The handle of the download in the database. Is not changed by | 76 // The handle of the download in the database. Is not changed by |
| 71 // UpdateEntry(). | 77 // UpdateEntry(). |
| 72 int64 db_handle; | 78 int64 db_handle; |
| 73 | 79 |
| 74 // Whether this download has ever been opened from the browser. | 80 // Whether this download has ever been opened from the browser. |
| 75 bool opened; | 81 bool opened; |
| 82 | |
| 83 // The local ID of the download (unique per profile, and therefore per | |
| 84 // history database). | |
| 85 int32 local_id; | |
|
Randy Smith (Not in Mondays)
2011/11/16 18:29:27
Why do we want to persist this? It's namespace is
ahendrickson
2011/11/19 20:18:03
Removed.
| |
| 86 | |
| 87 // Sha256 hash of the content. This might be empty either because | |
| 88 // the download hasn't started yet or because the hash isn't needed | |
| 89 // (ChromeDownloadManagerDelegate::GenerateFileHash() returned false). | |
| 90 std::string hash; | |
| 91 | |
| 92 // Server's time stamp for the file. | |
| 93 std::string last_modified_time; | |
| 94 | |
| 95 // Server's ETAG for the file. | |
| 96 std::string etag; | |
| 97 | |
| 98 // Last reason. | |
|
Randy Smith (Not in Mondays)
2011/11/16 18:29:27
A bit more of a comment here? Duplicating the var
ahendrickson
2011/11/19 20:18:03
Done.
| |
| 99 InterruptReason last_reason; | |
| 76 }; | 100 }; |
| 77 | 101 |
| 78 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_PERSISTENT_STORE_INFO_H_ | 102 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_PERSISTENT_STORE_INFO_H_ |
| OLD | NEW |