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 #include "content/browser/download/save_file.h" | 5 #include "content/browser/download/save_file.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "net/base/file_stream.h" | 9 #include "net/base/file_stream.h" |
10 | 10 |
11 using content::BrowserThread; | 11 using content::BrowserThread; |
12 | 12 |
13 SaveFile::SaveFile(const SaveFileCreateInfo* info) | 13 SaveFile::SaveFile(const SaveFileCreateInfo* info) |
14 : BaseFile(FilePath(), info->url, GURL(), 0, linked_ptr<net::FileStream>()), | 14 : file_(FilePath(), info->url, GURL(), 0, linked_ptr<net::FileStream>()), |
15 info_(info) { | 15 info_(info) { |
16 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 16 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
17 | 17 |
18 DCHECK(info); | 18 DCHECK(info); |
19 DCHECK(info->path.empty()); | 19 DCHECK(info->path.empty()); |
20 } | 20 } |
21 | 21 |
22 SaveFile::~SaveFile() { | 22 SaveFile::~SaveFile() { |
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
24 } | 24 } |
| 25 |
| 26 net::Error SaveFile::Initialize(bool calculate_hash) { |
| 27 return file_.Initialize(calculate_hash); |
| 28 } |
| 29 |
| 30 net::Error SaveFile::AppendDataToFile(const char* data, size_t data_len) { |
| 31 return file_.AppendDataToFile(data, data_len); |
| 32 } |
| 33 |
| 34 net::Error SaveFile::Rename(const FilePath& full_path) { |
| 35 return file_.Rename(full_path); |
| 36 } |
| 37 |
| 38 void SaveFile::Detach() { |
| 39 file_.Detach(); |
| 40 } |
| 41 |
| 42 void SaveFile::Cancel() { |
| 43 file_.Cancel(); |
| 44 } |
| 45 |
| 46 void SaveFile::Finish() { |
| 47 file_.Finish(); |
| 48 } |
| 49 |
| 50 void SaveFile::AnnotateWithSourceInformation() { |
| 51 file_.AnnotateWithSourceInformation(); |
| 52 } |
| 53 |
| 54 FilePath SaveFile::FullPath() const { |
| 55 return file_.full_path(); |
| 56 } |
| 57 |
| 58 bool SaveFile::InProgress() const { |
| 59 return file_.in_progress(); |
| 60 } |
| 61 |
| 62 int64 SaveFile::BytesSoFar() const { |
| 63 return file_.bytes_so_far(); |
| 64 } |
| 65 |
| 66 bool SaveFile::GetSha256Hash(std::string* hash) { |
| 67 return file_.GetSha256Hash(hash); |
| 68 } |
| 69 |
| 70 std::string SaveFile::DebugString() const { |
| 71 return file_.DebugString(); |
| 72 } |
OLD | NEW |