Add ICU message format support
[chromium-blink-merge.git] / content / browser / download / save_file.cc
bloba5c7488242f317dd77953ff5565378fed33806d2
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
3 // found in the LICENSE file.
5 #include "content/browser/download/save_file.h"
7 #include "base/logging.h"
8 #include "content/public/browser/browser_thread.h"
10 namespace content {
12 // TODO(asanka): SaveFile should use the target directory of the save package as
13 // the default download directory when initializing |file_|.
14 // Unfortunately, as it is, constructors of SaveFile don't always
15 // have access to the SavePackage at this point.
16 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash)
17 : file_(base::FilePath(),
18 info->url,
19 GURL(),
21 calculate_hash,
22 std::string(),
23 base::File(),
24 net::BoundNetLog()),
25 info_(info) {
26 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
28 DCHECK(info);
29 DCHECK(info->path.empty());
32 SaveFile::~SaveFile() {
33 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
36 DownloadInterruptReason SaveFile::Initialize() {
37 return file_.Initialize(base::FilePath());
40 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data,
41 size_t data_len) {
42 return file_.AppendDataToFile(data, data_len);
45 DownloadInterruptReason SaveFile::Rename(const base::FilePath& full_path) {
46 return file_.Rename(full_path);
49 void SaveFile::Detach() {
50 file_.Detach();
53 void SaveFile::Cancel() {
54 file_.Cancel();
57 void SaveFile::Finish() {
58 file_.Finish();
61 void SaveFile::AnnotateWithSourceInformation() {
62 // TODO(gbillock): If this method is called, it should set the
63 // file_.SetClientGuid() method first.
64 file_.AnnotateWithSourceInformation();
67 base::FilePath SaveFile::FullPath() const {
68 return file_.full_path();
71 bool SaveFile::InProgress() const {
72 return file_.in_progress();
75 int64 SaveFile::BytesSoFar() const {
76 return file_.bytes_so_far();
79 bool SaveFile::GetHash(std::string* hash) {
80 return file_.GetHash(hash);
83 std::string SaveFile::DebugString() const {
84 return file_.DebugString();
87 } // namespace content