| 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/drag_download_util.h" | 5 #include "content/browser/download/drag_download_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #endif | 73 #endif |
| 74 new_file_path = file_path->InsertBeforeExtension(suffix); | 74 new_file_path = file_path->InsertBeforeExtension(suffix); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // http://crbug.com/110709 | 77 // http://crbug.com/110709 |
| 78 base::ThreadRestrictions::ScopedAllowIO allow_io; | 78 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 79 | 79 |
| 80 // Explicitly (and redundantly check) for file -- despite the fact that our | 80 // Explicitly (and redundantly check) for file -- despite the fact that our |
| 81 // open won't overwrite -- just to avoid log spew. | 81 // open won't overwrite -- just to avoid log spew. |
| 82 if (!file_util::PathExists(new_file_path) && | 82 if (!file_util::PathExists(new_file_path) && |
| 83 file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE | | 83 file_stream->OpenSync(new_file_path, base::PLATFORM_FILE_CREATE | |
| 84 base::PLATFORM_FILE_WRITE) == net::OK) { | 84 base::PLATFORM_FILE_WRITE) == net::OK) { |
| 85 *file_path = new_file_path; | 85 *file_path = new_file_path; |
| 86 return file_stream.release(); | 86 return file_stream.release(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 return NULL; | 90 return NULL; |
| 91 } | 91 } |
| 92 | 92 |
| 93 PromiseFileFinalizer::PromiseFileFinalizer( | 93 PromiseFileFinalizer::PromiseFileFinalizer( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 108 base::Bind(&PromiseFileFinalizer::Cleanup, this)); | 108 base::Bind(&PromiseFileFinalizer::Cleanup, this)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void PromiseFileFinalizer::OnDownloadAborted() { | 111 void PromiseFileFinalizer::OnDownloadAborted() { |
| 112 BrowserThread::PostTask( | 112 BrowserThread::PostTask( |
| 113 BrowserThread::UI, FROM_HERE, | 113 BrowserThread::UI, FROM_HERE, |
| 114 base::Bind(&PromiseFileFinalizer::Cleanup, this)); | 114 base::Bind(&PromiseFileFinalizer::Cleanup, this)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace drag_download_util | 117 } // namespace drag_download_util |
| OLD | NEW |