| 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, bool calculate_hash) |
| 14 : file_(FilePath(), info->url, GURL(), 0, linked_ptr<net::FileStream>()), | 14 : file_(FilePath(), |
| 15 info->url, |
| 16 GURL(), |
| 17 0, |
| 18 calculate_hash, |
| 19 "", |
| 20 linked_ptr<net::FileStream>()), |
| 15 info_(info) { | 21 info_(info) { |
| 16 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 17 | 23 |
| 18 DCHECK(info); | 24 DCHECK(info); |
| 19 DCHECK(info->path.empty()); | 25 DCHECK(info->path.empty()); |
| 20 } | 26 } |
| 21 | 27 |
| 22 SaveFile::~SaveFile() { | 28 SaveFile::~SaveFile() { |
| 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 24 } | 30 } |
| 25 | 31 |
| 26 net::Error SaveFile::Initialize(bool calculate_hash) { | 32 net::Error SaveFile::Initialize() { |
| 27 return file_.Initialize(calculate_hash); | 33 return file_.Initialize(); |
| 28 } | 34 } |
| 29 | 35 |
| 30 net::Error SaveFile::AppendDataToFile(const char* data, size_t data_len) { | 36 net::Error SaveFile::AppendDataToFile(const char* data, size_t data_len) { |
| 31 return file_.AppendDataToFile(data, data_len); | 37 return file_.AppendDataToFile(data, data_len); |
| 32 } | 38 } |
| 33 | 39 |
| 34 net::Error SaveFile::Rename(const FilePath& full_path) { | 40 net::Error SaveFile::Rename(const FilePath& full_path) { |
| 35 return file_.Rename(full_path); | 41 return file_.Rename(full_path); |
| 36 } | 42 } |
| 37 | 43 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 } | 62 } |
| 57 | 63 |
| 58 bool SaveFile::InProgress() const { | 64 bool SaveFile::InProgress() const { |
| 59 return file_.in_progress(); | 65 return file_.in_progress(); |
| 60 } | 66 } |
| 61 | 67 |
| 62 int64 SaveFile::BytesSoFar() const { | 68 int64 SaveFile::BytesSoFar() const { |
| 63 return file_.bytes_so_far(); | 69 return file_.bytes_so_far(); |
| 64 } | 70 } |
| 65 | 71 |
| 66 bool SaveFile::GetSha256Hash(std::string* hash) { | 72 bool SaveFile::GetHash(std::string* hash) { |
| 67 return file_.GetSha256Hash(hash); | 73 return file_.GetHash(hash); |
| 68 } | 74 } |
| 69 | 75 |
| 70 std::string SaveFile::DebugString() const { | 76 std::string SaveFile::DebugString() const { |
| 71 return file_.DebugString(); | 77 return file_.DebugString(); |
| 72 } | 78 } |
| OLD | NEW |