| 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_file.h" | 5 #include "content/browser/download/drag_download_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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "content/browser/download/download_stats.h" | 10 #include "content/browser/download/download_stats.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 save_info.file_stream = file_stream_; | 134 save_info.file_stream = file_stream_; |
| 135 | 135 |
| 136 download_stats::RecordDownloadSource( | 136 download_stats::RecordDownloadSource( |
| 137 download_stats::INITIATED_BY_DRAG_N_DROP); | 137 download_stats::INITIATED_BY_DRAG_N_DROP); |
| 138 download_manager_->DownloadUrl(url_, | 138 download_manager_->DownloadUrl(url_, |
| 139 referrer_, | 139 referrer_, |
| 140 referrer_encoding_, | 140 referrer_encoding_, |
| 141 false, | 141 false, |
| 142 -1, | 142 -1, |
| 143 save_info, | 143 save_info, |
| 144 web_contents_); | 144 web_contents_, |
| 145 DownloadManager::OnStartedCallback()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void DragDownloadFile::DownloadCompleted(bool is_successful) { | 148 void DragDownloadFile::DownloadCompleted(bool is_successful) { |
| 148 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
| 149 // If not in drag-and-drop thread, defer the running to it. | 150 // If not in drag-and-drop thread, defer the running to it. |
| 150 if (drag_message_loop_ != MessageLoop::current()) { | 151 if (drag_message_loop_ != MessageLoop::current()) { |
| 151 drag_message_loop_->PostTask( | 152 drag_message_loop_->PostTask( |
| 152 FROM_HERE, | 153 FROM_HERE, |
| 153 base::Bind(&DragDownloadFile::DownloadCompleted, this, is_successful)); | 154 base::Bind(&DragDownloadFile::DownloadCompleted, this, is_successful)); |
| 154 return; | 155 return; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 232 |
| 232 void DragDownloadFile::QuitNestedMessageLoop() { | 233 void DragDownloadFile::QuitNestedMessageLoop() { |
| 233 AssertCurrentlyOnDragThread(); | 234 AssertCurrentlyOnDragThread(); |
| 234 | 235 |
| 235 if (is_running_nested_message_loop_) { | 236 if (is_running_nested_message_loop_) { |
| 236 is_running_nested_message_loop_ = false; | 237 is_running_nested_message_loop_ = false; |
| 237 MessageLoop::current()->Quit(); | 238 MessageLoop::current()->Quit(); |
| 238 } | 239 } |
| 239 } | 240 } |
| 240 #endif | 241 #endif |
| OLD | NEW |