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

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service.cc

Issue 734843002: Safebrowsing: Fix crash if DownloadItem is destroyed before history check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_protection_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 BrowserThread::UI, 637 BrowserThread::UI,
638 FROM_HERE, 638 FROM_HERE,
639 base::Bind(&CheckClientDownloadRequest::GetTabRedirects, this)); 639 base::Bind(&CheckClientDownloadRequest::GetTabRedirects, this));
640 #else 640 #else
641 PostFinishTask(UNKNOWN, REASON_OS_NOT_SUPPORTED); 641 PostFinishTask(UNKNOWN, REASON_OS_NOT_SUPPORTED);
642 #endif 642 #endif
643 } 643 }
644 644
645 void GetTabRedirects() { 645 void GetTabRedirects() {
646 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 646 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
647 if (!service_)
648 return;
649
647 if (!tab_url_.is_valid()) { 650 if (!tab_url_.is_valid()) {
648 SendRequest(); 651 SendRequest();
649 return; 652 return;
650 } 653 }
651 654
652 Profile* profile = Profile::FromBrowserContext(item_->GetBrowserContext()); 655 Profile* profile = Profile::FromBrowserContext(item_->GetBrowserContext());
653 HistoryService* history = 656 HistoryService* history =
654 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); 657 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
655 if (!history) { 658 if (!history) {
656 SendRequest(); 659 SendRequest();
657 return; 660 return;
658 } 661 }
659 662
660 history->QueryRedirectsTo( 663 history->QueryRedirectsTo(
661 tab_url_, 664 tab_url_,
662 base::Bind(&CheckClientDownloadRequest::OnGotTabRedirects, 665 base::Bind(&CheckClientDownloadRequest::OnGotTabRedirects,
663 base::Unretained(this), 666 base::Unretained(this),
664 tab_url_), 667 tab_url_),
665 &request_tracker_); 668 &request_tracker_);
666 } 669 }
667 670
668 void OnGotTabRedirects(const GURL& url, 671 void OnGotTabRedirects(const GURL& url,
669 const history::RedirectList* redirect_list) { 672 const history::RedirectList* redirect_list) {
670 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
671 DCHECK_EQ(url, tab_url_); 674 DCHECK_EQ(url, tab_url_);
675 if (!service_)
676 return;
672 677
673 if (!redirect_list->empty()) { 678 if (!redirect_list->empty()) {
674 tab_redirects_.insert( 679 tab_redirects_.insert(
675 tab_redirects_.end(), redirect_list->rbegin(), redirect_list->rend()); 680 tab_redirects_.end(), redirect_list->rbegin(), redirect_list->rend());
676 } 681 }
677 682
678 SendRequest(); 683 SendRequest();
679 } 684 }
680 685
681 void SendRequest() { 686 void SendRequest() {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 GURL DownloadProtectionService::GetDownloadRequestUrl() { 1105 GURL DownloadProtectionService::GetDownloadRequestUrl() {
1101 GURL url(kDownloadRequestUrl); 1106 GURL url(kDownloadRequestUrl);
1102 std::string api_key = google_apis::GetAPIKey(); 1107 std::string api_key = google_apis::GetAPIKey();
1103 if (!api_key.empty()) 1108 if (!api_key.empty())
1104 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); 1109 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true));
1105 1110
1106 return url; 1111 return url;
1107 } 1112 }
1108 1113
1109 } // namespace safe_browsing 1114 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_protection_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698