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

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

Issue 8399001: Use a DownloadRequestHandle pointer in construction to allow mocking for tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to TOT. Created 9 years, 1 month 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) 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/download_file_manager.h" 5 #include "content/browser/download/download_file_manager.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle, 57 DownloadCreateInfo* info, const DownloadRequestHandle& request_handle,
58 DownloadManager* download_manager, bool get_hash) { 58 DownloadManager* download_manager, bool get_hash) {
59 DCHECK(info); 59 DCHECK(info);
60 VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString(); 60 VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString();
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
62 62
63 // Life of |info| ends here. No more references to it after this method. 63 // Life of |info| ends here. No more references to it after this method.
64 scoped_ptr<DownloadCreateInfo> infop(info); 64 scoped_ptr<DownloadCreateInfo> infop(info);
65 65
66 scoped_ptr<DownloadFile> 66 scoped_ptr<DownloadFile>
67 download_file(new DownloadFile(info, request_handle, download_manager)); 67 download_file(new DownloadFile(info,
68 new DownloadRequestHandle(request_handle),
69 download_manager));
68 if (net::OK != download_file->Initialize(get_hash)) { 70 if (net::OK != download_file->Initialize(get_hash)) {
69 request_handle.CancelRequest(); 71 request_handle.CancelRequest();
70 return; 72 return;
71 } 73 }
72 74
73 DCHECK(GetDownloadFile(info->download_id) == NULL); 75 DCHECK(GetDownloadFile(info->download_id) == NULL);
74 downloads_[info->download_id] = download_file.release(); 76 downloads_[info->download_id] = download_file.release();
75 77
76 // The file is now ready, we can un-pause the request and start saving data. 78 // The file is now ready, we can un-pause the request and start saving data.
77 request_handle.ResumeRequest(); 79 request_handle.ResumeRequest();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 << " id = " << global_id 418 << " id = " << global_id
417 << " download_file = " << download_file->DebugString(); 419 << " download_file = " << download_file->DebugString();
418 420
419 downloads_.erase(global_id); 421 downloads_.erase(global_id);
420 422
421 delete download_file; 423 delete download_file;
422 424
423 if (downloads_.empty()) 425 if (downloads_.empty())
424 StopUpdateTimer(); 426 StopUpdateTimer();
425 } 427 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file.cc ('k') | content/browser/download/download_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698