Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/browser/download/drag_download_file.cc

Issue 10837125: Revert 149794 - DownloadItem::Observer::OnDownloadDestroyed() replaces DownloadItem::REMOVING (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1228/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/download/drag_download_file.h ('k') | content/browser/download/save_package.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if ((*i)->GetOriginalUrl() == url_) { 189 if ((*i)->GetOriginalUrl() == url_) {
190 download_item_ = *i; 190 download_item_ = *i;
191 download_item_->AddObserver(this); 191 download_item_->AddObserver(this);
192 break; 192 break;
193 } 193 }
194 } 194 }
195 } 195 }
196 196
197 void DragDownloadFile::OnDownloadUpdated(content::DownloadItem* download) { 197 void DragDownloadFile::OnDownloadUpdated(content::DownloadItem* download) {
198 AssertCurrentlyOnUIThread(); 198 AssertCurrentlyOnUIThread();
199 if (download->IsCancelled()) { 199 if (download->IsCancelled() ||
200 (download->GetState() == DownloadItem::REMOVING)) {
200 RemoveObservers(); 201 RemoveObservers();
201 DownloadCompleted(false); 202 DownloadCompleted(false);
202 } else if (download->IsComplete()) { 203 } else if (download->IsComplete()) {
203 RemoveObservers(); 204 RemoveObservers();
204 DownloadCompleted(true); 205 DownloadCompleted(true);
205 } 206 }
206 // Ignore other states. 207 // Ignore other states.
207 } 208 }
208 209
209 // If the download completes or is cancelled, then OnDownloadUpdated() will
210 // handle it and RemoveObserver() so that OnDownloadDestroyed is never called.
211 // OnDownloadDestroyed is only called if OnDownloadUpdated() does not detect
212 // completion or cancellation (in which cases it removes this observer).
213 // TODO(benjhayden): Try to change this to NOTREACHED()?
214 void DragDownloadFile::OnDownloadDestroyed(content::DownloadItem* download) {
215 AssertCurrentlyOnUIThread();
216 RemoveObservers();
217 DownloadCompleted(false);
218 }
219
220 void DragDownloadFile::AssertCurrentlyOnDragThread() { 210 void DragDownloadFile::AssertCurrentlyOnDragThread() {
221 // Only do the check on Windows where two threads are involved. 211 // Only do the check on Windows where two threads are involved.
222 #if defined(OS_WIN) 212 #if defined(OS_WIN)
223 DCHECK(drag_message_loop_ == MessageLoop::current()); 213 DCHECK(drag_message_loop_ == MessageLoop::current());
224 #endif 214 #endif
225 } 215 }
226 216
227 void DragDownloadFile::AssertCurrentlyOnUIThread() { 217 void DragDownloadFile::AssertCurrentlyOnUIThread() {
228 // Only do the check on Windows where two threads are involved. 218 // Only do the check on Windows where two threads are involved.
229 #if defined(OS_WIN) 219 #if defined(OS_WIN)
(...skipping 13 matching lines...) Expand all
243 233
244 void DragDownloadFile::QuitNestedMessageLoop() { 234 void DragDownloadFile::QuitNestedMessageLoop() {
245 AssertCurrentlyOnDragThread(); 235 AssertCurrentlyOnDragThread();
246 236
247 if (is_running_nested_message_loop_) { 237 if (is_running_nested_message_loop_) {
248 is_running_nested_message_loop_ = false; 238 is_running_nested_message_loop_ = false;
249 MessageLoop::current()->Quit(); 239 MessageLoop::current()->Quit();
250 } 240 }
251 } 241 }
252 #endif 242 #endif
OLDNEW
« no previous file with comments | « content/browser/download/drag_download_file.h ('k') | content/browser/download/save_package.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698