| 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 #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 // TODO(asanka): SaveFile should use the target directory of the save package as |
| 14 // the default download directory when initializing |file_|. |
| 15 // Unfortunately, as it is, constructors of SaveFile don't always |
| 16 // have access to the SavePackage at this point. |
| 13 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) | 17 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) |
| 14 : file_(FilePath(), | 18 : file_(FilePath(), |
| 15 info->url, | 19 info->url, |
| 16 GURL(), | 20 GURL(), |
| 17 0, | 21 0, |
| 18 calculate_hash, | 22 calculate_hash, |
| 19 "", | 23 "", |
| 20 linked_ptr<net::FileStream>(), | 24 linked_ptr<net::FileStream>(), |
| 21 net::BoundNetLog()), | 25 net::BoundNetLog()), |
| 22 info_(info) { | 26 info_(info) { |
| 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 24 | 28 |
| 25 DCHECK(info); | 29 DCHECK(info); |
| 26 DCHECK(info->path.empty()); | 30 DCHECK(info->path.empty()); |
| 27 } | 31 } |
| 28 | 32 |
| 29 SaveFile::~SaveFile() { | 33 SaveFile::~SaveFile() { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 31 } | 35 } |
| 32 | 36 |
| 33 net::Error SaveFile::Initialize() { | 37 net::Error SaveFile::Initialize() { |
| 34 return file_.Initialize(); | 38 return file_.Initialize(FilePath()); |
| 35 } | 39 } |
| 36 | 40 |
| 37 net::Error SaveFile::AppendDataToFile(const char* data, size_t data_len) { | 41 net::Error SaveFile::AppendDataToFile(const char* data, size_t data_len) { |
| 38 return file_.AppendDataToFile(data, data_len); | 42 return file_.AppendDataToFile(data, data_len); |
| 39 } | 43 } |
| 40 | 44 |
| 41 net::Error SaveFile::Rename(const FilePath& full_path) { | 45 net::Error SaveFile::Rename(const FilePath& full_path) { |
| 42 return file_.Rename(full_path); | 46 return file_.Rename(full_path); |
| 43 } | 47 } |
| 44 | 48 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 return file_.bytes_so_far(); | 74 return file_.bytes_so_far(); |
| 71 } | 75 } |
| 72 | 76 |
| 73 bool SaveFile::GetHash(std::string* hash) { | 77 bool SaveFile::GetHash(std::string* hash) { |
| 74 return file_.GetHash(hash); | 78 return file_.GetHash(hash); |
| 75 } | 79 } |
| 76 | 80 |
| 77 std::string SaveFile::DebugString() const { | 81 std::string SaveFile::DebugString() const { |
| 78 return file_.DebugString(); | 82 return file_.DebugString(); |
| 79 } | 83 } |
| OLD | NEW |