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

Side by Side Diff: chrome/browser/download/download_target_determiner.cc

Issue 2166163003: Fix a Use-after-free bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix another violation missed earlier Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/download/download_target_determiner.h" 5 #include "chrome/browser/download/download_target_determiner.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 void DownloadTargetDeterminer::ReserveVirtualPathDone( 318 void DownloadTargetDeterminer::ReserveVirtualPathDone(
319 const base::FilePath& path, bool verified) { 319 const base::FilePath& path, bool verified) {
320 DCHECK_CURRENTLY_ON(BrowserThread::UI); 320 DCHECK_CURRENTLY_ON(BrowserThread::UI);
321 DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe() 321 DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe()
322 << " Verified:" << verified; 322 << " Verified:" << verified;
323 DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_); 323 DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_);
324 #if BUILDFLAG(ANDROID_JAVA_UI) 324 #if BUILDFLAG(ANDROID_JAVA_UI)
325 if (!verified) { 325 if (!verified) {
326 if (path.empty()) { 326 if (path.empty()) {
327 CancelOnFailureAndDeleteSelf();
328 DownloadManagerService::OnDownloadCanceled( 327 DownloadManagerService::OnDownloadCanceled(
329 download_, DownloadController::CANCEL_REASON_NO_EXTERNAL_STORAGE); 328 download_, DownloadController::CANCEL_REASON_NO_EXTERNAL_STORAGE);
329 CancelOnFailureAndDeleteSelf();
330 return; 330 return;
331 } 331 }
332 if (!download_->GetWebContents()) { 332 if (!download_->GetWebContents()) {
333 // If we cannot reserve the path and the WebContent is already gone, there 333 // If we cannot reserve the path and the WebContent is already gone, there
334 // is no way to prompt user for an infobar. This could happen after chrome 334 // is no way to prompt user for an infobar. This could happen after chrome
335 // gets killed, and user tries to resume a download while another app has 335 // gets killed, and user tries to resume a download while another app has
336 // created the target file (not the temporary .crdownload file). 336 // created the target file (not the temporary .crdownload file).
337 CancelOnFailureAndDeleteSelf();
338 DownloadManagerService::OnDownloadCanceled( 337 DownloadManagerService::OnDownloadCanceled(
339 download_, 338 download_,
340 DownloadController::CANCEL_REASON_CANNOT_DETERMINE_DOWNLOAD_TARGET); 339 DownloadController::CANCEL_REASON_CANNOT_DETERMINE_DOWNLOAD_TARGET);
340 CancelOnFailureAndDeleteSelf();
341 return; 341 return;
342 } 342 }
343 } 343 }
344 #endif 344 #endif
345 should_prompt_ = (should_prompt_ || !verified); 345 should_prompt_ = (should_prompt_ || !verified);
346 virtual_path_ = path; 346 virtual_path_ = path;
347 DoLoop(); 347 DoLoop();
348 } 348 }
349 349
350 DownloadTargetDeterminer::Result 350 DownloadTargetDeterminer::Result
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 const base::FilePath& suggested_path) { 946 const base::FilePath& suggested_path) {
947 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); 947 return base::FilePath(suggested_path.value() + kCrdownloadSuffix);
948 } 948 }
949 949
950 #if defined(OS_WIN) 950 #if defined(OS_WIN)
951 // static 951 // static
952 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { 952 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() {
953 return g_is_adobe_reader_up_to_date_; 953 return g_is_adobe_reader_up_to_date_;
954 } 954 }
955 #endif 955 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698