| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "content/browser/download/save_types.h" | 10 #include "content/browser/download/save_types.h" |
| 11 #include "content/public/common/referrer.h" | 11 #include "content/public/common/referrer.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class SavePackage; | 15 class SavePackage; |
| 16 | 16 |
| 17 // One SaveItem per save file. This is the model class that stores all the | 17 // One SaveItem per save file. This is the model class that stores all the |
| 18 // state for one save file. | 18 // state for one save file. |
| 19 class SaveItem { | 19 class SaveItem { |
| 20 public: | 20 public: |
| 21 enum SaveState { | 21 enum SaveState { |
| 22 WAIT_START, | 22 WAIT_START, |
| 23 IN_PROGRESS, | 23 IN_PROGRESS, |
| 24 COMPLETE, | 24 COMPLETE, |
| 25 CANCELED | 25 CANCELED |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 SaveItem(const GURL& url, | 28 SaveItem(const GURL& url, |
| 29 const Referrer& referrer, | |
| 30 SavePackage* package, | 29 SavePackage* package, |
| 31 SaveFileCreateInfo::SaveFileSource save_source); | 30 SaveFileCreateInfo::SaveFileSource save_source); |
| 32 | 31 |
| 33 ~SaveItem(); | 32 ~SaveItem(); |
| 34 | 33 |
| 35 void Start(); | 34 void Start(); |
| 36 | 35 |
| 37 // Received a new chunk of data. | 36 // Received a new chunk of data. |
| 38 void Update(int64 bytes_so_far); | 37 void Update(int64 bytes_so_far); |
| 39 | 38 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 int64 total_bytes() const { return total_bytes_; } | 62 int64 total_bytes() const { return total_bytes_; } |
| 64 int64 received_bytes() const { return received_bytes_; } | 63 int64 received_bytes() const { return received_bytes_; } |
| 65 int32 save_id() const { return save_id_; } | 64 int32 save_id() const { return save_id_; } |
| 66 bool has_final_name() const { return has_final_name_; } | 65 bool has_final_name() const { return has_final_name_; } |
| 67 bool success() const { return is_success_; } | 66 bool success() const { return is_success_; } |
| 68 SaveFileCreateInfo::SaveFileSource save_source() const { | 67 SaveFileCreateInfo::SaveFileSource save_source() const { |
| 69 return save_source_; | 68 return save_source_; |
| 70 } | 69 } |
| 71 SavePackage* package() const { return package_; } | 70 SavePackage* package() const { return package_; } |
| 72 | 71 |
| 72 // Setters. |
| 73 void set_referrer(const Referrer& referrer) { referrer_ = referrer; } |
| 74 |
| 73 private: | 75 private: |
| 74 // Internal helper for maintaining consistent received and total sizes. | 76 // Internal helper for maintaining consistent received and total sizes. |
| 75 void UpdateSize(int64 size); | 77 void UpdateSize(int64 size); |
| 76 | 78 |
| 77 // Request ID assigned by the ResourceDispatcherHost. | 79 // Request ID assigned by the ResourceDispatcherHost. |
| 78 int32 save_id_; | 80 int32 save_id_; |
| 79 | 81 |
| 80 // Full path to the save item file. | 82 // Full path to the save item file. |
| 81 base::FilePath full_path_; | 83 base::FilePath full_path_; |
| 82 | 84 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 | 108 |
| 107 // Our owning object. | 109 // Our owning object. |
| 108 SavePackage* package_; | 110 SavePackage* package_; |
| 109 | 111 |
| 110 DISALLOW_COPY_AND_ASSIGN(SaveItem); | 112 DISALLOW_COPY_AND_ASSIGN(SaveItem); |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 } // namespace content | 115 } // namespace content |
| 114 | 116 |
| 115 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ | 117 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_ITEM_H_ |
| OLD | NEW |