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

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

Issue 2624463003: Address 2 crashes in download attribution code (Closed)
Patch Set: Created 3 years, 11 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 if (!base::FeatureList::IsEnabled( 1827 if (!base::FeatureList::IsEnabled(
1828 SafeBrowsingNavigationObserverManager::kDownloadAttribution) || 1828 SafeBrowsingNavigationObserverManager::kDownloadAttribution) ||
1829 !navigation_observer_manager_) { 1829 !navigation_observer_manager_) {
1830 return; 1830 return;
1831 } 1831 }
1832 1832
1833 int download_tab_id = SessionTabHelper::IdForTab(web_contents); 1833 int download_tab_id = SessionTabHelper::IdForTab(web_contents);
1834 UMA_HISTOGRAM_BOOLEAN( 1834 UMA_HISTOGRAM_BOOLEAN(
1835 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution", 1835 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution",
1836 download_tab_id == -1); 1836 download_tab_id == -1);
1837 std::vector<ReferrerChainEntry> attribution_chain; 1837 SafeBrowsingNavigationObserverManager::ReferrerChain attribution_chain;
1838 SafeBrowsingNavigationObserverManager::AttributionResult result = 1838 SafeBrowsingNavigationObserverManager::AttributionResult result =
1839 navigation_observer_manager_->IdentifyReferrerChainForDownload( 1839 navigation_observer_manager_->IdentifyReferrerChainForDownload(
1840 download_url, 1840 download_url,
1841 download_tab_id, 1841 download_tab_id,
1842 kDownloadAttributionUserGestureLimit, 1842 kDownloadAttributionUserGestureLimit,
1843 &attribution_chain); 1843 &attribution_chain);
1844 UMA_HISTOGRAM_COUNTS_100( 1844 UMA_HISTOGRAM_COUNTS_100(
1845 "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution", 1845 "SafeBrowsing.ReferrerURLChainSize.DownloadAttribution",
1846 attribution_chain.size()); 1846 attribution_chain.size());
1847 UMA_HISTOGRAM_ENUMERATION( 1847 UMA_HISTOGRAM_ENUMERATION(
1848 "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result, 1848 "SafeBrowsing.ReferrerAttributionResult.DownloadAttribution", result,
1849 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1849 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
1850 for (auto entry : attribution_chain) 1850 for (auto it = attribution_chain.begin(); it != attribution_chain.end(); it++)
Nathan Parker 2017/01/10 01:25:13 Could this be for (auto& entry : attribution_chai
Jialiu Lin 2017/01/10 02:15:12 You're right. Done.
1851 out_request->add_referrer_chain()->Swap(&entry); 1851 out_request->add_referrer_chain()->Swap(it->release());
1852 } 1852 }
1853 1853
1854 void DownloadProtectionService::AddReferrerChainToPPAPIClientDownloadRequest( 1854 void DownloadProtectionService::AddReferrerChainToPPAPIClientDownloadRequest(
1855 const GURL& initiating_frame_url, 1855 const GURL& initiating_frame_url,
1856 int tab_id, 1856 int tab_id,
1857 bool has_user_gesture, 1857 bool has_user_gesture,
1858 ClientDownloadRequest* out_request) { 1858 ClientDownloadRequest* out_request) {
1859 if (!base::FeatureList::IsEnabled( 1859 if (!base::FeatureList::IsEnabled(
1860 SafeBrowsingNavigationObserverManager::kDownloadAttribution) || 1860 SafeBrowsingNavigationObserverManager::kDownloadAttribution) ||
1861 !navigation_observer_manager_) { 1861 !navigation_observer_manager_) {
1862 return; 1862 return;
1863 } 1863 }
1864 1864
1865 UMA_HISTOGRAM_BOOLEAN( 1865 UMA_HISTOGRAM_BOOLEAN(
1866 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution", 1866 "SafeBrowsing.ReferrerHasInvalidTabID.DownloadAttribution",
1867 tab_id == -1); 1867 tab_id == -1);
1868 std::vector<ReferrerChainEntry> attribution_chain; 1868 SafeBrowsingNavigationObserverManager::ReferrerChain attribution_chain;
1869 SafeBrowsingNavigationObserverManager::AttributionResult result = 1869 SafeBrowsingNavigationObserverManager::AttributionResult result =
1870 navigation_observer_manager_->IdentifyReferrerChainForPPAPIDownload( 1870 navigation_observer_manager_->IdentifyReferrerChainForPPAPIDownload(
1871 initiating_frame_url, 1871 initiating_frame_url,
1872 tab_id, 1872 tab_id,
1873 has_user_gesture, 1873 has_user_gesture,
1874 kDownloadAttributionUserGestureLimit, 1874 kDownloadAttributionUserGestureLimit,
1875 &attribution_chain); 1875 &attribution_chain);
1876 UMA_HISTOGRAM_COUNTS_100( 1876 UMA_HISTOGRAM_COUNTS_100(
1877 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", 1877 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution",
1878 attribution_chain.size()); 1878 attribution_chain.size());
1879 UMA_HISTOGRAM_ENUMERATION( 1879 UMA_HISTOGRAM_ENUMERATION(
1880 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, 1880 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result,
1881 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1881 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
1882 for (auto entry : attribution_chain) 1882 for (auto it = attribution_chain.begin(); it != attribution_chain.end(); it++)
1883 out_request->add_referrer_chain()->Swap(&entry); 1883 out_request->add_referrer_chain()->Swap(it->release());
1884 } 1884 }
1885 1885
1886 } // namespace safe_browsing 1886 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698