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/save_file.h" | 5 #include "chrome/browser/download/save_file.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/browser/download/save_types.h" | 12 #include "chrome/browser/download/save_types.h" |
13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
14 #include "chrome/common/win_safe_util.h" | 14 #include "chrome/common/win_safe_util.h" |
15 #endif | 15 #endif |
16 | 16 |
17 SaveFile::SaveFile(const SaveFileCreateInfo* info) | 17 SaveFile::SaveFile(const SaveFileCreateInfo* info) |
18 : info_(info), | 18 : info_(info), |
19 file_(NULL), | 19 file_(NULL), |
20 bytes_so_far_(0), | 20 bytes_so_far_(0), |
21 path_renamed_(false), | 21 path_renamed_(false), |
22 in_progress_(true) { | 22 in_progress_(true) { |
23 DCHECK(info); | 23 DCHECK(info); |
24 DCHECK(info->path.empty()); | 24 DCHECK(info->path.empty()); |
25 if (file_util::CreateTemporaryFileName(&full_path_)) | 25 if (file_util::CreateTemporaryFile(&full_path_)) |
26 Open("wb"); | 26 Open("wb"); |
27 } | 27 } |
28 | 28 |
29 SaveFile::~SaveFile() { | 29 SaveFile::~SaveFile() { |
30 Close(); | 30 Close(); |
31 } | 31 } |
32 | 32 |
33 // Return false indicate that we got disk error, save file manager will tell | 33 // Return false indicate that we got disk error, save file manager will tell |
34 // SavePackage this error, then SavePackage will call its Cancel() method to | 34 // SavePackage this error, then SavePackage will call its Cancel() method to |
35 // cancel whole save job. | 35 // cancel whole save job. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return false; | 97 return false; |
98 } | 98 } |
99 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
100 // Sets the zone to tell Windows that this file comes from the Internet. | 100 // Sets the zone to tell Windows that this file comes from the Internet. |
101 // We ignore the return value because a failure is not fatal. | 101 // We ignore the return value because a failure is not fatal. |
102 // TODO(port): Similarly mark on Mac. | 102 // TODO(port): Similarly mark on Mac. |
103 win_util::SetInternetZoneIdentifier(full_path_); | 103 win_util::SetInternetZoneIdentifier(full_path_); |
104 #endif | 104 #endif |
105 return true; | 105 return true; |
106 } | 106 } |
OLD | NEW |