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/browser/download/download_task_runner.h" |
8 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
9 #include "net/log/net_log_with_source.h" | 10 #include "net/log/net_log_with_source.h" |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 // TODO(asanka): SaveFile should use the target directory of the save package as | 14 // TODO(asanka): SaveFile should use the target directory of the save package as |
14 // the default download directory when initializing |file_|. | 15 // the default download directory when initializing |file_|. |
15 // Unfortunately, as it is, constructors of SaveFile don't always | 16 // Unfortunately, as it is, constructors of SaveFile don't always |
16 // have access to the SavePackage at this point. | 17 // have access to the SavePackage at this point. |
17 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) | 18 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) |
18 : file_(net::NetLogWithSource()), info_(info) { | 19 : file_(net::NetLogWithSource()), info_(info) { |
19 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 20 DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence()); |
20 | 21 |
21 DCHECK(info); | 22 DCHECK(info); |
22 DCHECK(info->path.empty()); | 23 DCHECK(info->path.empty()); |
23 } | 24 } |
24 | 25 |
25 SaveFile::~SaveFile() { | 26 SaveFile::~SaveFile() { |
26 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 27 DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence()); |
27 } | 28 } |
28 | 29 |
29 DownloadInterruptReason SaveFile::Initialize() { | 30 DownloadInterruptReason SaveFile::Initialize() { |
30 return file_.Initialize(base::FilePath(), base::FilePath(), base::File(), 0, | 31 return file_.Initialize(base::FilePath(), base::FilePath(), base::File(), 0, |
31 std::string(), std::unique_ptr<crypto::SecureHash>(), | 32 std::string(), std::unique_ptr<crypto::SecureHash>(), |
32 false); | 33 false); |
33 } | 34 } |
34 | 35 |
35 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, | 36 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, |
36 size_t data_len) { | 37 size_t data_len) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 70 |
70 int64_t SaveFile::BytesSoFar() const { | 71 int64_t SaveFile::BytesSoFar() const { |
71 return file_.bytes_so_far(); | 72 return file_.bytes_so_far(); |
72 } | 73 } |
73 | 74 |
74 std::string SaveFile::DebugString() const { | 75 std::string SaveFile::DebugString() const { |
75 return file_.DebugString(); | 76 return file_.DebugString(); |
76 } | 77 } |
77 | 78 |
78 } // namespace content | 79 } // namespace content |
OLD | NEW |