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 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 // TODO(asanka): SaveFile should use the target directory of the save package as | 12 // TODO(asanka): SaveFile should use the target directory of the save package as |
13 // the default download directory when initializing |file_|. | 13 // the default download directory when initializing |file_|. |
14 // Unfortunately, as it is, constructors of SaveFile don't always | 14 // Unfortunately, as it is, constructors of SaveFile don't always |
15 // have access to the SavePackage at this point. | 15 // have access to the SavePackage at this point. |
16 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) | 16 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) |
17 : file_(base::FilePath(), | 17 : file_(base::FilePath(), |
18 info->url, | 18 info->url, |
19 GURL(), | 19 GURL(), |
20 0, | 20 0, |
21 calculate_hash, | 21 calculate_hash, |
22 std::string(), | 22 std::string(), |
23 base::File(), | 23 base::File(), |
24 net::BoundNetLog()), | 24 net::BoundNetLog()), |
25 info_(info) { | 25 info_(info) { |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 26 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
27 | 27 |
28 DCHECK(info); | 28 DCHECK(info); |
29 DCHECK(info->path.empty()); | 29 DCHECK(info->path.empty()); |
30 } | 30 } |
31 | 31 |
32 SaveFile::~SaveFile() { | 32 SaveFile::~SaveFile() { |
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 33 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
34 } | 34 } |
35 | 35 |
36 DownloadInterruptReason SaveFile::Initialize() { | 36 DownloadInterruptReason SaveFile::Initialize() { |
37 return file_.Initialize(base::FilePath()); | 37 return file_.Initialize(base::FilePath()); |
38 } | 38 } |
39 | 39 |
40 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, | 40 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, |
41 size_t data_len) { | 41 size_t data_len) { |
42 return file_.AppendDataToFile(data, data_len); | 42 return file_.AppendDataToFile(data, data_len); |
43 } | 43 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 bool SaveFile::GetHash(std::string* hash) { | 79 bool SaveFile::GetHash(std::string* hash) { |
80 return file_.GetHash(hash); | 80 return file_.GetHash(hash); |
81 } | 81 } |
82 | 82 |
83 std::string SaveFile::DebugString() const { | 83 std::string SaveFile::DebugString() const { |
84 return file_.DebugString(); | 84 return file_.DebugString(); |
85 } | 85 } |
86 | 86 |
87 } // namespace content | 87 } // namespace content |
OLD | NEW |