OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/download/base_file.h" | 12 #include "content/browser/download/base_file.h" |
13 #include "content/browser/download/save_types.h" | 13 #include "content/browser/download/save_types.h" |
14 | 14 |
15 // SaveFile ---------------------------------------------------------------- | 15 // SaveFile ---------------------------------------------------------------- |
16 | 16 |
17 // These objects live exclusively on the file thread and handle the writing | 17 // 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 | 18 // 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 | 19 // 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 | 20 // canceled, the SaveFile is destroyed. One SaveFile object represents one item |
21 // in a save session. | 21 // in a save session. |
22 class SaveFile : public BaseFile { | 22 class SaveFile { |
23 public: | 23 public: |
24 explicit SaveFile(const SaveFileCreateInfo* info); | 24 explicit SaveFile(const SaveFileCreateInfo* info); |
25 virtual ~SaveFile(); | 25 virtual ~SaveFile(); |
26 | 26 |
27 // BaseFile delegated functions. | |
Randy Smith (Not in Mondays)
2011/11/10 21:58:43
nit: As I understand chrome custom (and I think th
ahendrickson
2011/11/13 00:50:21
Done.
| |
28 net::Error Initialize(bool calculate_hash) { | |
29 return file_.Initialize(calculate_hash); | |
30 } | |
31 net::Error AppendDataToFile(const char* data, size_t data_len) { | |
32 return file_.AppendDataToFile(data, data_len); | |
33 } | |
34 net::Error Rename(const FilePath& full_path) { | |
35 return file_.Rename(full_path); | |
36 } | |
37 void Detach() { file_.Detach(); } | |
38 void Cancel() { file_.Cancel(); } | |
39 void Finish() { file_.Finish(); } | |
40 void AnnotateWithSourceInformation() { | |
41 file_.AnnotateWithSourceInformation(); | |
42 } | |
43 FilePath full_path() const { return file_.full_path(); } | |
44 bool in_progress() const { return file_.in_progress(); } | |
45 int64 bytes_so_far() const { return file_.bytes_so_far(); } | |
46 bool GetSha256Hash(std::string* hash) { | |
47 return file_.GetSha256Hash(hash); | |
48 } | |
49 std::string DebugString() const { return file_.DebugString(); } | |
50 | |
27 // Accessors. | 51 // Accessors. |
28 int save_id() const { return info_->save_id; } | 52 int save_id() const { return info_->save_id; } |
29 int render_process_id() const { return info_->render_process_id; } | 53 int render_process_id() const { return info_->render_process_id; } |
30 int render_view_id() const { return info_->render_view_id; } | 54 int render_view_id() const { return info_->render_view_id; } |
31 int request_id() const { return info_->request_id; } | 55 int request_id() const { return info_->request_id; } |
32 SaveFileCreateInfo::SaveFileSource save_source() const { | 56 SaveFileCreateInfo::SaveFileSource save_source() const { |
33 return info_->save_source; | 57 return info_->save_source; |
34 } | 58 } |
35 | 59 |
36 private: | 60 private: |
61 BaseFile file_; | |
37 scoped_ptr<const SaveFileCreateInfo> info_; | 62 scoped_ptr<const SaveFileCreateInfo> info_; |
38 | 63 |
39 DISALLOW_COPY_AND_ASSIGN(SaveFile); | 64 DISALLOW_COPY_AND_ASSIGN(SaveFile); |
40 }; | 65 }; |
41 | 66 |
42 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ | 67 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_H_ |
OLD | NEW |