diff options
Diffstat (limited to 'chromium/content/browser/download/drag_download_util.cc')
-rw-r--r-- | chromium/content/browser/download/drag_download_util.cc | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/chromium/content/browser/download/drag_download_util.cc b/chromium/content/browser/download/drag_download_util.cc index 0850c3ba081..f259af22c6c 100644 --- a/chromium/content/browser/download/drag_download_util.cc +++ b/chromium/content/browser/download/drag_download_util.cc @@ -7,7 +7,7 @@ #include <string> #include "base/bind.h" -#include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" @@ -15,19 +15,15 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_restrictions.h" #include "content/public/browser/browser_thread.h" -#include "net/base/file_stream.h" -#include "net/base/net_errors.h" #include "url/gurl.h" -using net::FileStream; - namespace content { bool ParseDownloadMetadata(const base::string16& metadata, base::string16* mime_type, base::FilePath* file_name, GURL* url) { - const char16 separator = L':'; + const base::char16 separator = L':'; size_t mime_type_end_pos = metadata.find(separator); if (mime_type_end_pos == base::string16::npos) @@ -49,7 +45,7 @@ bool ParseDownloadMetadata(const base::string16& metadata, #if defined(OS_WIN) *file_name = base::FilePath(file_name_str); #else - *file_name = base::FilePath(UTF16ToUTF8(file_name_str)); + *file_name = base::FilePath(base::UTF16ToUTF8(file_name_str)); #endif } if (url) @@ -58,11 +54,9 @@ bool ParseDownloadMetadata(const base::string16& metadata, return true; } -FileStream* CreateFileStreamForDrop(base::FilePath* file_path, - net::NetLog* net_log) { +base::File CreateFileForDrop(base::FilePath* file_path) { DCHECK(file_path && !file_path->empty()); - scoped_ptr<FileStream> file_stream(new FileStream(net_log)); const int kMaxSeq = 99; for (int seq = 0; seq <= kMaxSeq; seq++) { base::FilePath new_file_path; @@ -70,7 +64,8 @@ FileStream* CreateFileStreamForDrop(base::FilePath* file_path, new_file_path = *file_path; } else { #if defined(OS_WIN) - base::string16 suffix = ASCIIToUTF16("-") + base::IntToString16(seq); + base::string16 suffix = + base::ASCIIToUTF16("-") + base::IntToString16(seq); #else std::string suffix = std::string("-") + base::IntToString(seq); #endif @@ -80,17 +75,15 @@ FileStream* CreateFileStreamForDrop(base::FilePath* file_path, // http://crbug.com/110709 base::ThreadRestrictions::ScopedAllowIO allow_io; - // Explicitly (and redundantly check) for file -- despite the fact that our - // open won't overwrite -- just to avoid log spew. - if (!base::PathExists(new_file_path) && - file_stream->OpenSync(new_file_path, base::PLATFORM_FILE_CREATE | - base::PLATFORM_FILE_WRITE) == net::OK) { + base::File file( + new_file_path, base::File::FLAG_CREATE | base::File::FLAG_WRITE); + if (file.IsValid()) { *file_path = new_file_path; - return file_stream.release(); + return file.Pass(); } } - return NULL; + return base::File(); } PromiseFileFinalizer::PromiseFileFinalizer( |