OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/download/download_file.h" | 5 #include "chrome/browser/download/download_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 bytes_so_far_(0), | 66 bytes_so_far_(0), |
67 path_renamed_(false), | 67 path_renamed_(false), |
68 in_progress_(true) { | 68 in_progress_(true) { |
69 } | 69 } |
70 | 70 |
71 DownloadFile::~DownloadFile() { | 71 DownloadFile::~DownloadFile() { |
72 Close(); | 72 Close(); |
73 } | 73 } |
74 | 74 |
75 bool DownloadFile::Initialize() { | 75 bool DownloadFile::Initialize() { |
76 if (file_util::CreateTemporaryFileName(&full_path_)) | 76 if (file_util::CreateTemporaryFile(&full_path_)) |
77 return Open("wb"); | 77 return Open("wb"); |
78 return false; | 78 return false; |
79 } | 79 } |
80 | 80 |
81 bool DownloadFile::AppendDataToFile(const char* data, int data_len) { | 81 bool DownloadFile::AppendDataToFile(const char* data, int data_len) { |
82 if (file_) { | 82 if (file_) { |
83 // FIXME bug 595247: handle errors on file writes. | 83 // FIXME bug 595247: handle errors on file writes. |
84 size_t written = fwrite(data, 1, data_len, file_); | 84 size_t written = fwrite(data, 1, data_len, file_); |
85 bytes_so_far_ += written; | 85 bytes_so_far_ += written; |
86 return true; | 86 return true; |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 598 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
599 this, &DownloadFileManager::StopUpdateTimer)); | 599 this, &DownloadFileManager::StopUpdateTimer)); |
600 } | 600 } |
601 | 601 |
602 // static | 602 // static |
603 void DownloadFileManager::DeleteFile(const FilePath& path) { | 603 void DownloadFileManager::DeleteFile(const FilePath& path) { |
604 // Make sure we only delete files. | 604 // Make sure we only delete files. |
605 if (!file_util::DirectoryExists(path)) | 605 if (!file_util::DirectoryExists(path)) |
606 file_util::Delete(path, false); | 606 file_util::Delete(path, false); |
607 } | 607 } |
OLD | NEW |