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

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

Issue 10905284: Use the user's preferred downloads directory for creating the initial download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows path check Created 8 years, 3 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 #include "content/browser/download/download_file_impl.h" 5 #include "content/browser/download/download_file_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 27 matching lines...) Expand all
38 : file_(info->save_info.file_path, 38 : file_(info->save_info.file_path,
39 info->url(), 39 info->url(),
40 info->referrer_url, 40 info->referrer_url,
41 info->received_bytes, 41 info->received_bytes,
42 calculate_hash, 42 calculate_hash,
43 info->save_info.hash_state, 43 info->save_info.hash_state,
44 info->save_info.file_stream, 44 info->save_info.file_stream,
45 bound_net_log), 45 bound_net_log),
46 stream_reader_(stream.Pass()), 46 stream_reader_(stream.Pass()),
47 id_(info->download_id), 47 id_(info->download_id),
48 default_download_directory_(info->default_download_directory),
48 request_handle_(request_handle), 49 request_handle_(request_handle),
49 download_manager_(download_manager), 50 download_manager_(download_manager),
50 bytes_seen_(0), 51 bytes_seen_(0),
51 bound_net_log_(bound_net_log), 52 bound_net_log_(bound_net_log),
52 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 53 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
53 power_save_blocker_(power_save_blocker.Pass()) { 54 power_save_blocker_(power_save_blocker.Pass()) {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
55 DCHECK(download_manager.get()); 56 DCHECK(download_manager.get());
56 } 57 }
57 58
58 DownloadFileImpl::~DownloadFileImpl() { 59 DownloadFileImpl::~DownloadFileImpl() {
59 } 60 }
60 61
61 content::DownloadInterruptReason DownloadFileImpl::Initialize() { 62 content::DownloadInterruptReason DownloadFileImpl::Initialize() {
62 update_timer_.reset(new base::RepeatingTimer<DownloadFileImpl>()); 63 update_timer_.reset(new base::RepeatingTimer<DownloadFileImpl>());
63 net::Error result = file_.Initialize(); 64 net::Error result = file_.Initialize(default_download_directory_);
64 if (result != net::OK) { 65 if (result != net::OK) {
65 return content::ConvertNetErrorToInterruptReason( 66 return content::ConvertNetErrorToInterruptReason(
66 result, content::DOWNLOAD_INTERRUPT_FROM_DISK); 67 result, content::DOWNLOAD_INTERRUPT_FROM_DISK);
67 } 68 }
68 69
69 stream_reader_->RegisterCallback( 70 stream_reader_->RegisterCallback(
70 base::Bind(&DownloadFileImpl::StreamActive, weak_factory_.GetWeakPtr())); 71 base::Bind(&DownloadFileImpl::StreamActive, weak_factory_.GetWeakPtr()));
71 72
72 download_start_ = base::TimeTicks::Now(); 73 download_start_ = base::TimeTicks::Now();
73 // Initial pull from the straw. 74 // Initial pull from the straw.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 295 }
295 } 296 }
296 297
297 void DownloadFileImpl::SendUpdate() { 298 void DownloadFileImpl::SendUpdate() {
298 BrowserThread::PostTask( 299 BrowserThread::PostTask(
299 BrowserThread::UI, FROM_HERE, 300 BrowserThread::UI, FROM_HERE,
300 base::Bind(&DownloadManager::UpdateDownload, 301 base::Bind(&DownloadManager::UpdateDownload,
301 download_manager_, id_.local(), 302 download_manager_, id_.local(),
302 BytesSoFar(), CurrentSpeed(), GetHashState())); 303 BytesSoFar(), CurrentSpeed(), GetHashState()));
303 } 304 }
OLDNEW
« no previous file with comments | « content/browser/download/download_file_impl.h ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698