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 namespace content { | 11 namespace content { |
12 | 12 |
13 // TODO(asanka): SaveFile should use the target directory of the save package as | 13 // TODO(asanka): SaveFile should use the target directory of the save package as |
14 // the default download directory when initializing |file_|. | 14 // the default download directory when initializing |file_|. |
15 // Unfortunately, as it is, constructors of SaveFile don't always | 15 // Unfortunately, as it is, constructors of SaveFile don't always |
16 // have access to the SavePackage at this point. | 16 // have access to the SavePackage at this point. |
17 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) | 17 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) |
18 : file_(FilePath(), | 18 : file_(base::FilePath(), |
19 info->url, | 19 info->url, |
20 GURL(), | 20 GURL(), |
21 0, | 21 0, |
22 calculate_hash, | 22 calculate_hash, |
23 "", | 23 "", |
24 scoped_ptr<net::FileStream>(), | 24 scoped_ptr<net::FileStream>(), |
25 net::BoundNetLog()), | 25 net::BoundNetLog()), |
26 info_(info) { | 26 info_(info) { |
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
28 | 28 |
29 DCHECK(info); | 29 DCHECK(info); |
30 DCHECK(info->path.empty()); | 30 DCHECK(info->path.empty()); |
31 } | 31 } |
32 | 32 |
33 SaveFile::~SaveFile() { | 33 SaveFile::~SaveFile() { |
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
35 } | 35 } |
36 | 36 |
37 DownloadInterruptReason SaveFile::Initialize() { | 37 DownloadInterruptReason SaveFile::Initialize() { |
38 return file_.Initialize(FilePath()); | 38 return file_.Initialize(base::FilePath()); |
39 } | 39 } |
40 | 40 |
41 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, | 41 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, |
42 size_t data_len) { | 42 size_t data_len) { |
43 return file_.AppendDataToFile(data, data_len); | 43 return file_.AppendDataToFile(data, data_len); |
44 } | 44 } |
45 | 45 |
46 DownloadInterruptReason SaveFile::Rename(const FilePath& full_path) { | 46 DownloadInterruptReason SaveFile::Rename(const base::FilePath& full_path) { |
47 return file_.Rename(full_path); | 47 return file_.Rename(full_path); |
48 } | 48 } |
49 | 49 |
50 void SaveFile::Detach() { | 50 void SaveFile::Detach() { |
51 file_.Detach(); | 51 file_.Detach(); |
52 } | 52 } |
53 | 53 |
54 void SaveFile::Cancel() { | 54 void SaveFile::Cancel() { |
55 file_.Cancel(); | 55 file_.Cancel(); |
56 } | 56 } |
57 | 57 |
58 void SaveFile::Finish() { | 58 void SaveFile::Finish() { |
59 file_.Finish(); | 59 file_.Finish(); |
60 } | 60 } |
61 | 61 |
62 void SaveFile::AnnotateWithSourceInformation() { | 62 void SaveFile::AnnotateWithSourceInformation() { |
63 file_.AnnotateWithSourceInformation(); | 63 file_.AnnotateWithSourceInformation(); |
64 } | 64 } |
65 | 65 |
66 FilePath SaveFile::FullPath() const { | 66 base::FilePath SaveFile::FullPath() const { |
67 return file_.full_path(); | 67 return file_.full_path(); |
68 } | 68 } |
69 | 69 |
70 bool SaveFile::InProgress() const { | 70 bool SaveFile::InProgress() const { |
71 return file_.in_progress(); | 71 return file_.in_progress(); |
72 } | 72 } |
73 | 73 |
74 int64 SaveFile::BytesSoFar() const { | 74 int64 SaveFile::BytesSoFar() const { |
75 return file_.bytes_so_far(); | 75 return file_.bytes_so_far(); |
76 } | 76 } |
77 | 77 |
78 bool SaveFile::GetHash(std::string* hash) { | 78 bool SaveFile::GetHash(std::string* hash) { |
79 return file_.GetHash(hash); | 79 return file_.GetHash(hash); |
80 } | 80 } |
81 | 81 |
82 std::string SaveFile::DebugString() const { | 82 std::string SaveFile::DebugString() const { |
83 return file_.DebugString(); | 83 return file_.DebugString(); |
84 } | 84 } |
85 | 85 |
86 } // namespace content | 86 } // namespace content |
OLD | NEW |