| 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_FILE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/browser/download/base_file.h" | 11 #include "content/browser/download/base_file.h" |
| 12 #include "content/browser/download/save_types.h" | 12 #include "content/browser/download/save_types.h" |
| 13 | 13 |
| 14 // SaveFile ---------------------------------------------------------------- | 14 // SaveFile ---------------------------------------------------------------- |
| 15 | 15 |
| 16 // These objects live exclusively on the file thread and handle the writing | 16 // These objects live exclusively on the file thread and handle the writing |
| 17 // operations for one save item. These objects live only for the duration that | 17 // operations for one save item. These objects live only for the duration that |
| 18 // the saving job is 'in progress': once the saving job has been completed or | 18 // the saving job is 'in progress': once the saving job has been completed or |
| 19 // canceled, the SaveFile is destroyed. One SaveFile object represents one item | 19 // canceled, the SaveFile is destroyed. One SaveFile object represents one item |
| 20 // in a save session. | 20 // in a save session. |
| 21 class SaveFile { | 21 class SaveFile { |
| 22 public: | 22 public: |
| 23 explicit SaveFile(const SaveFileCreateInfo* info, bool calculate_hash); | 23 explicit SaveFile(const SaveFileCreateInfo* info, bool calculate_hash); |
| 24 virtual ~SaveFile(); | 24 virtual ~SaveFile(); |
| 25 | 25 |
| 26 // BaseFile delegated functions. | 26 // BaseFile delegated functions. |
| 27 net::Error Initialize(); | 27 content::DownloadInterruptReason Initialize(); |
| 28 net::Error AppendDataToFile(const char* data, size_t data_len); | 28 content::DownloadInterruptReason AppendDataToFile(const char* data, |
| 29 net::Error Rename(const FilePath& full_path); | 29 size_t data_len); |
| 30 content::DownloadInterruptReason Rename(const FilePath& full_path); |
| 30 void Detach(); | 31 void Detach(); |
| 31 void Cancel(); | 32 void Cancel(); |
| 32 void Finish(); | 33 void Finish(); |
| 33 void AnnotateWithSourceInformation(); | 34 void AnnotateWithSourceInformation(); |
| 34 FilePath FullPath() const; | 35 FilePath FullPath() const; |
| 35 bool InProgress() const; | 36 bool InProgress() const; |
| 36 int64 BytesSoFar() const; | 37 int64 BytesSoFar() const; |
| 37 bool GetHash(std::string* hash); | 38 bool GetHash(std::string* hash); |
| 38 std::string DebugString() const; | 39 std::string DebugString() const; |
| 39 | 40 |
| 40 // Accessors. | 41 // Accessors. |
| 41 int save_id() const { return info_->save_id; } | 42 int save_id() const { return info_->save_id; } |
| 42 int render_process_id() const { return info_->render_process_id; } | 43 int render_process_id() const { return info_->render_process_id; } |
| 43 int render_view_id() const { return info_->render_view_id; } | 44 int render_view_id() const { return info_->render_view_id; } |
| 44 int request_id() const { return info_->request_id; } | 45 int request_id() const { return info_->request_id; } |
| 45 SaveFileCreateInfo::SaveFileSource save_source() const { | 46 SaveFileCreateInfo::SaveFileSource save_source() const { |
| 46 return info_->save_source; | 47 return info_->save_source; |
| 47 } | 48 } |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 BaseFile file_; | 51 BaseFile file_; |
| 51 scoped_ptr<const SaveFileCreateInfo> info_; | 52 scoped_ptr<const SaveFileCreateInfo> info_; |
| 52 | 53 |
| 53 DISALLOW_COPY_AND_ASSIGN(SaveFile); | 54 DISALLOW_COPY_AND_ASSIGN(SaveFile); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ | 57 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ |
| OLD | NEW |