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/base_file.h" | 5 #include "content/browser/download/base_file.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 if (full_path_.empty()) { | 75 if (full_path_.empty()) { |
76 base::FilePath initial_directory(default_directory); | 76 base::FilePath initial_directory(default_directory); |
77 base::FilePath temp_file; | 77 base::FilePath temp_file; |
78 if (initial_directory.empty()) { | 78 if (initial_directory.empty()) { |
79 initial_directory = | 79 initial_directory = |
80 GetContentClient()->browser()->GetDefaultDownloadDirectory(); | 80 GetContentClient()->browser()->GetDefaultDownloadDirectory(); |
81 } | 81 } |
82 // |initial_directory| can still be empty if ContentBrowserClient returned | 82 // |initial_directory| can still be empty if ContentBrowserClient returned |
83 // an empty path for the downloads directory. | 83 // an empty path for the downloads directory. |
84 if ((initial_directory.empty() || | 84 if ((initial_directory.empty() || |
85 !file_util::CreateTemporaryFileInDir(initial_directory, &temp_file)) && | 85 !base::CreateTemporaryFileInDir(initial_directory, &temp_file)) && |
86 !file_util::CreateTemporaryFile(&temp_file)) { | 86 !base::CreateTemporaryFile(&temp_file)) { |
87 return LogInterruptReason("Unable to create", 0, | 87 return LogInterruptReason("Unable to create", 0, |
88 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); | 88 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); |
89 } | 89 } |
90 full_path_ = temp_file; | 90 full_path_ = temp_file; |
91 } | 91 } |
92 | 92 |
93 return Open(); | 93 return Open(); |
94 } | 94 } |
95 | 95 |
96 DownloadInterruptReason BaseFile::AppendDataToFile(const char* data, | 96 DownloadInterruptReason BaseFile::AppendDataToFile(const char* data, |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 const char* operation, | 362 const char* operation, |
363 int os_error, | 363 int os_error, |
364 DownloadInterruptReason reason) { | 364 DownloadInterruptReason reason) { |
365 bound_net_log_.AddEvent( | 365 bound_net_log_.AddEvent( |
366 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 366 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, |
367 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 367 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); |
368 return reason; | 368 return reason; |
369 } | 369 } |
370 | 370 |
371 } // namespace content | 371 } // namespace content |
OLD | NEW |