| 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 CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "content/common/id_type.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 21 class SavePackage; |
| 22 using SavePackageId = IdType32<SavePackage>; |
| 23 |
| 24 class SaveItem; |
| 25 using SaveItemId = IdType32<SaveItem>; |
| 26 |
| 20 // Map from save_item_id into final file path. | 27 // Map from save_item_id into final file path. |
| 21 typedef std::map<int, base::FilePath> FinalNamesMap; | 28 using FinalNamesMap = std::map<SaveItemId, base::FilePath>; |
| 22 | 29 |
| 23 // This structure is used to handle and deliver some info | 30 // This structure is used to handle and deliver some info |
| 24 // when processing each save item job. | 31 // when processing each save item job. |
| 25 struct SaveFileCreateInfo { | 32 struct SaveFileCreateInfo { |
| 26 enum SaveFileSource { | 33 enum SaveFileSource { |
| 27 // This type indicates the source is not set. | 34 // This type indicates the source is not set. |
| 28 SAVE_FILE_FROM_UNKNOWN = -1, | 35 SAVE_FILE_FROM_UNKNOWN = -1, |
| 29 // This type indicates the save item needs to be retrieved from the network. | 36 // This type indicates the save item needs to be retrieved from the network. |
| 30 SAVE_FILE_FROM_NET = 0, | 37 SAVE_FILE_FROM_NET = 0, |
| 31 // This type indicates the save item needs to be retrieved from serializing | 38 // This type indicates the save item needs to be retrieved from serializing |
| 32 // DOM. | 39 // DOM. |
| 33 SAVE_FILE_FROM_DOM, | 40 SAVE_FILE_FROM_DOM, |
| 34 // This type indicates the save item needs to be retrieved from local file | 41 // This type indicates the save item needs to be retrieved from local file |
| 35 // system. | 42 // system. |
| 36 SAVE_FILE_FROM_FILE | 43 SAVE_FILE_FROM_FILE |
| 37 }; | 44 }; |
| 38 | 45 |
| 39 // Constructor for SAVE_FILE_FROM_DOM and/or SAVE_FILE_FROM_FILE. | 46 // Constructor for SAVE_FILE_FROM_DOM and/or SAVE_FILE_FROM_FILE. |
| 40 SaveFileCreateInfo(const base::FilePath& path, | 47 SaveFileCreateInfo(const base::FilePath& path, |
| 41 const GURL& url, | 48 const GURL& url, |
| 42 int save_item_id, | 49 SaveItemId save_item_id, |
| 43 int save_package_id, | 50 SavePackageId save_package_id, |
| 44 int render_process_id, | 51 int render_process_id, |
| 45 int render_frame_routing_id, | 52 int render_frame_routing_id, |
| 46 SaveFileSource save_source); | 53 SaveFileSource save_source); |
| 47 | 54 |
| 48 // Constructor for SAVE_FILE_FROM_NET case. | 55 // Constructor for SAVE_FILE_FROM_NET case. |
| 49 SaveFileCreateInfo(const GURL& url, | 56 SaveFileCreateInfo(const GURL& url, |
| 50 const GURL& final_url, | 57 const GURL& final_url, |
| 51 int save_item_id, | 58 SaveItemId save_item_id, |
| 52 int save_package_id, | 59 SavePackageId save_package_id, |
| 53 int render_process_id, | 60 int render_process_id, |
| 54 int render_frame_routing_id, | 61 int render_frame_routing_id, |
| 55 int request_id, | 62 int request_id, |
| 56 const std::string& content_disposition, | 63 const std::string& content_disposition, |
| 57 int64_t total_bytes); | 64 int64_t total_bytes); |
| 58 | 65 |
| 59 ~SaveFileCreateInfo(); | 66 ~SaveFileCreateInfo(); |
| 60 | 67 |
| 61 // SaveItem fields. | 68 // SaveItem fields. |
| 62 // The local file path of saved file. | 69 // The local file path of saved file. |
| 63 base::FilePath path; | 70 base::FilePath path; |
| 64 // Original URL of the saved resource. | 71 // Original URL of the saved resource. |
| 65 GURL url; | 72 GURL url; |
| 66 // Final URL of the saved resource since some URL might be redirected. | 73 // Final URL of the saved resource since some URL might be redirected. |
| 67 GURL final_url; | 74 GURL final_url; |
| 68 // The unique identifier of SaveItem object associated with this job. | 75 // The unique identifier of SaveItem object associated with this job. |
| 69 int save_item_id; | 76 SaveItemId save_item_id; |
| 70 // ID of SavePackage object. | 77 // ID of SavePackage object. |
| 71 int save_package_id; | 78 SavePackageId save_package_id; |
| 72 // IDs for looking up the contents we are associated with. | 79 // IDs for looking up the contents we are associated with. |
| 73 int render_process_id; | 80 int render_process_id; |
| 74 int render_frame_routing_id; | 81 int render_frame_routing_id; |
| 75 // Handle for informing the ResourceDispatcherHost of a UI based cancel. | 82 // Handle for informing the ResourceDispatcherHost of a UI based cancel. |
| 76 int request_id; | 83 int request_id; |
| 77 // Disposition info from HTTP response. | 84 // Disposition info from HTTP response. |
| 78 std::string content_disposition; | 85 std::string content_disposition; |
| 79 // Total bytes of saved file. | 86 // Total bytes of saved file. |
| 80 int64_t total_bytes; | 87 int64_t total_bytes; |
| 81 // Source type of saved file. | 88 // Source type of saved file. |
| 82 SaveFileSource save_source; | 89 SaveFileSource save_source; |
| 83 }; | 90 }; |
| 84 | 91 |
| 85 } // namespace content | 92 } // namespace content |
| 86 | 93 |
| 87 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_ | 94 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_TYPES_H_ |
| OLD | NEW |