| 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 "content/browser/download/drag_download_file.h" | 5 #include "content/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 "content/browser/browser_context.h" | 9 #include "content/browser/browser_context.h" |
| 10 #include "content/browser/download/download_item.h" | 10 #include "content/browser/download/download_item.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 void DragDownloadFile::ModelChanged() { | 168 void DragDownloadFile::ModelChanged() { |
| 169 AssertCurrentlyOnUIThread(); | 169 AssertCurrentlyOnUIThread(); |
| 170 | 170 |
| 171 if (download_item_) | 171 if (download_item_) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 std::vector<DownloadItem*> downloads; | 174 std::vector<DownloadItem*> downloads; |
| 175 download_manager_->GetTemporaryDownloads(file_path_.DirName(), &downloads); | 175 download_manager_->GetTemporaryDownloads(file_path_.DirName(), &downloads); |
| 176 for (std::vector<DownloadItem*>::const_iterator i = downloads.begin(); | 176 for (std::vector<DownloadItem*>::const_iterator i = downloads.begin(); |
| 177 i != downloads.end(); ++i) { | 177 i != downloads.end(); ++i) { |
| 178 if ((*i)->original_url() == url_) { | 178 if ((*i)->GetOriginalUrl() == url_) { |
| 179 download_item_ = *i; | 179 download_item_ = *i; |
| 180 download_item_->AddObserver(this); | 180 download_item_->AddObserver(this); |
| 181 break; | 181 break; |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void DragDownloadFile::OnDownloadUpdated(DownloadItem* download) { | 186 void DragDownloadFile::OnDownloadUpdated(DownloadItem* download) { |
| 187 AssertCurrentlyOnUIThread(); | 187 AssertCurrentlyOnUIThread(); |
| 188 if (download->IsCancelled() || download->state() == DownloadItem::REMOVING) { | 188 if (download->IsCancelled() || |
| 189 (download->GetState() == DownloadItem::REMOVING)) { |
| 189 RemoveObservers(); | 190 RemoveObservers(); |
| 190 DownloadCompleted(false); | 191 DownloadCompleted(false); |
| 191 } else if (download->IsComplete()) { | 192 } else if (download->IsComplete()) { |
| 192 RemoveObservers(); | 193 RemoveObservers(); |
| 193 DownloadCompleted(true); | 194 DownloadCompleted(true); |
| 194 } | 195 } |
| 195 // Ignore other states. | 196 // Ignore other states. |
| 196 } | 197 } |
| 197 | 198 |
| 198 void DragDownloadFile::AssertCurrentlyOnDragThread() { | 199 void DragDownloadFile::AssertCurrentlyOnDragThread() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 222 | 223 |
| 223 void DragDownloadFile::QuitNestedMessageLoop() { | 224 void DragDownloadFile::QuitNestedMessageLoop() { |
| 224 AssertCurrentlyOnDragThread(); | 225 AssertCurrentlyOnDragThread(); |
| 225 | 226 |
| 226 if (is_running_nested_message_loop_) { | 227 if (is_running_nested_message_loop_) { |
| 227 is_running_nested_message_loop_ = false; | 228 is_running_nested_message_loop_ = false; |
| 228 MessageLoop::current()->Quit(); | 229 MessageLoop::current()->Quit(); |
| 229 } | 230 } |
| 230 } | 231 } |
| 231 #endif | 232 #endif |
| OLD | NEW |