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