| 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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE | | 79 file_stream->Open(new_file_path, base::PLATFORM_FILE_CREATE | |
| 80 base::PLATFORM_FILE_WRITE) == net::OK) { | 80 base::PLATFORM_FILE_WRITE) == net::OK) { |
| 81 *file_path = new_file_path; | 81 *file_path = new_file_path; |
| 82 return file_stream.release(); | 82 return file_stream.release(); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 return NULL; | 86 return NULL; |
| 87 } | 87 } |
| 88 | 88 |
| 89 PromiseFileFinalizer::PromiseFileFinalizer( |
| 90 DragDownloadFile* drag_file_downloader) |
| 91 : drag_file_downloader_(drag_file_downloader) { |
| 92 } |
| 93 |
| 94 PromiseFileFinalizer::~PromiseFileFinalizer() {} |
| 95 |
| 89 void PromiseFileFinalizer::Cleanup() { | 96 void PromiseFileFinalizer::Cleanup() { |
| 90 if (drag_file_downloader_.get()) | 97 if (drag_file_downloader_.get()) |
| 91 drag_file_downloader_ = NULL; | 98 drag_file_downloader_ = NULL; |
| 92 } | 99 } |
| 93 | 100 |
| 94 void PromiseFileFinalizer::OnDownloadCompleted(const FilePath& file_path) { | 101 void PromiseFileFinalizer::OnDownloadCompleted(const FilePath& file_path) { |
| 95 BrowserThread::PostTask( | 102 BrowserThread::PostTask( |
| 96 BrowserThread::UI, FROM_HERE, | 103 BrowserThread::UI, FROM_HERE, |
| 97 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); | 104 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); |
| 98 } | 105 } |
| 99 | 106 |
| 100 void PromiseFileFinalizer::OnDownloadAborted() { | 107 void PromiseFileFinalizer::OnDownloadAborted() { |
| 101 BrowserThread::PostTask( | 108 BrowserThread::PostTask( |
| 102 BrowserThread::UI, FROM_HERE, | 109 BrowserThread::UI, FROM_HERE, |
| 103 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); | 110 NewRunnableMethod(this, &PromiseFileFinalizer::Cleanup)); |
| 104 } | 111 } |
| 105 | 112 |
| 106 } // namespace drag_download_util | 113 } // namespace drag_download_util |
| OLD | NEW |