| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009-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_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/chrome_thread.h" | 9 #include "chrome/browser/chrome_thread.h" |
| 10 #include "chrome/browser/download/download_file.h" | 10 #include "chrome/browser/download/download_file.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // On Windows, we need to stop the waiting. | 145 // On Windows, we need to stop the waiting. |
| 146 #if defined(OS_WIN) | 146 #if defined(OS_WIN) |
| 147 QuitNestedMessageLoop(); | 147 QuitNestedMessageLoop(); |
| 148 #endif | 148 #endif |
| 149 } | 149 } |
| 150 | 150 |
| 151 void DragDownloadFile::ModelChanged() { | 151 void DragDownloadFile::ModelChanged() { |
| 152 AssertCurrentlyOnUIThread(); | 152 AssertCurrentlyOnUIThread(); |
| 153 | 153 |
| 154 download_manager_->GetTemporaryDownloads(this, file_path_.DirName()); | 154 std::vector<DownloadItem*> downloads; |
| 155 } | 155 download_manager_->GetTemporaryDownloads(file_path_.DirName(), &downloads); |
| 156 | 156 for (std::vector<DownloadItem*>::const_iterator i = downloads.begin(); |
| 157 void DragDownloadFile::SetDownloads(std::vector<DownloadItem*>& downloads) { | 157 i != downloads.end(); ++i) { |
| 158 AssertCurrentlyOnUIThread(); | 158 if (!download_item_observer_added_ && (*i)->url() == url_) { |
| 159 | |
| 160 std::vector<DownloadItem*>::const_iterator it = downloads.begin(); | |
| 161 for (; it != downloads.end(); ++it) { | |
| 162 if (!download_item_observer_added_ && (*it)->url() == url_) { | |
| 163 download_item_observer_added_ = true; | 159 download_item_observer_added_ = true; |
| 164 (*it)->AddObserver(this); | 160 (*i)->AddObserver(this); |
| 165 } | 161 } |
| 166 } | 162 } |
| 167 } | 163 } |
| 168 | 164 |
| 169 void DragDownloadFile::OnDownloadUpdated(DownloadItem* download) { | 165 void DragDownloadFile::OnDownloadUpdated(DownloadItem* download) { |
| 170 AssertCurrentlyOnUIThread(); | 166 AssertCurrentlyOnUIThread(); |
| 171 | 167 |
| 172 if (download->state() == DownloadItem::CANCELLED) { | 168 if (download->state() == DownloadItem::CANCELLED) { |
| 173 download->RemoveObserver(this); | 169 download->RemoveObserver(this); |
| 174 download_manager_->RemoveObserver(this); | 170 download_manager_->RemoveObserver(this); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 210 |
| 215 void DragDownloadFile::QuitNestedMessageLoop() { | 211 void DragDownloadFile::QuitNestedMessageLoop() { |
| 216 AssertCurrentlyOnDragThread(); | 212 AssertCurrentlyOnDragThread(); |
| 217 | 213 |
| 218 if (is_running_nested_message_loop_) { | 214 if (is_running_nested_message_loop_) { |
| 219 is_running_nested_message_loop_ = false; | 215 is_running_nested_message_loop_ = false; |
| 220 MessageLoop::current()->Quit(); | 216 MessageLoop::current()->Quit(); |
| 221 } | 217 } |
| 222 } | 218 } |
| 223 #endif | 219 #endif |
| OLD | NEW |