OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/net/file_downloader.h" | 5 #include "chrome/browser/net/file_downloader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 const DownloadFinishedCallback& callback) | 26 const DownloadFinishedCallback& callback) |
27 : callback_(callback), | 27 : callback_(callback), |
28 fetcher_(URLFetcher::Create(url, URLFetcher::GET, this)), | 28 fetcher_(URLFetcher::Create(url, URLFetcher::GET, this)), |
29 local_path_(path), | 29 local_path_(path), |
30 weak_ptr_factory_(this) { | 30 weak_ptr_factory_(this) { |
31 fetcher_->SetRequestContext(request_context); | 31 fetcher_->SetRequestContext(request_context); |
32 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 32 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
33 net::LOAD_DO_NOT_SAVE_COOKIES); | 33 net::LOAD_DO_NOT_SAVE_COOKIES); |
34 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); | 34 fetcher_->SetAutomaticallyRetryOnNetworkChanges(kNumRetries); |
35 fetcher_->SaveResponseToTemporaryFile( | 35 fetcher_->SaveResponseToTemporaryFile( |
36 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 36 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
37 | 37 |
38 if (overwrite) { | 38 if (overwrite) { |
39 fetcher_->Start(); | 39 fetcher_->Start(); |
40 } else { | 40 } else { |
41 base::PostTaskAndReplyWithResult( | 41 base::PostTaskAndReplyWithResult( |
42 BrowserThread::GetBlockingPool() | 42 BrowserThread::GetBlockingPool() |
43 ->GetTaskRunnerWithShutdownBehavior( | 43 ->GetTaskRunnerWithShutdownBehavior( |
44 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN) | 44 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN) |
45 .get(), | 45 .get(), |
46 FROM_HERE, base::Bind(&base::PathExists, local_path_), | 46 FROM_HERE, base::Bind(&base::PathExists, local_path_), |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 void FileDownloader::OnFileMoveDone(bool success) { | 97 void FileDownloader::OnFileMoveDone(bool success) { |
98 if (!success) { | 98 if (!success) { |
99 DLOG(WARNING) << "Could not move file to " | 99 DLOG(WARNING) << "Could not move file to " |
100 << local_path_.LossyDisplayName(); | 100 << local_path_.LossyDisplayName(); |
101 } | 101 } |
102 | 102 |
103 callback_.Run(success ? DOWNLOADED : FAILED); | 103 callback_.Run(success ? DOWNLOADED : FAILED); |
104 } | 104 } |
OLD | NEW |