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

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

Issue 11711003: Remove the DownloadItem::TogglePause() interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to r175145. Created 7 years, 11 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
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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 bound_net_log_.AddEvent( 312 bound_net_log_.AddEvent(
313 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, 313 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED,
314 base::Bind(&ItemCheckedNetLogCallback, 314 base::Bind(&ItemCheckedNetLogCallback,
315 GetDangerType(), GetSafetyState())); 315 GetDangerType(), GetSafetyState()));
316 316
317 UpdateObservers(); 317 UpdateObservers();
318 318
319 MaybeCompleteDownload(); 319 MaybeCompleteDownload();
320 } 320 }
321 321
322 void DownloadItemImpl::TogglePause() { 322 void DownloadItemImpl::Pause() {
323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 323 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
324 DCHECK(state_ == IN_PROGRESS_INTERNAL || state_ == COMPLETING_INTERNAL);
325 VLOG(20) << __FUNCTION__ << " download=" << DebugString(true);
326 324
327 // Ignore pauses when we've passed the commit point. 325 // Ignore irrelevant states.
328 if (state_ == COMPLETING_INTERNAL) 326 if (state_ != IN_PROGRESS_INTERNAL || is_paused_)
329 return; 327 return;
330 328
331 if (is_paused_) 329 request_handle_->PauseRequest();
332 request_handle_->ResumeRequest(); 330 is_paused_ = true;
333 else
334 request_handle_->PauseRequest();
335 is_paused_ = !is_paused_;
336 UpdateObservers(); 331 UpdateObservers();
337 } 332 }
338 333
334 void DownloadItemImpl::Resume() {
335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
336
337 // Ignore irrelevant states.
338 if (state_ != IN_PROGRESS_INTERNAL || !is_paused_)
339 return;
340
341 request_handle_->ResumeRequest();
342 is_paused_ = false;
343 UpdateObservers();
344 }
345
339 void DownloadItemImpl::Cancel(bool user_cancel) { 346 void DownloadItemImpl::Cancel(bool user_cancel) {
340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 347 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
341 348
342 last_reason_ = user_cancel ? 349 last_reason_ = user_cancel ?
343 DOWNLOAD_INTERRUPT_REASON_USER_CANCELED : 350 DOWNLOAD_INTERRUPT_REASON_USER_CANCELED :
344 DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; 351 DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN;
345 352
346 VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true); 353 VLOG(20) << __FUNCTION__ << "() download = " << DebugString(true);
347 if (state_ != IN_PROGRESS_INTERNAL) { 354 if (state_ != IN_PROGRESS_INTERNAL) {
348 // Small downloads might be complete before this method has 355 // Small downloads might be complete before this method has
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 return "CANCELLED"; 1426 return "CANCELLED";
1420 case INTERRUPTED_INTERNAL: 1427 case INTERRUPTED_INTERNAL:
1421 return "INTERRUPTED"; 1428 return "INTERRUPTED";
1422 default: 1429 default:
1423 NOTREACHED() << "Unknown download state " << state; 1430 NOTREACHED() << "Unknown download state " << state;
1424 return "unknown"; 1431 return "unknown";
1425 }; 1432 };
1426 } 1433 }
1427 1434
1428 } // namespace content 1435 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698