OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_file.h" | 5 #include "chrome/browser/download/drag_download_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/download/download_util.h" | |
10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
11 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
12 #include "content/browser/download/download_item.h" | 11 #include "content/browser/download/download_item.h" |
| 12 #include "content/browser/download/download_stats.h" |
13 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
14 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
15 | 15 |
16 DragDownloadFile::DragDownloadFile( | 16 DragDownloadFile::DragDownloadFile( |
17 const FilePath& file_name_or_path, | 17 const FilePath& file_name_or_path, |
18 linked_ptr<net::FileStream> file_stream, | 18 linked_ptr<net::FileStream> file_stream, |
19 const GURL& url, | 19 const GURL& url, |
20 const GURL& referrer, | 20 const GURL& referrer, |
21 const std::string& referrer_encoding, | 21 const std::string& referrer_encoding, |
22 TabContents* tab_contents) | 22 TabContents* tab_contents) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 download_manager_->AddObserver(this); | 121 download_manager_->AddObserver(this); |
122 | 122 |
123 DownloadSaveInfo save_info; | 123 DownloadSaveInfo save_info; |
124 save_info.file_path = file_path_; | 124 save_info.file_path = file_path_; |
125 save_info.file_stream = file_stream_; | 125 save_info.file_stream = file_stream_; |
126 download_manager_->DownloadUrlToFile(url_, | 126 download_manager_->DownloadUrlToFile(url_, |
127 referrer_, | 127 referrer_, |
128 referrer_encoding_, | 128 referrer_encoding_, |
129 save_info, | 129 save_info, |
130 tab_contents_); | 130 tab_contents_); |
131 download_util::RecordDownloadCount( | 131 download_stats::RecordDownloadCount( |
132 download_util::INITIATED_BY_DRAG_N_DROP_COUNT); | 132 download_stats::INITIATED_BY_DRAG_N_DROP_COUNT); |
133 } | 133 } |
134 | 134 |
135 void DragDownloadFile::DownloadCompleted(bool is_successful) { | 135 void DragDownloadFile::DownloadCompleted(bool is_successful) { |
136 #if defined(OS_WIN) | 136 #if defined(OS_WIN) |
137 // If not in drag-and-drop thread, defer the running to it. | 137 // If not in drag-and-drop thread, defer the running to it. |
138 if (drag_message_loop_ != MessageLoop::current()) { | 138 if (drag_message_loop_ != MessageLoop::current()) { |
139 drag_message_loop_->PostTask( | 139 drag_message_loop_->PostTask( |
140 FROM_HERE, | 140 FROM_HERE, |
141 NewRunnableMethod(this, | 141 NewRunnableMethod(this, |
142 &DragDownloadFile::DownloadCompleted, | 142 &DragDownloadFile::DownloadCompleted, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 void DragDownloadFile::QuitNestedMessageLoop() { | 221 void DragDownloadFile::QuitNestedMessageLoop() { |
222 AssertCurrentlyOnDragThread(); | 222 AssertCurrentlyOnDragThread(); |
223 | 223 |
224 if (is_running_nested_message_loop_) { | 224 if (is_running_nested_message_loop_) { |
225 is_running_nested_message_loop_ = false; | 225 is_running_nested_message_loop_ = false; |
226 MessageLoop::current()->Quit(); | 226 MessageLoop::current()->Quit(); |
227 } | 227 } |
228 } | 228 } |
229 #endif | 229 #endif |
OLD | NEW |