OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/drag_download_util.h" | 5 #include "chrome/browser/download/drag_download_util.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "base/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 #include "net/base/file_stream.h" | 16 #include "net/base/file_stream.h" |
16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
17 | 18 |
18 using net::FileStream; | 19 using net::FileStream; |
19 | 20 |
20 namespace drag_download_util { | 21 namespace drag_download_util { |
21 | 22 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 DCHECK(file_path && !file_path->empty()); | 59 DCHECK(file_path && !file_path->empty()); |
59 | 60 |
60 scoped_ptr<FileStream> file_stream(new FileStream); | 61 scoped_ptr<FileStream> file_stream(new FileStream); |
61 const int kMaxSeq = 99; | 62 const int kMaxSeq = 99; |
62 for (int seq = 0; seq <= kMaxSeq; seq++) { | 63 for (int seq = 0; seq <= kMaxSeq; seq++) { |
63 FilePath new_file_path; | 64 FilePath new_file_path; |
64 if (seq == 0) { | 65 if (seq == 0) { |
65 new_file_path = *file_path; | 66 new_file_path = *file_path; |
66 } else { | 67 } else { |
67 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
68 std::wstring suffix = std::wstring(L"-") + IntToWString(seq); | 69 string16 suffix = ASCIIToUTF16("-") + base::IntToString16(seq); |
69 #else | 70 #else |
70 std::string suffix = std::string("-") + IntToString(seq); | 71 std::string suffix = std::string("-") + base::IntToString(seq); |
71 #endif | 72 #endif |
72 new_file_path = file_path->InsertBeforeExtension(suffix); | 73 new_file_path = file_path->InsertBeforeExtension(suffix); |
73 } | 74 } |
74 | 75 |
75 // Explicitly (and redundantly check) for file -- despite the fact that our | 76 // Explicitly (and redundantly check) for file -- despite the fact that our |
76 // open won't overwrite -- just to avoid log spew. | 77 // open won't overwrite -- just to avoid log spew. |
77 if (!file_util::PathExists(new_file_path) && | 78 if (!file_util::PathExists(new_file_path) && |
78 file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE | | 79 file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE | |
79 base::PLATFORM_FILE_WRITE) == net::OK) { | 80 base::PLATFORM_FILE_WRITE) == net::OK) { |
80 *file_path = new_file_path; | 81 *file_path = new_file_path; |
(...skipping 15 matching lines...) Expand all Loading... |
96 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); | 97 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); |
97 } | 98 } |
98 | 99 |
99 void PromiseFileFinalizer::OnDownloadAborted() { | 100 void PromiseFileFinalizer::OnDownloadAborted() { |
100 ChromeThread::PostTask( | 101 ChromeThread::PostTask( |
101 ChromeThread::UI, FROM_HERE, | 102 ChromeThread::UI, FROM_HERE, |
102 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); | 103 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); |
103 } | 104 } |
104 | 105 |
105 } // namespace drag_download_util | 106 } // namespace drag_download_util |
OLD | NEW |