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_ITEM_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 13 matching lines...) Loading... |
24 WAIT_START, | 24 WAIT_START, |
25 IN_PROGRESS, | 25 IN_PROGRESS, |
26 COMPLETE, | 26 COMPLETE, |
27 CANCELED | 27 CANCELED |
28 }; | 28 }; |
29 | 29 |
30 SaveItem(const GURL& url, | 30 SaveItem(const GURL& url, |
31 const Referrer& referrer, | 31 const Referrer& referrer, |
32 SavePackage* package, | 32 SavePackage* package, |
33 SaveFileCreateInfo::SaveFileSource save_source, | 33 SaveFileCreateInfo::SaveFileSource save_source, |
34 int frame_tree_node_id); | 34 int frame_tree_node_id, |
| 35 int container_frame_tree_node_id); |
35 | 36 |
36 ~SaveItem(); | 37 ~SaveItem(); |
37 | 38 |
38 void Start(); | 39 void Start(); |
39 | 40 |
40 // Received a new chunk of data. | 41 // Received a new chunk of data. |
41 void Update(int64_t bytes_so_far); | 42 void Update(int64_t bytes_so_far); |
42 | 43 |
43 // Cancel saving item. | 44 // Cancel saving item. |
44 void Cancel(); | 45 void Cancel(); |
45 | 46 |
46 // Saving operation completed. | 47 // Saving operation completed. |
47 void Finish(int64_t size, bool is_success); | 48 void Finish(int64_t size, bool is_success); |
48 | 49 |
49 // Update path for SaveItem, the actual file is renamed on the file thread. | 50 // Update path for SaveItem, the actual file is renamed on the file thread. |
50 void SetTargetPath(const base::FilePath& full_path); | 51 void SetTargetPath(const base::FilePath& full_path); |
51 | 52 |
52 void SetTotalBytes(int64_t total_bytes); | 53 void SetTotalBytes(int64_t total_bytes); |
53 | 54 |
54 // Accessors. | 55 // Accessors. |
55 SaveItemId id() const { return save_item_id_; } | 56 SaveItemId id() const { return save_item_id_; } |
56 SaveState state() const { return state_; } | 57 SaveState state() const { return state_; } |
57 const base::FilePath& full_path() const { return full_path_; } | 58 const base::FilePath& full_path() const { return full_path_; } |
58 const GURL& url() const { return url_; } | 59 const GURL& url() const { return url_; } |
59 const Referrer& referrer() const { return referrer_; } | 60 const Referrer& referrer() const { return referrer_; } |
60 int frame_tree_node_id() const { return frame_tree_node_id_; } | 61 int frame_tree_node_id() const { return frame_tree_node_id_; } |
| 62 int container_frame_tree_node_id() const { |
| 63 return container_frame_tree_node_id_; |
| 64 } |
61 int64_t received_bytes() const { return received_bytes_; } | 65 int64_t received_bytes() const { return received_bytes_; } |
62 bool has_final_name() const { return !full_path_.empty(); } | 66 bool has_final_name() const { return !full_path_.empty(); } |
63 bool success() const { return is_success_; } | 67 bool success() const { return is_success_; } |
64 SaveFileCreateInfo::SaveFileSource save_source() const { | 68 SaveFileCreateInfo::SaveFileSource save_source() const { |
65 return save_source_; | 69 return save_source_; |
66 } | 70 } |
67 | 71 |
68 private: | 72 private: |
69 // Internal helper for maintaining consistent received and total sizes. | 73 // Internal helper for maintaining consistent received and total sizes. |
70 void UpdateSize(int64_t size); | 74 void UpdateSize(int64_t size); |
71 | 75 |
72 // Unique identifier for this SaveItem instance. | 76 // Unique identifier for this SaveItem instance. |
73 const SaveItemId save_item_id_; | 77 const SaveItemId save_item_id_; |
74 | 78 |
75 // Full path to the save item file. | 79 // Full path to the save item file. |
76 base::FilePath full_path_; | 80 base::FilePath full_path_; |
77 | 81 |
78 // The URL for this save item. | 82 // The URL for this save item. |
79 GURL url_; | 83 GURL url_; |
80 Referrer referrer_; | 84 Referrer referrer_; |
81 | 85 |
82 // Frame tree node id, if this save item represents a frame | 86 // Frame tree node id, if this save item represents a frame |
83 // (otherwise FrameTreeNode::kFrameTreeNodeInvalidID). | 87 // (otherwise FrameTreeNode::kFrameTreeNodeInvalidId). |
84 int frame_tree_node_id_; | 88 int frame_tree_node_id_; |
85 | 89 |
| 90 // Frame tree node id of the frame containing this save item. |
| 91 // (FrameTreeNode::kFrameTreeNodeInvalidId if this save item represents the |
| 92 // main frame, which obviously doesn't have a containing/parent frame). |
| 93 int container_frame_tree_node_id_; |
| 94 |
86 // Total bytes expected. | 95 // Total bytes expected. |
87 int64_t total_bytes_; | 96 int64_t total_bytes_; |
88 | 97 |
89 // Current received bytes. | 98 // Current received bytes. |
90 int64_t received_bytes_; | 99 int64_t received_bytes_; |
91 | 100 |
92 // The current state of this save item. | 101 // The current state of this save item. |
93 SaveState state_; | 102 SaveState state_; |
94 | 103 |
95 // Flag indicates whether SaveItem has error while in saving process. | 104 // Flag indicates whether SaveItem has error while in saving process. |
96 bool is_success_; | 105 bool is_success_; |
97 | 106 |
98 SaveFileCreateInfo::SaveFileSource save_source_; | 107 SaveFileCreateInfo::SaveFileSource save_source_; |
99 | 108 |
100 // Our owning object. | 109 // Our owning object. |
101 SavePackage* package_; | 110 SavePackage* package_; |
102 | 111 |
103 DISALLOW_COPY_AND_ASSIGN(SaveItem); | 112 DISALLOW_COPY_AND_ASSIGN(SaveItem); |
104 }; | 113 }; |
105 | 114 |
106 } // namespace content | 115 } // namespace content |
107 | 116 |
108 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ | 117 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ |
OLD | NEW |