diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js
index 7e791e01ae..9d5dc47808 100644
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -338,63 +338,6 @@ pref("dom.w3c_touch_events.enabled", 1);
pref("dom.w3c_touch_events.safetyX", 0); // escape borders in units of 1/240"
pref("dom.w3c_touch_events.safetyY", 120); // escape borders in units of 1/240"
-#ifdef MOZ_SAFE_BROWSING
-// Safe browsing does nothing unless this pref is set
-pref("browser.safebrowsing.enabled", false);
-
-// Prevent loading of pages identified as malware
-pref("browser.safebrowsing.malware.enabled", false);
-
-pref("browser.safebrowsing.debug", false);
-pref("browser.safebrowsing.updateURL", "https://safebrowsing.google.com/safebrowsing/downloads?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2&key=%GOOGLE_API_KEY%");
-pref("browser.safebrowsing.gethashURL", "https://safebrowsing.google.com/safebrowsing/gethash?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
-pref("browser.safebrowsing.reportURL", "https://safebrowsing.google.com/safebrowsing/report?");
-pref("browser.safebrowsing.reportGenericURL", "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportErrorURL", "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportPhishURL", "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
-
-pref("browser.safebrowsing.id", "Firefox");
-
-// Tables for application reputation.
-pref("urlclassifier.downloadBlockTable", "goog-badbinurl-shavar");
-
-// Non-enhanced mode (local url lists) URL list to check for updates
-pref("browser.safebrowsing.provider.0.updateURL", "https://safebrowsing.google.com/safebrowsing/downloads?client={moz:client}&appver={moz:version}&pver=2.2&key=%GOOGLE_API_KEY%");
-
-pref("browser.safebrowsing.dataProvider", 0);
-
-// Does the provider name need to be localizable?
-pref("browser.safebrowsing.provider.0.name", "Google");
-pref("browser.safebrowsing.provider.0.reportURL", "https://safebrowsing.google.com/safebrowsing/report?");
-pref("browser.safebrowsing.provider.0.gethashURL", "https://safebrowsing.google.com/safebrowsing/gethash?client={moz:client}&appver={moz:version}&pver=2.2");
-
-// HTML report pages
-pref("browser.safebrowsing.provider.0.reportGenericURL", "http://{moz:locale}.phish-generic.mozilla.com/?hl={moz:locale}");
-pref("browser.safebrowsing.provider.0.reportErrorURL", "http://{moz:locale}.phish-error.mozilla.com/?hl={moz:locale}");
-pref("browser.safebrowsing.provider.0.reportPhishURL", "http://{moz:locale}.phish-report.mozilla.com/?hl={moz:locale}");
-pref("browser.safebrowsing.provider.0.reportMalwareURL", "http://{moz:locale}.malware-report.mozilla.com/?hl={moz:locale}");
-pref("browser.safebrowsing.provider.0.reportMalwareErrorURL", "http://{moz:locale}.malware-error.mozilla.com/?hl={moz:locale}");
-
-// FAQ URLs
-
-// The number of random entries to send with a gethash request.
-pref("urlclassifier.gethashnoise", 4);
-
-// Gethash timeout for Safebrowsing.
-pref("urlclassifier.gethash.timeout_ms", 5000);
-
-// If an urlclassifier table has not been updated in this number of seconds,
-// a gethash request will be forced to check that the result is still in
-// the database.
-pref("urlclassifier.max-complete-age", 2700);
-
-// URL for checking the reason for a malware warning.
-pref("browser.safebrowsing.malware.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
-#endif
-
// True if this is the first time we are showing about:firstrun
pref("browser.firstrun.show.uidiscovery", true);
pref("browser.firstrun.show.localepicker", true);
diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js
index 2aba9ac5a6..3e7ed5821c 100644
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -70,11 +70,6 @@ XPCOMUtils.defineLazyServiceGetter(Services, 'captivePortalDetector',
'nsICaptivePortalDetector');
#endif
-#ifdef MOZ_SAFE_BROWSING
-XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
- "resource://gre/modules/SafeBrowsing.jsm");
-#endif
-
function getContentWindow() {
return shell.contentBrowser.contentWindow;
}
@@ -353,11 +348,6 @@ var shell = {
ppmm.addMessageListener("sms-handler", this);
ppmm.addMessageListener("mail-handler", this);
ppmm.addMessageListener("file-picker", this);
-#ifdef MOZ_SAFE_BROWSING
- setTimeout(function() {
- SafeBrowsing.init();
- }, 5000);
-#endif
},
stop: function shell_stop() {
diff --git a/b2g/confvars.sh b/b2g/confvars.sh
index cd309b6ade..a59eab08f3 100755
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -17,7 +17,6 @@ MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
# MOZ_APP_DISPLAYNAME is set by branding/configure.sh
-MOZ_SAFE_BROWSING=1
MOZ_SERVICES_COMMON=1
MOZ_SERVICES_METRICS=1
MOZ_CAPTIVEDETECT=1
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index 5664050d86..87b6f7461e 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -726,46 +726,6 @@ pref("goanna.handlerService.schemes.ircs.3.uriTemplate", "chrome://browser-regio
// By default, we don't want protocol/content handlers to be registered from a different host, see bug 402287
pref("goanna.handlerService.allowRegisterFromDifferentHost", false);
-#ifdef MOZ_SAFE_BROWSING
-pref("browser.safebrowsing.enabled", true);
-pref("browser.safebrowsing.malware.enabled", true);
-pref("browser.safebrowsing.debug", false);
-
-pref("browser.safebrowsing.updateURL", "http://safebrowsing.clients.google.com/safebrowsing/downloads?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
-pref("browser.safebrowsing.keyURL", "https://sb-ssl.google.com/safebrowsing/newkey?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
-pref("browser.safebrowsing.gethashURL", "http://safebrowsing.clients.google.com/safebrowsing/gethash?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
-pref("browser.safebrowsing.reportURL", "http://safebrowsing.clients.google.com/safebrowsing/report?");
-pref("browser.safebrowsing.reportGenericURL", "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportErrorURL", "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportPhishURL", "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
-
-pref("browser.safebrowsing.warning.infoURL", "https://www.mozilla.org/%LOCALE%/firefox/phishing-protection/");
-pref("browser.safebrowsing.malware.reportURL", "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
-
-#ifdef MOZILLA_OFFICIAL
-// Normally the "client ID" sent in updates is appinfo.name, but for
-// official Firefox releases from Mozilla we use a special identifier.
-pref("browser.safebrowsing.id", "navclient-auto-ffox");
-#endif
-
-// Name of the about: page contributed by safebrowsing to handle display of error
-// pages on phishing/malware hits. (bug 399233)
-pref("urlclassifier.alternate_error_page", "blocked");
-
-// The number of random entries to send with a gethash request.
-pref("urlclassifier.gethashnoise", 4);
-
-// The list of tables that use the gethash request to confirm partial results.
-pref("urlclassifier.gethashtables", "goog-phish-shavar,goog-malware-shavar");
-
-// If an urlclassifier table has not been updated in this number of seconds,
-// a gethash request will be forced to check that the result is still in
-// the database.
-pref("urlclassifier.max-complete-age", 2700);
-#endif
-
pref("browser.geolocation.warning.infoURL", "https://www.mozilla.org/%LOCALE%/firefox/geolocation/");
pref("browser.mixedcontent.warning.infoURL", "http://support.mozilla.org/1/%APP%/%VERSION%/%OS%/%LOCALE%/mixed-content/");
@@ -950,10 +910,6 @@ pref("services.sync.prefs.sync.browser.download.manager.showWhenStarting", true)
pref("services.sync.prefs.sync.browser.formfill.enable", true);
pref("services.sync.prefs.sync.browser.link.open_newwindow", true);
pref("services.sync.prefs.sync.browser.offline-apps.notify", true);
-#ifdef MOZ_SAFE_BROWSING
-pref("services.sync.prefs.sync.browser.safebrowsing.enabled", true);
-pref("services.sync.prefs.sync.browser.safebrowsing.malware.enabled", true);
-#endif
pref("services.sync.prefs.sync.browser.search.selectedEngine", true);
pref("services.sync.prefs.sync.browser.search.update", true);
pref("services.sync.prefs.sync.browser.sessionstore.restore_on_demand", true);
diff --git a/browser/base/content/browser-doctype.inc b/browser/base/content/browser-doctype.inc
index bd0cd28b7b..6ee6384b64 100644
--- a/browser/base/content/browser-doctype.inc
+++ b/browser/base/content/browser-doctype.inc
@@ -13,10 +13,6 @@
%customizeToolbarDTD;
%placesDTD;
-#ifdef MOZ_SAFE_BROWSING
-
-%safebrowsingDTD;
-#endif
%aboutHomeDTD;
]>
diff --git a/browser/base/content/browser-safebrowsing.js b/browser/base/content/browser-safebrowsing.js
deleted file mode 100644
index e40a31957d..0000000000
--- a/browser/base/content/browser-safebrowsing.js
+++ /dev/null
@@ -1,53 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifdef MOZ_SAFE_BROWSING
-var gSafeBrowsing = {
-
- setReportPhishingMenu: function() {
-
- // A phishing page will have a specific about:blocked content documentURI
- var isPhishingPage = content.document.documentURI.startsWith("about:blocked?e=phishingBlocked");
-
- // Show/hide the appropriate menu item.
- document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
- .hidden = isPhishingPage;
- document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
- .hidden = !isPhishingPage;
-
- var broadcasterId = isPhishingPage
- ? "reportPhishingErrorBroadcaster"
- : "reportPhishingBroadcaster";
-
- var broadcaster = document.getElementById(broadcasterId);
- if (!broadcaster)
- return;
-
- var uri = getBrowser().currentURI;
- if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
- broadcaster.removeAttribute("disabled");
- else
- broadcaster.setAttribute("disabled", true);
- },
-
- /**
- * Used to report a phishing page or a false positive
- * @param name String One of "Phish", "Error", "Malware" or "MalwareError"
- * @return String the report phishing URL.
- */
- getReportURL: function(name) {
- var reportUrl = SafeBrowsing.getReportURL(name);
-
- var pageUri = gBrowser.currentURI.clone();
-
- // Remove the query to avoid including potentially sensitive data
- if (pageUri instanceof Ci.nsIURL)
- pageUri.query = '';
-
- reportUrl += "&url=" + encodeURIComponent(pageUri.asciiSpec);
-
- return reportUrl;
- }
-}
-#endif
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 09c39f1d2c..b6afa9832b 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -125,11 +125,6 @@ XPCOMUtils.defineLazyGetter(this, "BrowserDebuggerProcess", function() {
XPCOMUtils.defineLazyModuleGetter(this, "PageThumbs",
"resource://gre/modules/PageThumbs.jsm");
-#ifdef MOZ_SAFE_BROWSING
-XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
- "resource://gre/modules/SafeBrowsing.jsm");
-#endif
-
XPCOMUtils.defineLazyModuleGetter(this, "gBrowserNewTabPreloader",
"resource:///modules/BrowserNewTabPreloader.jsm", "BrowserNewTabPreloader");
@@ -154,9 +149,6 @@ let gInitialPages = [
#include browser-fullZoom.js
#include browser-places.js
#include browser-plugins.js
-#ifdef MOZ_SAFE_BROWSING
-#include browser-safebrowsing.js
-#endif
#include browser-tabPreviews.js
#include browser-thumbnails.js
#include browser-webrtcUI.js
@@ -984,11 +976,6 @@ var gBrowserInit = {
loadOneOrMoreURIs(uriToLoad);
}
-#ifdef MOZ_SAFE_BROWSING
- // Bug 778855 - Perf regression if we do this here. To be addressed in bug 779008.
- setTimeout(function() { SafeBrowsing.init(); }, 2000);
-#endif
-
Services.obs.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false);
Services.obs.addObserver(gXPInstallObserver, "addon-install-started", false);
@@ -2374,11 +2361,6 @@ let BrowserOnClick = {
if (ownerDoc.documentURI.startsWith("about:certerror")) {
this.onAboutCertError(originalTarget, ownerDoc);
}
-#ifdef MOZ_SAFE_BROWSING
- else if (ownerDoc.documentURI.startsWith("about:blocked")) {
- this.onAboutBlocked(originalTarget, ownerDoc);
- }
-#endif
else if (ownerDoc.documentURI.startsWith("about:neterror")) {
this.onAboutNetError(originalTarget, ownerDoc);
}
@@ -2428,115 +2410,6 @@ let BrowserOnClick = {
}
},
-#ifdef MOZ_SAFE_BROWSING
- onAboutBlocked: function BrowserOnClick_onAboutBlocked(aTargetElm, aOwnerDoc) {
- let elmId = aTargetElm.getAttribute("id");
-
- // The event came from a button on a malware/phishing block page
- // First check whether it's malware or phishing, so that we can
- // use the right strings/links
- let isMalware = /e=malwareBlocked/.test(aOwnerDoc.documentURI);
- let bucketName = isMalware ? "WARNING_MALWARE_PAGE_":"WARNING_PHISHING_PAGE_";
- let nsISecTel = Ci.nsISecurityUITelemetry;
- let isIframe = (aOwnerDoc.defaultView.parent === aOwnerDoc.defaultView);
- bucketName += isIframe ? "TOP_" : "FRAME_";
-
- switch (elmId) {
- case "getMeOutButton":
- getMeOutOfHere();
- break;
-
- case "reportButton":
- // This is the "Why is this site blocked" button. For malware,
- // we can fetch a site-specific report, for phishing, we redirect
- // to the generic page describing phishing protection.
-
- if (isMalware) {
- // Get the stop badware "why is this blocked" report url,
- // append the current url, and go there.
- try {
- let reportURL = formatURL("browser.safebrowsing.malware.reportURL", true);
- reportURL += aOwnerDoc.location.href;
- content.location = reportURL;
- } catch (e) {
- Components.utils.reportError("Couldn't get malware report URL: " + e);
- }
- }
- else { // It's a phishing site, not malware
- try {
- content.location = formatURL("browser.safebrowsing.warning.infoURL", true);
- } catch (e) {
- Components.utils.reportError("Couldn't get phishing info URL: " + e);
- }
- }
- break;
-
- case "ignoreWarningButton":
- this.ignoreWarningButton(isMalware);
- break;
- }
- },
-
- ignoreWarningButton: function BrowserOnClick_ignoreWarningButton(aIsMalware) {
- // Allow users to override and continue through to the site,
- // but add a notify bar as a reminder, so that they don't lose
- // track after, e.g., tab switching.
- gBrowser.loadURIWithFlags(content.location.href,
- nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
- null, null, null);
-
- Services.perms.add(makeURI(content.location.href), "safe-browsing",
- Ci.nsIPermissionManager.ALLOW_ACTION,
- Ci.nsIPermissionManager.EXPIRE_SESSION);
-
- let buttons = [{
- label: gNavigatorBundle.getString("safebrowsing.getMeOutOfHereButton.label"),
- accessKey: gNavigatorBundle.getString("safebrowsing.getMeOutOfHereButton.accessKey"),
- callback: function() { getMeOutOfHere(); }
- }];
-
- let title;
- if (aIsMalware) {
- title = gNavigatorBundle.getString("safebrowsing.reportedAttackSite");
- buttons[1] = {
- label: gNavigatorBundle.getString("safebrowsing.notAnAttackButton.label"),
- accessKey: gNavigatorBundle.getString("safebrowsing.notAnAttackButton.accessKey"),
- callback: function() {
- openUILinkIn(gSafeBrowsing.getReportURL('MalwareError'), 'tab');
- }
- };
- } else {
- title = gNavigatorBundle.getString("safebrowsing.reportedWebForgery");
- buttons[1] = {
- label: gNavigatorBundle.getString("safebrowsing.notAForgeryButton.label"),
- accessKey: gNavigatorBundle.getString("safebrowsing.notAForgeryButton.accessKey"),
- callback: function() {
- openUILinkIn(gSafeBrowsing.getReportURL('Error'), 'tab');
- }
- };
- }
-
- let notificationBox = gBrowser.getNotificationBox();
- let value = "blocked-badware-page";
-
- let previousNotification = notificationBox.getNotificationWithValue(value);
- if (previousNotification) {
- notificationBox.removeNotification(previousNotification);
- }
-
- let notification = notificationBox.appendNotification(
- title,
- value,
- "chrome://global/skin/icons/blacklist_favicon.png",
- notificationBox.PRIORITY_CRITICAL_HIGH,
- buttons
- );
- // Persist the notification until the user removes so it
- // doesn't get removed on redirects.
- notification.persistence = -1;
- },
-#endif
-
onAboutNetError: function BrowserOnClick_onAboutNetError(aTargetElm, aOwnerDoc) {
let elmId = aTargetElm.getAttribute("id");
if (elmId != "errorTryAgain" || !/e=netOffline/.test(aOwnerDoc.documentURI))
diff --git a/browser/base/jar.mn b/browser/base/jar.mn
index 42b56a91eb..f95fe4b462 100644
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -131,8 +131,3 @@ browser.jar:
# the following files are browser-specific overrides
* content/browser/license.html (/toolkit/content/license.html)
% override chrome://global/content/license.html chrome://browser/content/license.html
-#ifdef MOZ_SAFE_BROWSING
- content/browser/report-phishing-overlay.xul (content/report-phishing-overlay.xul)
- content/browser/blockedSite.xhtml (content/blockedSite.xhtml)
-% overlay chrome://browser/content/browser.xul chrome://browser/content/report-phishing-overlay.xul
-#endif
diff --git a/browser/components/about/AboutRedirector.cpp b/browser/components/about/AboutRedirector.cpp
index 88a8472922..d5effc7780 100644
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -33,12 +33,6 @@ struct RedirEntry {
URI_SAFE_FOR_UNTRUSTED_CONTENT.
*/
static RedirEntry kRedirMap[] = {
-#ifdef MOZ_SAFE_BROWSING
- { "blocked", "chrome://browser/content/blockedSite.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::ALLOW_SCRIPT |
- nsIAboutModule::HIDE_FROM_ABOUTABOUT },
-#endif
{ "certerror", "chrome://browser/content/certerror/aboutCertError.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT |
diff --git a/browser/components/build/nsModule.cpp b/browser/components/build/nsModule.cpp
index ed18dd74a6..d5b79b455d 100644
--- a/browser/components/build/nsModule.cpp
+++ b/browser/components/build/nsModule.cpp
@@ -85,9 +85,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
#endif
{ NS_FEEDSNIFFER_CONTRACTID, &kNS_FEEDSNIFFER_CID },
-#ifdef MOZ_SAFE_BROWSING
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "blocked", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-#endif
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "socialerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "feeds", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
diff --git a/browser/components/moz.build b/browser/components/moz.build
index bf1953766b..7514c7cd76 100644
--- a/browser/components/moz.build
+++ b/browser/components/moz.build
@@ -23,9 +23,6 @@ DIRS += [
if CONFIG['MOZ_BROWSER_SIDEBAR']:
DIRS += ['sidebar']
-if CONFIG['MOZ_SAFE_BROWSING']:
- DIRS += ['safebrowsing']
-
DIRS += ['build']
XPIDL_SOURCES += [
diff --git a/browser/components/preferences/security.xul b/browser/components/preferences/security.xul
index 1db96273c9..35a6e1b66e 100644
--- a/browser/components/preferences/security.xul
+++ b/browser/components/preferences/security.xul
@@ -66,18 +66,6 @@
accesskey="&addonExceptions.accesskey;"
oncommand="gSecurityPane.showAddonExceptions();"/>
-
-#ifdef MOZ_SAFE_BROWSING
-
-
-
-#endif
diff --git a/browser/components/safebrowsing/moz.build b/browser/components/safebrowsing/moz.build
deleted file mode 100644
index 8deb0b1382..0000000000
--- a/browser/components/safebrowsing/moz.build
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
index e617716a5e..5b4dce5414 100644
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -635,15 +635,6 @@
@RESPATH@/browser/modules/*
@RESPATH@/modules/*
-; Safe Browsing
-#ifdef MOZ_URL_CLASSIFIER
-@RESPATH@/components/nsURLClassifier.manifest
-@RESPATH@/components/nsUrlClassifierHashCompleter.js
-@RESPATH@/components/nsUrlClassifierListManager.js
-@RESPATH@/components/nsUrlClassifierLib.js
-@RESPATH@/components/url-classifier.xpt
-#endif
-
; ANGLE GLES-on-D3D rendering library
#ifdef MOZ_ANGLE_RENDERER
@BINPATH@/libEGL.dll
diff --git a/browser/locales/en-US/chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd b/browser/locales/en-US/chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd
deleted file mode 100644
index eb8b71dc77..0000000000
--- a/browser/locales/en-US/chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
- has been reported as an attack page and has been blocked based on your security preferences.">
-Attack pages try to install programs that steal private information, use your computer to attack others, or damage your system.
Some attack pages intentionally distribute harmful software, but many are compromised without the knowledge or permission of their owners.
">
-
-
-
- has been reported as a web forgery and has been blocked based on your security preferences.">
-Web forgeries are designed to trick you into revealing personal or financial information by imitating sources you may trust.Entering any information on this web page may result in identity theft or other fraud.
">
diff --git a/browser/locales/en-US/chrome/browser/safebrowsing/report-phishing.dtd b/browser/locales/en-US/chrome/browser/safebrowsing/report-phishing.dtd
deleted file mode 100644
index 863e124545..0000000000
--- a/browser/locales/en-US/chrome/browser/safebrowsing/report-phishing.dtd
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/browser/locales/jar.mn b/browser/locales/jar.mn
index 9619653b8e..a6499c1f25 100644
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -101,10 +101,6 @@
locale/browser/places/bookmarkProperties.properties (%chrome/browser/places/bookmarkProperties.properties)
locale/browser/preferences/selectBookmark.dtd (%chrome/browser/preferences/selectBookmark.dtd)
locale/browser/places/moveBookmarks.dtd (%chrome/browser/places/moveBookmarks.dtd)
-#ifdef MOZ_SAFE_BROWSING
- locale/browser/safebrowsing/phishing-afterload-warning-message.dtd (%chrome/browser/safebrowsing/phishing-afterload-warning-message.dtd)
- locale/browser/safebrowsing/report-phishing.dtd (%chrome/browser/safebrowsing/report-phishing.dtd)
-#endif
locale/browser/feeds/subscribe.dtd (%chrome/browser/feeds/subscribe.dtd)
locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties)
locale/browser/migration/migration.dtd (%chrome/browser/migration/migration.dtd)
diff --git a/configure.in b/configure.in
index 34db266ec7..4fc500c68d 100644
--- a/configure.in
+++ b/configure.in
@@ -3895,14 +3895,12 @@ MOZ_SOCIAL=1
MOZ_PREF_EXTENSIONS=1
MOZ_PROFILELOCKING=1
MOZ_REFLOW_PERF=
-MOZ_SAFE_BROWSING=
MOZ_HELP_VIEWER=
MOZ_SPELLCHECK=1
MOZ_ANDROID_APZ=
MOZ_TOOLKIT_SEARCH=1
MOZ_UI_LOCALE=en-US
MOZ_UNIVERSALCHARDET=1
-MOZ_URL_CLASSIFIER=
MOZ_XUL=1
MOZ_ZIPWRITER=1
NS_PRINTING=1
@@ -6675,34 +6673,6 @@ if test -n "$MOZ_HELP_VIEWER"; then
AC_DEFINE(MOZ_HELP_VIEWER)
fi
-dnl ========================================================
-dnl = Enable safe browsing (anti-phishing)
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(safe-browsing,
-[ --enable-safe-browsing Enable safe browsing (anti-phishing) implementation],
- MOZ_SAFE_BROWSING=1,
- MOZ_SAFE_BROWSING= )
-if test -n "$MOZ_SAFE_BROWSING"; then
- AC_DEFINE(MOZ_SAFE_BROWSING)
-fi
-AC_SUBST(MOZ_SAFE_BROWSING)
-
-dnl ========================================================
-dnl = Enable url-classifier
-dnl ========================================================
-dnl Implicitly enabled by default if building with safe-browsing
-if test -n "$MOZ_SAFE_BROWSING"; then
- MOZ_URL_CLASSIFIER=1
-fi
-MOZ_ARG_ENABLE_BOOL(url-classifier,
-[ --enable-url-classifier Enable url classifier module],
- MOZ_URL_CLASSIFIER=1,
- MOZ_URL_CLASSIFIER= )
-if test -n "$MOZ_URL_CLASSIFIER"; then
- AC_DEFINE(MOZ_URL_CLASSIFIER)
-fi
-AC_SUBST(MOZ_URL_CLASSIFIER)
-
dnl ========================================================
dnl = Disable zipwriter
dnl ========================================================
diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js
index a848fb80ba..6b70aea847 100644
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -576,40 +576,6 @@ pref("shumway.disabled", true);
// enable touch events interfaces
pref("dom.w3c_touch_events.enabled", 1);
-#ifdef MOZ_SAFE_BROWSING
-pref("browser.safebrowsing.enabled", true);
-pref("browser.safebrowsing.malware.enabled", true);
-pref("browser.safebrowsing.debug", false);
-
-pref("browser.safebrowsing.updateURL", "https://safebrowsing.google.com/safebrowsing/downloads?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2&key=%GOOGLE_API_KEY%");
-pref("browser.safebrowsing.gethashURL", "https://safebrowsing.google.com/safebrowsing/gethash?client=SAFEBROWSING_ID&appver=%VERSION%&pver=2.2");
-pref("browser.safebrowsing.reportURL", "https://safebrowsing.google.com/safebrowsing/report?");
-pref("browser.safebrowsing.reportGenericURL", "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportErrorURL", "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportPhishURL", "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%");
-pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
-
-pref("browser.safebrowsing.malware.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
-
-pref("browser.safebrowsing.id", @MOZ_APP_UA_NAME@);
-
-// Name of the about: page contributed by safebrowsing to handle display of error
-// pages on phishing/malware hits. (bug 399233)
-pref("urlclassifier.alternate_error_page", "blocked");
-
-// The number of random entries to send with a gethash request.
-pref("urlclassifier.gethashnoise", 4);
-
-// Gethash timeout for Safebrowsing.
-pref("urlclassifier.gethash.timeout_ms", 5000);
-
-// If an urlclassifier table has not been updated in this number of seconds,
-// a gethash request will be forced to check that the result is still in
-// the database.
-pref("urlclassifier.max-complete-age", 2700);
-#endif
-
// URL for posting tiles metrics.
#ifdef RELEASE_BUILD
pref("browser.tiles.reportURL", "https://tiles.services.mozilla.com/v2/links/click");
diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js
index 70f12b7f37..fdb88062dc 100644
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -57,11 +57,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
-if (AppConstants.MOZ_SAFE_BROWSING) {
- XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
- "resource://gre/modules/SafeBrowsing.jsm");
-}
-
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
@@ -381,11 +376,6 @@ var BrowserApp = {
CastingApps.init();
DownloadNotifications.init();
- if (AppConstants.MOZ_SAFE_BROWSING) {
- // Bug 778855 - Perf regression if we do this here. To be addressed in bug 779008.
- SafeBrowsing.init();
- };
-
// Delay this a minute because there's no rush
setTimeout(() => {
BrowserApp.gmpInstallManager = new GMPInstallManager();
diff --git a/mobile/android/components/MobileComponents.manifest b/mobile/android/components/MobileComponents.manifest
index 9e33376a59..e2cb508104 100644
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -15,9 +15,6 @@ contract @mozilla.org/network/protocol/about;1?what=privatebrowsing {322ba47e-70
#ifdef MOZ_SERVICES_HEALTHREPORT
contract @mozilla.org/network/protocol/about;1?what=healthreport {322ba47e-7047-4f71-aebf-cb7d69325cd9}
#endif
-#ifdef MOZ_SAFE_BROWSING
-contract @mozilla.org/network/protocol/about;1?what=blocked {322ba47e-7047-4f71-aebf-cb7d69325cd9}
-#endif
#ifdef MOZ_DEVICES
contract @mozilla.org/network/protocol/about;1?what=devices {322ba47e-7047-4f71-aebf-cb7d69325cd9}
#endif
diff --git a/mobile/android/confvars.sh b/mobile/android/confvars.sh
index 85de36d794..003f340ba5 100755
--- a/mobile/android/confvars.sh
+++ b/mobile/android/confvars.sh
@@ -16,8 +16,6 @@ MOZ_OFFICIAL_BRANDING_DIRECTORY=mobile/android/branding/official
# See the --enable-android-min-sdk and --enable-android-max-sdk arguments in configure.in.
MOZ_ANDROID_MIN_SDK_VERSION=9
-MOZ_SAFE_BROWSING=1
-
MOZ_NO_SMART_CARDS=1
# Enable getUserMedia
diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in
index ae9e77b422..e8bf5cae62 100644
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -457,15 +457,6 @@
; Modules
@BINPATH@/modules/*
-#ifdef MOZ_SAFE_BROWSING
-; Safe Browsing
-@BINPATH@/components/nsURLClassifier.manifest
-@BINPATH@/components/nsUrlClassifierHashCompleter.js
-@BINPATH@/components/nsUrlClassifierListManager.js
-@BINPATH@/components/nsUrlClassifierLib.js
-@BINPATH@/components/url-classifier.xpt
-#endif
-
; GNOME hooks
#ifdef MOZ_ENABLE_GNOME_COMPONENT
@BINPATH@/components/@DLL_PREFIX@mozgnome@DLL_SUFFIX@
@@ -606,9 +597,6 @@ bin/libfreebl_32int64_3.so
@BINPATH@/components/PaymentsUI.js
@BINPATH@/components/PaymentProviderStrategy.js
-#ifdef MOZ_SAFE_BROWSING
-@BINPATH@/components/SafeBrowsing.jsm
-#endif
@BINPATH@/components/XPIDialogService.js
@BINPATH@/components/browsercomps.xpt
diff --git a/mobile/android/modules/AppConstants.jsm b/mobile/android/modules/AppConstants.jsm
index 903e75725e..5524e00599 100644
--- a/mobile/android/modules/AppConstants.jsm
+++ b/mobile/android/modules/AppConstants.jsm
@@ -63,13 +63,6 @@ let AppConstants = Object.freeze({
false,
#endif
- MOZ_SAFE_BROWSING:
-#ifdef MOZ_SAFE_BROWSING
- true,
-#else
- false,
-#endif
-
MOZ_TELEMETRY_REPORTING:
#ifdef MOZ_TELEMETRY_REPORTING
true,
diff --git a/mobile/android/modules/moz.build b/mobile/android/modules/moz.build
index 1a69369f07..c0437db14f 100644
--- a/mobile/android/modules/moz.build
+++ b/mobile/android/modules/moz.build
@@ -36,8 +36,7 @@ for var in ('ANDROID_PACKAGE_NAME', 'MOZ_APP_VERSION'):
for var in ('NIGHTLY_BUILD', 'RELEASE_BUILD', 'ACCESSIBILITY',
'MOZILLA_OFFICIAL', 'MOZ_OFFICIAL_BRANDING', 'MOZ_SERVICES_HEALTHREPORT',
- 'MOZ_DEVICES', 'MOZ_DEVICES', 'MOZ_SAFE_BROWSING',
- 'MOZ_TELEMETRY_REPORTING', 'MOZ_WEBRTC'):
+ 'MOZ_DEVICES', 'MOZ_DEVICES', 'MOZ_TELEMETRY_REPORTING', 'MOZ_WEBRTC'):
if CONFIG[var]:
DEFINES[var] = 1
diff --git a/toolkit/components/build/moz.build b/toolkit/components/build/moz.build
index 4998edc865..57f7272e7d 100644
--- a/toolkit/components/build/moz.build
+++ b/toolkit/components/build/moz.build
@@ -25,7 +25,6 @@ LOCAL_INCLUDES += [
'../startup',
'../statusfilter',
'../typeaheadfind',
- '../url-classifier',
]
if not CONFIG['MOZ_DISABLE_PARENTAL_CONTROLS']:
diff --git a/toolkit/components/build/nsToolkitCompsModule.cpp b/toolkit/components/build/nsToolkitCompsModule.cpp
index 6c3f36fe3a..9988bbcda1 100644
--- a/toolkit/components/build/nsToolkitCompsModule.cpp
+++ b/toolkit/components/build/nsToolkitCompsModule.cpp
@@ -24,14 +24,6 @@
#include "nsTypeAheadFind.h"
-#ifdef MOZ_URL_CLASSIFIER
-#include "ApplicationReputation.h"
-#include "nsUrlClassifierDBService.h"
-#include "nsUrlClassifierStreamUpdater.h"
-#include "nsUrlClassifierUtils.h"
-#include "nsUrlClassifierPrefixSet.h"
-#endif
-
#include "nsBrowserStatusFilter.h"
#include "mozilla/FinalizationWitnessService.h"
#include "mozilla/NativeOSFileInternals.h"
@@ -77,33 +69,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadProxy)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTypeAheadFind)
-#ifdef MOZ_URL_CLASSIFIER
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ApplicationReputationService,
- ApplicationReputationService::GetSingleton)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierPrefixSet)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsUrlClassifierStreamUpdater)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUrlClassifierUtils, Init)
-
-static nsresult
-nsUrlClassifierDBServiceConstructor(nsISupports *aOuter, REFNSIID aIID,
- void **aResult)
-{
- nsresult rv;
- NS_ENSURE_ARG_POINTER(aResult);
- NS_ENSURE_NO_AGGREGATION(aOuter);
-
- nsUrlClassifierDBService *inst = nsUrlClassifierDBService::GetInstance(&rv);
- if (nullptr == inst) {
- return rv;
- }
- /* NS_ADDREF(inst); */
- rv = inst->QueryInterface(aIID, aResult);
- NS_RELEASE(inst);
-
- return rv;
-}
-#endif
-
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
#if defined(USE_MOZ_UPDATER)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUpdateProcessor)
@@ -128,13 +93,6 @@ NS_DEFINE_NAMED_CID(NS_DOWNLOADPLATFORM_CID);
NS_DEFINE_NAMED_CID(NS_DOWNLOAD_CID);
NS_DEFINE_NAMED_CID(NS_FIND_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_TYPEAHEADFIND_CID);
-#ifdef MOZ_URL_CLASSIFIER
-NS_DEFINE_NAMED_CID(NS_APPLICATION_REPUTATION_SERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERPREFIXSET_CID);
-NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERDBSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERSTREAMUPDATER_CID);
-NS_DEFINE_NAMED_CID(NS_URLCLASSIFIERUTILS_CID);
-#endif
NS_DEFINE_NAMED_CID(NS_BROWSERSTATUSFILTER_CID);
#if defined(USE_MOZ_UPDATER)
NS_DEFINE_NAMED_CID(NS_UPDATEPROCESSOR_CID);
@@ -159,13 +117,6 @@ static const Module::CIDEntry kToolkitCIDs[] = {
{ &kNS_DOWNLOAD_CID, false, nullptr, nsDownloadProxyConstructor },
{ &kNS_FIND_SERVICE_CID, false, nullptr, nsFindServiceConstructor },
{ &kNS_TYPEAHEADFIND_CID, false, nullptr, nsTypeAheadFindConstructor },
-#ifdef MOZ_URL_CLASSIFIER
- { &kNS_APPLICATION_REPUTATION_SERVICE_CID, false, nullptr, ApplicationReputationServiceConstructor },
- { &kNS_URLCLASSIFIERPREFIXSET_CID, false, nullptr, nsUrlClassifierPrefixSetConstructor },
- { &kNS_URLCLASSIFIERDBSERVICE_CID, false, nullptr, nsUrlClassifierDBServiceConstructor },
- { &kNS_URLCLASSIFIERSTREAMUPDATER_CID, false, nullptr, nsUrlClassifierStreamUpdaterConstructor },
- { &kNS_URLCLASSIFIERUTILS_CID, false, nullptr, nsUrlClassifierUtilsConstructor },
-#endif
{ &kNS_BROWSERSTATUSFILTER_CID, false, nullptr, nsBrowserStatusFilterConstructor },
#if defined(USE_MOZ_UPDATER)
{ &kNS_UPDATEPROCESSOR_CID, false, nullptr, nsUpdateProcessorConstructor },
@@ -191,14 +142,6 @@ static const Module::ContractIDEntry kToolkitContracts[] = {
{ NS_DOWNLOADPLATFORM_CONTRACTID, &kNS_DOWNLOADPLATFORM_CID },
{ NS_FIND_SERVICE_CONTRACTID, &kNS_FIND_SERVICE_CID },
{ NS_TYPEAHEADFIND_CONTRACTID, &kNS_TYPEAHEADFIND_CID },
-#ifdef MOZ_URL_CLASSIFIER
- { NS_APPLICATION_REPUTATION_SERVICE_CONTRACTID, &kNS_APPLICATION_REPUTATION_SERVICE_CID },
- { NS_URLCLASSIFIERPREFIXSET_CONTRACTID, &kNS_URLCLASSIFIERPREFIXSET_CID },
- { NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID },
- { NS_URICLASSIFIERSERVICE_CONTRACTID, &kNS_URLCLASSIFIERDBSERVICE_CID },
- { NS_URLCLASSIFIERSTREAMUPDATER_CONTRACTID, &kNS_URLCLASSIFIERSTREAMUPDATER_CID },
- { NS_URLCLASSIFIERUTILS_CONTRACTID, &kNS_URLCLASSIFIERUTILS_CID },
-#endif
{ NS_BROWSERSTATUSFILTER_CONTRACTID, &kNS_BROWSERSTATUSFILTER_CID },
#if defined(USE_MOZ_UPDATER)
{ NS_UPDATEPROCESSOR_CONTRACTID, &kNS_UPDATEPROCESSOR_CID },
diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp
deleted file mode 100644
index cb8c85ae57..0000000000
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ /dev/null
@@ -1,1125 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// See
-// https://wiki.mozilla.org/Security/Features/Application_Reputation_Design_Doc
-// for a description of Chrome's implementation of this feature.
-#include "ApplicationReputation.h"
-#include "csd.pb.h"
-
-#include "nsIArray.h"
-#include "nsIApplicationReputation.h"
-#include "nsIChannel.h"
-#include "nsIHttpChannel.h"
-#include "nsIIOService.h"
-#include "nsIPrefService.h"
-#include "nsIScriptSecurityManager.h"
-#include "nsIStreamListener.h"
-#include "nsIStringStream.h"
-#include "nsIUploadChannel2.h"
-#include "nsIURI.h"
-#include "nsIUrlClassifierDBService.h"
-#include "nsIX509Cert.h"
-#include "nsIX509CertDB.h"
-#include "nsIX509CertList.h"
-
-#include "mozilla/Preferences.h"
-#include "mozilla/Services.h"
-#include "mozilla/Telemetry.h"
-#include "mozilla/TimeStamp.h"
-#include "mozilla/LoadContext.h"
-
-#include "nsAutoPtr.h"
-#include "nsCOMPtr.h"
-#include "nsDebug.h"
-#include "nsError.h"
-#include "nsNetCID.h"
-#include "nsReadableUtils.h"
-#include "nsServiceManagerUtils.h"
-#include "nsString.h"
-#include "nsTArray.h"
-#include "nsThreadUtils.h"
-#include "nsXPCOMStrings.h"
-
-#include "nsIContentPolicy.h"
-#include "nsILoadInfo.h"
-#include "nsContentUtils.h"
-
-using mozilla::Preferences;
-using mozilla::TimeStamp;
-using mozilla::Telemetry::Accumulate;
-using safe_browsing::ClientDownloadRequest;
-using safe_browsing::ClientDownloadRequest_CertificateChain;
-using safe_browsing::ClientDownloadRequest_Resource;
-using safe_browsing::ClientDownloadRequest_SignatureInfo;
-
-// Preferences that we need to initialize the query.
-#define PREF_SB_APP_REP_URL "browser.safebrowsing.appRepURL"
-#define PREF_SB_MALWARE_ENABLED "browser.safebrowsing.malware.enabled"
-#define PREF_SB_DOWNLOADS_ENABLED "browser.safebrowsing.downloads.enabled"
-#define PREF_SB_DOWNLOADS_REMOTE_ENABLED "browser.safebrowsing.downloads.remote.enabled"
-#define PREF_GENERAL_LOCALE "general.useragent.locale"
-#define PREF_DOWNLOAD_BLOCK_TABLE "urlclassifier.downloadBlockTable"
-#define PREF_DOWNLOAD_ALLOW_TABLE "urlclassifier.downloadAllowTable"
-
-// NSPR_LOG_MODULES=ApplicationReputation:5
-#if defined(PR_LOGGING)
-PRLogModuleInfo *ApplicationReputationService::prlog = nullptr;
-#define LOG(args) PR_LOG(ApplicationReputationService::prlog, PR_LOG_DEBUG, args)
-#define LOG_ENABLED() PR_LOG_TEST(ApplicationReputationService::prlog, 4)
-#else
-#define LOG(args)
-#define LOG_ENABLED() (false)
-#endif
-
-class PendingDBLookup;
-
-// A single use class private to ApplicationReputationService encapsulating an
-// nsIApplicationReputationQuery and an nsIApplicationReputationCallback. Once
-// created by ApplicationReputationService, it is guaranteed to call mCallback.
-// This class is private to ApplicationReputationService.
-class PendingLookup final : public nsIStreamListener
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIREQUESTOBSERVER
- NS_DECL_NSISTREAMLISTENER
-
- // Constructor and destructor.
- PendingLookup(nsIApplicationReputationQuery* aQuery,
- nsIApplicationReputationCallback* aCallback);
-
- // Start the lookup. The lookup may have 2 parts: local and remote. In the
- // local lookup, PendingDBLookups are created to query the local allow and
- // blocklists for various URIs associated with this downloaded file. In the
- // event that no results are found, a remote lookup is sent to the Application
- // Reputation server.
- nsresult StartLookup();
-
-private:
- ~PendingLookup();
-
- friend class PendingDBLookup;
-
- // Telemetry states.
- // Status of the remote response (valid or not).
- enum SERVER_RESPONSE_TYPES {
- SERVER_RESPONSE_VALID = 0,
- SERVER_RESPONSE_FAILED = 1,
- SERVER_RESPONSE_INVALID = 2,
- };
-
- // Number of blocklist and allowlist hits we have seen.
- uint32_t mBlocklistCount;
- uint32_t mAllowlistCount;
-
- // The query containing metadata about the downloaded file.
- nsCOMPtr mQuery;
-
- // The callback with which to report the verdict.
- nsCOMPtr mCallback;
-
- // An array of strings created from certificate information used to whitelist
- // the downloaded file.
- nsTArray mAllowlistSpecs;
- // The source URI of the download, the referrer and possibly any redirects.
- nsTArray mAnylistSpecs;
-
- // When we started this query
- TimeStamp mStartTime;
-
- // A protocol buffer for storing things we need in the remote request. We
- // store the resource chain (redirect information) as well as signature
- // information extracted using the Windows Authenticode API, if the binary is
- // signed.
- ClientDownloadRequest mRequest;
-
- // The response from the application reputation query. This is read in chunks
- // as part of our nsIStreamListener implementation and may contain embedded
- // NULLs.
- nsCString mResponse;
-
- // Returns true if the file is likely to be binary on Windows.
- bool IsBinaryFile();
-
- // Clean up and call the callback. PendingLookup must not be used after this
- // function is called.
- nsresult OnComplete(bool shouldBlock, nsresult rv);
-
- // Wrapper function for nsIStreamListener.onStopRequest to make it easy to
- // guarantee calling the callback
- nsresult OnStopRequestInternal(nsIRequest *aRequest,
- nsISupports *aContext,
- nsresult aResult,
- bool* aShouldBlock);
-
- // Strip url parameters, fragments, and user@pass fields from the URI spec
- // using nsIURL. If aURI is not an nsIURL, returns the original nsIURI.spec.
- nsresult GetStrippedSpec(nsIURI* aUri, nsACString& spec);
-
- // Escape '/' and '%' in certificate attribute values.
- nsCString EscapeCertificateAttribute(const nsACString& aAttribute);
-
- // Escape ':' in fingerprint values.
- nsCString EscapeFingerprint(const nsACString& aAttribute);
-
- // Generate whitelist strings for the given certificate pair from the same
- // certificate chain.
- nsresult GenerateWhitelistStringsForPair(
- nsIX509Cert* certificate, nsIX509Cert* issuer);
-
- // Generate whitelist strings for the given certificate chain, which starts
- // with the signer and may go all the way to the root cert.
- nsresult GenerateWhitelistStringsForChain(
- const ClientDownloadRequest_CertificateChain& aChain);
-
- // For signed binaries, generate strings of the form:
- // http://sb-ssl.google.com/safebrowsing/csd/certificate/
- // [/CN=][/O=][/OU=]
- // for each (cert, issuer) pair in each chain of certificates that is
- // associated with the binary.
- nsresult GenerateWhitelistStrings();
-
- // Parse the XPCOM certificate lists and stick them into the protocol buffer
- // version.
- nsresult ParseCertificates(nsIArray* aSigArray);
-
- // Adds the redirects to mAnylistSpecs to be looked up.
- nsresult AddRedirects(nsIArray* aRedirects);
-
- // Helper function to ensure that we call PendingLookup::LookupNext or
- // PendingLookup::OnComplete.
- nsresult DoLookupInternal();
-
- // Looks up all the URIs that may be responsible for allowlisting or
- // blocklisting the downloaded file. These URIs may include whitelist strings
- // generated by certificates verifying the binary as well as the target URI
- // from which the file was downloaded.
- nsresult LookupNext();
-
- // Sends a query to the remote application reputation service. Returns NS_OK
- // on success.
- nsresult SendRemoteQuery();
-
- // Helper function to ensure that we always call the callback.
- nsresult SendRemoteQueryInternal();
-};
-
-// A single-use class for looking up a single URI in the safebrowsing DB. This
-// class is private to PendingLookup.
-class PendingDBLookup final : public nsIUrlClassifierCallback
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIURLCLASSIFIERCALLBACK
-
- // Constructor and destructor
- explicit PendingDBLookup(PendingLookup* aPendingLookup);
-
- // Look up the given URI in the safebrowsing DBs, optionally on both the allow
- // list and the blocklist. If there is a match, call
- // PendingLookup::OnComplete. Otherwise, call PendingLookup::LookupNext.
- nsresult LookupSpec(const nsACString& aSpec, bool aAllowlistOnly);
-
-private:
- ~PendingDBLookup();
-
- // The download appeared on the allowlist, blocklist, or no list (and thus
- // could trigger a remote query.
- enum LIST_TYPES {
- ALLOW_LIST = 0,
- BLOCK_LIST = 1,
- NO_LIST = 2,
- };
-
- nsCString mSpec;
- bool mAllowlistOnly;
- nsRefPtr mPendingLookup;
- nsresult LookupSpecInternal(const nsACString& aSpec);
-};
-
-NS_IMPL_ISUPPORTS(PendingDBLookup,
- nsIUrlClassifierCallback)
-
-PendingDBLookup::PendingDBLookup(PendingLookup* aPendingLookup) :
- mAllowlistOnly(false),
- mPendingLookup(aPendingLookup)
-{
- LOG(("Created pending DB lookup [this = %p]", this));
-}
-
-PendingDBLookup::~PendingDBLookup()
-{
- LOG(("Destroying pending DB lookup [this = %p]", this));
- mPendingLookup = nullptr;
-}
-
-nsresult
-PendingDBLookup::LookupSpec(const nsACString& aSpec,
- bool aAllowlistOnly)
-{
- LOG(("Checking principal %s [this=%p]", aSpec.Data(), this));
- mSpec = aSpec;
- mAllowlistOnly = aAllowlistOnly;
- nsresult rv = LookupSpecInternal(aSpec);
- if (NS_FAILED(rv)) {
- LOG(("Error in LookupSpecInternal"));
- return mPendingLookup->OnComplete(false, NS_OK);
- }
- // LookupSpecInternal has called nsIUrlClassifierCallback.lookup, which is
- // guaranteed to call HandleEvent.
- return rv;
-}
-
-nsresult
-PendingDBLookup::LookupSpecInternal(const nsACString& aSpec)
-{
- nsresult rv;
-
- nsCOMPtr uri;
- nsCOMPtr ios = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
- rv = ios->NewURI(aSpec, nullptr, nullptr, getter_AddRefs(uri));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr principal;
- nsCOMPtr secMan =
- do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = secMan->GetNoAppCodebasePrincipal(uri, getter_AddRefs(principal));
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Check local lists to see if the URI has already been whitelisted or
- // blacklisted.
- LOG(("Checking DB service for principal %s [this = %p]", mSpec.get(), this));
- nsCOMPtr dbService =
- do_GetService(NS_URLCLASSIFIERDBSERVICE_CONTRACTID, &rv);
- nsAutoCString tables;
- nsAutoCString allowlist;
- Preferences::GetCString(PREF_DOWNLOAD_ALLOW_TABLE, &allowlist);
- if (!allowlist.IsEmpty()) {
- tables.Append(allowlist);
- }
- nsAutoCString blocklist;
- Preferences::GetCString(PREF_DOWNLOAD_BLOCK_TABLE, &blocklist);
- if (!mAllowlistOnly && !blocklist.IsEmpty()) {
- tables.Append(',');
- tables.Append(blocklist);
- }
- return dbService->Lookup(principal, tables, this);
-}
-
-NS_IMETHODIMP
-PendingDBLookup::HandleEvent(const nsACString& tables)
-{
- // HandleEvent is guaranteed to call either:
- // 1) PendingLookup::OnComplete if the URL matches the blocklist, or
- // 2) PendingLookup::LookupNext if the URL does not match the blocklist.
- // Blocklisting trumps allowlisting.
- nsAutoCString blockList;
- Preferences::GetCString(PREF_DOWNLOAD_BLOCK_TABLE, &blockList);
- if (!mAllowlistOnly && FindInReadable(blockList, tables)) {
- mPendingLookup->mBlocklistCount++;
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_LOCAL, BLOCK_LIST);
- LOG(("Found principal %s on blocklist [this = %p]", mSpec.get(), this));
- return mPendingLookup->OnComplete(true, NS_OK);
- }
-
- nsAutoCString allowList;
- Preferences::GetCString(PREF_DOWNLOAD_ALLOW_TABLE, &allowList);
- if (FindInReadable(allowList, tables)) {
- mPendingLookup->mAllowlistCount++;
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_LOCAL, ALLOW_LIST);
- LOG(("Found principal %s on allowlist [this = %p]", mSpec.get(), this));
- // Don't call onComplete, since blocklisting trumps allowlisting
- } else {
- LOG(("Didn't find principal %s on any list [this = %p]", mSpec.get(),
- this));
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_LOCAL, NO_LIST);
- }
- return mPendingLookup->LookupNext();
-}
-
-NS_IMPL_ISUPPORTS(PendingLookup,
- nsIStreamListener,
- nsIRequestObserver)
-
-PendingLookup::PendingLookup(nsIApplicationReputationQuery* aQuery,
- nsIApplicationReputationCallback* aCallback) :
- mBlocklistCount(0),
- mAllowlistCount(0),
- mQuery(aQuery),
- mCallback(aCallback)
-{
- LOG(("Created pending lookup [this = %p]", this));
-}
-
-PendingLookup::~PendingLookup()
-{
- LOG(("Destroying pending lookup [this = %p]", this));
-}
-
-bool
-PendingLookup::IsBinaryFile()
-{
- nsString fileName;
- nsresult rv = mQuery->GetSuggestedFileName(fileName);
- if (NS_FAILED(rv)) {
- LOG(("No suggested filename [this = %p]", this));
- return false;
- }
- LOG(("Suggested filename: %s [this = %p]",
- NS_ConvertUTF16toUTF8(fileName).get(), this));
- return
- // Executable extensions for MS Windows, from
- // https://code.google.com/p/chromium/codesearch#chromium/src/chrome/common/safe_browsing/download_protection_util.cc&l=14
- StringEndsWith(fileName, NS_LITERAL_STRING(".apk")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".bas")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".bat")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".cab")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".cmd")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".com")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".exe")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".hta")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".msi")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".pif")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".reg")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".scr")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".vb")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".vbs")) ||
- StringEndsWith(fileName, NS_LITERAL_STRING(".zip"));
-}
-
-nsresult
-PendingLookup::LookupNext()
-{
- // We must call LookupNext or SendRemoteQuery upon return.
- // Look up all of the URLs that could allow or block this download.
- // Blocklist first.
- if (mBlocklistCount > 0) {
- return OnComplete(true, NS_OK);
- }
- int index = mAnylistSpecs.Length() - 1;
- nsCString spec;
- if (index >= 0) {
- // Check the source URI, referrer and redirect chain.
- spec = mAnylistSpecs[index];
- mAnylistSpecs.RemoveElementAt(index);
- nsRefPtr lookup(new PendingDBLookup(this));
- return lookup->LookupSpec(spec, false);
- }
- // If any of mAnylistSpecs matched the blocklist, go ahead and block.
- if (mBlocklistCount > 0) {
- return OnComplete(true, NS_OK);
- }
- // If any of mAnylistSpecs matched the allowlist, go ahead and pass.
- if (mAllowlistCount > 0) {
- return OnComplete(false, NS_OK);
- }
- // Only binary signatures remain.
- index = mAllowlistSpecs.Length() - 1;
- if (index >= 0) {
- spec = mAllowlistSpecs[index];
- LOG(("PendingLookup::LookupNext: checking %s on allowlist", spec.get()));
- mAllowlistSpecs.RemoveElementAt(index);
- nsRefPtr lookup(new PendingDBLookup(this));
- return lookup->LookupSpec(spec, true);
- }
-#ifdef XP_WIN
- // There are no more URIs to check against local list. If the file is
- // not eligible for remote lookup, bail.
- if (!IsBinaryFile()) {
- LOG(("Not eligible for remote lookups [this=%x]", this));
- return OnComplete(false, NS_OK);
- }
- // Send the remote query if we are on Windows.
- nsresult rv = SendRemoteQuery();
- if (NS_FAILED(rv)) {
- return OnComplete(false, rv);
- }
- return NS_OK;
-#else
- LOG(("PendingLookup: Nothing left to check [this=%p]", this));
- return OnComplete(false, NS_OK);
-#endif
-}
-
-nsCString
-PendingLookup::EscapeCertificateAttribute(const nsACString& aAttribute)
-{
- // Escape '/' because it's a field separator, and '%' because Chrome does
- nsCString escaped;
- escaped.SetCapacity(aAttribute.Length());
- for (unsigned int i = 0; i < aAttribute.Length(); ++i) {
- if (aAttribute.Data()[i] == '%') {
- escaped.AppendLiteral("%25");
- } else if (aAttribute.Data()[i] == '/') {
- escaped.AppendLiteral("%2F");
- } else if (aAttribute.Data()[i] == ' ') {
- escaped.AppendLiteral("%20");
- } else {
- escaped.Append(aAttribute.Data()[i]);
- }
- }
- return escaped;
-}
-
-nsCString
-PendingLookup::EscapeFingerprint(const nsACString& aFingerprint)
-{
- // Google's fingerprint doesn't have colons
- nsCString escaped;
- escaped.SetCapacity(aFingerprint.Length());
- for (unsigned int i = 0; i < aFingerprint.Length(); ++i) {
- if (aFingerprint.Data()[i] != ':') {
- escaped.Append(aFingerprint.Data()[i]);
- }
- }
- return escaped;
-}
-
-nsresult
-PendingLookup::GenerateWhitelistStringsForPair(
- nsIX509Cert* certificate,
- nsIX509Cert* issuer)
-{
- // The whitelist paths have format:
- // http://sb-ssl.google.com/safebrowsing/csd/certificate/[/CN=][/O=][/OU=]
- // Any of CN, O, or OU may be omitted from the whitelist entry. Unfortunately
- // this is not publicly documented, but the Chrome implementation can be found
- // here:
- // https://code.google.com/p/chromium/codesearch#search/&q=GetCertificateWhitelistStrings
- nsCString whitelistString(
- "http://sb-ssl.google.com/safebrowsing/csd/certificate/");
-
- nsString fingerprint;
- nsresult rv = issuer->GetSha1Fingerprint(fingerprint);
- NS_ENSURE_SUCCESS(rv, rv);
- whitelistString.Append(
- EscapeFingerprint(NS_ConvertUTF16toUTF8(fingerprint)));
-
- nsString commonName;
- rv = certificate->GetCommonName(commonName);
- NS_ENSURE_SUCCESS(rv, rv);
- if (!commonName.IsEmpty()) {
- whitelistString.AppendLiteral("/CN=");
- whitelistString.Append(
- EscapeCertificateAttribute(NS_ConvertUTF16toUTF8(commonName)));
- }
-
- nsString organization;
- rv = certificate->GetOrganization(organization);
- NS_ENSURE_SUCCESS(rv, rv);
- if (!organization.IsEmpty()) {
- whitelistString.AppendLiteral("/O=");
- whitelistString.Append(
- EscapeCertificateAttribute(NS_ConvertUTF16toUTF8(organization)));
- }
-
- nsString organizationalUnit;
- rv = certificate->GetOrganizationalUnit(organizationalUnit);
- NS_ENSURE_SUCCESS(rv, rv);
- if (!organizationalUnit.IsEmpty()) {
- whitelistString.AppendLiteral("/OU=");
- whitelistString.Append(
- EscapeCertificateAttribute(NS_ConvertUTF16toUTF8(organizationalUnit)));
- }
- LOG(("Whitelisting %s", whitelistString.get()));
-
- mAllowlistSpecs.AppendElement(whitelistString);
- return NS_OK;
-}
-
-nsresult
-PendingLookup::GenerateWhitelistStringsForChain(
- const safe_browsing::ClientDownloadRequest_CertificateChain& aChain)
-{
- // We need a signing certificate and an issuer to construct a whitelist
- // entry.
- if (aChain.element_size() < 2) {
- return NS_OK;
- }
-
- // Get the signer.
- nsresult rv;
- nsCOMPtr certDB = do_GetService(NS_X509CERTDB_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr signer;
- rv = certDB->ConstructX509(
- const_cast(aChain.element(0).certificate().data()),
- aChain.element(0).certificate().size(), getter_AddRefs(signer));
- NS_ENSURE_SUCCESS(rv, rv);
-
- for (int i = 1; i < aChain.element_size(); ++i) {
- // Get the issuer.
- nsCOMPtr issuer;
- rv = certDB->ConstructX509(
- const_cast(aChain.element(i).certificate().data()),
- aChain.element(i).certificate().size(), getter_AddRefs(issuer));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsresult rv = GenerateWhitelistStringsForPair(signer, issuer);
- NS_ENSURE_SUCCESS(rv, rv);
- }
- return NS_OK;
-}
-
-nsresult
-PendingLookup::GenerateWhitelistStrings()
-{
- for (int i = 0; i < mRequest.signature().certificate_chain_size(); ++i) {
- nsresult rv = GenerateWhitelistStringsForChain(
- mRequest.signature().certificate_chain(i));
- NS_ENSURE_SUCCESS(rv, rv);
- }
- return NS_OK;
-}
-
-nsresult
-PendingLookup::AddRedirects(nsIArray* aRedirects)
-{
- uint32_t length = 0;
- aRedirects->GetLength(&length);
- LOG(("ApplicationReputation: Got %u redirects", length));
- nsCOMPtr iter;
- nsresult rv = aRedirects->Enumerate(getter_AddRefs(iter));
- NS_ENSURE_SUCCESS(rv, rv);
-
- bool hasMoreRedirects = false;
- rv = iter->HasMoreElements(&hasMoreRedirects);
- NS_ENSURE_SUCCESS(rv, rv);
-
- while (hasMoreRedirects) {
- nsCOMPtr supports;
- rv = iter->GetNext(getter_AddRefs(supports));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr principal = do_QueryInterface(supports, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr uri;
- rv = principal->GetURI(getter_AddRefs(uri));
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Add the spec to our list of local lookups. The most recent redirect is
- // the last element.
- nsCString spec;
- rv = GetStrippedSpec(uri, spec);
- NS_ENSURE_SUCCESS(rv, rv);
- mAnylistSpecs.AppendElement(spec);
- LOG(("ApplicationReputation: Appending redirect %s\n", spec.get()));
-
- // Store the redirect information in the remote request.
- ClientDownloadRequest_Resource* resource = mRequest.add_resources();
- resource->set_url(spec.get());
- resource->set_type(ClientDownloadRequest::DOWNLOAD_REDIRECT);
-
- rv = iter->HasMoreElements(&hasMoreRedirects);
- NS_ENSURE_SUCCESS(rv, rv);
- }
- return NS_OK;
-}
-
-nsresult
-PendingLookup::StartLookup()
-{
- mStartTime = TimeStamp::Now();
- nsresult rv = DoLookupInternal();
- if (NS_FAILED(rv)) {
- return OnComplete(false, NS_OK);
- };
- return rv;
-}
-
-nsresult
-PendingLookup::GetStrippedSpec(nsIURI* aUri, nsACString& escaped)
-{
- // If aURI is not an nsIURL, we do not want to check the lists or send a
- // remote query.
- nsresult rv;
- nsCOMPtr url = do_QueryInterface(aUri, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = url->GetScheme(escaped);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCString temp;
- rv = url->GetHostPort(temp);
- NS_ENSURE_SUCCESS(rv, rv);
-
- escaped.Append("://");
- escaped.Append(temp);
-
- rv = url->GetFilePath(temp);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // nsIUrl.filePath starts with '/'
- escaped.Append(temp);
-
- return NS_OK;
-}
-
-nsresult
-PendingLookup::DoLookupInternal()
-{
- // We want to check the target URI, its referrer, and associated redirects
- // against the local lists.
- nsCOMPtr uri;
- nsresult rv = mQuery->GetSourceURI(getter_AddRefs(uri));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCString spec;
- rv = GetStrippedSpec(uri, spec);
- NS_ENSURE_SUCCESS(rv, rv);
-
- mAnylistSpecs.AppendElement(spec);
-
- ClientDownloadRequest_Resource* resource = mRequest.add_resources();
- resource->set_url(spec.get());
- resource->set_type(ClientDownloadRequest::DOWNLOAD_URL);
-
- nsCOMPtr referrer = nullptr;
- rv = mQuery->GetReferrerURI(getter_AddRefs(referrer));
- if (referrer) {
- nsCString spec;
- rv = GetStrippedSpec(referrer, spec);
- NS_ENSURE_SUCCESS(rv, rv);
- mAnylistSpecs.AppendElement(spec);
- resource->set_referrer(spec.get());
- }
- nsCOMPtr redirects;
- rv = mQuery->GetRedirects(getter_AddRefs(redirects));
- if (redirects) {
- AddRedirects(redirects);
- } else {
- LOG(("ApplicationReputation: Got no redirects [this=%p]", this));
- }
-
- // Extract the signature and parse certificates so we can use it to check
- // whitelists.
- nsCOMPtr sigArray;
- rv = mQuery->GetSignatureInfo(getter_AddRefs(sigArray));
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (sigArray) {
- rv = ParseCertificates(sigArray);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- rv = GenerateWhitelistStrings();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Start the call chain.
- return LookupNext();
-}
-
-nsresult
-PendingLookup::OnComplete(bool shouldBlock, nsresult rv)
-{
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SHOULD_BLOCK,
- shouldBlock);
-#if defined(PR_LOGGING)
- double t = (TimeStamp::Now() - mStartTime).ToMilliseconds();
-#endif
- if (shouldBlock) {
- LOG(("Application Reputation check failed, blocking bad binary in %f ms "
- "[this = %p]", t, this));
- } else {
- LOG(("Application Reputation check passed in %f ms [this = %p]", t, this));
- }
- nsresult res = mCallback->OnComplete(shouldBlock, rv);
- return res;
-}
-
-nsresult
-PendingLookup::ParseCertificates(nsIArray* aSigArray)
-{
- // If we haven't been set for any reason, bail.
- NS_ENSURE_ARG_POINTER(aSigArray);
-
- // Binaries may be signed by multiple chains of certificates. If there are no
- // chains, the binary is unsigned (or we were unable to extract signature
- // information on a non-Windows platform)
- nsCOMPtr chains;
- nsresult rv = aSigArray->Enumerate(getter_AddRefs(chains));
- NS_ENSURE_SUCCESS(rv, rv);
-
- bool hasMoreChains = false;
- rv = chains->HasMoreElements(&hasMoreChains);
- NS_ENSURE_SUCCESS(rv, rv);
-
- while (hasMoreChains) {
- nsCOMPtr supports;
- rv = chains->GetNext(getter_AddRefs(supports));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr certList = do_QueryInterface(supports, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- safe_browsing::ClientDownloadRequest_CertificateChain* certChain =
- mRequest.mutable_signature()->add_certificate_chain();
- nsCOMPtr chainElt;
- rv = certList->GetEnumerator(getter_AddRefs(chainElt));
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Each chain may have multiple certificates.
- bool hasMoreCerts = false;
- rv = chainElt->HasMoreElements(&hasMoreCerts);
- while (hasMoreCerts) {
- nsCOMPtr supports;
- rv = chainElt->GetNext(getter_AddRefs(supports));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr cert = do_QueryInterface(supports, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- uint8_t* data = nullptr;
- uint32_t len = 0;
- rv = cert->GetRawDER(&len, &data);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Add this certificate to the protobuf to send remotely.
- certChain->add_element()->set_certificate(data, len);
- nsMemory::Free(data);
-
- rv = chainElt->HasMoreElements(&hasMoreCerts);
- NS_ENSURE_SUCCESS(rv, rv);
- }
- rv = chains->HasMoreElements(&hasMoreChains);
- NS_ENSURE_SUCCESS(rv, rv);
- }
- if (mRequest.signature().certificate_chain_size() > 0) {
- mRequest.mutable_signature()->set_trusted(true);
- }
- return NS_OK;
-}
-
-nsresult
-PendingLookup::SendRemoteQuery()
-{
- nsresult rv = SendRemoteQueryInternal();
- if (NS_FAILED(rv)) {
- LOG(("Failed sending remote query for application reputation "
- "[this = %p]", this));
- return OnComplete(false, rv);
- }
- // SendRemoteQueryInternal has fired off the query and we call OnComplete in
- // the nsIStreamListener.onStopRequest.
- return rv;
-}
-
-nsresult
-PendingLookup::SendRemoteQueryInternal()
-{
- // If we aren't supposed to do remote lookups, bail.
- if (!Preferences::GetBool(PREF_SB_DOWNLOADS_REMOTE_ENABLED, false)) {
- return NS_ERROR_NOT_AVAILABLE;
- }
- // If the remote lookup URL is empty or absent, bail.
- nsCString serviceUrl;
- NS_ENSURE_SUCCESS(Preferences::GetCString(PREF_SB_APP_REP_URL, &serviceUrl),
- NS_ERROR_NOT_AVAILABLE);
- if (serviceUrl.EqualsLiteral("")) {
- return NS_ERROR_NOT_AVAILABLE;
- }
-
- // If the blocklist or allowlist is empty (so we couldn't do local lookups),
- // bail
- nsCString table;
- NS_ENSURE_SUCCESS(Preferences::GetCString(PREF_DOWNLOAD_BLOCK_TABLE, &table),
- NS_ERROR_NOT_AVAILABLE);
- if (table.EqualsLiteral("")) {
- return NS_ERROR_NOT_AVAILABLE;
- }
- NS_ENSURE_SUCCESS(Preferences::GetCString(PREF_DOWNLOAD_ALLOW_TABLE, &table),
- NS_ERROR_NOT_AVAILABLE);
- if (table.EqualsLiteral("")) {
- return NS_ERROR_NOT_AVAILABLE;
- }
-
- LOG(("Sending remote query for application reputation [this = %p]",
- this));
- // We did not find a local result, so fire off the query to the
- // application reputation service.
- nsCOMPtr uri;
- nsresult rv;
- rv = mQuery->GetSourceURI(getter_AddRefs(uri));
- NS_ENSURE_SUCCESS(rv, rv);
- nsCString spec;
- rv = GetStrippedSpec(uri, spec);
- NS_ENSURE_SUCCESS(rv, rv);
- mRequest.set_url(spec.get());
-
- uint32_t fileSize;
- rv = mQuery->GetFileSize(&fileSize);
- NS_ENSURE_SUCCESS(rv, rv);
- mRequest.set_length(fileSize);
- // We have no way of knowing whether or not a user initiated the
- // download. Set it to true to lessen the chance of false positives.
- mRequest.set_user_initiated(true);
-
- nsCString locale;
- NS_ENSURE_SUCCESS(Preferences::GetCString(PREF_GENERAL_LOCALE, &locale),
- NS_ERROR_NOT_AVAILABLE);
- mRequest.set_locale(locale.get());
- nsCString sha256Hash;
- rv = mQuery->GetSha256Hash(sha256Hash);
- NS_ENSURE_SUCCESS(rv, rv);
- mRequest.mutable_digests()->set_sha256(sha256Hash.Data());
- nsString fileName;
- rv = mQuery->GetSuggestedFileName(fileName);
- NS_ENSURE_SUCCESS(rv, rv);
- mRequest.set_file_basename(NS_ConvertUTF16toUTF8(fileName).get());
-
- if (mRequest.signature().trusted()) {
- LOG(("Got signed binary for remote application reputation check "
- "[this = %p]", this));
- } else {
- LOG(("Got unsigned binary for remote application reputation check "
- "[this = %p]", this));
- }
-
- // Serialize the protocol buffer to a string. This can only fail if we are
- // out of memory, or if the protocol buffer req is missing required fields
- // (only the URL for now).
- std::string serialized;
- if (!mRequest.SerializeToString(&serialized)) {
- return NS_ERROR_UNEXPECTED;
- }
-
- // Set the input stream to the serialized protocol buffer
- nsCOMPtr sstream =
- do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = sstream->SetData(serialized.c_str(), serialized.length());
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Set up the channel to transmit the request to the service.
- nsCOMPtr channel;
- nsCOMPtr ios = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
- rv = ios->NewChannel2(serviceUrl,
- nullptr,
- nullptr,
- nullptr, // aLoadingNode
- nsContentUtils::GetSystemPrincipal(),
- nullptr, // aTriggeringPrincipal
- nsILoadInfo::SEC_NORMAL,
- nsIContentPolicy::TYPE_OTHER,
- getter_AddRefs(channel));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr httpChannel(do_QueryInterface(channel, &rv));
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Upload the protobuf to the application reputation service.
- nsCOMPtr uploadChannel = do_QueryInterface(channel, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = uploadChannel->ExplicitSetUploadStream(sstream,
- NS_LITERAL_CSTRING("application/octet-stream"), serialized.size(),
- NS_LITERAL_CSTRING("POST"), false);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Set the Safebrowsing cookie jar, so that the regular Google cookie is not
- // sent with this request. See bug 897516.
- nsCOMPtr loadContext =
- new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID);
- rv = channel->SetNotificationCallbacks(loadContext);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = channel->AsyncOpen(this, nullptr);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//// nsIStreamListener
-static NS_METHOD
-AppendSegmentToString(nsIInputStream* inputStream,
- void *closure,
- const char *rawSegment,
- uint32_t toOffset,
- uint32_t count,
- uint32_t *writeCount) {
- nsAutoCString* decodedData = static_cast(closure);
- decodedData->Append(rawSegment, count);
- *writeCount = count;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-PendingLookup::OnDataAvailable(nsIRequest *aRequest,
- nsISupports *aContext,
- nsIInputStream *aStream,
- uint64_t offset,
- uint32_t count) {
- uint32_t read;
- return aStream->ReadSegments(AppendSegmentToString, &mResponse, count, &read);
-}
-
-NS_IMETHODIMP
-PendingLookup::OnStartRequest(nsIRequest *aRequest,
- nsISupports *aContext) {
- return NS_OK;
-}
-
-NS_IMETHODIMP
-PendingLookup::OnStopRequest(nsIRequest *aRequest,
- nsISupports *aContext,
- nsresult aResult) {
- NS_ENSURE_STATE(mCallback);
-
- bool shouldBlock = false;
- nsresult rv = OnStopRequestInternal(aRequest, aContext, aResult,
- &shouldBlock);
- OnComplete(shouldBlock, rv);
- return rv;
-}
-
-nsresult
-PendingLookup::OnStopRequestInternal(nsIRequest *aRequest,
- nsISupports *aContext,
- nsresult aResult,
- bool* aShouldBlock) {
- if (NS_FAILED(aResult)) {
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER,
- SERVER_RESPONSE_FAILED);
- return aResult;
- }
-
- *aShouldBlock = false;
- nsresult rv;
- nsCOMPtr channel = do_QueryInterface(aRequest, &rv);
- if (NS_FAILED(rv)) {
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER,
- SERVER_RESPONSE_FAILED);
- return rv;
- }
-
- uint32_t status = 0;
- rv = channel->GetResponseStatus(&status);
- if (NS_FAILED(rv)) {
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER,
- SERVER_RESPONSE_FAILED);
- return rv;
- }
-
- if (status != 200) {
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER,
- SERVER_RESPONSE_FAILED);
- return NS_ERROR_NOT_AVAILABLE;
- }
-
- std::string buf(mResponse.Data(), mResponse.Length());
- safe_browsing::ClientDownloadResponse response;
- if (!response.ParseFromString(buf)) {
- NS_WARNING("Could not parse protocol buffer");
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER,
- SERVER_RESPONSE_INVALID);
- return NS_ERROR_CANNOT_CONVERT_DATA;
- }
-
- // There are several more verdicts, but we only respect DANGEROUS and
- // DANGEROUS_HOST for now and treat everything else as SAFE.
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER,
- SERVER_RESPONSE_VALID);
- // Clamp responses 0-7, we only know about 0-4 for now.
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SERVER_VERDICT,
- std::min(response.verdict(), 7));
- switch(response.verdict()) {
- case safe_browsing::ClientDownloadResponse::DANGEROUS:
- case safe_browsing::ClientDownloadResponse::DANGEROUS_HOST:
- *aShouldBlock = true;
- break;
- default:
- break;
- }
-
- return NS_OK;
-}
-
-NS_IMPL_ISUPPORTS(ApplicationReputationService,
- nsIApplicationReputationService)
-
-ApplicationReputationService*
- ApplicationReputationService::gApplicationReputationService = nullptr;
-
-ApplicationReputationService*
-ApplicationReputationService::GetSingleton()
-{
- if (gApplicationReputationService) {
- NS_ADDREF(gApplicationReputationService);
- return gApplicationReputationService;
- }
-
- // We're not initialized yet.
- gApplicationReputationService = new ApplicationReputationService();
- if (gApplicationReputationService) {
- NS_ADDREF(gApplicationReputationService);
- }
-
- return gApplicationReputationService;
-}
-
-ApplicationReputationService::ApplicationReputationService()
-{
-#if defined(PR_LOGGING)
- if (!prlog) {
- prlog = PR_NewLogModule("ApplicationReputation");
- }
-#endif
- LOG(("Application reputation service started up"));
-}
-
-ApplicationReputationService::~ApplicationReputationService() {
- LOG(("Application reputation service shutting down"));
-}
-
-NS_IMETHODIMP
-ApplicationReputationService::QueryReputation(
- nsIApplicationReputationQuery* aQuery,
- nsIApplicationReputationCallback* aCallback) {
- LOG(("Starting application reputation check [query=%p]", aQuery));
- NS_ENSURE_ARG_POINTER(aQuery);
- NS_ENSURE_ARG_POINTER(aCallback);
-
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_COUNT, true);
- nsresult rv = QueryReputationInternal(aQuery, aCallback);
- if (NS_FAILED(rv)) {
- Accumulate(mozilla::Telemetry::APPLICATION_REPUTATION_SHOULD_BLOCK,
- false);
- aCallback->OnComplete(false, rv);
- }
- return NS_OK;
-}
-
-nsresult ApplicationReputationService::QueryReputationInternal(
- nsIApplicationReputationQuery* aQuery,
- nsIApplicationReputationCallback* aCallback) {
- nsresult rv;
- // If malware checks aren't enabled, don't query application reputation.
- if (!Preferences::GetBool(PREF_SB_MALWARE_ENABLED, false)) {
- return NS_ERROR_NOT_AVAILABLE;
- }
-
- if (!Preferences::GetBool(PREF_SB_DOWNLOADS_ENABLED, false)) {
- return NS_ERROR_NOT_AVAILABLE;
- }
-
- nsCOMPtr uri;
- rv = aQuery->GetSourceURI(getter_AddRefs(uri));
- NS_ENSURE_SUCCESS(rv, rv);
- // Bail if the URI hasn't been set.
- NS_ENSURE_STATE(uri);
-
- // Create a new pending lookup and start the call chain.
- nsRefPtr lookup(new PendingLookup(aQuery, aCallback));
- NS_ENSURE_STATE(lookup);
-
- return lookup->StartLookup();
-}
diff --git a/toolkit/components/downloads/ApplicationReputation.h b/toolkit/components/downloads/ApplicationReputation.h
deleted file mode 100644
index 7ae0208a6b..0000000000
--- a/toolkit/components/downloads/ApplicationReputation.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef ApplicationReputation_h__
-#define ApplicationReputation_h__
-
-#include "nsIApplicationReputation.h"
-#include "nsIRequestObserver.h"
-#include "nsIStreamListener.h"
-#include "nsISupports.h"
-
-#include "nsCOMPtr.h"
-#include "nsString.h"
-
-class nsIRequest;
-class PendingDBLookup;
-class PendingLookup;
-struct PRLogModuleInfo;
-
-class ApplicationReputationService final :
- public nsIApplicationReputationService {
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIAPPLICATIONREPUTATIONSERVICE
-
-public:
- static ApplicationReputationService* GetSingleton();
-
-private:
- friend class PendingLookup;
- friend class PendingDBLookup;
- /**
- * Global singleton object for holding this factory service.
- */
- static ApplicationReputationService* gApplicationReputationService;
- /**
- * NSPR_LOG_MODULES=ApplicationReputation:5
- */
- static PRLogModuleInfo* prlog;
- /**
- * This is a singleton, so disallow construction.
- */
- ApplicationReputationService();
- ~ApplicationReputationService();
- /**
- * Wrapper function for QueryReputation that makes it easier to ensure the
- * callback is called.
- */
- nsresult QueryReputationInternal(nsIApplicationReputationQuery* aQuery,
- nsIApplicationReputationCallback* aCallback);
-};
-#endif /* ApplicationReputation_h__ */
diff --git a/toolkit/components/downloads/csd.pb.cc b/toolkit/components/downloads/csd.pb.cc
deleted file mode 100644
index 99108deecf..0000000000
--- a/toolkit/components/downloads/csd.pb.cc
+++ /dev/null
@@ -1,2887 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-
-#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
-#include "csd.pb.h"
-
-#include
-
-#include
-#include
-#include
-// @@protoc_insertion_point(includes)
-
-namespace safe_browsing {
-
-void protobuf_ShutdownFile_csd_2eproto() {
- delete ClientDownloadRequest::default_instance_;
- delete ClientDownloadRequest_Digests::default_instance_;
- delete ClientDownloadRequest_Resource::default_instance_;
- delete ClientDownloadRequest_CertificateChain::default_instance_;
- delete ClientDownloadRequest_CertificateChain_Element::default_instance_;
- delete ClientDownloadRequest_SignatureInfo::default_instance_;
- delete ClientDownloadRequest_PEImageHeaders::default_instance_;
- delete ClientDownloadRequest_PEImageHeaders_DebugData::default_instance_;
- delete ClientDownloadRequest_ImageHeaders::default_instance_;
- delete ClientDownloadResponse::default_instance_;
- delete ClientDownloadResponse_MoreInfo::default_instance_;
-}
-
-void protobuf_AddDesc_csd_2eproto() {
- static bool already_here = false;
- if (already_here) return;
- already_here = true;
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- ClientDownloadRequest::default_instance_ = new ClientDownloadRequest();
- ClientDownloadRequest_Digests::default_instance_ = new ClientDownloadRequest_Digests();
- ClientDownloadRequest_Resource::default_instance_ = new ClientDownloadRequest_Resource();
- ClientDownloadRequest_CertificateChain::default_instance_ = new ClientDownloadRequest_CertificateChain();
- ClientDownloadRequest_CertificateChain_Element::default_instance_ = new ClientDownloadRequest_CertificateChain_Element();
- ClientDownloadRequest_SignatureInfo::default_instance_ = new ClientDownloadRequest_SignatureInfo();
- ClientDownloadRequest_PEImageHeaders::default_instance_ = new ClientDownloadRequest_PEImageHeaders();
- ClientDownloadRequest_PEImageHeaders_DebugData::default_instance_ = new ClientDownloadRequest_PEImageHeaders_DebugData();
- ClientDownloadRequest_ImageHeaders::default_instance_ = new ClientDownloadRequest_ImageHeaders();
- ClientDownloadResponse::default_instance_ = new ClientDownloadResponse();
- ClientDownloadResponse_MoreInfo::default_instance_ = new ClientDownloadResponse_MoreInfo();
- ClientDownloadRequest::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_Digests::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_Resource::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_CertificateChain::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_CertificateChain_Element::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_SignatureInfo::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_PEImageHeaders::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_PEImageHeaders_DebugData::default_instance_->InitAsDefaultInstance();
- ClientDownloadRequest_ImageHeaders::default_instance_->InitAsDefaultInstance();
- ClientDownloadResponse::default_instance_->InitAsDefaultInstance();
- ClientDownloadResponse_MoreInfo::default_instance_->InitAsDefaultInstance();
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_csd_2eproto);
-}
-
-// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_csd_2eproto {
- StaticDescriptorInitializer_csd_2eproto() {
- protobuf_AddDesc_csd_2eproto();
- }
-} static_descriptor_initializer_csd_2eproto_;
-
-
-// ===================================================================
-
-bool ClientDownloadRequest_ResourceType_IsValid(int value) {
- switch(value) {
- case 0:
- case 1:
- case 2:
- case 3:
- return true;
- default:
- return false;
- }
-}
-
-#ifndef _MSC_VER
-const ClientDownloadRequest_ResourceType ClientDownloadRequest::DOWNLOAD_URL;
-const ClientDownloadRequest_ResourceType ClientDownloadRequest::DOWNLOAD_REDIRECT;
-const ClientDownloadRequest_ResourceType ClientDownloadRequest::TAB_URL;
-const ClientDownloadRequest_ResourceType ClientDownloadRequest::TAB_REDIRECT;
-const ClientDownloadRequest_ResourceType ClientDownloadRequest::ResourceType_MIN;
-const ClientDownloadRequest_ResourceType ClientDownloadRequest::ResourceType_MAX;
-const int ClientDownloadRequest::ResourceType_ARRAYSIZE;
-#endif // _MSC_VER
-bool ClientDownloadRequest_DownloadType_IsValid(int value) {
- switch(value) {
- case 0:
- case 1:
- case 2:
- case 3:
- return true;
- default:
- return false;
- }
-}
-
-#ifndef _MSC_VER
-const ClientDownloadRequest_DownloadType ClientDownloadRequest::WIN_EXECUTABLE;
-const ClientDownloadRequest_DownloadType ClientDownloadRequest::CHROME_EXTENSION;
-const ClientDownloadRequest_DownloadType ClientDownloadRequest::ANDROID_APK;
-const ClientDownloadRequest_DownloadType ClientDownloadRequest::ZIPPED_EXECUTABLE;
-const ClientDownloadRequest_DownloadType ClientDownloadRequest::DownloadType_MIN;
-const ClientDownloadRequest_DownloadType ClientDownloadRequest::DownloadType_MAX;
-const int ClientDownloadRequest::DownloadType_ARRAYSIZE;
-#endif // _MSC_VER
-#ifndef _MSC_VER
-const int ClientDownloadRequest_Digests::kSha256FieldNumber;
-const int ClientDownloadRequest_Digests::kSha1FieldNumber;
-const int ClientDownloadRequest_Digests::kMd5FieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_Digests::ClientDownloadRequest_Digests()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_Digests::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_Digests::ClientDownloadRequest_Digests(const ClientDownloadRequest_Digests& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_Digests::SharedCtor() {
- _cached_size_ = 0;
- sha256_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- sha1_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- md5_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_Digests::~ClientDownloadRequest_Digests() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_Digests::SharedDtor() {
- if (sha256_ != &::google::protobuf::internal::kEmptyString) {
- delete sha256_;
- }
- if (sha1_ != &::google::protobuf::internal::kEmptyString) {
- delete sha1_;
- }
- if (md5_ != &::google::protobuf::internal::kEmptyString) {
- delete md5_;
- }
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_Digests::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_Digests& ClientDownloadRequest_Digests::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_Digests* ClientDownloadRequest_Digests::default_instance_ = NULL;
-
-ClientDownloadRequest_Digests* ClientDownloadRequest_Digests::New() const {
- return new ClientDownloadRequest_Digests;
-}
-
-void ClientDownloadRequest_Digests::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_sha256()) {
- if (sha256_ != &::google::protobuf::internal::kEmptyString) {
- sha256_->clear();
- }
- }
- if (has_sha1()) {
- if (sha1_ != &::google::protobuf::internal::kEmptyString) {
- sha1_->clear();
- }
- }
- if (has_md5()) {
- if (md5_ != &::google::protobuf::internal::kEmptyString) {
- md5_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_Digests::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bytes sha256 = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_sha256()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(18)) goto parse_sha1;
- break;
- }
-
- // optional bytes sha1 = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_sha1:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_sha1()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(26)) goto parse_md5;
- break;
- }
-
- // optional bytes md5 = 3;
- case 3: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_md5:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_md5()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_Digests::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // optional bytes sha256 = 1;
- if (has_sha256()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 1, this->sha256(), output);
- }
-
- // optional bytes sha1 = 2;
- if (has_sha1()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 2, this->sha1(), output);
- }
-
- // optional bytes md5 = 3;
- if (has_md5()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 3, this->md5(), output);
- }
-
-}
-
-int ClientDownloadRequest_Digests::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional bytes sha256 = 1;
- if (has_sha256()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->sha256());
- }
-
- // optional bytes sha1 = 2;
- if (has_sha1()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->sha1());
- }
-
- // optional bytes md5 = 3;
- if (has_md5()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->md5());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_Digests::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_Digests::MergeFrom(const ClientDownloadRequest_Digests& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_sha256()) {
- set_sha256(from.sha256());
- }
- if (from.has_sha1()) {
- set_sha1(from.sha1());
- }
- if (from.has_md5()) {
- set_md5(from.md5());
- }
- }
-}
-
-void ClientDownloadRequest_Digests::CopyFrom(const ClientDownloadRequest_Digests& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_Digests::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_Digests::Swap(ClientDownloadRequest_Digests* other) {
- if (other != this) {
- std::swap(sha256_, other->sha256_);
- std::swap(sha1_, other->sha1_);
- std::swap(md5_, other->md5_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_Digests::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.Digests";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_Resource::kUrlFieldNumber;
-const int ClientDownloadRequest_Resource::kTypeFieldNumber;
-const int ClientDownloadRequest_Resource::kRemoteIpFieldNumber;
-const int ClientDownloadRequest_Resource::kReferrerFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_Resource::ClientDownloadRequest_Resource()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_Resource::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_Resource::ClientDownloadRequest_Resource(const ClientDownloadRequest_Resource& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_Resource::SharedCtor() {
- _cached_size_ = 0;
- url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- type_ = 0;
- remote_ip_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- referrer_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_Resource::~ClientDownloadRequest_Resource() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_Resource::SharedDtor() {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- delete url_;
- }
- if (remote_ip_ != &::google::protobuf::internal::kEmptyString) {
- delete remote_ip_;
- }
- if (referrer_ != &::google::protobuf::internal::kEmptyString) {
- delete referrer_;
- }
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_Resource::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_Resource& ClientDownloadRequest_Resource::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_Resource* ClientDownloadRequest_Resource::default_instance_ = NULL;
-
-ClientDownloadRequest_Resource* ClientDownloadRequest_Resource::New() const {
- return new ClientDownloadRequest_Resource;
-}
-
-void ClientDownloadRequest_Resource::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_url()) {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- url_->clear();
- }
- }
- type_ = 0;
- if (has_remote_ip()) {
- if (remote_ip_ != &::google::protobuf::internal::kEmptyString) {
- remote_ip_->clear();
- }
- }
- if (has_referrer()) {
- if (referrer_ != &::google::protobuf::internal::kEmptyString) {
- referrer_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_Resource::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required string url = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_url()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(16)) goto parse_type;
- break;
- }
-
- // required .safe_browsing.ClientDownloadRequest.ResourceType type = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
- parse_type:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::safe_browsing::ClientDownloadRequest_ResourceType_IsValid(value)) {
- set_type(static_cast< ::safe_browsing::ClientDownloadRequest_ResourceType >(value));
- }
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(26)) goto parse_remote_ip;
- break;
- }
-
- // optional bytes remote_ip = 3;
- case 3: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_remote_ip:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_remote_ip()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(34)) goto parse_referrer;
- break;
- }
-
- // optional string referrer = 4;
- case 4: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_referrer:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_referrer()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_Resource::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // required string url = 1;
- if (has_url()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 1, this->url(), output);
- }
-
- // required .safe_browsing.ClientDownloadRequest.ResourceType type = 2;
- if (has_type()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 2, this->type(), output);
- }
-
- // optional bytes remote_ip = 3;
- if (has_remote_ip()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 3, this->remote_ip(), output);
- }
-
- // optional string referrer = 4;
- if (has_referrer()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 4, this->referrer(), output);
- }
-
-}
-
-int ClientDownloadRequest_Resource::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required string url = 1;
- if (has_url()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->url());
- }
-
- // required .safe_browsing.ClientDownloadRequest.ResourceType type = 2;
- if (has_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
- }
-
- // optional bytes remote_ip = 3;
- if (has_remote_ip()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->remote_ip());
- }
-
- // optional string referrer = 4;
- if (has_referrer()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->referrer());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_Resource::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_Resource::MergeFrom(const ClientDownloadRequest_Resource& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_url()) {
- set_url(from.url());
- }
- if (from.has_type()) {
- set_type(from.type());
- }
- if (from.has_remote_ip()) {
- set_remote_ip(from.remote_ip());
- }
- if (from.has_referrer()) {
- set_referrer(from.referrer());
- }
- }
-}
-
-void ClientDownloadRequest_Resource::CopyFrom(const ClientDownloadRequest_Resource& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_Resource::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;
-
- return true;
-}
-
-void ClientDownloadRequest_Resource::Swap(ClientDownloadRequest_Resource* other) {
- if (other != this) {
- std::swap(url_, other->url_);
- std::swap(type_, other->type_);
- std::swap(remote_ip_, other->remote_ip_);
- std::swap(referrer_, other->referrer_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_Resource::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.Resource";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_CertificateChain_Element::kCertificateFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_CertificateChain_Element::ClientDownloadRequest_CertificateChain_Element()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_CertificateChain_Element::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_CertificateChain_Element::ClientDownloadRequest_CertificateChain_Element(const ClientDownloadRequest_CertificateChain_Element& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_CertificateChain_Element::SharedCtor() {
- _cached_size_ = 0;
- certificate_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_CertificateChain_Element::~ClientDownloadRequest_CertificateChain_Element() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_CertificateChain_Element::SharedDtor() {
- if (certificate_ != &::google::protobuf::internal::kEmptyString) {
- delete certificate_;
- }
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_CertificateChain_Element::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_CertificateChain_Element& ClientDownloadRequest_CertificateChain_Element::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_CertificateChain_Element* ClientDownloadRequest_CertificateChain_Element::default_instance_ = NULL;
-
-ClientDownloadRequest_CertificateChain_Element* ClientDownloadRequest_CertificateChain_Element::New() const {
- return new ClientDownloadRequest_CertificateChain_Element;
-}
-
-void ClientDownloadRequest_CertificateChain_Element::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_certificate()) {
- if (certificate_ != &::google::protobuf::internal::kEmptyString) {
- certificate_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_CertificateChain_Element::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bytes certificate = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_certificate()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_CertificateChain_Element::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // optional bytes certificate = 1;
- if (has_certificate()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 1, this->certificate(), output);
- }
-
-}
-
-int ClientDownloadRequest_CertificateChain_Element::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional bytes certificate = 1;
- if (has_certificate()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->certificate());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_CertificateChain_Element::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_CertificateChain_Element::MergeFrom(const ClientDownloadRequest_CertificateChain_Element& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_certificate()) {
- set_certificate(from.certificate());
- }
- }
-}
-
-void ClientDownloadRequest_CertificateChain_Element::CopyFrom(const ClientDownloadRequest_CertificateChain_Element& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_CertificateChain_Element::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_CertificateChain_Element::Swap(ClientDownloadRequest_CertificateChain_Element* other) {
- if (other != this) {
- std::swap(certificate_, other->certificate_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_CertificateChain_Element::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.CertificateChain.Element";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_CertificateChain::kElementFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_CertificateChain::ClientDownloadRequest_CertificateChain()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_CertificateChain::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_CertificateChain::ClientDownloadRequest_CertificateChain(const ClientDownloadRequest_CertificateChain& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_CertificateChain::SharedCtor() {
- _cached_size_ = 0;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_CertificateChain::~ClientDownloadRequest_CertificateChain() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_CertificateChain::SharedDtor() {
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_CertificateChain::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_CertificateChain& ClientDownloadRequest_CertificateChain::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_CertificateChain* ClientDownloadRequest_CertificateChain::default_instance_ = NULL;
-
-ClientDownloadRequest_CertificateChain* ClientDownloadRequest_CertificateChain::New() const {
- return new ClientDownloadRequest_CertificateChain;
-}
-
-void ClientDownloadRequest_CertificateChain::Clear() {
- element_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_CertificateChain::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain.Element element = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_element:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_element()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(10)) goto parse_element;
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_CertificateChain::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain.Element element = 1;
- for (int i = 0; i < this->element_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 1, this->element(i), output);
- }
-
-}
-
-int ClientDownloadRequest_CertificateChain::ByteSize() const {
- int total_size = 0;
-
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain.Element element = 1;
- total_size += 1 * this->element_size();
- for (int i = 0; i < this->element_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->element(i));
- }
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_CertificateChain::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_CertificateChain::MergeFrom(const ClientDownloadRequest_CertificateChain& from) {
- GOOGLE_CHECK_NE(&from, this);
- element_.MergeFrom(from.element_);
-}
-
-void ClientDownloadRequest_CertificateChain::CopyFrom(const ClientDownloadRequest_CertificateChain& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_CertificateChain::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_CertificateChain::Swap(ClientDownloadRequest_CertificateChain* other) {
- if (other != this) {
- element_.Swap(&other->element_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_CertificateChain::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.CertificateChain";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_SignatureInfo::kCertificateChainFieldNumber;
-const int ClientDownloadRequest_SignatureInfo::kTrustedFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_SignatureInfo::ClientDownloadRequest_SignatureInfo()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_SignatureInfo::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_SignatureInfo::ClientDownloadRequest_SignatureInfo(const ClientDownloadRequest_SignatureInfo& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_SignatureInfo::SharedCtor() {
- _cached_size_ = 0;
- trusted_ = false;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_SignatureInfo::~ClientDownloadRequest_SignatureInfo() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_SignatureInfo::SharedDtor() {
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_SignatureInfo::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_SignatureInfo& ClientDownloadRequest_SignatureInfo::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_SignatureInfo* ClientDownloadRequest_SignatureInfo::default_instance_ = NULL;
-
-ClientDownloadRequest_SignatureInfo* ClientDownloadRequest_SignatureInfo::New() const {
- return new ClientDownloadRequest_SignatureInfo;
-}
-
-void ClientDownloadRequest_SignatureInfo::Clear() {
- if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) {
- trusted_ = false;
- }
- certificate_chain_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_SignatureInfo::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain certificate_chain = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_certificate_chain:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_certificate_chain()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(10)) goto parse_certificate_chain;
- if (input->ExpectTag(16)) goto parse_trusted;
- break;
- }
-
- // optional bool trusted = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
- parse_trusted:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &trusted_)));
- set_has_trusted();
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_SignatureInfo::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain certificate_chain = 1;
- for (int i = 0; i < this->certificate_chain_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 1, this->certificate_chain(i), output);
- }
-
- // optional bool trusted = 2;
- if (has_trusted()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->trusted(), output);
- }
-
-}
-
-int ClientDownloadRequest_SignatureInfo::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[1 / 32] & (0xffu << (1 % 32))) {
- // optional bool trusted = 2;
- if (has_trusted()) {
- total_size += 1 + 1;
- }
-
- }
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain certificate_chain = 1;
- total_size += 1 * this->certificate_chain_size();
- for (int i = 0; i < this->certificate_chain_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->certificate_chain(i));
- }
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_SignatureInfo::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_SignatureInfo::MergeFrom(const ClientDownloadRequest_SignatureInfo& from) {
- GOOGLE_CHECK_NE(&from, this);
- certificate_chain_.MergeFrom(from.certificate_chain_);
- if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {
- if (from.has_trusted()) {
- set_trusted(from.trusted());
- }
- }
-}
-
-void ClientDownloadRequest_SignatureInfo::CopyFrom(const ClientDownloadRequest_SignatureInfo& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_SignatureInfo::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_SignatureInfo::Swap(ClientDownloadRequest_SignatureInfo* other) {
- if (other != this) {
- certificate_chain_.Swap(&other->certificate_chain_);
- std::swap(trusted_, other->trusted_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_SignatureInfo::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.SignatureInfo";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_PEImageHeaders_DebugData::kDirectoryEntryFieldNumber;
-const int ClientDownloadRequest_PEImageHeaders_DebugData::kRawDataFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_PEImageHeaders_DebugData::ClientDownloadRequest_PEImageHeaders_DebugData()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_PEImageHeaders_DebugData::ClientDownloadRequest_PEImageHeaders_DebugData(const ClientDownloadRequest_PEImageHeaders_DebugData& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::SharedCtor() {
- _cached_size_ = 0;
- directory_entry_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- raw_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_PEImageHeaders_DebugData::~ClientDownloadRequest_PEImageHeaders_DebugData() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::SharedDtor() {
- if (directory_entry_ != &::google::protobuf::internal::kEmptyString) {
- delete directory_entry_;
- }
- if (raw_data_ != &::google::protobuf::internal::kEmptyString) {
- delete raw_data_;
- }
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_PEImageHeaders_DebugData& ClientDownloadRequest_PEImageHeaders_DebugData::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_PEImageHeaders_DebugData* ClientDownloadRequest_PEImageHeaders_DebugData::default_instance_ = NULL;
-
-ClientDownloadRequest_PEImageHeaders_DebugData* ClientDownloadRequest_PEImageHeaders_DebugData::New() const {
- return new ClientDownloadRequest_PEImageHeaders_DebugData;
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_directory_entry()) {
- if (directory_entry_ != &::google::protobuf::internal::kEmptyString) {
- directory_entry_->clear();
- }
- }
- if (has_raw_data()) {
- if (raw_data_ != &::google::protobuf::internal::kEmptyString) {
- raw_data_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_PEImageHeaders_DebugData::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bytes directory_entry = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_directory_entry()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(18)) goto parse_raw_data;
- break;
- }
-
- // optional bytes raw_data = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_raw_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_raw_data()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // optional bytes directory_entry = 1;
- if (has_directory_entry()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 1, this->directory_entry(), output);
- }
-
- // optional bytes raw_data = 2;
- if (has_raw_data()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 2, this->raw_data(), output);
- }
-
-}
-
-int ClientDownloadRequest_PEImageHeaders_DebugData::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional bytes directory_entry = 1;
- if (has_directory_entry()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->directory_entry());
- }
-
- // optional bytes raw_data = 2;
- if (has_raw_data()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->raw_data());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::MergeFrom(const ClientDownloadRequest_PEImageHeaders_DebugData& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_directory_entry()) {
- set_directory_entry(from.directory_entry());
- }
- if (from.has_raw_data()) {
- set_raw_data(from.raw_data());
- }
- }
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::CopyFrom(const ClientDownloadRequest_PEImageHeaders_DebugData& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_PEImageHeaders_DebugData::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_PEImageHeaders_DebugData::Swap(ClientDownloadRequest_PEImageHeaders_DebugData* other) {
- if (other != this) {
- std::swap(directory_entry_, other->directory_entry_);
- std::swap(raw_data_, other->raw_data_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_PEImageHeaders_DebugData::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_PEImageHeaders::kDosHeaderFieldNumber;
-const int ClientDownloadRequest_PEImageHeaders::kFileHeaderFieldNumber;
-const int ClientDownloadRequest_PEImageHeaders::kOptionalHeaders32FieldNumber;
-const int ClientDownloadRequest_PEImageHeaders::kOptionalHeaders64FieldNumber;
-const int ClientDownloadRequest_PEImageHeaders::kSectionHeaderFieldNumber;
-const int ClientDownloadRequest_PEImageHeaders::kExportSectionDataFieldNumber;
-const int ClientDownloadRequest_PEImageHeaders::kDebugDataFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_PEImageHeaders::ClientDownloadRequest_PEImageHeaders()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_PEImageHeaders::InitAsDefaultInstance() {
-}
-
-ClientDownloadRequest_PEImageHeaders::ClientDownloadRequest_PEImageHeaders(const ClientDownloadRequest_PEImageHeaders& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_PEImageHeaders::SharedCtor() {
- _cached_size_ = 0;
- dos_header_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- file_header_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- optional_headers32_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- optional_headers64_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- export_section_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_PEImageHeaders::~ClientDownloadRequest_PEImageHeaders() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_PEImageHeaders::SharedDtor() {
- if (dos_header_ != &::google::protobuf::internal::kEmptyString) {
- delete dos_header_;
- }
- if (file_header_ != &::google::protobuf::internal::kEmptyString) {
- delete file_header_;
- }
- if (optional_headers32_ != &::google::protobuf::internal::kEmptyString) {
- delete optional_headers32_;
- }
- if (optional_headers64_ != &::google::protobuf::internal::kEmptyString) {
- delete optional_headers64_;
- }
- if (export_section_data_ != &::google::protobuf::internal::kEmptyString) {
- delete export_section_data_;
- }
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadRequest_PEImageHeaders::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_PEImageHeaders& ClientDownloadRequest_PEImageHeaders::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_PEImageHeaders* ClientDownloadRequest_PEImageHeaders::default_instance_ = NULL;
-
-ClientDownloadRequest_PEImageHeaders* ClientDownloadRequest_PEImageHeaders::New() const {
- return new ClientDownloadRequest_PEImageHeaders;
-}
-
-void ClientDownloadRequest_PEImageHeaders::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_dos_header()) {
- if (dos_header_ != &::google::protobuf::internal::kEmptyString) {
- dos_header_->clear();
- }
- }
- if (has_file_header()) {
- if (file_header_ != &::google::protobuf::internal::kEmptyString) {
- file_header_->clear();
- }
- }
- if (has_optional_headers32()) {
- if (optional_headers32_ != &::google::protobuf::internal::kEmptyString) {
- optional_headers32_->clear();
- }
- }
- if (has_optional_headers64()) {
- if (optional_headers64_ != &::google::protobuf::internal::kEmptyString) {
- optional_headers64_->clear();
- }
- }
- if (has_export_section_data()) {
- if (export_section_data_ != &::google::protobuf::internal::kEmptyString) {
- export_section_data_->clear();
- }
- }
- }
- section_header_.Clear();
- debug_data_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_PEImageHeaders::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bytes dos_header = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_dos_header()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(18)) goto parse_file_header;
- break;
- }
-
- // optional bytes file_header = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_file_header:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_file_header()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(26)) goto parse_optional_headers32;
- break;
- }
-
- // optional bytes optional_headers32 = 3;
- case 3: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_optional_headers32:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_optional_headers32()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(34)) goto parse_optional_headers64;
- break;
- }
-
- // optional bytes optional_headers64 = 4;
- case 4: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_optional_headers64:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_optional_headers64()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(42)) goto parse_section_header;
- break;
- }
-
- // repeated bytes section_header = 5;
- case 5: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_section_header:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->add_section_header()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(42)) goto parse_section_header;
- if (input->ExpectTag(50)) goto parse_export_section_data;
- break;
- }
-
- // optional bytes export_section_data = 6;
- case 6: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_export_section_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_export_section_data()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(58)) goto parse_debug_data;
- break;
- }
-
- // repeated .safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData debug_data = 7;
- case 7: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_debug_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_debug_data()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(58)) goto parse_debug_data;
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_PEImageHeaders::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // optional bytes dos_header = 1;
- if (has_dos_header()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 1, this->dos_header(), output);
- }
-
- // optional bytes file_header = 2;
- if (has_file_header()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 2, this->file_header(), output);
- }
-
- // optional bytes optional_headers32 = 3;
- if (has_optional_headers32()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 3, this->optional_headers32(), output);
- }
-
- // optional bytes optional_headers64 = 4;
- if (has_optional_headers64()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 4, this->optional_headers64(), output);
- }
-
- // repeated bytes section_header = 5;
- for (int i = 0; i < this->section_header_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 5, this->section_header(i), output);
- }
-
- // optional bytes export_section_data = 6;
- if (has_export_section_data()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 6, this->export_section_data(), output);
- }
-
- // repeated .safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData debug_data = 7;
- for (int i = 0; i < this->debug_data_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 7, this->debug_data(i), output);
- }
-
-}
-
-int ClientDownloadRequest_PEImageHeaders::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional bytes dos_header = 1;
- if (has_dos_header()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->dos_header());
- }
-
- // optional bytes file_header = 2;
- if (has_file_header()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->file_header());
- }
-
- // optional bytes optional_headers32 = 3;
- if (has_optional_headers32()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->optional_headers32());
- }
-
- // optional bytes optional_headers64 = 4;
- if (has_optional_headers64()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->optional_headers64());
- }
-
- // optional bytes export_section_data = 6;
- if (has_export_section_data()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->export_section_data());
- }
-
- }
- // repeated bytes section_header = 5;
- total_size += 1 * this->section_header_size();
- for (int i = 0; i < this->section_header_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->section_header(i));
- }
-
- // repeated .safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData debug_data = 7;
- total_size += 1 * this->debug_data_size();
- for (int i = 0; i < this->debug_data_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->debug_data(i));
- }
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_PEImageHeaders::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_PEImageHeaders::MergeFrom(const ClientDownloadRequest_PEImageHeaders& from) {
- GOOGLE_CHECK_NE(&from, this);
- section_header_.MergeFrom(from.section_header_);
- debug_data_.MergeFrom(from.debug_data_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_dos_header()) {
- set_dos_header(from.dos_header());
- }
- if (from.has_file_header()) {
- set_file_header(from.file_header());
- }
- if (from.has_optional_headers32()) {
- set_optional_headers32(from.optional_headers32());
- }
- if (from.has_optional_headers64()) {
- set_optional_headers64(from.optional_headers64());
- }
- if (from.has_export_section_data()) {
- set_export_section_data(from.export_section_data());
- }
- }
-}
-
-void ClientDownloadRequest_PEImageHeaders::CopyFrom(const ClientDownloadRequest_PEImageHeaders& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_PEImageHeaders::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_PEImageHeaders::Swap(ClientDownloadRequest_PEImageHeaders* other) {
- if (other != this) {
- std::swap(dos_header_, other->dos_header_);
- std::swap(file_header_, other->file_header_);
- std::swap(optional_headers32_, other->optional_headers32_);
- std::swap(optional_headers64_, other->optional_headers64_);
- section_header_.Swap(&other->section_header_);
- std::swap(export_section_data_, other->export_section_data_);
- debug_data_.Swap(&other->debug_data_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_PEImageHeaders::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.PEImageHeaders";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest_ImageHeaders::kPeHeadersFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest_ImageHeaders::ClientDownloadRequest_ImageHeaders()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest_ImageHeaders::InitAsDefaultInstance() {
- pe_headers_ = const_cast< ::safe_browsing::ClientDownloadRequest_PEImageHeaders*>(&::safe_browsing::ClientDownloadRequest_PEImageHeaders::default_instance());
-}
-
-ClientDownloadRequest_ImageHeaders::ClientDownloadRequest_ImageHeaders(const ClientDownloadRequest_ImageHeaders& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest_ImageHeaders::SharedCtor() {
- _cached_size_ = 0;
- pe_headers_ = NULL;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest_ImageHeaders::~ClientDownloadRequest_ImageHeaders() {
- SharedDtor();
-}
-
-void ClientDownloadRequest_ImageHeaders::SharedDtor() {
- if (this != default_instance_) {
- delete pe_headers_;
- }
-}
-
-void ClientDownloadRequest_ImageHeaders::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest_ImageHeaders& ClientDownloadRequest_ImageHeaders::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest_ImageHeaders* ClientDownloadRequest_ImageHeaders::default_instance_ = NULL;
-
-ClientDownloadRequest_ImageHeaders* ClientDownloadRequest_ImageHeaders::New() const {
- return new ClientDownloadRequest_ImageHeaders;
-}
-
-void ClientDownloadRequest_ImageHeaders::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_pe_headers()) {
- if (pe_headers_ != NULL) pe_headers_->::safe_browsing::ClientDownloadRequest_PEImageHeaders::Clear();
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest_ImageHeaders::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .safe_browsing.ClientDownloadRequest.PEImageHeaders pe_headers = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_pe_headers()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest_ImageHeaders::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // optional .safe_browsing.ClientDownloadRequest.PEImageHeaders pe_headers = 1;
- if (has_pe_headers()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 1, this->pe_headers(), output);
- }
-
-}
-
-int ClientDownloadRequest_ImageHeaders::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional .safe_browsing.ClientDownloadRequest.PEImageHeaders pe_headers = 1;
- if (has_pe_headers()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->pe_headers());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest_ImageHeaders::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest_ImageHeaders::MergeFrom(const ClientDownloadRequest_ImageHeaders& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_pe_headers()) {
- mutable_pe_headers()->::safe_browsing::ClientDownloadRequest_PEImageHeaders::MergeFrom(from.pe_headers());
- }
- }
-}
-
-void ClientDownloadRequest_ImageHeaders::CopyFrom(const ClientDownloadRequest_ImageHeaders& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest_ImageHeaders::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadRequest_ImageHeaders::Swap(ClientDownloadRequest_ImageHeaders* other) {
- if (other != this) {
- std::swap(pe_headers_, other->pe_headers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest_ImageHeaders::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest.ImageHeaders";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadRequest::kUrlFieldNumber;
-const int ClientDownloadRequest::kDigestsFieldNumber;
-const int ClientDownloadRequest::kLengthFieldNumber;
-const int ClientDownloadRequest::kResourcesFieldNumber;
-const int ClientDownloadRequest::kSignatureFieldNumber;
-const int ClientDownloadRequest::kUserInitiatedFieldNumber;
-const int ClientDownloadRequest::kFileBasenameFieldNumber;
-const int ClientDownloadRequest::kDownloadTypeFieldNumber;
-const int ClientDownloadRequest::kLocaleFieldNumber;
-const int ClientDownloadRequest::kImageHeadersFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadRequest::ClientDownloadRequest()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadRequest::InitAsDefaultInstance() {
- digests_ = const_cast< ::safe_browsing::ClientDownloadRequest_Digests*>(&::safe_browsing::ClientDownloadRequest_Digests::default_instance());
- signature_ = const_cast< ::safe_browsing::ClientDownloadRequest_SignatureInfo*>(&::safe_browsing::ClientDownloadRequest_SignatureInfo::default_instance());
- image_headers_ = const_cast< ::safe_browsing::ClientDownloadRequest_ImageHeaders*>(&::safe_browsing::ClientDownloadRequest_ImageHeaders::default_instance());
-}
-
-ClientDownloadRequest::ClientDownloadRequest(const ClientDownloadRequest& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadRequest::SharedCtor() {
- _cached_size_ = 0;
- url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- digests_ = NULL;
- length_ = GOOGLE_LONGLONG(0);
- signature_ = NULL;
- user_initiated_ = false;
- file_basename_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- download_type_ = 0;
- locale_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- image_headers_ = NULL;
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadRequest::~ClientDownloadRequest() {
- SharedDtor();
-}
-
-void ClientDownloadRequest::SharedDtor() {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- delete url_;
- }
- if (file_basename_ != &::google::protobuf::internal::kEmptyString) {
- delete file_basename_;
- }
- if (locale_ != &::google::protobuf::internal::kEmptyString) {
- delete locale_;
- }
- if (this != default_instance_) {
- delete digests_;
- delete signature_;
- delete image_headers_;
- }
-}
-
-void ClientDownloadRequest::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadRequest& ClientDownloadRequest::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadRequest* ClientDownloadRequest::default_instance_ = NULL;
-
-ClientDownloadRequest* ClientDownloadRequest::New() const {
- return new ClientDownloadRequest;
-}
-
-void ClientDownloadRequest::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_url()) {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- url_->clear();
- }
- }
- if (has_digests()) {
- if (digests_ != NULL) digests_->::safe_browsing::ClientDownloadRequest_Digests::Clear();
- }
- length_ = GOOGLE_LONGLONG(0);
- if (has_signature()) {
- if (signature_ != NULL) signature_->::safe_browsing::ClientDownloadRequest_SignatureInfo::Clear();
- }
- user_initiated_ = false;
- if (has_file_basename()) {
- if (file_basename_ != &::google::protobuf::internal::kEmptyString) {
- file_basename_->clear();
- }
- }
- download_type_ = 0;
- }
- if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (has_locale()) {
- if (locale_ != &::google::protobuf::internal::kEmptyString) {
- locale_->clear();
- }
- }
- if (has_image_headers()) {
- if (image_headers_ != NULL) image_headers_->::safe_browsing::ClientDownloadRequest_ImageHeaders::Clear();
- }
- }
- resources_.Clear();
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadRequest::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required string url = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_url()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(18)) goto parse_digests;
- break;
- }
-
- // required .safe_browsing.ClientDownloadRequest.Digests digests = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_digests:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_digests()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(24)) goto parse_length;
- break;
- }
-
- // required int64 length = 3;
- case 3: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
- parse_length:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
- input, &length_)));
- set_has_length();
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(34)) goto parse_resources;
- break;
- }
-
- // repeated .safe_browsing.ClientDownloadRequest.Resource resources = 4;
- case 4: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_resources:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, add_resources()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(34)) goto parse_resources;
- if (input->ExpectTag(42)) goto parse_signature;
- break;
- }
-
- // optional .safe_browsing.ClientDownloadRequest.SignatureInfo signature = 5;
- case 5: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_signature:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_signature()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(48)) goto parse_user_initiated;
- break;
- }
-
- // optional bool user_initiated = 6;
- case 6: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
- parse_user_initiated:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &user_initiated_)));
- set_has_user_initiated();
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(74)) goto parse_file_basename;
- break;
- }
-
- // optional string file_basename = 9;
- case 9: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_file_basename:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_file_basename()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(80)) goto parse_download_type;
- break;
- }
-
- // optional .safe_browsing.ClientDownloadRequest.DownloadType download_type = 10 [default = WIN_EXECUTABLE];
- case 10: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
- parse_download_type:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::safe_browsing::ClientDownloadRequest_DownloadType_IsValid(value)) {
- set_download_type(static_cast< ::safe_browsing::ClientDownloadRequest_DownloadType >(value));
- }
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(90)) goto parse_locale;
- break;
- }
-
- // optional string locale = 11;
- case 11: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_locale:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_locale()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(146)) goto parse_image_headers;
- break;
- }
-
- // optional .safe_browsing.ClientDownloadRequest.ImageHeaders image_headers = 18;
- case 18: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_image_headers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_image_headers()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadRequest::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // required string url = 1;
- if (has_url()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 1, this->url(), output);
- }
-
- // required .safe_browsing.ClientDownloadRequest.Digests digests = 2;
- if (has_digests()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 2, this->digests(), output);
- }
-
- // required int64 length = 3;
- if (has_length()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt64(3, this->length(), output);
- }
-
- // repeated .safe_browsing.ClientDownloadRequest.Resource resources = 4;
- for (int i = 0; i < this->resources_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 4, this->resources(i), output);
- }
-
- // optional .safe_browsing.ClientDownloadRequest.SignatureInfo signature = 5;
- if (has_signature()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 5, this->signature(), output);
- }
-
- // optional bool user_initiated = 6;
- if (has_user_initiated()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->user_initiated(), output);
- }
-
- // optional string file_basename = 9;
- if (has_file_basename()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 9, this->file_basename(), output);
- }
-
- // optional .safe_browsing.ClientDownloadRequest.DownloadType download_type = 10 [default = WIN_EXECUTABLE];
- if (has_download_type()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 10, this->download_type(), output);
- }
-
- // optional string locale = 11;
- if (has_locale()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 11, this->locale(), output);
- }
-
- // optional .safe_browsing.ClientDownloadRequest.ImageHeaders image_headers = 18;
- if (has_image_headers()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 18, this->image_headers(), output);
- }
-
-}
-
-int ClientDownloadRequest::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required string url = 1;
- if (has_url()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->url());
- }
-
- // required .safe_browsing.ClientDownloadRequest.Digests digests = 2;
- if (has_digests()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->digests());
- }
-
- // required int64 length = 3;
- if (has_length()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int64Size(
- this->length());
- }
-
- // optional .safe_browsing.ClientDownloadRequest.SignatureInfo signature = 5;
- if (has_signature()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->signature());
- }
-
- // optional bool user_initiated = 6;
- if (has_user_initiated()) {
- total_size += 1 + 1;
- }
-
- // optional string file_basename = 9;
- if (has_file_basename()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->file_basename());
- }
-
- // optional .safe_browsing.ClientDownloadRequest.DownloadType download_type = 10 [default = WIN_EXECUTABLE];
- if (has_download_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->download_type());
- }
-
- }
- if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- // optional string locale = 11;
- if (has_locale()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->locale());
- }
-
- // optional .safe_browsing.ClientDownloadRequest.ImageHeaders image_headers = 18;
- if (has_image_headers()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->image_headers());
- }
-
- }
- // repeated .safe_browsing.ClientDownloadRequest.Resource resources = 4;
- total_size += 1 * this->resources_size();
- for (int i = 0; i < this->resources_size(); i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->resources(i));
- }
-
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadRequest::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadRequest::MergeFrom(const ClientDownloadRequest& from) {
- GOOGLE_CHECK_NE(&from, this);
- resources_.MergeFrom(from.resources_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_url()) {
- set_url(from.url());
- }
- if (from.has_digests()) {
- mutable_digests()->::safe_browsing::ClientDownloadRequest_Digests::MergeFrom(from.digests());
- }
- if (from.has_length()) {
- set_length(from.length());
- }
- if (from.has_signature()) {
- mutable_signature()->::safe_browsing::ClientDownloadRequest_SignatureInfo::MergeFrom(from.signature());
- }
- if (from.has_user_initiated()) {
- set_user_initiated(from.user_initiated());
- }
- if (from.has_file_basename()) {
- set_file_basename(from.file_basename());
- }
- if (from.has_download_type()) {
- set_download_type(from.download_type());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_locale()) {
- set_locale(from.locale());
- }
- if (from.has_image_headers()) {
- mutable_image_headers()->::safe_browsing::ClientDownloadRequest_ImageHeaders::MergeFrom(from.image_headers());
- }
- }
-}
-
-void ClientDownloadRequest::CopyFrom(const ClientDownloadRequest& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadRequest::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000007) != 0x00000007) return false;
-
- for (int i = 0; i < resources_size(); i++) {
- if (!this->resources(i).IsInitialized()) return false;
- }
- return true;
-}
-
-void ClientDownloadRequest::Swap(ClientDownloadRequest* other) {
- if (other != this) {
- std::swap(url_, other->url_);
- std::swap(digests_, other->digests_);
- std::swap(length_, other->length_);
- resources_.Swap(&other->resources_);
- std::swap(signature_, other->signature_);
- std::swap(user_initiated_, other->user_initiated_);
- std::swap(file_basename_, other->file_basename_);
- std::swap(download_type_, other->download_type_);
- std::swap(locale_, other->locale_);
- std::swap(image_headers_, other->image_headers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadRequest::GetTypeName() const {
- return "safe_browsing.ClientDownloadRequest";
-}
-
-
-// ===================================================================
-
-bool ClientDownloadResponse_Verdict_IsValid(int value) {
- switch(value) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- return true;
- default:
- return false;
- }
-}
-
-#ifndef _MSC_VER
-const ClientDownloadResponse_Verdict ClientDownloadResponse::SAFE;
-const ClientDownloadResponse_Verdict ClientDownloadResponse::DANGEROUS;
-const ClientDownloadResponse_Verdict ClientDownloadResponse::UNCOMMON;
-const ClientDownloadResponse_Verdict ClientDownloadResponse::POTENTIALLY_UNWANTED;
-const ClientDownloadResponse_Verdict ClientDownloadResponse::DANGEROUS_HOST;
-const ClientDownloadResponse_Verdict ClientDownloadResponse::Verdict_MIN;
-const ClientDownloadResponse_Verdict ClientDownloadResponse::Verdict_MAX;
-const int ClientDownloadResponse::Verdict_ARRAYSIZE;
-#endif // _MSC_VER
-#ifndef _MSC_VER
-const int ClientDownloadResponse_MoreInfo::kDescriptionFieldNumber;
-const int ClientDownloadResponse_MoreInfo::kUrlFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadResponse_MoreInfo::ClientDownloadResponse_MoreInfo()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadResponse_MoreInfo::InitAsDefaultInstance() {
-}
-
-ClientDownloadResponse_MoreInfo::ClientDownloadResponse_MoreInfo(const ClientDownloadResponse_MoreInfo& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadResponse_MoreInfo::SharedCtor() {
- _cached_size_ = 0;
- description_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadResponse_MoreInfo::~ClientDownloadResponse_MoreInfo() {
- SharedDtor();
-}
-
-void ClientDownloadResponse_MoreInfo::SharedDtor() {
- if (description_ != &::google::protobuf::internal::kEmptyString) {
- delete description_;
- }
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- delete url_;
- }
- if (this != default_instance_) {
- }
-}
-
-void ClientDownloadResponse_MoreInfo::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadResponse_MoreInfo& ClientDownloadResponse_MoreInfo::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadResponse_MoreInfo* ClientDownloadResponse_MoreInfo::default_instance_ = NULL;
-
-ClientDownloadResponse_MoreInfo* ClientDownloadResponse_MoreInfo::New() const {
- return new ClientDownloadResponse_MoreInfo;
-}
-
-void ClientDownloadResponse_MoreInfo::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (has_description()) {
- if (description_ != &::google::protobuf::internal::kEmptyString) {
- description_->clear();
- }
- }
- if (has_url()) {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- url_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadResponse_MoreInfo::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string description = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_description()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(18)) goto parse_url;
- break;
- }
-
- // optional string url = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_url:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_url()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadResponse_MoreInfo::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // optional string description = 1;
- if (has_description()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 1, this->description(), output);
- }
-
- // optional string url = 2;
- if (has_url()) {
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 2, this->url(), output);
- }
-
-}
-
-int ClientDownloadResponse_MoreInfo::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // optional string description = 1;
- if (has_description()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->description());
- }
-
- // optional string url = 2;
- if (has_url()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->url());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadResponse_MoreInfo::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadResponse_MoreInfo::MergeFrom(const ClientDownloadResponse_MoreInfo& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_description()) {
- set_description(from.description());
- }
- if (from.has_url()) {
- set_url(from.url());
- }
- }
-}
-
-void ClientDownloadResponse_MoreInfo::CopyFrom(const ClientDownloadResponse_MoreInfo& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadResponse_MoreInfo::IsInitialized() const {
-
- return true;
-}
-
-void ClientDownloadResponse_MoreInfo::Swap(ClientDownloadResponse_MoreInfo* other) {
- if (other != this) {
- std::swap(description_, other->description_);
- std::swap(url_, other->url_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadResponse_MoreInfo::GetTypeName() const {
- return "safe_browsing.ClientDownloadResponse.MoreInfo";
-}
-
-
-// -------------------------------------------------------------------
-
-#ifndef _MSC_VER
-const int ClientDownloadResponse::kVerdictFieldNumber;
-const int ClientDownloadResponse::kMoreInfoFieldNumber;
-const int ClientDownloadResponse::kTokenFieldNumber;
-#endif // !_MSC_VER
-
-ClientDownloadResponse::ClientDownloadResponse()
- : ::google::protobuf::MessageLite() {
- SharedCtor();
-}
-
-void ClientDownloadResponse::InitAsDefaultInstance() {
- more_info_ = const_cast< ::safe_browsing::ClientDownloadResponse_MoreInfo*>(&::safe_browsing::ClientDownloadResponse_MoreInfo::default_instance());
-}
-
-ClientDownloadResponse::ClientDownloadResponse(const ClientDownloadResponse& from)
- : ::google::protobuf::MessageLite() {
- SharedCtor();
- MergeFrom(from);
-}
-
-void ClientDownloadResponse::SharedCtor() {
- _cached_size_ = 0;
- verdict_ = 0;
- more_info_ = NULL;
- token_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-ClientDownloadResponse::~ClientDownloadResponse() {
- SharedDtor();
-}
-
-void ClientDownloadResponse::SharedDtor() {
- if (token_ != &::google::protobuf::internal::kEmptyString) {
- delete token_;
- }
- if (this != default_instance_) {
- delete more_info_;
- }
-}
-
-void ClientDownloadResponse::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ClientDownloadResponse& ClientDownloadResponse::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_csd_2eproto(); return *default_instance_;
-}
-
-ClientDownloadResponse* ClientDownloadResponse::default_instance_ = NULL;
-
-ClientDownloadResponse* ClientDownloadResponse::New() const {
- return new ClientDownloadResponse;
-}
-
-void ClientDownloadResponse::Clear() {
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- verdict_ = 0;
- if (has_more_info()) {
- if (more_info_ != NULL) more_info_->::safe_browsing::ClientDownloadResponse_MoreInfo::Clear();
- }
- if (has_token()) {
- if (token_ != &::google::protobuf::internal::kEmptyString) {
- token_->clear();
- }
- }
- }
- ::memset(_has_bits_, 0, sizeof(_has_bits_));
-}
-
-bool ClientDownloadResponse::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
- ::google::protobuf::uint32 tag;
- while ((tag = input->ReadTag()) != 0) {
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // required .safe_browsing.ClientDownloadResponse.Verdict verdict = 1;
- case 1: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::safe_browsing::ClientDownloadResponse_Verdict_IsValid(value)) {
- set_verdict(static_cast< ::safe_browsing::ClientDownloadResponse_Verdict >(value));
- }
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(18)) goto parse_more_info;
- break;
- }
-
- // optional .safe_browsing.ClientDownloadResponse.MoreInfo more_info = 2;
- case 2: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_more_info:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_more_info()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectTag(26)) goto parse_token;
- break;
- }
-
- // optional bytes token = 3;
- case 3: {
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
- parse_token:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_token()));
- } else {
- goto handle_uninterpreted;
- }
- if (input->ExpectAtEnd()) return true;
- break;
- }
-
- default: {
- handle_uninterpreted:
- if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- return true;
- }
- DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));
- break;
- }
- }
- }
- return true;
-#undef DO_
-}
-
-void ClientDownloadResponse::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // required .safe_browsing.ClientDownloadResponse.Verdict verdict = 1;
- if (has_verdict()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->verdict(), output);
- }
-
- // optional .safe_browsing.ClientDownloadResponse.MoreInfo more_info = 2;
- if (has_more_info()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessage(
- 2, this->more_info(), output);
- }
-
- // optional bytes token = 3;
- if (has_token()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytes(
- 3, this->token(), output);
- }
-
-}
-
-int ClientDownloadResponse::ByteSize() const {
- int total_size = 0;
-
- if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- // required .safe_browsing.ClientDownloadResponse.Verdict verdict = 1;
- if (has_verdict()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->verdict());
- }
-
- // optional .safe_browsing.ClientDownloadResponse.MoreInfo more_info = 2;
- if (has_more_info()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->more_info());
- }
-
- // optional bytes token = 3;
- if (has_token()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->token());
- }
-
- }
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = total_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ClientDownloadResponse::CheckTypeAndMergeFrom(
- const ::google::protobuf::MessageLite& from) {
- MergeFrom(*::google::protobuf::down_cast(&from));
-}
-
-void ClientDownloadResponse::MergeFrom(const ClientDownloadResponse& from) {
- GOOGLE_CHECK_NE(&from, this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_verdict()) {
- set_verdict(from.verdict());
- }
- if (from.has_more_info()) {
- mutable_more_info()->::safe_browsing::ClientDownloadResponse_MoreInfo::MergeFrom(from.more_info());
- }
- if (from.has_token()) {
- set_token(from.token());
- }
- }
-}
-
-void ClientDownloadResponse::CopyFrom(const ClientDownloadResponse& from) {
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-bool ClientDownloadResponse::IsInitialized() const {
- if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
-
- return true;
-}
-
-void ClientDownloadResponse::Swap(ClientDownloadResponse* other) {
- if (other != this) {
- std::swap(verdict_, other->verdict_);
- std::swap(more_info_, other->more_info_);
- std::swap(token_, other->token_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_cached_size_, other->_cached_size_);
- }
-}
-
-::std::string ClientDownloadResponse::GetTypeName() const {
- return "safe_browsing.ClientDownloadResponse";
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace safe_browsing
-
-// @@protoc_insertion_point(global_scope)
diff --git a/toolkit/components/downloads/csd.pb.h b/toolkit/components/downloads/csd.pb.h
deleted file mode 100644
index 77e5d79329..0000000000
--- a/toolkit/components/downloads/csd.pb.h
+++ /dev/null
@@ -1,2890 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: csd.proto
-
-#ifndef PROTOBUF_csd_2eproto__INCLUDED
-#define PROTOBUF_csd_2eproto__INCLUDED
-
-#include
-
-#include
-
-#if GOOGLE_PROTOBUF_VERSION < 2004000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers. Please update
-#error your headers.
-#endif
-#if 2004001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers. Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include
-#include
-#include
-// @@protoc_insertion_point(includes)
-
-namespace safe_browsing {
-
-// Internal implementation detail -- do not call these.
-void protobuf_AddDesc_csd_2eproto();
-void protobuf_AssignDesc_csd_2eproto();
-void protobuf_ShutdownFile_csd_2eproto();
-
-class ClientDownloadRequest;
-class ClientDownloadRequest_Digests;
-class ClientDownloadRequest_Resource;
-class ClientDownloadRequest_CertificateChain;
-class ClientDownloadRequest_CertificateChain_Element;
-class ClientDownloadRequest_SignatureInfo;
-class ClientDownloadRequest_PEImageHeaders;
-class ClientDownloadRequest_PEImageHeaders_DebugData;
-class ClientDownloadRequest_ImageHeaders;
-class ClientDownloadResponse;
-class ClientDownloadResponse_MoreInfo;
-
-enum ClientDownloadRequest_ResourceType {
- ClientDownloadRequest_ResourceType_DOWNLOAD_URL = 0,
- ClientDownloadRequest_ResourceType_DOWNLOAD_REDIRECT = 1,
- ClientDownloadRequest_ResourceType_TAB_URL = 2,
- ClientDownloadRequest_ResourceType_TAB_REDIRECT = 3
-};
-bool ClientDownloadRequest_ResourceType_IsValid(int value);
-const ClientDownloadRequest_ResourceType ClientDownloadRequest_ResourceType_ResourceType_MIN = ClientDownloadRequest_ResourceType_DOWNLOAD_URL;
-const ClientDownloadRequest_ResourceType ClientDownloadRequest_ResourceType_ResourceType_MAX = ClientDownloadRequest_ResourceType_TAB_REDIRECT;
-const int ClientDownloadRequest_ResourceType_ResourceType_ARRAYSIZE = ClientDownloadRequest_ResourceType_ResourceType_MAX + 1;
-
-enum ClientDownloadRequest_DownloadType {
- ClientDownloadRequest_DownloadType_WIN_EXECUTABLE = 0,
- ClientDownloadRequest_DownloadType_CHROME_EXTENSION = 1,
- ClientDownloadRequest_DownloadType_ANDROID_APK = 2,
- ClientDownloadRequest_DownloadType_ZIPPED_EXECUTABLE = 3
-};
-bool ClientDownloadRequest_DownloadType_IsValid(int value);
-const ClientDownloadRequest_DownloadType ClientDownloadRequest_DownloadType_DownloadType_MIN = ClientDownloadRequest_DownloadType_WIN_EXECUTABLE;
-const ClientDownloadRequest_DownloadType ClientDownloadRequest_DownloadType_DownloadType_MAX = ClientDownloadRequest_DownloadType_ZIPPED_EXECUTABLE;
-const int ClientDownloadRequest_DownloadType_DownloadType_ARRAYSIZE = ClientDownloadRequest_DownloadType_DownloadType_MAX + 1;
-
-enum ClientDownloadResponse_Verdict {
- ClientDownloadResponse_Verdict_SAFE = 0,
- ClientDownloadResponse_Verdict_DANGEROUS = 1,
- ClientDownloadResponse_Verdict_UNCOMMON = 2,
- ClientDownloadResponse_Verdict_POTENTIALLY_UNWANTED = 3,
- ClientDownloadResponse_Verdict_DANGEROUS_HOST = 4
-};
-bool ClientDownloadResponse_Verdict_IsValid(int value);
-const ClientDownloadResponse_Verdict ClientDownloadResponse_Verdict_Verdict_MIN = ClientDownloadResponse_Verdict_SAFE;
-const ClientDownloadResponse_Verdict ClientDownloadResponse_Verdict_Verdict_MAX = ClientDownloadResponse_Verdict_DANGEROUS_HOST;
-const int ClientDownloadResponse_Verdict_Verdict_ARRAYSIZE = ClientDownloadResponse_Verdict_Verdict_MAX + 1;
-
-// ===================================================================
-
-class ClientDownloadRequest_Digests : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_Digests();
- virtual ~ClientDownloadRequest_Digests();
-
- ClientDownloadRequest_Digests(const ClientDownloadRequest_Digests& from);
-
- inline ClientDownloadRequest_Digests& operator=(const ClientDownloadRequest_Digests& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_Digests& default_instance();
-
- void Swap(ClientDownloadRequest_Digests* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_Digests* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_Digests& from);
- void MergeFrom(const ClientDownloadRequest_Digests& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional bytes sha256 = 1;
- inline bool has_sha256() const;
- inline void clear_sha256();
- static const int kSha256FieldNumber = 1;
- inline const ::std::string& sha256() const;
- inline void set_sha256(const ::std::string& value);
- inline void set_sha256(const char* value);
- inline void set_sha256(const void* value, size_t size);
- inline ::std::string* mutable_sha256();
- inline ::std::string* release_sha256();
-
- // optional bytes sha1 = 2;
- inline bool has_sha1() const;
- inline void clear_sha1();
- static const int kSha1FieldNumber = 2;
- inline const ::std::string& sha1() const;
- inline void set_sha1(const ::std::string& value);
- inline void set_sha1(const char* value);
- inline void set_sha1(const void* value, size_t size);
- inline ::std::string* mutable_sha1();
- inline ::std::string* release_sha1();
-
- // optional bytes md5 = 3;
- inline bool has_md5() const;
- inline void clear_md5();
- static const int kMd5FieldNumber = 3;
- inline const ::std::string& md5() const;
- inline void set_md5(const ::std::string& value);
- inline void set_md5(const char* value);
- inline void set_md5(const void* value, size_t size);
- inline ::std::string* mutable_md5();
- inline ::std::string* release_md5();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.Digests)
- private:
- inline void set_has_sha256();
- inline void clear_has_sha256();
- inline void set_has_sha1();
- inline void clear_has_sha1();
- inline void set_has_md5();
- inline void clear_has_md5();
-
- ::std::string* sha256_;
- ::std::string* sha1_;
- ::std::string* md5_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_Digests* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_Resource : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_Resource();
- virtual ~ClientDownloadRequest_Resource();
-
- ClientDownloadRequest_Resource(const ClientDownloadRequest_Resource& from);
-
- inline ClientDownloadRequest_Resource& operator=(const ClientDownloadRequest_Resource& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_Resource& default_instance();
-
- void Swap(ClientDownloadRequest_Resource* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_Resource* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_Resource& from);
- void MergeFrom(const ClientDownloadRequest_Resource& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // required string url = 1;
- inline bool has_url() const;
- inline void clear_url();
- static const int kUrlFieldNumber = 1;
- inline const ::std::string& url() const;
- inline void set_url(const ::std::string& value);
- inline void set_url(const char* value);
- inline void set_url(const char* value, size_t size);
- inline ::std::string* mutable_url();
- inline ::std::string* release_url();
-
- // required .safe_browsing.ClientDownloadRequest.ResourceType type = 2;
- inline bool has_type() const;
- inline void clear_type();
- static const int kTypeFieldNumber = 2;
- inline ::safe_browsing::ClientDownloadRequest_ResourceType type() const;
- inline void set_type(::safe_browsing::ClientDownloadRequest_ResourceType value);
-
- // optional bytes remote_ip = 3;
- inline bool has_remote_ip() const;
- inline void clear_remote_ip();
- static const int kRemoteIpFieldNumber = 3;
- inline const ::std::string& remote_ip() const;
- inline void set_remote_ip(const ::std::string& value);
- inline void set_remote_ip(const char* value);
- inline void set_remote_ip(const void* value, size_t size);
- inline ::std::string* mutable_remote_ip();
- inline ::std::string* release_remote_ip();
-
- // optional string referrer = 4;
- inline bool has_referrer() const;
- inline void clear_referrer();
- static const int kReferrerFieldNumber = 4;
- inline const ::std::string& referrer() const;
- inline void set_referrer(const ::std::string& value);
- inline void set_referrer(const char* value);
- inline void set_referrer(const char* value, size_t size);
- inline ::std::string* mutable_referrer();
- inline ::std::string* release_referrer();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.Resource)
- private:
- inline void set_has_url();
- inline void clear_has_url();
- inline void set_has_type();
- inline void clear_has_type();
- inline void set_has_remote_ip();
- inline void clear_has_remote_ip();
- inline void set_has_referrer();
- inline void clear_has_referrer();
-
- ::std::string* url_;
- ::std::string* remote_ip_;
- ::std::string* referrer_;
- int type_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_Resource* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_CertificateChain_Element : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_CertificateChain_Element();
- virtual ~ClientDownloadRequest_CertificateChain_Element();
-
- ClientDownloadRequest_CertificateChain_Element(const ClientDownloadRequest_CertificateChain_Element& from);
-
- inline ClientDownloadRequest_CertificateChain_Element& operator=(const ClientDownloadRequest_CertificateChain_Element& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_CertificateChain_Element& default_instance();
-
- void Swap(ClientDownloadRequest_CertificateChain_Element* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_CertificateChain_Element* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_CertificateChain_Element& from);
- void MergeFrom(const ClientDownloadRequest_CertificateChain_Element& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional bytes certificate = 1;
- inline bool has_certificate() const;
- inline void clear_certificate();
- static const int kCertificateFieldNumber = 1;
- inline const ::std::string& certificate() const;
- inline void set_certificate(const ::std::string& value);
- inline void set_certificate(const char* value);
- inline void set_certificate(const void* value, size_t size);
- inline ::std::string* mutable_certificate();
- inline ::std::string* release_certificate();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.CertificateChain.Element)
- private:
- inline void set_has_certificate();
- inline void clear_has_certificate();
-
- ::std::string* certificate_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_CertificateChain_Element* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_CertificateChain : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_CertificateChain();
- virtual ~ClientDownloadRequest_CertificateChain();
-
- ClientDownloadRequest_CertificateChain(const ClientDownloadRequest_CertificateChain& from);
-
- inline ClientDownloadRequest_CertificateChain& operator=(const ClientDownloadRequest_CertificateChain& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_CertificateChain& default_instance();
-
- void Swap(ClientDownloadRequest_CertificateChain* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_CertificateChain* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_CertificateChain& from);
- void MergeFrom(const ClientDownloadRequest_CertificateChain& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef ClientDownloadRequest_CertificateChain_Element Element;
-
- // accessors -------------------------------------------------------
-
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain.Element element = 1;
- inline int element_size() const;
- inline void clear_element();
- static const int kElementFieldNumber = 1;
- inline const ::safe_browsing::ClientDownloadRequest_CertificateChain_Element& element(int index) const;
- inline ::safe_browsing::ClientDownloadRequest_CertificateChain_Element* mutable_element(int index);
- inline ::safe_browsing::ClientDownloadRequest_CertificateChain_Element* add_element();
- inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain_Element >&
- element() const;
- inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain_Element >*
- mutable_element();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.CertificateChain)
- private:
-
- ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain_Element > element_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_CertificateChain* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_SignatureInfo : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_SignatureInfo();
- virtual ~ClientDownloadRequest_SignatureInfo();
-
- ClientDownloadRequest_SignatureInfo(const ClientDownloadRequest_SignatureInfo& from);
-
- inline ClientDownloadRequest_SignatureInfo& operator=(const ClientDownloadRequest_SignatureInfo& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_SignatureInfo& default_instance();
-
- void Swap(ClientDownloadRequest_SignatureInfo* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_SignatureInfo* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_SignatureInfo& from);
- void MergeFrom(const ClientDownloadRequest_SignatureInfo& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // repeated .safe_browsing.ClientDownloadRequest.CertificateChain certificate_chain = 1;
- inline int certificate_chain_size() const;
- inline void clear_certificate_chain();
- static const int kCertificateChainFieldNumber = 1;
- inline const ::safe_browsing::ClientDownloadRequest_CertificateChain& certificate_chain(int index) const;
- inline ::safe_browsing::ClientDownloadRequest_CertificateChain* mutable_certificate_chain(int index);
- inline ::safe_browsing::ClientDownloadRequest_CertificateChain* add_certificate_chain();
- inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain >&
- certificate_chain() const;
- inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain >*
- mutable_certificate_chain();
-
- // optional bool trusted = 2;
- inline bool has_trusted() const;
- inline void clear_trusted();
- static const int kTrustedFieldNumber = 2;
- inline bool trusted() const;
- inline void set_trusted(bool value);
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.SignatureInfo)
- private:
- inline void set_has_trusted();
- inline void clear_has_trusted();
-
- ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain > certificate_chain_;
- bool trusted_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_SignatureInfo* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_PEImageHeaders_DebugData : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_PEImageHeaders_DebugData();
- virtual ~ClientDownloadRequest_PEImageHeaders_DebugData();
-
- ClientDownloadRequest_PEImageHeaders_DebugData(const ClientDownloadRequest_PEImageHeaders_DebugData& from);
-
- inline ClientDownloadRequest_PEImageHeaders_DebugData& operator=(const ClientDownloadRequest_PEImageHeaders_DebugData& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_PEImageHeaders_DebugData& default_instance();
-
- void Swap(ClientDownloadRequest_PEImageHeaders_DebugData* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_PEImageHeaders_DebugData* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_PEImageHeaders_DebugData& from);
- void MergeFrom(const ClientDownloadRequest_PEImageHeaders_DebugData& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional bytes directory_entry = 1;
- inline bool has_directory_entry() const;
- inline void clear_directory_entry();
- static const int kDirectoryEntryFieldNumber = 1;
- inline const ::std::string& directory_entry() const;
- inline void set_directory_entry(const ::std::string& value);
- inline void set_directory_entry(const char* value);
- inline void set_directory_entry(const void* value, size_t size);
- inline ::std::string* mutable_directory_entry();
- inline ::std::string* release_directory_entry();
-
- // optional bytes raw_data = 2;
- inline bool has_raw_data() const;
- inline void clear_raw_data();
- static const int kRawDataFieldNumber = 2;
- inline const ::std::string& raw_data() const;
- inline void set_raw_data(const ::std::string& value);
- inline void set_raw_data(const char* value);
- inline void set_raw_data(const void* value, size_t size);
- inline ::std::string* mutable_raw_data();
- inline ::std::string* release_raw_data();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData)
- private:
- inline void set_has_directory_entry();
- inline void clear_has_directory_entry();
- inline void set_has_raw_data();
- inline void clear_has_raw_data();
-
- ::std::string* directory_entry_;
- ::std::string* raw_data_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_PEImageHeaders_DebugData* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_PEImageHeaders : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_PEImageHeaders();
- virtual ~ClientDownloadRequest_PEImageHeaders();
-
- ClientDownloadRequest_PEImageHeaders(const ClientDownloadRequest_PEImageHeaders& from);
-
- inline ClientDownloadRequest_PEImageHeaders& operator=(const ClientDownloadRequest_PEImageHeaders& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_PEImageHeaders& default_instance();
-
- void Swap(ClientDownloadRequest_PEImageHeaders* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_PEImageHeaders* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_PEImageHeaders& from);
- void MergeFrom(const ClientDownloadRequest_PEImageHeaders& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef ClientDownloadRequest_PEImageHeaders_DebugData DebugData;
-
- // accessors -------------------------------------------------------
-
- // optional bytes dos_header = 1;
- inline bool has_dos_header() const;
- inline void clear_dos_header();
- static const int kDosHeaderFieldNumber = 1;
- inline const ::std::string& dos_header() const;
- inline void set_dos_header(const ::std::string& value);
- inline void set_dos_header(const char* value);
- inline void set_dos_header(const void* value, size_t size);
- inline ::std::string* mutable_dos_header();
- inline ::std::string* release_dos_header();
-
- // optional bytes file_header = 2;
- inline bool has_file_header() const;
- inline void clear_file_header();
- static const int kFileHeaderFieldNumber = 2;
- inline const ::std::string& file_header() const;
- inline void set_file_header(const ::std::string& value);
- inline void set_file_header(const char* value);
- inline void set_file_header(const void* value, size_t size);
- inline ::std::string* mutable_file_header();
- inline ::std::string* release_file_header();
-
- // optional bytes optional_headers32 = 3;
- inline bool has_optional_headers32() const;
- inline void clear_optional_headers32();
- static const int kOptionalHeaders32FieldNumber = 3;
- inline const ::std::string& optional_headers32() const;
- inline void set_optional_headers32(const ::std::string& value);
- inline void set_optional_headers32(const char* value);
- inline void set_optional_headers32(const void* value, size_t size);
- inline ::std::string* mutable_optional_headers32();
- inline ::std::string* release_optional_headers32();
-
- // optional bytes optional_headers64 = 4;
- inline bool has_optional_headers64() const;
- inline void clear_optional_headers64();
- static const int kOptionalHeaders64FieldNumber = 4;
- inline const ::std::string& optional_headers64() const;
- inline void set_optional_headers64(const ::std::string& value);
- inline void set_optional_headers64(const char* value);
- inline void set_optional_headers64(const void* value, size_t size);
- inline ::std::string* mutable_optional_headers64();
- inline ::std::string* release_optional_headers64();
-
- // repeated bytes section_header = 5;
- inline int section_header_size() const;
- inline void clear_section_header();
- static const int kSectionHeaderFieldNumber = 5;
- inline const ::std::string& section_header(int index) const;
- inline ::std::string* mutable_section_header(int index);
- inline void set_section_header(int index, const ::std::string& value);
- inline void set_section_header(int index, const char* value);
- inline void set_section_header(int index, const void* value, size_t size);
- inline ::std::string* add_section_header();
- inline void add_section_header(const ::std::string& value);
- inline void add_section_header(const char* value);
- inline void add_section_header(const void* value, size_t size);
- inline const ::google::protobuf::RepeatedPtrField< ::std::string>& section_header() const;
- inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_section_header();
-
- // optional bytes export_section_data = 6;
- inline bool has_export_section_data() const;
- inline void clear_export_section_data();
- static const int kExportSectionDataFieldNumber = 6;
- inline const ::std::string& export_section_data() const;
- inline void set_export_section_data(const ::std::string& value);
- inline void set_export_section_data(const char* value);
- inline void set_export_section_data(const void* value, size_t size);
- inline ::std::string* mutable_export_section_data();
- inline ::std::string* release_export_section_data();
-
- // repeated .safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData debug_data = 7;
- inline int debug_data_size() const;
- inline void clear_debug_data();
- static const int kDebugDataFieldNumber = 7;
- inline const ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData& debug_data(int index) const;
- inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData* mutable_debug_data(int index);
- inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData* add_debug_data();
- inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData >&
- debug_data() const;
- inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData >*
- mutable_debug_data();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.PEImageHeaders)
- private:
- inline void set_has_dos_header();
- inline void clear_has_dos_header();
- inline void set_has_file_header();
- inline void clear_has_file_header();
- inline void set_has_optional_headers32();
- inline void clear_has_optional_headers32();
- inline void set_has_optional_headers64();
- inline void clear_has_optional_headers64();
- inline void set_has_export_section_data();
- inline void clear_has_export_section_data();
-
- ::std::string* dos_header_;
- ::std::string* file_header_;
- ::std::string* optional_headers32_;
- ::std::string* optional_headers64_;
- ::google::protobuf::RepeatedPtrField< ::std::string> section_header_;
- ::std::string* export_section_data_;
- ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData > debug_data_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(7 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_PEImageHeaders* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest_ImageHeaders : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest_ImageHeaders();
- virtual ~ClientDownloadRequest_ImageHeaders();
-
- ClientDownloadRequest_ImageHeaders(const ClientDownloadRequest_ImageHeaders& from);
-
- inline ClientDownloadRequest_ImageHeaders& operator=(const ClientDownloadRequest_ImageHeaders& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest_ImageHeaders& default_instance();
-
- void Swap(ClientDownloadRequest_ImageHeaders* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest_ImageHeaders* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest_ImageHeaders& from);
- void MergeFrom(const ClientDownloadRequest_ImageHeaders& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional .safe_browsing.ClientDownloadRequest.PEImageHeaders pe_headers = 1;
- inline bool has_pe_headers() const;
- inline void clear_pe_headers();
- static const int kPeHeadersFieldNumber = 1;
- inline const ::safe_browsing::ClientDownloadRequest_PEImageHeaders& pe_headers() const;
- inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders* mutable_pe_headers();
- inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders* release_pe_headers();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest.ImageHeaders)
- private:
- inline void set_has_pe_headers();
- inline void clear_has_pe_headers();
-
- ::safe_browsing::ClientDownloadRequest_PEImageHeaders* pe_headers_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest_ImageHeaders* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadRequest : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadRequest();
- virtual ~ClientDownloadRequest();
-
- ClientDownloadRequest(const ClientDownloadRequest& from);
-
- inline ClientDownloadRequest& operator=(const ClientDownloadRequest& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadRequest& default_instance();
-
- void Swap(ClientDownloadRequest* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadRequest* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadRequest& from);
- void MergeFrom(const ClientDownloadRequest& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef ClientDownloadRequest_Digests Digests;
- typedef ClientDownloadRequest_Resource Resource;
- typedef ClientDownloadRequest_CertificateChain CertificateChain;
- typedef ClientDownloadRequest_SignatureInfo SignatureInfo;
- typedef ClientDownloadRequest_PEImageHeaders PEImageHeaders;
- typedef ClientDownloadRequest_ImageHeaders ImageHeaders;
-
- typedef ClientDownloadRequest_ResourceType ResourceType;
- static const ResourceType DOWNLOAD_URL = ClientDownloadRequest_ResourceType_DOWNLOAD_URL;
- static const ResourceType DOWNLOAD_REDIRECT = ClientDownloadRequest_ResourceType_DOWNLOAD_REDIRECT;
- static const ResourceType TAB_URL = ClientDownloadRequest_ResourceType_TAB_URL;
- static const ResourceType TAB_REDIRECT = ClientDownloadRequest_ResourceType_TAB_REDIRECT;
- static inline bool ResourceType_IsValid(int value) {
- return ClientDownloadRequest_ResourceType_IsValid(value);
- }
- static const ResourceType ResourceType_MIN =
- ClientDownloadRequest_ResourceType_ResourceType_MIN;
- static const ResourceType ResourceType_MAX =
- ClientDownloadRequest_ResourceType_ResourceType_MAX;
- static const int ResourceType_ARRAYSIZE =
- ClientDownloadRequest_ResourceType_ResourceType_ARRAYSIZE;
-
- typedef ClientDownloadRequest_DownloadType DownloadType;
- static const DownloadType WIN_EXECUTABLE = ClientDownloadRequest_DownloadType_WIN_EXECUTABLE;
- static const DownloadType CHROME_EXTENSION = ClientDownloadRequest_DownloadType_CHROME_EXTENSION;
- static const DownloadType ANDROID_APK = ClientDownloadRequest_DownloadType_ANDROID_APK;
- static const DownloadType ZIPPED_EXECUTABLE = ClientDownloadRequest_DownloadType_ZIPPED_EXECUTABLE;
- static inline bool DownloadType_IsValid(int value) {
- return ClientDownloadRequest_DownloadType_IsValid(value);
- }
- static const DownloadType DownloadType_MIN =
- ClientDownloadRequest_DownloadType_DownloadType_MIN;
- static const DownloadType DownloadType_MAX =
- ClientDownloadRequest_DownloadType_DownloadType_MAX;
- static const int DownloadType_ARRAYSIZE =
- ClientDownloadRequest_DownloadType_DownloadType_ARRAYSIZE;
-
- // accessors -------------------------------------------------------
-
- // required string url = 1;
- inline bool has_url() const;
- inline void clear_url();
- static const int kUrlFieldNumber = 1;
- inline const ::std::string& url() const;
- inline void set_url(const ::std::string& value);
- inline void set_url(const char* value);
- inline void set_url(const char* value, size_t size);
- inline ::std::string* mutable_url();
- inline ::std::string* release_url();
-
- // required .safe_browsing.ClientDownloadRequest.Digests digests = 2;
- inline bool has_digests() const;
- inline void clear_digests();
- static const int kDigestsFieldNumber = 2;
- inline const ::safe_browsing::ClientDownloadRequest_Digests& digests() const;
- inline ::safe_browsing::ClientDownloadRequest_Digests* mutable_digests();
- inline ::safe_browsing::ClientDownloadRequest_Digests* release_digests();
-
- // required int64 length = 3;
- inline bool has_length() const;
- inline void clear_length();
- static const int kLengthFieldNumber = 3;
- inline ::google::protobuf::int64 length() const;
- inline void set_length(::google::protobuf::int64 value);
-
- // repeated .safe_browsing.ClientDownloadRequest.Resource resources = 4;
- inline int resources_size() const;
- inline void clear_resources();
- static const int kResourcesFieldNumber = 4;
- inline const ::safe_browsing::ClientDownloadRequest_Resource& resources(int index) const;
- inline ::safe_browsing::ClientDownloadRequest_Resource* mutable_resources(int index);
- inline ::safe_browsing::ClientDownloadRequest_Resource* add_resources();
- inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_Resource >&
- resources() const;
- inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_Resource >*
- mutable_resources();
-
- // optional .safe_browsing.ClientDownloadRequest.SignatureInfo signature = 5;
- inline bool has_signature() const;
- inline void clear_signature();
- static const int kSignatureFieldNumber = 5;
- inline const ::safe_browsing::ClientDownloadRequest_SignatureInfo& signature() const;
- inline ::safe_browsing::ClientDownloadRequest_SignatureInfo* mutable_signature();
- inline ::safe_browsing::ClientDownloadRequest_SignatureInfo* release_signature();
-
- // optional bool user_initiated = 6;
- inline bool has_user_initiated() const;
- inline void clear_user_initiated();
- static const int kUserInitiatedFieldNumber = 6;
- inline bool user_initiated() const;
- inline void set_user_initiated(bool value);
-
- // optional string file_basename = 9;
- inline bool has_file_basename() const;
- inline void clear_file_basename();
- static const int kFileBasenameFieldNumber = 9;
- inline const ::std::string& file_basename() const;
- inline void set_file_basename(const ::std::string& value);
- inline void set_file_basename(const char* value);
- inline void set_file_basename(const char* value, size_t size);
- inline ::std::string* mutable_file_basename();
- inline ::std::string* release_file_basename();
-
- // optional .safe_browsing.ClientDownloadRequest.DownloadType download_type = 10 [default = WIN_EXECUTABLE];
- inline bool has_download_type() const;
- inline void clear_download_type();
- static const int kDownloadTypeFieldNumber = 10;
- inline ::safe_browsing::ClientDownloadRequest_DownloadType download_type() const;
- inline void set_download_type(::safe_browsing::ClientDownloadRequest_DownloadType value);
-
- // optional string locale = 11;
- inline bool has_locale() const;
- inline void clear_locale();
- static const int kLocaleFieldNumber = 11;
- inline const ::std::string& locale() const;
- inline void set_locale(const ::std::string& value);
- inline void set_locale(const char* value);
- inline void set_locale(const char* value, size_t size);
- inline ::std::string* mutable_locale();
- inline ::std::string* release_locale();
-
- // optional .safe_browsing.ClientDownloadRequest.ImageHeaders image_headers = 18;
- inline bool has_image_headers() const;
- inline void clear_image_headers();
- static const int kImageHeadersFieldNumber = 18;
- inline const ::safe_browsing::ClientDownloadRequest_ImageHeaders& image_headers() const;
- inline ::safe_browsing::ClientDownloadRequest_ImageHeaders* mutable_image_headers();
- inline ::safe_browsing::ClientDownloadRequest_ImageHeaders* release_image_headers();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadRequest)
- private:
- inline void set_has_url();
- inline void clear_has_url();
- inline void set_has_digests();
- inline void clear_has_digests();
- inline void set_has_length();
- inline void clear_has_length();
- inline void set_has_signature();
- inline void clear_has_signature();
- inline void set_has_user_initiated();
- inline void clear_has_user_initiated();
- inline void set_has_file_basename();
- inline void clear_has_file_basename();
- inline void set_has_download_type();
- inline void clear_has_download_type();
- inline void set_has_locale();
- inline void clear_has_locale();
- inline void set_has_image_headers();
- inline void clear_has_image_headers();
-
- ::std::string* url_;
- ::safe_browsing::ClientDownloadRequest_Digests* digests_;
- ::google::protobuf::int64 length_;
- ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_Resource > resources_;
- ::safe_browsing::ClientDownloadRequest_SignatureInfo* signature_;
- ::std::string* file_basename_;
- bool user_initiated_;
- int download_type_;
- ::std::string* locale_;
- ::safe_browsing::ClientDownloadRequest_ImageHeaders* image_headers_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(10 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadRequest* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadResponse_MoreInfo : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadResponse_MoreInfo();
- virtual ~ClientDownloadResponse_MoreInfo();
-
- ClientDownloadResponse_MoreInfo(const ClientDownloadResponse_MoreInfo& from);
-
- inline ClientDownloadResponse_MoreInfo& operator=(const ClientDownloadResponse_MoreInfo& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadResponse_MoreInfo& default_instance();
-
- void Swap(ClientDownloadResponse_MoreInfo* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadResponse_MoreInfo* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadResponse_MoreInfo& from);
- void MergeFrom(const ClientDownloadResponse_MoreInfo& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string description = 1;
- inline bool has_description() const;
- inline void clear_description();
- static const int kDescriptionFieldNumber = 1;
- inline const ::std::string& description() const;
- inline void set_description(const ::std::string& value);
- inline void set_description(const char* value);
- inline void set_description(const char* value, size_t size);
- inline ::std::string* mutable_description();
- inline ::std::string* release_description();
-
- // optional string url = 2;
- inline bool has_url() const;
- inline void clear_url();
- static const int kUrlFieldNumber = 2;
- inline const ::std::string& url() const;
- inline void set_url(const ::std::string& value);
- inline void set_url(const char* value);
- inline void set_url(const char* value, size_t size);
- inline ::std::string* mutable_url();
- inline ::std::string* release_url();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadResponse.MoreInfo)
- private:
- inline void set_has_description();
- inline void clear_has_description();
- inline void set_has_url();
- inline void clear_has_url();
-
- ::std::string* description_;
- ::std::string* url_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadResponse_MoreInfo* default_instance_;
-};
-// -------------------------------------------------------------------
-
-class ClientDownloadResponse : public ::google::protobuf::MessageLite {
- public:
- ClientDownloadResponse();
- virtual ~ClientDownloadResponse();
-
- ClientDownloadResponse(const ClientDownloadResponse& from);
-
- inline ClientDownloadResponse& operator=(const ClientDownloadResponse& from) {
- CopyFrom(from);
- return *this;
- }
-
- static const ClientDownloadResponse& default_instance();
-
- void Swap(ClientDownloadResponse* other);
-
- // implements Message ----------------------------------------------
-
- ClientDownloadResponse* New() const;
- void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);
- void CopyFrom(const ClientDownloadResponse& from);
- void MergeFrom(const ClientDownloadResponse& from);
- void Clear();
- bool IsInitialized() const;
-
- int ByteSize() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- public:
-
- ::std::string GetTypeName() const;
-
- // nested types ----------------------------------------------------
-
- typedef ClientDownloadResponse_MoreInfo MoreInfo;
-
- typedef ClientDownloadResponse_Verdict Verdict;
- static const Verdict SAFE = ClientDownloadResponse_Verdict_SAFE;
- static const Verdict DANGEROUS = ClientDownloadResponse_Verdict_DANGEROUS;
- static const Verdict UNCOMMON = ClientDownloadResponse_Verdict_UNCOMMON;
- static const Verdict POTENTIALLY_UNWANTED = ClientDownloadResponse_Verdict_POTENTIALLY_UNWANTED;
- static const Verdict DANGEROUS_HOST = ClientDownloadResponse_Verdict_DANGEROUS_HOST;
- static inline bool Verdict_IsValid(int value) {
- return ClientDownloadResponse_Verdict_IsValid(value);
- }
- static const Verdict Verdict_MIN =
- ClientDownloadResponse_Verdict_Verdict_MIN;
- static const Verdict Verdict_MAX =
- ClientDownloadResponse_Verdict_Verdict_MAX;
- static const int Verdict_ARRAYSIZE =
- ClientDownloadResponse_Verdict_Verdict_ARRAYSIZE;
-
- // accessors -------------------------------------------------------
-
- // required .safe_browsing.ClientDownloadResponse.Verdict verdict = 1;
- inline bool has_verdict() const;
- inline void clear_verdict();
- static const int kVerdictFieldNumber = 1;
- inline ::safe_browsing::ClientDownloadResponse_Verdict verdict() const;
- inline void set_verdict(::safe_browsing::ClientDownloadResponse_Verdict value);
-
- // optional .safe_browsing.ClientDownloadResponse.MoreInfo more_info = 2;
- inline bool has_more_info() const;
- inline void clear_more_info();
- static const int kMoreInfoFieldNumber = 2;
- inline const ::safe_browsing::ClientDownloadResponse_MoreInfo& more_info() const;
- inline ::safe_browsing::ClientDownloadResponse_MoreInfo* mutable_more_info();
- inline ::safe_browsing::ClientDownloadResponse_MoreInfo* release_more_info();
-
- // optional bytes token = 3;
- inline bool has_token() const;
- inline void clear_token();
- static const int kTokenFieldNumber = 3;
- inline const ::std::string& token() const;
- inline void set_token(const ::std::string& value);
- inline void set_token(const char* value);
- inline void set_token(const void* value, size_t size);
- inline ::std::string* mutable_token();
- inline ::std::string* release_token();
-
- // @@protoc_insertion_point(class_scope:safe_browsing.ClientDownloadResponse)
- private:
- inline void set_has_verdict();
- inline void clear_has_verdict();
- inline void set_has_more_info();
- inline void clear_has_more_info();
- inline void set_has_token();
- inline void clear_has_token();
-
- ::safe_browsing::ClientDownloadResponse_MoreInfo* more_info_;
- ::std::string* token_;
- int verdict_;
-
- mutable int _cached_size_;
- ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32];
-
- friend void protobuf_AddDesc_csd_2eproto();
- friend void protobuf_AssignDesc_csd_2eproto();
- friend void protobuf_ShutdownFile_csd_2eproto();
-
- void InitAsDefaultInstance();
- static ClientDownloadResponse* default_instance_;
-};
-// ===================================================================
-
-
-// ===================================================================
-
-// ClientDownloadRequest_Digests
-
-// optional bytes sha256 = 1;
-inline bool ClientDownloadRequest_Digests::has_sha256() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest_Digests::set_has_sha256() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest_Digests::clear_has_sha256() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest_Digests::clear_sha256() {
- if (sha256_ != &::google::protobuf::internal::kEmptyString) {
- sha256_->clear();
- }
- clear_has_sha256();
-}
-inline const ::std::string& ClientDownloadRequest_Digests::sha256() const {
- return *sha256_;
-}
-inline void ClientDownloadRequest_Digests::set_sha256(const ::std::string& value) {
- set_has_sha256();
- if (sha256_ == &::google::protobuf::internal::kEmptyString) {
- sha256_ = new ::std::string;
- }
- sha256_->assign(value);
-}
-inline void ClientDownloadRequest_Digests::set_sha256(const char* value) {
- set_has_sha256();
- if (sha256_ == &::google::protobuf::internal::kEmptyString) {
- sha256_ = new ::std::string;
- }
- sha256_->assign(value);
-}
-inline void ClientDownloadRequest_Digests::set_sha256(const void* value, size_t size) {
- set_has_sha256();
- if (sha256_ == &::google::protobuf::internal::kEmptyString) {
- sha256_ = new ::std::string;
- }
- sha256_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_Digests::mutable_sha256() {
- set_has_sha256();
- if (sha256_ == &::google::protobuf::internal::kEmptyString) {
- sha256_ = new ::std::string;
- }
- return sha256_;
-}
-inline ::std::string* ClientDownloadRequest_Digests::release_sha256() {
- clear_has_sha256();
- if (sha256_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = sha256_;
- sha256_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional bytes sha1 = 2;
-inline bool ClientDownloadRequest_Digests::has_sha1() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadRequest_Digests::set_has_sha1() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadRequest_Digests::clear_has_sha1() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadRequest_Digests::clear_sha1() {
- if (sha1_ != &::google::protobuf::internal::kEmptyString) {
- sha1_->clear();
- }
- clear_has_sha1();
-}
-inline const ::std::string& ClientDownloadRequest_Digests::sha1() const {
- return *sha1_;
-}
-inline void ClientDownloadRequest_Digests::set_sha1(const ::std::string& value) {
- set_has_sha1();
- if (sha1_ == &::google::protobuf::internal::kEmptyString) {
- sha1_ = new ::std::string;
- }
- sha1_->assign(value);
-}
-inline void ClientDownloadRequest_Digests::set_sha1(const char* value) {
- set_has_sha1();
- if (sha1_ == &::google::protobuf::internal::kEmptyString) {
- sha1_ = new ::std::string;
- }
- sha1_->assign(value);
-}
-inline void ClientDownloadRequest_Digests::set_sha1(const void* value, size_t size) {
- set_has_sha1();
- if (sha1_ == &::google::protobuf::internal::kEmptyString) {
- sha1_ = new ::std::string;
- }
- sha1_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_Digests::mutable_sha1() {
- set_has_sha1();
- if (sha1_ == &::google::protobuf::internal::kEmptyString) {
- sha1_ = new ::std::string;
- }
- return sha1_;
-}
-inline ::std::string* ClientDownloadRequest_Digests::release_sha1() {
- clear_has_sha1();
- if (sha1_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = sha1_;
- sha1_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional bytes md5 = 3;
-inline bool ClientDownloadRequest_Digests::has_md5() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ClientDownloadRequest_Digests::set_has_md5() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ClientDownloadRequest_Digests::clear_has_md5() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ClientDownloadRequest_Digests::clear_md5() {
- if (md5_ != &::google::protobuf::internal::kEmptyString) {
- md5_->clear();
- }
- clear_has_md5();
-}
-inline const ::std::string& ClientDownloadRequest_Digests::md5() const {
- return *md5_;
-}
-inline void ClientDownloadRequest_Digests::set_md5(const ::std::string& value) {
- set_has_md5();
- if (md5_ == &::google::protobuf::internal::kEmptyString) {
- md5_ = new ::std::string;
- }
- md5_->assign(value);
-}
-inline void ClientDownloadRequest_Digests::set_md5(const char* value) {
- set_has_md5();
- if (md5_ == &::google::protobuf::internal::kEmptyString) {
- md5_ = new ::std::string;
- }
- md5_->assign(value);
-}
-inline void ClientDownloadRequest_Digests::set_md5(const void* value, size_t size) {
- set_has_md5();
- if (md5_ == &::google::protobuf::internal::kEmptyString) {
- md5_ = new ::std::string;
- }
- md5_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_Digests::mutable_md5() {
- set_has_md5();
- if (md5_ == &::google::protobuf::internal::kEmptyString) {
- md5_ = new ::std::string;
- }
- return md5_;
-}
-inline ::std::string* ClientDownloadRequest_Digests::release_md5() {
- clear_has_md5();
- if (md5_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = md5_;
- md5_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_Resource
-
-// required string url = 1;
-inline bool ClientDownloadRequest_Resource::has_url() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest_Resource::set_has_url() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest_Resource::clear_has_url() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest_Resource::clear_url() {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- url_->clear();
- }
- clear_has_url();
-}
-inline const ::std::string& ClientDownloadRequest_Resource::url() const {
- return *url_;
-}
-inline void ClientDownloadRequest_Resource::set_url(const ::std::string& value) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(value);
-}
-inline void ClientDownloadRequest_Resource::set_url(const char* value) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(value);
-}
-inline void ClientDownloadRequest_Resource::set_url(const char* value, size_t size) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_Resource::mutable_url() {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- return url_;
-}
-inline ::std::string* ClientDownloadRequest_Resource::release_url() {
- clear_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = url_;
- url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// required .safe_browsing.ClientDownloadRequest.ResourceType type = 2;
-inline bool ClientDownloadRequest_Resource::has_type() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadRequest_Resource::set_has_type() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadRequest_Resource::clear_has_type() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadRequest_Resource::clear_type() {
- type_ = 0;
- clear_has_type();
-}
-inline ::safe_browsing::ClientDownloadRequest_ResourceType ClientDownloadRequest_Resource::type() const {
- return static_cast< ::safe_browsing::ClientDownloadRequest_ResourceType >(type_);
-}
-inline void ClientDownloadRequest_Resource::set_type(::safe_browsing::ClientDownloadRequest_ResourceType value) {
- GOOGLE_DCHECK(::safe_browsing::ClientDownloadRequest_ResourceType_IsValid(value));
- set_has_type();
- type_ = value;
-}
-
-// optional bytes remote_ip = 3;
-inline bool ClientDownloadRequest_Resource::has_remote_ip() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ClientDownloadRequest_Resource::set_has_remote_ip() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ClientDownloadRequest_Resource::clear_has_remote_ip() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ClientDownloadRequest_Resource::clear_remote_ip() {
- if (remote_ip_ != &::google::protobuf::internal::kEmptyString) {
- remote_ip_->clear();
- }
- clear_has_remote_ip();
-}
-inline const ::std::string& ClientDownloadRequest_Resource::remote_ip() const {
- return *remote_ip_;
-}
-inline void ClientDownloadRequest_Resource::set_remote_ip(const ::std::string& value) {
- set_has_remote_ip();
- if (remote_ip_ == &::google::protobuf::internal::kEmptyString) {
- remote_ip_ = new ::std::string;
- }
- remote_ip_->assign(value);
-}
-inline void ClientDownloadRequest_Resource::set_remote_ip(const char* value) {
- set_has_remote_ip();
- if (remote_ip_ == &::google::protobuf::internal::kEmptyString) {
- remote_ip_ = new ::std::string;
- }
- remote_ip_->assign(value);
-}
-inline void ClientDownloadRequest_Resource::set_remote_ip(const void* value, size_t size) {
- set_has_remote_ip();
- if (remote_ip_ == &::google::protobuf::internal::kEmptyString) {
- remote_ip_ = new ::std::string;
- }
- remote_ip_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_Resource::mutable_remote_ip() {
- set_has_remote_ip();
- if (remote_ip_ == &::google::protobuf::internal::kEmptyString) {
- remote_ip_ = new ::std::string;
- }
- return remote_ip_;
-}
-inline ::std::string* ClientDownloadRequest_Resource::release_remote_ip() {
- clear_has_remote_ip();
- if (remote_ip_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = remote_ip_;
- remote_ip_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional string referrer = 4;
-inline bool ClientDownloadRequest_Resource::has_referrer() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void ClientDownloadRequest_Resource::set_has_referrer() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void ClientDownloadRequest_Resource::clear_has_referrer() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void ClientDownloadRequest_Resource::clear_referrer() {
- if (referrer_ != &::google::protobuf::internal::kEmptyString) {
- referrer_->clear();
- }
- clear_has_referrer();
-}
-inline const ::std::string& ClientDownloadRequest_Resource::referrer() const {
- return *referrer_;
-}
-inline void ClientDownloadRequest_Resource::set_referrer(const ::std::string& value) {
- set_has_referrer();
- if (referrer_ == &::google::protobuf::internal::kEmptyString) {
- referrer_ = new ::std::string;
- }
- referrer_->assign(value);
-}
-inline void ClientDownloadRequest_Resource::set_referrer(const char* value) {
- set_has_referrer();
- if (referrer_ == &::google::protobuf::internal::kEmptyString) {
- referrer_ = new ::std::string;
- }
- referrer_->assign(value);
-}
-inline void ClientDownloadRequest_Resource::set_referrer(const char* value, size_t size) {
- set_has_referrer();
- if (referrer_ == &::google::protobuf::internal::kEmptyString) {
- referrer_ = new ::std::string;
- }
- referrer_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_Resource::mutable_referrer() {
- set_has_referrer();
- if (referrer_ == &::google::protobuf::internal::kEmptyString) {
- referrer_ = new ::std::string;
- }
- return referrer_;
-}
-inline ::std::string* ClientDownloadRequest_Resource::release_referrer() {
- clear_has_referrer();
- if (referrer_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = referrer_;
- referrer_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_CertificateChain_Element
-
-// optional bytes certificate = 1;
-inline bool ClientDownloadRequest_CertificateChain_Element::has_certificate() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest_CertificateChain_Element::set_has_certificate() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest_CertificateChain_Element::clear_has_certificate() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest_CertificateChain_Element::clear_certificate() {
- if (certificate_ != &::google::protobuf::internal::kEmptyString) {
- certificate_->clear();
- }
- clear_has_certificate();
-}
-inline const ::std::string& ClientDownloadRequest_CertificateChain_Element::certificate() const {
- return *certificate_;
-}
-inline void ClientDownloadRequest_CertificateChain_Element::set_certificate(const ::std::string& value) {
- set_has_certificate();
- if (certificate_ == &::google::protobuf::internal::kEmptyString) {
- certificate_ = new ::std::string;
- }
- certificate_->assign(value);
-}
-inline void ClientDownloadRequest_CertificateChain_Element::set_certificate(const char* value) {
- set_has_certificate();
- if (certificate_ == &::google::protobuf::internal::kEmptyString) {
- certificate_ = new ::std::string;
- }
- certificate_->assign(value);
-}
-inline void ClientDownloadRequest_CertificateChain_Element::set_certificate(const void* value, size_t size) {
- set_has_certificate();
- if (certificate_ == &::google::protobuf::internal::kEmptyString) {
- certificate_ = new ::std::string;
- }
- certificate_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_CertificateChain_Element::mutable_certificate() {
- set_has_certificate();
- if (certificate_ == &::google::protobuf::internal::kEmptyString) {
- certificate_ = new ::std::string;
- }
- return certificate_;
-}
-inline ::std::string* ClientDownloadRequest_CertificateChain_Element::release_certificate() {
- clear_has_certificate();
- if (certificate_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = certificate_;
- certificate_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_CertificateChain
-
-// repeated .safe_browsing.ClientDownloadRequest.CertificateChain.Element element = 1;
-inline int ClientDownloadRequest_CertificateChain::element_size() const {
- return element_.size();
-}
-inline void ClientDownloadRequest_CertificateChain::clear_element() {
- element_.Clear();
-}
-inline const ::safe_browsing::ClientDownloadRequest_CertificateChain_Element& ClientDownloadRequest_CertificateChain::element(int index) const {
- return element_.Get(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_CertificateChain_Element* ClientDownloadRequest_CertificateChain::mutable_element(int index) {
- return element_.Mutable(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_CertificateChain_Element* ClientDownloadRequest_CertificateChain::add_element() {
- return element_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain_Element >&
-ClientDownloadRequest_CertificateChain::element() const {
- return element_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain_Element >*
-ClientDownloadRequest_CertificateChain::mutable_element() {
- return &element_;
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_SignatureInfo
-
-// repeated .safe_browsing.ClientDownloadRequest.CertificateChain certificate_chain = 1;
-inline int ClientDownloadRequest_SignatureInfo::certificate_chain_size() const {
- return certificate_chain_.size();
-}
-inline void ClientDownloadRequest_SignatureInfo::clear_certificate_chain() {
- certificate_chain_.Clear();
-}
-inline const ::safe_browsing::ClientDownloadRequest_CertificateChain& ClientDownloadRequest_SignatureInfo::certificate_chain(int index) const {
- return certificate_chain_.Get(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_CertificateChain* ClientDownloadRequest_SignatureInfo::mutable_certificate_chain(int index) {
- return certificate_chain_.Mutable(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_CertificateChain* ClientDownloadRequest_SignatureInfo::add_certificate_chain() {
- return certificate_chain_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain >&
-ClientDownloadRequest_SignatureInfo::certificate_chain() const {
- return certificate_chain_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_CertificateChain >*
-ClientDownloadRequest_SignatureInfo::mutable_certificate_chain() {
- return &certificate_chain_;
-}
-
-// optional bool trusted = 2;
-inline bool ClientDownloadRequest_SignatureInfo::has_trusted() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadRequest_SignatureInfo::set_has_trusted() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadRequest_SignatureInfo::clear_has_trusted() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadRequest_SignatureInfo::clear_trusted() {
- trusted_ = false;
- clear_has_trusted();
-}
-inline bool ClientDownloadRequest_SignatureInfo::trusted() const {
- return trusted_;
-}
-inline void ClientDownloadRequest_SignatureInfo::set_trusted(bool value) {
- set_has_trusted();
- trusted_ = value;
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_PEImageHeaders_DebugData
-
-// optional bytes directory_entry = 1;
-inline bool ClientDownloadRequest_PEImageHeaders_DebugData::has_directory_entry() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_has_directory_entry() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::clear_has_directory_entry() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::clear_directory_entry() {
- if (directory_entry_ != &::google::protobuf::internal::kEmptyString) {
- directory_entry_->clear();
- }
- clear_has_directory_entry();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders_DebugData::directory_entry() const {
- return *directory_entry_;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_directory_entry(const ::std::string& value) {
- set_has_directory_entry();
- if (directory_entry_ == &::google::protobuf::internal::kEmptyString) {
- directory_entry_ = new ::std::string;
- }
- directory_entry_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_directory_entry(const char* value) {
- set_has_directory_entry();
- if (directory_entry_ == &::google::protobuf::internal::kEmptyString) {
- directory_entry_ = new ::std::string;
- }
- directory_entry_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_directory_entry(const void* value, size_t size) {
- set_has_directory_entry();
- if (directory_entry_ == &::google::protobuf::internal::kEmptyString) {
- directory_entry_ = new ::std::string;
- }
- directory_entry_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders_DebugData::mutable_directory_entry() {
- set_has_directory_entry();
- if (directory_entry_ == &::google::protobuf::internal::kEmptyString) {
- directory_entry_ = new ::std::string;
- }
- return directory_entry_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders_DebugData::release_directory_entry() {
- clear_has_directory_entry();
- if (directory_entry_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = directory_entry_;
- directory_entry_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional bytes raw_data = 2;
-inline bool ClientDownloadRequest_PEImageHeaders_DebugData::has_raw_data() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_has_raw_data() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::clear_has_raw_data() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::clear_raw_data() {
- if (raw_data_ != &::google::protobuf::internal::kEmptyString) {
- raw_data_->clear();
- }
- clear_has_raw_data();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders_DebugData::raw_data() const {
- return *raw_data_;
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_raw_data(const ::std::string& value) {
- set_has_raw_data();
- if (raw_data_ == &::google::protobuf::internal::kEmptyString) {
- raw_data_ = new ::std::string;
- }
- raw_data_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_raw_data(const char* value) {
- set_has_raw_data();
- if (raw_data_ == &::google::protobuf::internal::kEmptyString) {
- raw_data_ = new ::std::string;
- }
- raw_data_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders_DebugData::set_raw_data(const void* value, size_t size) {
- set_has_raw_data();
- if (raw_data_ == &::google::protobuf::internal::kEmptyString) {
- raw_data_ = new ::std::string;
- }
- raw_data_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders_DebugData::mutable_raw_data() {
- set_has_raw_data();
- if (raw_data_ == &::google::protobuf::internal::kEmptyString) {
- raw_data_ = new ::std::string;
- }
- return raw_data_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders_DebugData::release_raw_data() {
- clear_has_raw_data();
- if (raw_data_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = raw_data_;
- raw_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_PEImageHeaders
-
-// optional bytes dos_header = 1;
-inline bool ClientDownloadRequest_PEImageHeaders::has_dos_header() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_has_dos_header() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_has_dos_header() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_dos_header() {
- if (dos_header_ != &::google::protobuf::internal::kEmptyString) {
- dos_header_->clear();
- }
- clear_has_dos_header();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders::dos_header() const {
- return *dos_header_;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_dos_header(const ::std::string& value) {
- set_has_dos_header();
- if (dos_header_ == &::google::protobuf::internal::kEmptyString) {
- dos_header_ = new ::std::string;
- }
- dos_header_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_dos_header(const char* value) {
- set_has_dos_header();
- if (dos_header_ == &::google::protobuf::internal::kEmptyString) {
- dos_header_ = new ::std::string;
- }
- dos_header_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_dos_header(const void* value, size_t size) {
- set_has_dos_header();
- if (dos_header_ == &::google::protobuf::internal::kEmptyString) {
- dos_header_ = new ::std::string;
- }
- dos_header_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::mutable_dos_header() {
- set_has_dos_header();
- if (dos_header_ == &::google::protobuf::internal::kEmptyString) {
- dos_header_ = new ::std::string;
- }
- return dos_header_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::release_dos_header() {
- clear_has_dos_header();
- if (dos_header_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = dos_header_;
- dos_header_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional bytes file_header = 2;
-inline bool ClientDownloadRequest_PEImageHeaders::has_file_header() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_has_file_header() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_has_file_header() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_file_header() {
- if (file_header_ != &::google::protobuf::internal::kEmptyString) {
- file_header_->clear();
- }
- clear_has_file_header();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders::file_header() const {
- return *file_header_;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_file_header(const ::std::string& value) {
- set_has_file_header();
- if (file_header_ == &::google::protobuf::internal::kEmptyString) {
- file_header_ = new ::std::string;
- }
- file_header_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_file_header(const char* value) {
- set_has_file_header();
- if (file_header_ == &::google::protobuf::internal::kEmptyString) {
- file_header_ = new ::std::string;
- }
- file_header_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_file_header(const void* value, size_t size) {
- set_has_file_header();
- if (file_header_ == &::google::protobuf::internal::kEmptyString) {
- file_header_ = new ::std::string;
- }
- file_header_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::mutable_file_header() {
- set_has_file_header();
- if (file_header_ == &::google::protobuf::internal::kEmptyString) {
- file_header_ = new ::std::string;
- }
- return file_header_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::release_file_header() {
- clear_has_file_header();
- if (file_header_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = file_header_;
- file_header_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional bytes optional_headers32 = 3;
-inline bool ClientDownloadRequest_PEImageHeaders::has_optional_headers32() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_has_optional_headers32() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_has_optional_headers32() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_optional_headers32() {
- if (optional_headers32_ != &::google::protobuf::internal::kEmptyString) {
- optional_headers32_->clear();
- }
- clear_has_optional_headers32();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders::optional_headers32() const {
- return *optional_headers32_;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_optional_headers32(const ::std::string& value) {
- set_has_optional_headers32();
- if (optional_headers32_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers32_ = new ::std::string;
- }
- optional_headers32_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_optional_headers32(const char* value) {
- set_has_optional_headers32();
- if (optional_headers32_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers32_ = new ::std::string;
- }
- optional_headers32_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_optional_headers32(const void* value, size_t size) {
- set_has_optional_headers32();
- if (optional_headers32_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers32_ = new ::std::string;
- }
- optional_headers32_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::mutable_optional_headers32() {
- set_has_optional_headers32();
- if (optional_headers32_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers32_ = new ::std::string;
- }
- return optional_headers32_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::release_optional_headers32() {
- clear_has_optional_headers32();
- if (optional_headers32_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = optional_headers32_;
- optional_headers32_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional bytes optional_headers64 = 4;
-inline bool ClientDownloadRequest_PEImageHeaders::has_optional_headers64() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_has_optional_headers64() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_has_optional_headers64() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_optional_headers64() {
- if (optional_headers64_ != &::google::protobuf::internal::kEmptyString) {
- optional_headers64_->clear();
- }
- clear_has_optional_headers64();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders::optional_headers64() const {
- return *optional_headers64_;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_optional_headers64(const ::std::string& value) {
- set_has_optional_headers64();
- if (optional_headers64_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers64_ = new ::std::string;
- }
- optional_headers64_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_optional_headers64(const char* value) {
- set_has_optional_headers64();
- if (optional_headers64_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers64_ = new ::std::string;
- }
- optional_headers64_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_optional_headers64(const void* value, size_t size) {
- set_has_optional_headers64();
- if (optional_headers64_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers64_ = new ::std::string;
- }
- optional_headers64_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::mutable_optional_headers64() {
- set_has_optional_headers64();
- if (optional_headers64_ == &::google::protobuf::internal::kEmptyString) {
- optional_headers64_ = new ::std::string;
- }
- return optional_headers64_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::release_optional_headers64() {
- clear_has_optional_headers64();
- if (optional_headers64_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = optional_headers64_;
- optional_headers64_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// repeated bytes section_header = 5;
-inline int ClientDownloadRequest_PEImageHeaders::section_header_size() const {
- return section_header_.size();
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_section_header() {
- section_header_.Clear();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders::section_header(int index) const {
- return section_header_.Get(index);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::mutable_section_header(int index) {
- return section_header_.Mutable(index);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_section_header(int index, const ::std::string& value) {
- section_header_.Mutable(index)->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_section_header(int index, const char* value) {
- section_header_.Mutable(index)->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_section_header(int index, const void* value, size_t size) {
- section_header_.Mutable(index)->assign(
- reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::add_section_header() {
- return section_header_.Add();
-}
-inline void ClientDownloadRequest_PEImageHeaders::add_section_header(const ::std::string& value) {
- section_header_.Add()->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::add_section_header(const char* value) {
- section_header_.Add()->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::add_section_header(const void* value, size_t size) {
- section_header_.Add()->assign(reinterpret_cast(value), size);
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-ClientDownloadRequest_PEImageHeaders::section_header() const {
- return section_header_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-ClientDownloadRequest_PEImageHeaders::mutable_section_header() {
- return §ion_header_;
-}
-
-// optional bytes export_section_data = 6;
-inline bool ClientDownloadRequest_PEImageHeaders::has_export_section_data() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_has_export_section_data() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_has_export_section_data() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_export_section_data() {
- if (export_section_data_ != &::google::protobuf::internal::kEmptyString) {
- export_section_data_->clear();
- }
- clear_has_export_section_data();
-}
-inline const ::std::string& ClientDownloadRequest_PEImageHeaders::export_section_data() const {
- return *export_section_data_;
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_export_section_data(const ::std::string& value) {
- set_has_export_section_data();
- if (export_section_data_ == &::google::protobuf::internal::kEmptyString) {
- export_section_data_ = new ::std::string;
- }
- export_section_data_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_export_section_data(const char* value) {
- set_has_export_section_data();
- if (export_section_data_ == &::google::protobuf::internal::kEmptyString) {
- export_section_data_ = new ::std::string;
- }
- export_section_data_->assign(value);
-}
-inline void ClientDownloadRequest_PEImageHeaders::set_export_section_data(const void* value, size_t size) {
- set_has_export_section_data();
- if (export_section_data_ == &::google::protobuf::internal::kEmptyString) {
- export_section_data_ = new ::std::string;
- }
- export_section_data_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::mutable_export_section_data() {
- set_has_export_section_data();
- if (export_section_data_ == &::google::protobuf::internal::kEmptyString) {
- export_section_data_ = new ::std::string;
- }
- return export_section_data_;
-}
-inline ::std::string* ClientDownloadRequest_PEImageHeaders::release_export_section_data() {
- clear_has_export_section_data();
- if (export_section_data_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = export_section_data_;
- export_section_data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// repeated .safe_browsing.ClientDownloadRequest.PEImageHeaders.DebugData debug_data = 7;
-inline int ClientDownloadRequest_PEImageHeaders::debug_data_size() const {
- return debug_data_.size();
-}
-inline void ClientDownloadRequest_PEImageHeaders::clear_debug_data() {
- debug_data_.Clear();
-}
-inline const ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData& ClientDownloadRequest_PEImageHeaders::debug_data(int index) const {
- return debug_data_.Get(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData* ClientDownloadRequest_PEImageHeaders::mutable_debug_data(int index) {
- return debug_data_.Mutable(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData* ClientDownloadRequest_PEImageHeaders::add_debug_data() {
- return debug_data_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData >&
-ClientDownloadRequest_PEImageHeaders::debug_data() const {
- return debug_data_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_PEImageHeaders_DebugData >*
-ClientDownloadRequest_PEImageHeaders::mutable_debug_data() {
- return &debug_data_;
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest_ImageHeaders
-
-// optional .safe_browsing.ClientDownloadRequest.PEImageHeaders pe_headers = 1;
-inline bool ClientDownloadRequest_ImageHeaders::has_pe_headers() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest_ImageHeaders::set_has_pe_headers() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest_ImageHeaders::clear_has_pe_headers() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest_ImageHeaders::clear_pe_headers() {
- if (pe_headers_ != NULL) pe_headers_->::safe_browsing::ClientDownloadRequest_PEImageHeaders::Clear();
- clear_has_pe_headers();
-}
-inline const ::safe_browsing::ClientDownloadRequest_PEImageHeaders& ClientDownloadRequest_ImageHeaders::pe_headers() const {
- return pe_headers_ != NULL ? *pe_headers_ : *default_instance_->pe_headers_;
-}
-inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders* ClientDownloadRequest_ImageHeaders::mutable_pe_headers() {
- set_has_pe_headers();
- if (pe_headers_ == NULL) pe_headers_ = new ::safe_browsing::ClientDownloadRequest_PEImageHeaders;
- return pe_headers_;
-}
-inline ::safe_browsing::ClientDownloadRequest_PEImageHeaders* ClientDownloadRequest_ImageHeaders::release_pe_headers() {
- clear_has_pe_headers();
- ::safe_browsing::ClientDownloadRequest_PEImageHeaders* temp = pe_headers_;
- pe_headers_ = NULL;
- return temp;
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadRequest
-
-// required string url = 1;
-inline bool ClientDownloadRequest::has_url() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadRequest::set_has_url() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadRequest::clear_has_url() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadRequest::clear_url() {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- url_->clear();
- }
- clear_has_url();
-}
-inline const ::std::string& ClientDownloadRequest::url() const {
- return *url_;
-}
-inline void ClientDownloadRequest::set_url(const ::std::string& value) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(value);
-}
-inline void ClientDownloadRequest::set_url(const char* value) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(value);
-}
-inline void ClientDownloadRequest::set_url(const char* value, size_t size) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest::mutable_url() {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- return url_;
-}
-inline ::std::string* ClientDownloadRequest::release_url() {
- clear_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = url_;
- url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// required .safe_browsing.ClientDownloadRequest.Digests digests = 2;
-inline bool ClientDownloadRequest::has_digests() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadRequest::set_has_digests() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadRequest::clear_has_digests() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadRequest::clear_digests() {
- if (digests_ != NULL) digests_->::safe_browsing::ClientDownloadRequest_Digests::Clear();
- clear_has_digests();
-}
-inline const ::safe_browsing::ClientDownloadRequest_Digests& ClientDownloadRequest::digests() const {
- return digests_ != NULL ? *digests_ : *default_instance_->digests_;
-}
-inline ::safe_browsing::ClientDownloadRequest_Digests* ClientDownloadRequest::mutable_digests() {
- set_has_digests();
- if (digests_ == NULL) digests_ = new ::safe_browsing::ClientDownloadRequest_Digests;
- return digests_;
-}
-inline ::safe_browsing::ClientDownloadRequest_Digests* ClientDownloadRequest::release_digests() {
- clear_has_digests();
- ::safe_browsing::ClientDownloadRequest_Digests* temp = digests_;
- digests_ = NULL;
- return temp;
-}
-
-// required int64 length = 3;
-inline bool ClientDownloadRequest::has_length() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ClientDownloadRequest::set_has_length() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ClientDownloadRequest::clear_has_length() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ClientDownloadRequest::clear_length() {
- length_ = GOOGLE_LONGLONG(0);
- clear_has_length();
-}
-inline ::google::protobuf::int64 ClientDownloadRequest::length() const {
- return length_;
-}
-inline void ClientDownloadRequest::set_length(::google::protobuf::int64 value) {
- set_has_length();
- length_ = value;
-}
-
-// repeated .safe_browsing.ClientDownloadRequest.Resource resources = 4;
-inline int ClientDownloadRequest::resources_size() const {
- return resources_.size();
-}
-inline void ClientDownloadRequest::clear_resources() {
- resources_.Clear();
-}
-inline const ::safe_browsing::ClientDownloadRequest_Resource& ClientDownloadRequest::resources(int index) const {
- return resources_.Get(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_Resource* ClientDownloadRequest::mutable_resources(int index) {
- return resources_.Mutable(index);
-}
-inline ::safe_browsing::ClientDownloadRequest_Resource* ClientDownloadRequest::add_resources() {
- return resources_.Add();
-}
-inline const ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_Resource >&
-ClientDownloadRequest::resources() const {
- return resources_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::safe_browsing::ClientDownloadRequest_Resource >*
-ClientDownloadRequest::mutable_resources() {
- return &resources_;
-}
-
-// optional .safe_browsing.ClientDownloadRequest.SignatureInfo signature = 5;
-inline bool ClientDownloadRequest::has_signature() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void ClientDownloadRequest::set_has_signature() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void ClientDownloadRequest::clear_has_signature() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void ClientDownloadRequest::clear_signature() {
- if (signature_ != NULL) signature_->::safe_browsing::ClientDownloadRequest_SignatureInfo::Clear();
- clear_has_signature();
-}
-inline const ::safe_browsing::ClientDownloadRequest_SignatureInfo& ClientDownloadRequest::signature() const {
- return signature_ != NULL ? *signature_ : *default_instance_->signature_;
-}
-inline ::safe_browsing::ClientDownloadRequest_SignatureInfo* ClientDownloadRequest::mutable_signature() {
- set_has_signature();
- if (signature_ == NULL) signature_ = new ::safe_browsing::ClientDownloadRequest_SignatureInfo;
- return signature_;
-}
-inline ::safe_browsing::ClientDownloadRequest_SignatureInfo* ClientDownloadRequest::release_signature() {
- clear_has_signature();
- ::safe_browsing::ClientDownloadRequest_SignatureInfo* temp = signature_;
- signature_ = NULL;
- return temp;
-}
-
-// optional bool user_initiated = 6;
-inline bool ClientDownloadRequest::has_user_initiated() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void ClientDownloadRequest::set_has_user_initiated() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void ClientDownloadRequest::clear_has_user_initiated() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void ClientDownloadRequest::clear_user_initiated() {
- user_initiated_ = false;
- clear_has_user_initiated();
-}
-inline bool ClientDownloadRequest::user_initiated() const {
- return user_initiated_;
-}
-inline void ClientDownloadRequest::set_user_initiated(bool value) {
- set_has_user_initiated();
- user_initiated_ = value;
-}
-
-// optional string file_basename = 9;
-inline bool ClientDownloadRequest::has_file_basename() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void ClientDownloadRequest::set_has_file_basename() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void ClientDownloadRequest::clear_has_file_basename() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void ClientDownloadRequest::clear_file_basename() {
- if (file_basename_ != &::google::protobuf::internal::kEmptyString) {
- file_basename_->clear();
- }
- clear_has_file_basename();
-}
-inline const ::std::string& ClientDownloadRequest::file_basename() const {
- return *file_basename_;
-}
-inline void ClientDownloadRequest::set_file_basename(const ::std::string& value) {
- set_has_file_basename();
- if (file_basename_ == &::google::protobuf::internal::kEmptyString) {
- file_basename_ = new ::std::string;
- }
- file_basename_->assign(value);
-}
-inline void ClientDownloadRequest::set_file_basename(const char* value) {
- set_has_file_basename();
- if (file_basename_ == &::google::protobuf::internal::kEmptyString) {
- file_basename_ = new ::std::string;
- }
- file_basename_->assign(value);
-}
-inline void ClientDownloadRequest::set_file_basename(const char* value, size_t size) {
- set_has_file_basename();
- if (file_basename_ == &::google::protobuf::internal::kEmptyString) {
- file_basename_ = new ::std::string;
- }
- file_basename_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest::mutable_file_basename() {
- set_has_file_basename();
- if (file_basename_ == &::google::protobuf::internal::kEmptyString) {
- file_basename_ = new ::std::string;
- }
- return file_basename_;
-}
-inline ::std::string* ClientDownloadRequest::release_file_basename() {
- clear_has_file_basename();
- if (file_basename_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = file_basename_;
- file_basename_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional .safe_browsing.ClientDownloadRequest.DownloadType download_type = 10 [default = WIN_EXECUTABLE];
-inline bool ClientDownloadRequest::has_download_type() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void ClientDownloadRequest::set_has_download_type() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void ClientDownloadRequest::clear_has_download_type() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void ClientDownloadRequest::clear_download_type() {
- download_type_ = 0;
- clear_has_download_type();
-}
-inline ::safe_browsing::ClientDownloadRequest_DownloadType ClientDownloadRequest::download_type() const {
- return static_cast< ::safe_browsing::ClientDownloadRequest_DownloadType >(download_type_);
-}
-inline void ClientDownloadRequest::set_download_type(::safe_browsing::ClientDownloadRequest_DownloadType value) {
- GOOGLE_DCHECK(::safe_browsing::ClientDownloadRequest_DownloadType_IsValid(value));
- set_has_download_type();
- download_type_ = value;
-}
-
-// optional string locale = 11;
-inline bool ClientDownloadRequest::has_locale() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void ClientDownloadRequest::set_has_locale() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void ClientDownloadRequest::clear_has_locale() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void ClientDownloadRequest::clear_locale() {
- if (locale_ != &::google::protobuf::internal::kEmptyString) {
- locale_->clear();
- }
- clear_has_locale();
-}
-inline const ::std::string& ClientDownloadRequest::locale() const {
- return *locale_;
-}
-inline void ClientDownloadRequest::set_locale(const ::std::string& value) {
- set_has_locale();
- if (locale_ == &::google::protobuf::internal::kEmptyString) {
- locale_ = new ::std::string;
- }
- locale_->assign(value);
-}
-inline void ClientDownloadRequest::set_locale(const char* value) {
- set_has_locale();
- if (locale_ == &::google::protobuf::internal::kEmptyString) {
- locale_ = new ::std::string;
- }
- locale_->assign(value);
-}
-inline void ClientDownloadRequest::set_locale(const char* value, size_t size) {
- set_has_locale();
- if (locale_ == &::google::protobuf::internal::kEmptyString) {
- locale_ = new ::std::string;
- }
- locale_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadRequest::mutable_locale() {
- set_has_locale();
- if (locale_ == &::google::protobuf::internal::kEmptyString) {
- locale_ = new ::std::string;
- }
- return locale_;
-}
-inline ::std::string* ClientDownloadRequest::release_locale() {
- clear_has_locale();
- if (locale_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = locale_;
- locale_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional .safe_browsing.ClientDownloadRequest.ImageHeaders image_headers = 18;
-inline bool ClientDownloadRequest::has_image_headers() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void ClientDownloadRequest::set_has_image_headers() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void ClientDownloadRequest::clear_has_image_headers() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void ClientDownloadRequest::clear_image_headers() {
- if (image_headers_ != NULL) image_headers_->::safe_browsing::ClientDownloadRequest_ImageHeaders::Clear();
- clear_has_image_headers();
-}
-inline const ::safe_browsing::ClientDownloadRequest_ImageHeaders& ClientDownloadRequest::image_headers() const {
- return image_headers_ != NULL ? *image_headers_ : *default_instance_->image_headers_;
-}
-inline ::safe_browsing::ClientDownloadRequest_ImageHeaders* ClientDownloadRequest::mutable_image_headers() {
- set_has_image_headers();
- if (image_headers_ == NULL) image_headers_ = new ::safe_browsing::ClientDownloadRequest_ImageHeaders;
- return image_headers_;
-}
-inline ::safe_browsing::ClientDownloadRequest_ImageHeaders* ClientDownloadRequest::release_image_headers() {
- clear_has_image_headers();
- ::safe_browsing::ClientDownloadRequest_ImageHeaders* temp = image_headers_;
- image_headers_ = NULL;
- return temp;
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadResponse_MoreInfo
-
-// optional string description = 1;
-inline bool ClientDownloadResponse_MoreInfo::has_description() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadResponse_MoreInfo::set_has_description() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadResponse_MoreInfo::clear_has_description() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadResponse_MoreInfo::clear_description() {
- if (description_ != &::google::protobuf::internal::kEmptyString) {
- description_->clear();
- }
- clear_has_description();
-}
-inline const ::std::string& ClientDownloadResponse_MoreInfo::description() const {
- return *description_;
-}
-inline void ClientDownloadResponse_MoreInfo::set_description(const ::std::string& value) {
- set_has_description();
- if (description_ == &::google::protobuf::internal::kEmptyString) {
- description_ = new ::std::string;
- }
- description_->assign(value);
-}
-inline void ClientDownloadResponse_MoreInfo::set_description(const char* value) {
- set_has_description();
- if (description_ == &::google::protobuf::internal::kEmptyString) {
- description_ = new ::std::string;
- }
- description_->assign(value);
-}
-inline void ClientDownloadResponse_MoreInfo::set_description(const char* value, size_t size) {
- set_has_description();
- if (description_ == &::google::protobuf::internal::kEmptyString) {
- description_ = new ::std::string;
- }
- description_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadResponse_MoreInfo::mutable_description() {
- set_has_description();
- if (description_ == &::google::protobuf::internal::kEmptyString) {
- description_ = new ::std::string;
- }
- return description_;
-}
-inline ::std::string* ClientDownloadResponse_MoreInfo::release_description() {
- clear_has_description();
- if (description_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = description_;
- description_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// optional string url = 2;
-inline bool ClientDownloadResponse_MoreInfo::has_url() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadResponse_MoreInfo::set_has_url() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadResponse_MoreInfo::clear_has_url() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadResponse_MoreInfo::clear_url() {
- if (url_ != &::google::protobuf::internal::kEmptyString) {
- url_->clear();
- }
- clear_has_url();
-}
-inline const ::std::string& ClientDownloadResponse_MoreInfo::url() const {
- return *url_;
-}
-inline void ClientDownloadResponse_MoreInfo::set_url(const ::std::string& value) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(value);
-}
-inline void ClientDownloadResponse_MoreInfo::set_url(const char* value) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(value);
-}
-inline void ClientDownloadResponse_MoreInfo::set_url(const char* value, size_t size) {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- url_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadResponse_MoreInfo::mutable_url() {
- set_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- url_ = new ::std::string;
- }
- return url_;
-}
-inline ::std::string* ClientDownloadResponse_MoreInfo::release_url() {
- clear_has_url();
- if (url_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = url_;
- url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-// -------------------------------------------------------------------
-
-// ClientDownloadResponse
-
-// required .safe_browsing.ClientDownloadResponse.Verdict verdict = 1;
-inline bool ClientDownloadResponse::has_verdict() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ClientDownloadResponse::set_has_verdict() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ClientDownloadResponse::clear_has_verdict() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ClientDownloadResponse::clear_verdict() {
- verdict_ = 0;
- clear_has_verdict();
-}
-inline ::safe_browsing::ClientDownloadResponse_Verdict ClientDownloadResponse::verdict() const {
- return static_cast< ::safe_browsing::ClientDownloadResponse_Verdict >(verdict_);
-}
-inline void ClientDownloadResponse::set_verdict(::safe_browsing::ClientDownloadResponse_Verdict value) {
- GOOGLE_DCHECK(::safe_browsing::ClientDownloadResponse_Verdict_IsValid(value));
- set_has_verdict();
- verdict_ = value;
-}
-
-// optional .safe_browsing.ClientDownloadResponse.MoreInfo more_info = 2;
-inline bool ClientDownloadResponse::has_more_info() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ClientDownloadResponse::set_has_more_info() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ClientDownloadResponse::clear_has_more_info() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ClientDownloadResponse::clear_more_info() {
- if (more_info_ != NULL) more_info_->::safe_browsing::ClientDownloadResponse_MoreInfo::Clear();
- clear_has_more_info();
-}
-inline const ::safe_browsing::ClientDownloadResponse_MoreInfo& ClientDownloadResponse::more_info() const {
- return more_info_ != NULL ? *more_info_ : *default_instance_->more_info_;
-}
-inline ::safe_browsing::ClientDownloadResponse_MoreInfo* ClientDownloadResponse::mutable_more_info() {
- set_has_more_info();
- if (more_info_ == NULL) more_info_ = new ::safe_browsing::ClientDownloadResponse_MoreInfo;
- return more_info_;
-}
-inline ::safe_browsing::ClientDownloadResponse_MoreInfo* ClientDownloadResponse::release_more_info() {
- clear_has_more_info();
- ::safe_browsing::ClientDownloadResponse_MoreInfo* temp = more_info_;
- more_info_ = NULL;
- return temp;
-}
-
-// optional bytes token = 3;
-inline bool ClientDownloadResponse::has_token() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ClientDownloadResponse::set_has_token() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ClientDownloadResponse::clear_has_token() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ClientDownloadResponse::clear_token() {
- if (token_ != &::google::protobuf::internal::kEmptyString) {
- token_->clear();
- }
- clear_has_token();
-}
-inline const ::std::string& ClientDownloadResponse::token() const {
- return *token_;
-}
-inline void ClientDownloadResponse::set_token(const ::std::string& value) {
- set_has_token();
- if (token_ == &::google::protobuf::internal::kEmptyString) {
- token_ = new ::std::string;
- }
- token_->assign(value);
-}
-inline void ClientDownloadResponse::set_token(const char* value) {
- set_has_token();
- if (token_ == &::google::protobuf::internal::kEmptyString) {
- token_ = new ::std::string;
- }
- token_->assign(value);
-}
-inline void ClientDownloadResponse::set_token(const void* value, size_t size) {
- set_has_token();
- if (token_ == &::google::protobuf::internal::kEmptyString) {
- token_ = new ::std::string;
- }
- token_->assign(reinterpret_cast(value), size);
-}
-inline ::std::string* ClientDownloadResponse::mutable_token() {
- set_has_token();
- if (token_ == &::google::protobuf::internal::kEmptyString) {
- token_ = new ::std::string;
- }
- return token_;
-}
-inline ::std::string* ClientDownloadResponse::release_token() {
- clear_has_token();
- if (token_ == &::google::protobuf::internal::kEmptyString) {
- return NULL;
- } else {
- ::std::string* temp = token_;
- token_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
- return temp;
- }
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace safe_browsing
-
-// @@protoc_insertion_point(global_scope)
-
-#endif // PROTOBUF_csd_2eproto__INCLUDED
diff --git a/toolkit/components/downloads/generate_csd.sh b/toolkit/components/downloads/generate_csd.sh
deleted file mode 100755
index a0eba711ae..0000000000
--- a/toolkit/components/downloads/generate_csd.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-# A script to generate toolkit/components/downloads/csd.pb.{cc,h} for use in
-# nsIApplicationReputationQuery. This script assumes you have downloaded and
-# installed the protocol buffer compiler.
-# As of June 26 2014, csd.proto contains many protobufs that are currently
-# unused by ApplicationReputation. You may want to strip csd.proto of these
-# before running the protocol compiler on it.
-if [ -n $PROTOC_PATH ]; then
- PROTOC_PATH=/usr/local/bin/protoc
-fi
-
-echo "Using $PROTOC_PATH as protocol compiler"
-
-if [ ! -e $PROTOC_PATH ]; then
- echo "You must install the protocol compiler from " \
- "https://code.google.com/p/protobuf/downloads/list"
- exit 1
-fi
-
-# Get the protocol buffer and compile it
-CMD='wget http://src.chromium.org/chrome/trunk/src/chrome/common/safe_browsing/csd.proto -O csd.proto'
-OUTPUT_PATH=toolkit/components/downloads
-
-$CMD
-$PROTOC_PATH csd.proto --cpp_out=$OUTPUT_PATH
diff --git a/toolkit/components/downloads/moz.build b/toolkit/components/downloads/moz.build
index 5f8ccbee71..dd522aa18a 100644
--- a/toolkit/components/downloads/moz.build
+++ b/toolkit/components/downloads/moz.build
@@ -30,12 +30,6 @@ SOURCES += [
'SQLFunctions.cpp',
]
-if CONFIG['MOZ_URL_CLASSIFIER']:
- UNIFIED_SOURCES += [
- 'ApplicationReputation.cpp',
- 'csd.pb.cc'
- ]
-
if CONFIG['OS_ARCH'] == 'WINNT':
# Can't build unified because we need CreateEvent which some IPC code
# included in LoadContext ends up undefining.
diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
index e534c47de7..ada168ebb7 100644
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -136,11 +136,7 @@ this.DownloadIntegration = {
dontLoadObservers: false,
dontCheckParentalControls: false,
shouldBlockInTest: false,
-#ifdef MOZ_URL_CLASSIFIER
- dontCheckApplicationReputation: false,
-#else
dontCheckApplicationReputation: true,
-#endif
shouldBlockInTestForApplicationReputation: false,
shouldKeepBlockedDataInTest: false,
dontOpenFileAndFolder: false,
diff --git a/toolkit/components/moz.build b/toolkit/components/moz.build
index 8307504901..29fd63e97a 100644
--- a/toolkit/components/moz.build
+++ b/toolkit/components/moz.build
@@ -78,9 +78,6 @@ if CONFIG['MOZ_XUL']:
if CONFIG['MOZ_TOOLKIT_SEARCH']:
DIRS += ['search']
-if CONFIG['MOZ_URL_CLASSIFIER']:
- DIRS += ['url-classifier']
-
if CONFIG['MOZ_CAPTIVEDETECT']:
DIRS += ['captivedetect']
diff --git a/toolkit/components/url-classifier/ChunkSet.cpp b/toolkit/components/url-classifier/ChunkSet.cpp
deleted file mode 100644
index 5d48c95ea2..0000000000
--- a/toolkit/components/url-classifier/ChunkSet.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "ChunkSet.h"
-
-namespace mozilla {
-namespace safebrowsing {
-
-nsresult
-ChunkSet::Serialize(nsACString& aChunkStr)
-{
- aChunkStr.Truncate();
-
- uint32_t i = 0;
- while (i < mChunks.Length()) {
- if (i != 0) {
- aChunkStr.Append(',');
- }
- aChunkStr.AppendInt((int32_t)mChunks[i]);
-
- uint32_t first = i;
- uint32_t last = first;
- i++;
- while (i < mChunks.Length() && (mChunks[i] == mChunks[i - 1] + 1 || mChunks[i] == mChunks[i - 1])) {
- last = i++;
- }
-
- if (last != first) {
- aChunkStr.Append('-');
- aChunkStr.AppendInt((int32_t)mChunks[last]);
- }
- }
-
- return NS_OK;
-}
-
-nsresult
-ChunkSet::Set(uint32_t aChunk)
-{
- size_t idx = mChunks.BinaryIndexOf(aChunk);
- if (idx == nsTArray::NoIndex) {
- mChunks.InsertElementSorted(aChunk);
- }
- return NS_OK;
-}
-
-nsresult
-ChunkSet::Unset(uint32_t aChunk)
-{
- mChunks.RemoveElementSorted(aChunk);
-
- return NS_OK;
-}
-
-bool
-ChunkSet::Has(uint32_t aChunk) const
-{
- return mChunks.BinaryIndexOf(aChunk) != nsTArray::NoIndex;
-}
-
-nsresult
-ChunkSet::Merge(const ChunkSet& aOther)
-{
- const uint32_t *dupIter = aOther.mChunks.Elements();
- const uint32_t *end = aOther.mChunks.Elements() + aOther.mChunks.Length();
-
- for (const uint32_t *iter = dupIter; iter != end; iter++) {
- nsresult rv = Set(*iter);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- return NS_OK;
-}
-
-nsresult
-ChunkSet::Remove(const ChunkSet& aOther)
-{
- uint32_t *addIter = mChunks.Elements();
- uint32_t *end = mChunks.Elements() + mChunks.Length();
-
- for (uint32_t *iter = addIter; iter != end; iter++) {
- if (!aOther.Has(*iter)) {
- *addIter = *iter;
- addIter++;
- }
- }
-
- mChunks.SetLength(addIter - mChunks.Elements());
-
- return NS_OK;
-}
-
-void
-ChunkSet::Clear()
-{
- mChunks.Clear();
-}
-
-}
-}
diff --git a/toolkit/components/url-classifier/ChunkSet.h b/toolkit/components/url-classifier/ChunkSet.h
deleted file mode 100644
index a39574c320..0000000000
--- a/toolkit/components/url-classifier/ChunkSet.h
+++ /dev/null
@@ -1,57 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef ChunkSet_h__
-#define ChunkSet_h__
-
-
-#include "Entries.h"
-#include "nsString.h"
-#include "nsTArray.h"
-
-namespace mozilla {
-namespace safebrowsing {
-
-/**
- * Store the chunk numbers as an array of uint32_t. We need chunk numbers in
- * order to ask for incremental updates from the server.
- * XXX: We should optimize this further to compress the many consecutive
- * numbers.
- */
-class ChunkSet {
-public:
- ChunkSet() {}
- ~ChunkSet() {}
-
- nsresult Serialize(nsACString& aStr);
- nsresult Set(uint32_t aChunk);
- nsresult Unset(uint32_t aChunk);
- void Clear();
- nsresult Merge(const ChunkSet& aOther);
- nsresult Remove(const ChunkSet& aOther);
-
- bool Has(uint32_t chunk) const;
-
- uint32_t Length() const { return mChunks.Length(); }
-
- nsresult Write(nsIOutputStream* aOut) {
- return WriteTArray(aOut, mChunks);
- }
-
- nsresult Read(nsIInputStream* aIn, uint32_t aNumElements) {
- return ReadTArray(aIn, &mChunks, aNumElements);
- }
-
- uint32_t *Begin() { return mChunks.Elements(); }
- uint32_t *End() { return mChunks.Elements() + mChunks.Length(); }
-
-private:
- nsTArray mChunks;
-};
-
-}
-}
-
-#endif
diff --git a/toolkit/components/url-classifier/Classifier.cpp b/toolkit/components/url-classifier/Classifier.cpp
deleted file mode 100644
index d258e3a5ee..0000000000
--- a/toolkit/components/url-classifier/Classifier.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "Classifier.h"
-#include "nsIPrefBranch.h"
-#include "nsIPrefService.h"
-#include "nsISimpleEnumerator.h"
-#include "nsIRandomGenerator.h"
-#include "nsIInputStream.h"
-#include "nsISeekableStream.h"
-#include "nsIFile.h"
-#include "nsThreadUtils.h"
-#include "mozilla/Telemetry.h"
-#include "prlog.h"
-
-// NSPR_LOG_MODULES=UrlClassifierDbService:5
-extern PRLogModuleInfo *gUrlClassifierDbServiceLog;
-#if defined(PR_LOGGING)
-#define LOG(args) PR_LOG(gUrlClassifierDbServiceLog, PR_LOG_DEBUG, args)
-#define LOG_ENABLED() PR_LOG_TEST(gUrlClassifierDbServiceLog, 4)
-#else
-#define LOG(args)
-#define LOG_ENABLED() (false)
-#endif
-
-#define STORE_DIRECTORY NS_LITERAL_CSTRING("safebrowsing")
-#define TO_DELETE_DIR_SUFFIX NS_LITERAL_CSTRING("-to_delete")
-#define BACKUP_DIR_SUFFIX NS_LITERAL_CSTRING("-backup")
-
-namespace mozilla {
-namespace safebrowsing {
-
-void
-Classifier::SplitTables(const nsACString& str, nsTArray& tables)
-{
- tables.Clear();
-
- nsACString::const_iterator begin, iter, end;
- str.BeginReading(begin);
- str.EndReading(end);
- while (begin != end) {
- iter = begin;
- FindCharInReadable(',', iter, end);
- nsDependentCSubstring table = Substring(begin,iter);
- if (!table.IsEmpty()) {
- tables.AppendElement(Substring(begin, iter));
- }
- begin = iter;
- if (begin != end) {
- begin++;
- }
- }
-}
-
-Classifier::Classifier()
-{
-}
-
-Classifier::~Classifier()
-{
- Close();
-}
-
-nsresult
-Classifier::SetupPathNames()
-{
- // Get the root directory where to store all the databases.
- nsresult rv = mCacheDirectory->Clone(getter_AddRefs(mStoreDirectory));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mStoreDirectory->AppendNative(STORE_DIRECTORY);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Make sure LookupCaches (which are persistent and survive updates)
- // are reading/writing in the right place. We will be moving their
- // files "underneath" them during backup/restore.
- for (uint32_t i = 0; i < mLookupCaches.Length(); i++) {
- mLookupCaches[i]->UpdateDirHandle(mStoreDirectory);
- }
-
- // Directory where to move a backup before an update.
- rv = mCacheDirectory->Clone(getter_AddRefs(mBackupDirectory));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mBackupDirectory->AppendNative(STORE_DIRECTORY + BACKUP_DIR_SUFFIX);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Directory where to move the backup so we can atomically
- // delete (really move) it.
- rv = mCacheDirectory->Clone(getter_AddRefs(mToDeleteDirectory));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mToDeleteDirectory->AppendNative(STORE_DIRECTORY + TO_DELETE_DIR_SUFFIX);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-Classifier::CreateStoreDirectory()
-{
- // Ensure the safebrowsing directory exists.
- bool storeExists;
- nsresult rv = mStoreDirectory->Exists(&storeExists);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (!storeExists) {
- rv = mStoreDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755);
- NS_ENSURE_SUCCESS(rv, rv);
- } else {
- bool storeIsDir;
- rv = mStoreDirectory->IsDirectory(&storeIsDir);
- NS_ENSURE_SUCCESS(rv, rv);
- if (!storeIsDir)
- return NS_ERROR_FILE_DESTINATION_NOT_DIR;
- }
-
- return NS_OK;
-}
-
-nsresult
-Classifier::Open(nsIFile& aCacheDirectory)
-{
- // Remember the Local profile directory.
- nsresult rv = aCacheDirectory.Clone(getter_AddRefs(mCacheDirectory));
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Create the handles to the update and backup directories.
- rv = SetupPathNames();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Clean up any to-delete directories that haven't been deleted yet.
- rv = CleanToDelete();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Check whether we have an incomplete update and recover from the
- // backup if so.
- rv = RecoverBackups();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Make sure the main store directory exists.
- rv = CreateStoreDirectory();
- NS_ENSURE_SUCCESS(rv, rv);
-
- mCryptoHash = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Build the list of know urlclassifier lists
- // XXX: Disk IO potentially on the main thread during startup
- RegenActiveTables();
-
- return NS_OK;
-}
-
-void
-Classifier::Close()
-{
- DropStores();
-}
-
-void
-Classifier::Reset()
-{
- DropStores();
-
- mStoreDirectory->Remove(true);
- mBackupDirectory->Remove(true);
- mToDeleteDirectory->Remove(true);
-
- CreateStoreDirectory();
-
- mTableFreshness.Clear();
- RegenActiveTables();
-}
-
-void
-Classifier::TableRequest(nsACString& aResult)
-{
- nsTArray tables;
- ActiveTables(tables);
- for (uint32_t i = 0; i < tables.Length(); i++) {
- HashStore store(tables[i], mStoreDirectory);
-
- nsresult rv = store.Open();
- if (NS_FAILED(rv))
- continue;
-
- aResult.Append(store.TableName());
- aResult.Append(';');
-
- ChunkSet &adds = store.AddChunks();
- ChunkSet &subs = store.SubChunks();
-
- if (adds.Length() > 0) {
- aResult.AppendLiteral("a:");
- nsAutoCString addList;
- adds.Serialize(addList);
- aResult.Append(addList);
- }
-
- if (subs.Length() > 0) {
- if (adds.Length() > 0)
- aResult.Append(':');
- aResult.AppendLiteral("s:");
- nsAutoCString subList;
- subs.Serialize(subList);
- aResult.Append(subList);
- }
-
- aResult.Append('\n');
- }
-}
-
-nsresult
-Classifier::Check(const nsACString& aSpec,
- const nsACString& aTables,
- uint32_t aFreshnessGuarantee,
- LookupResultArray& aResults)
-{
- Telemetry::AutoTimer timer;
-
- // Get the set of fragments based on the url. This is necessary because we
- // only look up at most 5 URLs per aSpec, even if aSpec has more than 5
- // components.
- nsTArray fragments;
- nsresult rv = LookupCache::GetLookupFragments(aSpec, &fragments);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsTArray activeTables;
- SplitTables(aTables, activeTables);
-
- nsTArray cacheArray;
- for (uint32_t i = 0; i < activeTables.Length(); i++) {
- LOG(("Checking table %s", activeTables[i].get()));
- LookupCache *cache = GetLookupCache(activeTables[i]);
- if (cache) {
- cacheArray.AppendElement(cache);
- } else {
- return NS_ERROR_FAILURE;
- }
- }
-
- // Now check each lookup fragment against the entries in the DB.
- for (uint32_t i = 0; i < fragments.Length(); i++) {
- Completion lookupHash;
- lookupHash.FromPlaintext(fragments[i], mCryptoHash);
-
- // Get list of host keys to look up
- Completion hostKey;
- rv = LookupCache::GetKey(fragments[i], &hostKey, mCryptoHash);
- if (NS_FAILED(rv)) {
- // Local host on the network.
- continue;
- }
-
-#if DEBUG && defined(PR_LOGGING)
- if (LOG_ENABLED()) {
- nsAutoCString checking;
- lookupHash.ToHexString(checking);
- LOG(("Checking fragment %s, hash %s (%X)", fragments[i].get(),
- checking.get(), lookupHash.ToUint32()));
- }
-#endif
- for (uint32_t i = 0; i < cacheArray.Length(); i++) {
- LookupCache *cache = cacheArray[i];
- bool has, complete;
- rv = cache->Has(lookupHash, &has, &complete);
- NS_ENSURE_SUCCESS(rv, rv);
- if (has) {
- LookupResult *result = aResults.AppendElement();
- if (!result)
- return NS_ERROR_OUT_OF_MEMORY;
-
- int64_t age;
- bool found = mTableFreshness.Get(cache->TableName(), &age);
- if (!found) {
- age = 24 * 60 * 60; // just a large number
- } else {
- int64_t now = (PR_Now() / PR_USEC_PER_SEC);
- age = now - age;
- }
-
- LOG(("Found a result in %s: %s (Age: %Lds)",
- cache->TableName().get(),
- complete ? "complete." : "Not complete.",
- age));
-
- result->hash.complete = lookupHash;
- result->mComplete = complete;
- result->mFresh = (age < aFreshnessGuarantee);
- result->mTableName.Assign(cache->TableName());
- }
- }
-
- }
-
- return NS_OK;
-}
-
-nsresult
-Classifier::ApplyUpdates(nsTArray* aUpdates)
-{
- Telemetry::AutoTimer timer;
-
-#if defined(PR_LOGGING)
- PRIntervalTime clockStart = 0;
- if (LOG_ENABLED() || true) {
- clockStart = PR_IntervalNow();
- }
-#endif
-
- LOG(("Backup before update."));
-
- nsresult rv = BackupTables();
- NS_ENSURE_SUCCESS(rv, rv);
-
- LOG(("Applying %d table updates.", aUpdates->Length()));
-
- for (uint32_t i = 0; i < aUpdates->Length(); i++) {
- // Previous ApplyTableUpdates() may have consumed this update..
- if ((*aUpdates)[i]) {
- // Run all updates for one table
- nsCString updateTable(aUpdates->ElementAt(i)->TableName());
- rv = ApplyTableUpdates(aUpdates, updateTable);
- if (NS_FAILED(rv)) {
- if (rv != NS_ERROR_OUT_OF_MEMORY) {
- Reset();
- }
- return rv;
- }
- }
- }
- aUpdates->Clear();
-
- rv = RegenActiveTables();
- NS_ENSURE_SUCCESS(rv, rv);
-
- LOG(("Cleaning up backups."));
-
- // Move the backup directory away (signaling the transaction finished
- // successfully). This is atomic.
- rv = RemoveBackupTables();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Do the actual deletion of the backup files.
- rv = CleanToDelete();
- NS_ENSURE_SUCCESS(rv, rv);
-
- LOG(("Done applying updates."));
-
-#if defined(PR_LOGGING)
- if (LOG_ENABLED() || true) {
- PRIntervalTime clockEnd = PR_IntervalNow();
- LOG(("update took %dms\n",
- PR_IntervalToMilliseconds(clockEnd - clockStart)));
- }
-#endif
-
- return NS_OK;
-}
-
-nsresult
-Classifier::MarkSpoiled(nsTArray& aTables)
-{
- for (uint32_t i = 0; i < aTables.Length(); i++) {
- LOG(("Spoiling table: %s", aTables[i].get()));
- // Spoil this table by marking it as no known freshness
- mTableFreshness.Remove(aTables[i]);
- // Remove any cached Completes for this table
- LookupCache *cache = GetLookupCache(aTables[i]);
- if (cache) {
- cache->ClearCompleteCache();
- }
- }
- return NS_OK;
-}
-
-void
-Classifier::DropStores()
-{
- for (uint32_t i = 0; i < mHashStores.Length(); i++) {
- delete mHashStores[i];
- }
- mHashStores.Clear();
- for (uint32_t i = 0; i < mLookupCaches.Length(); i++) {
- delete mLookupCaches[i];
- }
- mLookupCaches.Clear();
-}
-
-nsresult
-Classifier::RegenActiveTables()
-{
- mActiveTablesCache.Clear();
-
- nsTArray foundTables;
- ScanStoreDir(foundTables);
-
- for (uint32_t i = 0; i < foundTables.Length(); i++) {
- nsCString table(foundTables[i]);
- HashStore store(table, mStoreDirectory);
-
- nsresult rv = store.Open();
- if (NS_FAILED(rv))
- continue;
-
- LookupCache *lookupCache = GetLookupCache(store.TableName());
- if (!lookupCache) {
- continue;
- }
-
- if (!lookupCache->IsPrimed())
- continue;
-
- const ChunkSet &adds = store.AddChunks();
- const ChunkSet &subs = store.SubChunks();
-
- if (adds.Length() == 0 && subs.Length() == 0)
- continue;
-
- LOG(("Active table: %s", store.TableName().get()));
- mActiveTablesCache.AppendElement(store.TableName());
- }
-
- return NS_OK;
-}
-
-nsresult
-Classifier::ScanStoreDir(nsTArray& aTables)
-{
- nsCOMPtr entries;
- nsresult rv = mStoreDirectory->GetDirectoryEntries(getter_AddRefs(entries));
- NS_ENSURE_SUCCESS(rv, rv);
-
- bool hasMore;
- while (NS_SUCCEEDED(rv = entries->HasMoreElements(&hasMore)) && hasMore) {
- nsCOMPtr supports;
- rv = entries->GetNext(getter_AddRefs(supports));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr file = do_QueryInterface(supports);
-
- nsCString leafName;
- rv = file->GetNativeLeafName(leafName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCString suffix(NS_LITERAL_CSTRING(".sbstore"));
-
- int32_t dot = leafName.RFind(suffix, 0);
- if (dot != -1) {
- leafName.Cut(dot, suffix.Length());
- aTables.AppendElement(leafName);
- }
- }
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-Classifier::ActiveTables(nsTArray& aTables)
-{
- aTables = mActiveTablesCache;
- return NS_OK;
-}
-
-nsresult
-Classifier::CleanToDelete()
-{
- bool exists;
- nsresult rv = mToDeleteDirectory->Exists(&exists);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (exists) {
- rv = mToDeleteDirectory->Remove(true);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- return NS_OK;
-}
-
-nsresult
-Classifier::BackupTables()
-{
- // We have to work in reverse here: first move the normal directory
- // away to be the backup directory, then copy the files over
- // to the normal directory. This ensures that if we crash the backup
- // dir always has a valid, complete copy, instead of a partial one,
- // because that's the one we will copy over the normal store dir.
-
- nsCString backupDirName;
- nsresult rv = mBackupDirectory->GetNativeLeafName(backupDirName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCString storeDirName;
- rv = mStoreDirectory->GetNativeLeafName(storeDirName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mStoreDirectory->MoveToNative(nullptr, backupDirName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mStoreDirectory->CopyToNative(nullptr, storeDirName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // We moved some things to new places, so move the handles around, too.
- rv = SetupPathNames();
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-Classifier::RemoveBackupTables()
-{
- nsCString toDeleteName;
- nsresult rv = mToDeleteDirectory->GetNativeLeafName(toDeleteName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mBackupDirectory->MoveToNative(nullptr, toDeleteName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // mBackupDirectory now points to toDelete, fix that up.
- rv = SetupPathNames();
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-Classifier::RecoverBackups()
-{
- bool backupExists;
- nsresult rv = mBackupDirectory->Exists(&backupExists);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (backupExists) {
- // Remove the safebrowsing dir if it exists
- nsCString storeDirName;
- rv = mStoreDirectory->GetNativeLeafName(storeDirName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- bool storeExists;
- rv = mStoreDirectory->Exists(&storeExists);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (storeExists) {
- rv = mStoreDirectory->Remove(true);
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- // Move the backup to the store location
- rv = mBackupDirectory->MoveToNative(nullptr, storeDirName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // mBackupDirectory now points to storeDir, fix up.
- rv = SetupPathNames();
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- return NS_OK;
-}
-
-/*
- * This will consume+delete updates from the passed nsTArray.
-*/
-nsresult
-Classifier::ApplyTableUpdates(nsTArray* aUpdates,
- const nsACString& aTable)
-{
- LOG(("Classifier::ApplyTableUpdates(%s)", PromiseFlatCString(aTable).get()));
-
- HashStore store(aTable, mStoreDirectory);
-
- // take the quick exit if there is no valid update for us
- // (common case)
- uint32_t validupdates = 0;
-
- for (uint32_t i = 0; i < aUpdates->Length(); i++) {
- TableUpdate *update = aUpdates->ElementAt(i);
- if (!update || !update->TableName().Equals(store.TableName()))
- continue;
- if (update->Empty()) {
- aUpdates->ElementAt(i) = nullptr;
- delete update;
- continue;
- }
- validupdates++;
- }
-
- if (!validupdates) {
- // This can happen if the update was only valid for one table.
- return NS_OK;
- }
-
- nsresult rv = store.Open();
- NS_ENSURE_SUCCESS(rv, rv);
- rv = store.BeginUpdate();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Read the part of the store that is (only) in the cache
- LookupCache *prefixSet = GetLookupCache(store.TableName());
- if (!prefixSet) {
- return NS_ERROR_FAILURE;
- }
- FallibleTArray AddPrefixHashes;
- rv = prefixSet->GetPrefixes(AddPrefixHashes);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = store.AugmentAdds(AddPrefixHashes);
- NS_ENSURE_SUCCESS(rv, rv);
- AddPrefixHashes.Clear();
-
- uint32_t applied = 0;
- bool updateFreshness = false;
- bool hasCompletes = false;
-
- for (uint32_t i = 0; i < aUpdates->Length(); i++) {
- TableUpdate *update = aUpdates->ElementAt(i);
- if (!update || !update->TableName().Equals(store.TableName()))
- continue;
-
- rv = store.ApplyUpdate(*update);
- NS_ENSURE_SUCCESS(rv, rv);
-
- applied++;
-
- LOG(("Applied update to table %s:", store.TableName().get()));
- LOG((" %d add chunks", update->AddChunks().Length()));
- LOG((" %d add prefixes", update->AddPrefixes().Length()));
- LOG((" %d add completions", update->AddCompletes().Length()));
- LOG((" %d sub chunks", update->SubChunks().Length()));
- LOG((" %d sub prefixes", update->SubPrefixes().Length()));
- LOG((" %d sub completions", update->SubCompletes().Length()));
- LOG((" %d add expirations", update->AddExpirations().Length()));
- LOG((" %d sub expirations", update->SubExpirations().Length()));
-
- if (!update->IsLocalUpdate()) {
- updateFreshness = true;
- LOG(("Remote update, updating freshness"));
- }
-
- if (update->AddCompletes().Length() > 0
- || update->SubCompletes().Length() > 0) {
- hasCompletes = true;
- LOG(("Contains Completes, keeping cache."));
- }
-
- aUpdates->ElementAt(i) = nullptr;
- delete update;
- }
-
- LOG(("Applied %d update(s) to %s.", applied, store.TableName().get()));
-
- rv = store.Rebuild();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Not an update with Completes, clear all completes data.
- if (!hasCompletes) {
- store.ClearCompletes();
- }
-
- LOG(("Table %s now has:", store.TableName().get()));
- LOG((" %d add chunks", store.AddChunks().Length()));
- LOG((" %d add prefixes", store.AddPrefixes().Length()));
- LOG((" %d add completions", store.AddCompletes().Length()));
- LOG((" %d sub chunks", store.SubChunks().Length()));
- LOG((" %d sub prefixes", store.SubPrefixes().Length()));
- LOG((" %d sub completions", store.SubCompletes().Length()));
-
- rv = store.WriteFile();
- NS_ENSURE_SUCCESS(rv, rv);
-
- // At this point the store is updated and written out to disk, but
- // the data is still in memory. Build our quick-lookup table here.
- rv = prefixSet->Build(store.AddPrefixes(), store.AddCompletes());
- NS_ENSURE_SUCCESS(rv, rv);
-
-#if defined(DEBUG) && defined(PR_LOGGING)
- prefixSet->Dump();
-#endif
- rv = prefixSet->WriteFile();
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (updateFreshness) {
- int64_t now = (PR_Now() / PR_USEC_PER_SEC);
- LOG(("Successfully updated %s", store.TableName().get()));
- mTableFreshness.Put(store.TableName(), now);
- }
-
- return NS_OK;
-}
-
-LookupCache *
-Classifier::GetLookupCache(const nsACString& aTable)
-{
- for (uint32_t i = 0; i < mLookupCaches.Length(); i++) {
- if (mLookupCaches[i]->TableName().Equals(aTable)) {
- return mLookupCaches[i];
- }
- }
-
- LookupCache *cache = new LookupCache(aTable, mStoreDirectory);
- nsresult rv = cache->Init();
- if (NS_FAILED(rv)) {
- return nullptr;
- }
- rv = cache->Open();
- if (NS_FAILED(rv)) {
- if (rv == NS_ERROR_FILE_CORRUPTED) {
- Reset();
- }
- return nullptr;
- }
- mLookupCaches.AppendElement(cache);
- return cache;
-}
-
-nsresult
-Classifier::ReadNoiseEntries(const Prefix& aPrefix,
- const nsACString& aTableName,
- uint32_t aCount,
- PrefixArray* aNoiseEntries)
-{
- LookupCache *cache = GetLookupCache(aTableName);
- if (!cache) {
- return NS_ERROR_FAILURE;
- }
-
- FallibleTArray prefixes;
- nsresult rv = cache->GetPrefixes(prefixes);
- NS_ENSURE_SUCCESS(rv, rv);
-
- size_t idx = prefixes.BinaryIndexOf(aPrefix.ToUint32());
-
- if (idx == nsTArray::NoIndex) {
- NS_WARNING("Could not find prefix in PrefixSet during noise lookup");
- return NS_ERROR_FAILURE;
- }
-
- idx -= idx % aCount;
-
- for (size_t i = 0; (i < aCount) && ((idx+i) < prefixes.Length()); i++) {
- Prefix newPref;
- newPref.FromUint32(prefixes[idx+i]);
- if (newPref != aPrefix) {
- aNoiseEntries->AppendElement(newPref);
- }
- }
-
- return NS_OK;
-}
-
-} // namespace safebrowsing
-} // namespace mozilla
diff --git a/toolkit/components/url-classifier/Classifier.h b/toolkit/components/url-classifier/Classifier.h
deleted file mode 100644
index f936bdfe85..0000000000
--- a/toolkit/components/url-classifier/Classifier.h
+++ /dev/null
@@ -1,110 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef Classifier_h__
-#define Classifier_h__
-
-#include "Entries.h"
-#include "HashStore.h"
-#include "ProtocolParser.h"
-#include "LookupCache.h"
-#include "nsCOMPtr.h"
-#include "nsString.h"
-#include "nsIFile.h"
-#include "nsICryptoHash.h"
-#include "nsDataHashtable.h"
-
-namespace mozilla {
-namespace safebrowsing {
-
-/**
- * Maintains the stores and LookupCaches for the url classifier.
- */
-class Classifier {
-public:
- Classifier();
- ~Classifier();
-
- nsresult Open(nsIFile& aCacheDirectory);
- void Close();
- void Reset();
-
- /**
- * Get the list of active tables and their chunks in a format
- * suitable for an update request.
- */
- void TableRequest(nsACString& aResult);
-
- /*
- * Get all tables that we know about.
- */
- nsresult ActiveTables(nsTArray& aTables);
-
- /**
- * Check a URL against the specified tables.
- */
- nsresult Check(const nsACString& aSpec,
- const nsACString& tables,
- uint32_t aFreshnessGuarantee,
- LookupResultArray& aResults);
-
- /**
- * Apply the table updates in the array. Takes ownership of
- * the updates in the array and clears it. Wacky!
- */
- nsresult ApplyUpdates(nsTArray* aUpdates);
- /**
- * Failed update. Spoil the entries so we don't block hosts
- * unnecessarily
- */
- nsresult MarkSpoiled(nsTArray& aTables);
- nsresult CacheCompletions(const CacheResultArray& aResults);
- uint32_t GetHashKey(void) { return mHashKey; }
- /*
- * Get a bunch of extra prefixes to query for completion
- * and mask the real entry being requested
- */
- nsresult ReadNoiseEntries(const Prefix& aPrefix,
- const nsACString& aTableName,
- uint32_t aCount,
- PrefixArray* aNoiseEntries);
- static void SplitTables(const nsACString& str, nsTArray& tables);
-
-private:
- void DropStores();
- nsresult CreateStoreDirectory();
- nsresult SetupPathNames();
- nsresult RecoverBackups();
- nsresult CleanToDelete();
- nsresult BackupTables();
- nsresult RemoveBackupTables();
- nsresult RegenActiveTables();
- nsresult ScanStoreDir(nsTArray& aTables);
-
- nsresult ApplyTableUpdates(nsTArray* aUpdates,
- const nsACString& aTable);
-
- LookupCache *GetLookupCache(const nsACString& aTable);
-
- // Root dir of the Local profile.
- nsCOMPtr mCacheDirectory;
- // Main directory where to store the databases.
- nsCOMPtr mStoreDirectory;
- // Used for atomically updating the other dirs.
- nsCOMPtr mBackupDirectory;
- nsCOMPtr mToDeleteDirectory;
- nsCOMPtr mCryptoHash;
- nsTArray mHashStores;
- nsTArray mLookupCaches;
- nsTArray mActiveTablesCache;
- uint32_t mHashKey;
- // Stores the last time a given table was updated (seconds).
- nsDataHashtable mTableFreshness;
-};
-
-}
-}
-
-#endif
diff --git a/toolkit/components/url-classifier/Entries.h b/toolkit/components/url-classifier/Entries.h
deleted file mode 100644
index 3f6136ddd1..0000000000
--- a/toolkit/components/url-classifier/Entries.h
+++ /dev/null
@@ -1,314 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// This header file defines the storage types of the actual safebrowsing
-// chunk data, which may be either 32-bit hashes or complete 256-bit hashes.
-// Chunk numbers are represented in ChunkSet.h.
-
-#ifndef SBEntries_h__
-#define SBEntries_h__
-
-#include "nsTArray.h"
-#include "nsString.h"
-#include "nsICryptoHash.h"
-#include "nsNetUtil.h"
-
-#if DEBUG
-#include "plbase64.h"
-#endif
-
-namespace mozilla {
-namespace safebrowsing {
-
-#define PREFIX_SIZE 4
-#define COMPLETE_SIZE 32
-
-// This is the struct that contains 4-byte hash prefixes.
-template
-struct SafebrowsingHash
-{
- static const uint32_t sHashSize = S;
- typedef SafebrowsingHash self_type;
- uint8_t buf[S];
-
- nsresult FromPlaintext(const nsACString& aPlainText, nsICryptoHash* aHash) {
- // From the protocol doc:
- // Each entry in the chunk is composed
- // of the SHA 256 hash of a suffix/prefix expression.
-
- nsresult rv = aHash->Init(nsICryptoHash::SHA256);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = aHash->Update
- (reinterpret_cast(aPlainText.BeginReading()),
- aPlainText.Length());
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsAutoCString hashed;
- rv = aHash->Finish(false, hashed);
- NS_ENSURE_SUCCESS(rv, rv);
-
- NS_ASSERTION(hashed.Length() >= sHashSize,
- "not enough characters in the hash");
-
- memcpy(buf, hashed.BeginReading(), sHashSize);
-
- return NS_OK;
- }
-
- void Assign(const nsACString& aStr) {
- NS_ASSERTION(aStr.Length() >= sHashSize,
- "string must be at least sHashSize characters long");
- memcpy(buf, aStr.BeginReading(), sHashSize);
- }
-
- int Compare(const self_type& aOther) const {
- return Comparator::Compare(buf, aOther.buf);
- }
-
- bool operator==(const self_type& aOther) const {
- return Comparator::Compare(buf, aOther.buf) == 0;
- }
-
- bool operator!=(const self_type& aOther) const {
- return Comparator::Compare(buf, aOther.buf) != 0;
- }
-
- bool operator<(const self_type& aOther) const {
- return Comparator::Compare(buf, aOther.buf) < 0;
- }
-
-#ifdef DEBUG
- void ToString(nsACString& aStr) const {
- uint32_t len = ((sHashSize + 2) / 3) * 4;
- aStr.SetCapacity(len + 1);
- PL_Base64Encode((char*)buf, sHashSize, aStr.BeginWriting());
- aStr.BeginWriting()[len] = '\0';
- }
-
- void ToHexString(nsACString& aStr) const {
- static const char* const lut = "0123456789ABCDEF";
- // 32 bytes is the longest hash
- size_t len = 32;
-
- aStr.SetCapacity(2 * len);
- for (size_t i = 0; i < len; ++i) {
- const char c = static_cast(buf[i]);
- aStr.Append(lut[(c >> 4) & 0x0F]);
- aStr.Append(lut[c & 15]);
- }
- }
-#endif
- uint32_t ToUint32() const {
- return *((uint32_t*)buf);
- }
- void FromUint32(uint32_t aHash) {
- *((uint32_t*)buf) = aHash;
- }
-};
-
-class PrefixComparator {
-public:
- static int Compare(const uint8_t* a, const uint8_t* b) {
- uint32_t first = *((uint32_t*)a);
- uint32_t second = *((uint32_t*)b);
- if (first > second) {
- return 1;
- } else if (first == second) {
- return 0;
- } else {
- return -1;
- }
- }
-};
-// Use this for 4-byte hashes
-typedef SafebrowsingHash Prefix;
-typedef nsTArray PrefixArray;
-
-class CompletionComparator {
-public:
- static int Compare(const uint8_t* a, const uint8_t* b) {
- return memcmp(a, b, COMPLETE_SIZE);
- }
-};
-// Use this for 32-byte hashes
-typedef SafebrowsingHash Completion;
-typedef nsTArray CompletionArray;
-
-struct AddPrefix {
- // The truncated hash.
- Prefix prefix;
- // The chunk number to which it belongs.
- uint32_t addChunk;
-
- AddPrefix() : addChunk(0) {}
-
- // Returns the chunk number.
- uint32_t Chunk() const { return addChunk; }
- const Prefix &PrefixHash() const { return prefix; }
-
- template
- int Compare(const T& other) const {
- int cmp = prefix.Compare(other.PrefixHash());
- if (cmp != 0) {
- return cmp;
- }
- return addChunk - other.addChunk;
- }
-};
-
-struct AddComplete {
- Completion complete;
- uint32_t addChunk;
-
- AddComplete() : addChunk(0) {}
-
- uint32_t Chunk() const { return addChunk; }
- // The 4-byte prefix of the sha256 hash.
- uint32_t ToUint32() const { return complete.ToUint32(); }
- // The 32-byte sha256 hash.
- const Completion &CompleteHash() const { return complete; }
-
- template
- int Compare(const T& other) const {
- int cmp = complete.Compare(other.CompleteHash());
- if (cmp != 0) {
- return cmp;
- }
- return addChunk - other.addChunk;
- }
-};
-
-struct SubPrefix {
- // The hash to subtract.
- Prefix prefix;
- // The chunk number of the add chunk to which the hash belonged.
- uint32_t addChunk;
- // The chunk number of this sub chunk.
- uint32_t subChunk;
-
- SubPrefix(): addChunk(0), subChunk(0) {}
-
- uint32_t Chunk() const { return subChunk; }
- uint32_t AddChunk() const { return addChunk; }
- const Prefix &PrefixHash() const { return prefix; }
-
- template
- // Returns 0 if and only if the chunks are the same in every way.
- int Compare(const T& aOther) const {
- int cmp = prefix.Compare(aOther.PrefixHash());
- if (cmp != 0)
- return cmp;
- if (addChunk != aOther.addChunk)
- return addChunk - aOther.addChunk;
- return subChunk - aOther.subChunk;
- }
-
- template
- int CompareAlt(const T& aOther) const {
- Prefix other;
- other.FromUint32(aOther.ToUint32());
- int cmp = prefix.Compare(other);
- if (cmp != 0)
- return cmp;
- return addChunk - aOther.addChunk;
- }
-};
-
-struct SubComplete {
- Completion complete;
- uint32_t addChunk;
- uint32_t subChunk;
-
- SubComplete() : addChunk(0), subChunk(0) {}
-
- uint32_t Chunk() const { return subChunk; }
- uint32_t AddChunk() const { return addChunk; }
- const Completion &CompleteHash() const { return complete; }
- // The 4-byte prefix of the sha256 hash.
- uint32_t ToUint32() const { return complete.ToUint32(); }
-
- int Compare(const SubComplete& aOther) const {
- int cmp = complete.Compare(aOther.complete);
- if (cmp != 0)
- return cmp;
- if (addChunk != aOther.addChunk)
- return addChunk - aOther.addChunk;
- return subChunk - aOther.subChunk;
- }
-};
-
-typedef FallibleTArray AddPrefixArray;
-typedef FallibleTArray AddCompleteArray;
-typedef FallibleTArray SubPrefixArray;
-typedef FallibleTArray SubCompleteArray;
-
-/**
- * Compares chunks by their add chunk, then their prefix.
- */
-template
-class EntryCompare {
-public:
- typedef T elem_type;
- static int Compare(const void* e1, const void* e2) {
- const elem_type* a = static_cast(e1);
- const elem_type* b = static_cast(e2);
- return a->Compare(*b);
- }
-};
-
-/**
- * Sort an array of store entries. nsTArray::Sort uses Equal/LessThan
- * to sort, this does a single Compare so it's a bit quicker over the
- * large sorts we do.
- */
-template
-void
-EntrySort(nsTArray_Impl& aArray)
-{
- qsort(aArray.Elements(), aArray.Length(), sizeof(T),
- EntryCompare::Compare);
-}
-
-template
-nsresult
-ReadTArray(nsIInputStream* aStream, nsTArray_Impl* aArray, uint32_t aNumElements)
-{
- aArray->SetLength(aNumElements);
-
- void *buffer = aArray->Elements();
- nsresult rv = NS_ReadInputStreamToBuffer(aStream, &buffer,
- (aNumElements * sizeof(T)));
- NS_ENSURE_SUCCESS(rv, rv);
- return NS_OK;
-}
-
-template
-nsresult
-ReadTArray(nsIInputStream* aStream, FallibleTArray* aArray, uint32_t aNumElements)
-{
- if (!aArray->SetLength(aNumElements))
- return NS_ERROR_OUT_OF_MEMORY;
-
- void *buffer = aArray->Elements();
- nsresult rv = NS_ReadInputStreamToBuffer(aStream, &buffer,
- (aNumElements * sizeof(T)));
- NS_ENSURE_SUCCESS(rv, rv);
- return NS_OK;
-}
-
-template
-nsresult
-WriteTArray(nsIOutputStream* aStream, nsTArray_Impl& aArray)
-{
- uint32_t written;
- return aStream->Write(reinterpret_cast(aArray.Elements()),
- aArray.Length() * sizeof(T),
- &written);
-}
-
-} // namespace safebrowsing
-} // namespace mozilla
-#endif // SBEntries_h__
diff --git a/toolkit/components/url-classifier/HashStore.cpp b/toolkit/components/url-classifier/HashStore.cpp
deleted file mode 100644
index 83d9f73c0d..0000000000
--- a/toolkit/components/url-classifier/HashStore.cpp
+++ /dev/null
@@ -1,1050 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-// Originally based on Chrome sources:
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-#include "HashStore.h"
-#include "nsICryptoHash.h"
-#include "nsISeekableStream.h"
-#include "nsIStreamConverterService.h"
-#include "nsNetUtil.h"
-#include "nsCheckSummedOutputStream.h"
-#include "prlog.h"
-#include "zlib.h"
-
-// Main store for SafeBrowsing protocol data. We store
-// known add/sub chunks, prefixes and completions in memory
-// during an update, and serialize to disk.
-// We do not store the add prefixes, those are retrieved by
-// decompressing the PrefixSet cache whenever we need to apply
-// an update.
-//
-// byte slicing: Many of the 4-byte values stored here are strongly
-// correlated in the upper bytes, and uncorrelated in the lower
-// bytes. Because zlib/DEFLATE requires match lengths of at least
-// 3 to achieve good compression, and we don't get those if only
-// the upper 16-bits are correlated, it is worthwhile to slice 32-bit
-// values into 4 1-byte slices and compress the slices individually.
-// The slices corresponding to MSBs will compress very well, and the
-// slice corresponding to LSB almost nothing. Because of this, we
-// only apply DEFLATE to the 3 most significant bytes, and store the
-// LSB uncompressed.
-//
-// byte sliced (numValues) data format:
-// uint32_t compressed-size
-// compressed-size bytes zlib DEFLATE data
-// 0...numValues byte MSB of 4-byte numValues data
-// uint32_t compressed-size
-// compressed-size bytes zlib DEFLATE data
-// 0...numValues byte 2nd byte of 4-byte numValues data
-// uint32_t compressed-size
-// compressed-size bytes zlib DEFLATE data
-// 0...numValues byte 3rd byte of 4-byte numValues data
-// 0...numValues byte LSB of 4-byte numValues data
-//
-// Store data format:
-// uint32_t magic
-// uint32_t version
-// uint32_t numAddChunks
-// uint32_t numSubChunks
-// uint32_t numAddPrefixes
-// uint32_t numSubPrefixes
-// uint32_t numAddCompletes
-// uint32_t numSubCompletes
-// 0...numAddChunks uint32_t addChunk
-// 0...numSubChunks uint32_t subChunk
-// byte sliced (numAddPrefixes) uint32_t add chunk of AddPrefixes
-// byte sliced (numSubPrefixes) uint32_t add chunk of SubPrefixes
-// byte sliced (numSubPrefixes) uint32_t sub chunk of SubPrefixes
-// byte sliced (numSubPrefixes) uint32_t SubPrefixes
-// 0...numAddCompletes 32-byte Completions + uint32_t addChunk
-// 0...numSubCompletes 32-byte Completions + uint32_t addChunk
-// + uint32_t subChunk
-// 16-byte MD5 of all preceding data
-
-// Name of the SafeBrowsing store
-#define STORE_SUFFIX ".sbstore"
-
-// NSPR_LOG_MODULES=UrlClassifierDbService:5
-extern PRLogModuleInfo *gUrlClassifierDbServiceLog;
-#if defined(PR_LOGGING)
-#define LOG(args) PR_LOG(gUrlClassifierDbServiceLog, PR_LOG_DEBUG, args)
-#define LOG_ENABLED() PR_LOG_TEST(gUrlClassifierDbServiceLog, 4)
-#else
-#define LOG(args)
-#define LOG_ENABLED() (false)
-#endif
-
-// Either the return was successful or we call the Reset function (unless we
-// hit an OOM). Used while reading in the store.
-#define SUCCESS_OR_RESET(res) \
- do { \
- nsresult __rv = res; /* Don't evaluate |res| more than once */ \
- if (__rv == NS_ERROR_OUT_OF_MEMORY) { \
- NS_WARNING("SafeBrowsing OOM."); \
- return __rv; \
- } \
- if (NS_FAILED(__rv)) { \
- NS_WARNING("SafeBrowsing store corrupted or out of date."); \
- Reset(); \
- return __rv; \
- } \
- } while(0)
-
-namespace mozilla {
-namespace safebrowsing {
-
-const uint32_t STORE_MAGIC = 0x1231af3b;
-const uint32_t CURRENT_VERSION = 3;
-
-void
-TableUpdate::NewAddPrefix(uint32_t aAddChunk, const Prefix& aHash)
-{
- AddPrefix *add = mAddPrefixes.AppendElement();
- add->addChunk = aAddChunk;
- add->prefix = aHash;
-}
-
-void
-TableUpdate::NewSubPrefix(uint32_t aAddChunk, const Prefix& aHash, uint32_t aSubChunk)
-{
- SubPrefix *sub = mSubPrefixes.AppendElement();
- sub->addChunk = aAddChunk;
- sub->prefix = aHash;
- sub->subChunk = aSubChunk;
-}
-
-void
-TableUpdate::NewAddComplete(uint32_t aAddChunk, const Completion& aHash)
-{
- AddComplete *add = mAddCompletes.AppendElement();
- add->addChunk = aAddChunk;
- add->complete = aHash;
-}
-
-void
-TableUpdate::NewSubComplete(uint32_t aAddChunk, const Completion& aHash, uint32_t aSubChunk)
-{
- SubComplete *sub = mSubCompletes.AppendElement();
- sub->addChunk = aAddChunk;
- sub->complete = aHash;
- sub->subChunk = aSubChunk;
-}
-
-
-HashStore::HashStore(const nsACString& aTableName, nsIFile* aStoreDir)
- : mTableName(aTableName)
- , mStoreDirectory(aStoreDir)
- , mInUpdate(false)
-{
-}
-
-HashStore::~HashStore()
-{
-}
-
-nsresult
-HashStore::Reset()
-{
- LOG(("HashStore resetting"));
-
- nsCOMPtr storeFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(STORE_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = storeFile->Remove(false);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::CheckChecksum(nsIFile* aStoreFile,
- uint32_t aFileSize)
-{
- // Check for file corruption by
- // comparing the stored checksum to actual checksum of data
- nsAutoCString hash;
- nsAutoCString compareHash;
- char *data;
- uint32_t read;
-
- nsresult rv = CalculateChecksum(hash, aFileSize, true);
- NS_ENSURE_SUCCESS(rv, rv);
-
- compareHash.GetMutableData(&data, hash.Length());
-
- if (hash.Length() > aFileSize) {
- NS_WARNING("SafeBrowing file not long enough to store its hash");
- return NS_ERROR_FAILURE;
- }
- nsCOMPtr seekIn = do_QueryInterface(mInputStream);
- rv = seekIn->Seek(nsISeekableStream::NS_SEEK_SET, aFileSize - hash.Length());
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mInputStream->Read(data, hash.Length(), &read);
- NS_ENSURE_SUCCESS(rv, rv);
- NS_ASSERTION(read == hash.Length(), "Could not read hash bytes");
-
- if (!hash.Equals(compareHash)) {
- NS_WARNING("Safebrowing file failed checksum.");
- return NS_ERROR_FAILURE;
- }
-
- return NS_OK;
-}
-
-nsresult
-HashStore::Open()
-{
- nsCOMPtr storeFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(".sbstore"));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr origStream;
- rv = NS_NewLocalFileInputStream(getter_AddRefs(origStream), storeFile,
- PR_RDONLY | nsIFile::OS_READAHEAD);
-
- if (rv == NS_ERROR_FILE_NOT_FOUND) {
- UpdateHeader();
- return NS_OK;
- } else {
- SUCCESS_OR_RESET(rv);
- }
-
- int64_t fileSize;
- rv = storeFile->GetFileSize(&fileSize);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (fileSize < 0 || fileSize > UINT32_MAX) {
- return NS_ERROR_FAILURE;
- }
-
- uint32_t fileSize32 = static_cast(fileSize);
-
- rv = NS_NewBufferedInputStream(getter_AddRefs(mInputStream), origStream,
- fileSize32);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = CheckChecksum(storeFile, fileSize32);
- SUCCESS_OR_RESET(rv);
-
- rv = ReadHeader();
- SUCCESS_OR_RESET(rv);
-
- rv = SanityCheck();
- SUCCESS_OR_RESET(rv);
-
- rv = ReadChunkNumbers();
- SUCCESS_OR_RESET(rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::ReadHeader()
-{
- if (!mInputStream) {
- UpdateHeader();
- return NS_OK;
- }
-
- nsCOMPtr seekable = do_QueryInterface(mInputStream);
- nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
- NS_ENSURE_SUCCESS(rv, rv);
-
- void *buffer = &mHeader;
- rv = NS_ReadInputStreamToBuffer(mInputStream,
- &buffer,
- sizeof(Header));
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::SanityCheck()
-{
- if (mHeader.magic != STORE_MAGIC || mHeader.version != CURRENT_VERSION) {
- NS_WARNING("Unexpected header data in the store.");
- return NS_ERROR_FAILURE;
- }
-
- return NS_OK;
-}
-
-nsresult
-HashStore::CalculateChecksum(nsAutoCString& aChecksum,
- uint32_t aFileSize,
- bool aChecksumPresent)
-{
- aChecksum.Truncate();
-
- // Reset mInputStream to start
- nsCOMPtr seekable = do_QueryInterface(mInputStream);
- nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
-
- nsCOMPtr hash = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Size of MD5 hash in bytes
- const uint32_t CHECKSUM_SIZE = 16;
-
- // MD5 is not a secure hash function, but since this is a filesystem integrity
- // check, this usage is ok.
- rv = hash->Init(nsICryptoHash::MD5);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (!aChecksumPresent) {
- // Hash entire file
- rv = hash->UpdateFromStream(mInputStream, UINT32_MAX);
- } else {
- // Hash everything but last checksum bytes
- if (aFileSize < CHECKSUM_SIZE) {
- NS_WARNING("SafeBrowsing file isn't long enough to store its checksum");
- return NS_ERROR_FAILURE;
- }
- rv = hash->UpdateFromStream(mInputStream, aFileSize - CHECKSUM_SIZE);
- }
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = hash->Finish(false, aChecksum);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-void
-HashStore::UpdateHeader()
-{
- mHeader.magic = STORE_MAGIC;
- mHeader.version = CURRENT_VERSION;
-
- mHeader.numAddChunks = mAddChunks.Length();
- mHeader.numSubChunks = mSubChunks.Length();
- mHeader.numAddPrefixes = mAddPrefixes.Length();
- mHeader.numSubPrefixes = mSubPrefixes.Length();
- mHeader.numAddCompletes = mAddCompletes.Length();
- mHeader.numSubCompletes = mSubCompletes.Length();
-}
-
-nsresult
-HashStore::ReadChunkNumbers()
-{
- NS_ENSURE_STATE(mInputStream);
-
- nsCOMPtr seekable = do_QueryInterface(mInputStream);
- nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET,
- sizeof(Header));
-
- rv = mAddChunks.Read(mInputStream, mHeader.numAddChunks);
- NS_ENSURE_SUCCESS(rv, rv);
- NS_ASSERTION(mAddChunks.Length() == mHeader.numAddChunks, "Read the right amount of add chunks.");
-
- rv = mSubChunks.Read(mInputStream, mHeader.numSubChunks);
- NS_ENSURE_SUCCESS(rv, rv);
- NS_ASSERTION(mSubChunks.Length() == mHeader.numSubChunks, "Read the right amount of sub chunks.");
-
- return NS_OK;
-}
-
-nsresult
-HashStore::ReadHashes()
-{
- if (!mInputStream) {
- // BeginUpdate has been called but Open hasn't initialized mInputStream,
- // because the existing HashStore is empty.
- return NS_OK;
- }
-
- nsCOMPtr seekable = do_QueryInterface(mInputStream);
-
- uint32_t offset = sizeof(Header);
- offset += (mHeader.numAddChunks + mHeader.numSubChunks) * sizeof(uint32_t);
- nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, offset);
-
- rv = ReadAddPrefixes();
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ReadSubPrefixes();
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ReadTArray(mInputStream, &mAddCompletes, mHeader.numAddCompletes);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ReadTArray(mInputStream, &mSubCompletes, mHeader.numSubCompletes);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::BeginUpdate()
-{
- // Read the rest of the store in memory.
- nsresult rv = ReadHashes();
- SUCCESS_OR_RESET(rv);
-
- // Close input stream, won't be needed any more and
- // we will rewrite ourselves.
- if (mInputStream) {
- rv = mInputStream->Close();
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- mInUpdate = true;
-
- return NS_OK;
-}
-
-template
-static nsresult
-Merge(ChunkSet* aStoreChunks,
- FallibleTArray* aStorePrefixes,
- ChunkSet& aUpdateChunks,
- FallibleTArray& aUpdatePrefixes,
- bool aAllowMerging = false)
-{
- EntrySort(aUpdatePrefixes);
-
- T* updateIter = aUpdatePrefixes.Elements();
- T* updateEnd = aUpdatePrefixes.Elements() + aUpdatePrefixes.Length();
-
- T* storeIter = aStorePrefixes->Elements();
- T* storeEnd = aStorePrefixes->Elements() + aStorePrefixes->Length();
-
- // use a separate array so we can keep the iterators valid
- // if the nsTArray grows
- nsTArray adds;
-
- for (; updateIter != updateEnd; updateIter++) {
- // skip this chunk if we already have it, unless we're
- // merging completions, in which case we'll always already
- // have the chunk from the original prefix
- if (aStoreChunks->Has(updateIter->Chunk()))
- if (!aAllowMerging)
- continue;
- // XXX: binary search for insertion point might be faster in common
- // case?
- while (storeIter < storeEnd && (storeIter->Compare(*updateIter) < 0)) {
- // skip forward to matching element (or not...)
- storeIter++;
- }
- // no match, add
- if (storeIter == storeEnd
- || storeIter->Compare(*updateIter) != 0) {
- if (!adds.AppendElement(*updateIter))
- return NS_ERROR_OUT_OF_MEMORY;
- }
- }
-
- // Chunks can be empty, but we should still report we have them
- // to make the chunkranges continuous.
- aStoreChunks->Merge(aUpdateChunks);
-
- aStorePrefixes->AppendElements(adds);
- EntrySort(*aStorePrefixes);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::ApplyUpdate(TableUpdate &update)
-{
- nsresult rv = mAddExpirations.Merge(update.AddExpirations());
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mSubExpirations.Merge(update.SubExpirations());
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = Expire();
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = Merge(&mAddChunks, &mAddPrefixes,
- update.AddChunks(), update.AddPrefixes());
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = Merge(&mAddChunks, &mAddCompletes,
- update.AddChunks(), update.AddCompletes(), true);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = Merge(&mSubChunks, &mSubPrefixes,
- update.SubChunks(), update.SubPrefixes());
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = Merge(&mSubChunks, &mSubCompletes,
- update.SubChunks(), update.SubCompletes(), true);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::Rebuild()
-{
- NS_ASSERTION(mInUpdate, "Must be in update to rebuild.");
-
- nsresult rv = ProcessSubs();
- NS_ENSURE_SUCCESS(rv, rv);
-
- UpdateHeader();
-
- return NS_OK;
-}
-
-void
-HashStore::ClearCompletes()
-{
- NS_ASSERTION(mInUpdate, "Must be in update to clear completes.");
-
- mAddCompletes.Clear();
- mSubCompletes.Clear();
-
- UpdateHeader();
-}
-
-template
-static void
-ExpireEntries(FallibleTArray* aEntries, ChunkSet& aExpirations)
-{
- T* addIter = aEntries->Elements();
- T* end = aEntries->Elements() + aEntries->Length();
-
- for (T *iter = addIter; iter != end; iter++) {
- if (!aExpirations.Has(iter->Chunk())) {
- *addIter = *iter;
- addIter++;
- }
- }
-
- aEntries->SetLength(addIter - aEntries->Elements());
-}
-
-nsresult
-HashStore::Expire()
-{
- ExpireEntries(&mAddPrefixes, mAddExpirations);
- ExpireEntries(&mAddCompletes, mAddExpirations);
- ExpireEntries(&mSubPrefixes, mSubExpirations);
- ExpireEntries(&mSubCompletes, mSubExpirations);
-
- mAddChunks.Remove(mAddExpirations);
- mSubChunks.Remove(mSubExpirations);
-
- mAddExpirations.Clear();
- mSubExpirations.Clear();
-
- return NS_OK;
-}
-
-template
-nsresult DeflateWriteTArray(nsIOutputStream* aStream, nsTArray& aIn)
-{
- uLongf insize = aIn.Length() * sizeof(T);
- uLongf outsize = compressBound(insize);
- FallibleTArray outBuff;
- if (!outBuff.SetLength(outsize)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- int zerr = compress(reinterpret_cast(outBuff.Elements()),
- &outsize,
- reinterpret_cast(aIn.Elements()),
- insize);
- if (zerr != Z_OK) {
- return NS_ERROR_FAILURE;
- }
- LOG(("DeflateWriteTArray: %d in %d out", insize, outsize));
-
- outBuff.TruncateLength(outsize);
-
- // Length of compressed data stream
- uint32_t dataLen = outBuff.Length();
- uint32_t written;
- nsresult rv = aStream->Write(reinterpret_cast(&dataLen), sizeof(dataLen), &written);
- NS_ENSURE_SUCCESS(rv, rv);
-
- NS_ASSERTION(written == sizeof(dataLen), "Error writing deflate length");
-
- // Store to stream
- rv = WriteTArray(aStream, outBuff);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-template
-nsresult InflateReadTArray(nsIInputStream* aStream, FallibleTArray* aOut,
- uint32_t aExpectedSize)
-{
-
- uint32_t inLen;
- uint32_t read;
- nsresult rv = aStream->Read(reinterpret_cast(&inLen), sizeof(inLen), &read);
- NS_ENSURE_SUCCESS(rv, rv);
-
- NS_ASSERTION(read == sizeof(inLen), "Error reading inflate length");
-
- FallibleTArray inBuff;
- if (!inBuff.SetLength(inLen)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- rv = ReadTArray(aStream, &inBuff, inLen);
- NS_ENSURE_SUCCESS(rv, rv);
-
- uLongf insize = inLen;
- uLongf outsize = aExpectedSize * sizeof(T);
- if (!aOut->SetLength(aExpectedSize)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- int zerr = uncompress(reinterpret_cast(aOut->Elements()),
- &outsize,
- reinterpret_cast(inBuff.Elements()),
- insize);
- if (zerr != Z_OK) {
- return NS_ERROR_FAILURE;
- }
- LOG(("InflateReadTArray: %d in %d out", insize, outsize));
-
- NS_ASSERTION(outsize == aExpectedSize * sizeof(T), "Decompression size mismatch");
-
- return NS_OK;
-}
-
-static nsresult
-ByteSliceWrite(nsIOutputStream* aOut, nsTArray& aData)
-{
- nsTArray slice1;
- nsTArray slice2;
- nsTArray slice3;
- nsTArray slice4;
- uint32_t count = aData.Length();
-
- slice1.SetCapacity(count);
- slice2.SetCapacity(count);
- slice3.SetCapacity(count);
- slice4.SetCapacity(count);
-
- for (uint32_t i = 0; i < count; i++) {
- slice1.AppendElement( aData[i] >> 24);
- slice2.AppendElement((aData[i] >> 16) & 0xFF);
- slice3.AppendElement((aData[i] >> 8) & 0xFF);
- slice4.AppendElement( aData[i] & 0xFF);
- }
-
- nsresult rv = DeflateWriteTArray(aOut, slice1);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = DeflateWriteTArray(aOut, slice2);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = DeflateWriteTArray(aOut, slice3);
- NS_ENSURE_SUCCESS(rv, rv);
- // The LSB slice is generally uncompressible, don't bother
- // compressing it.
- rv = WriteTArray(aOut, slice4);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-static nsresult
-ByteSliceRead(nsIInputStream* aInStream, FallibleTArray* aData, uint32_t count)
-{
- FallibleTArray slice1;
- FallibleTArray slice2;
- FallibleTArray slice3;
- FallibleTArray slice4;
-
- nsresult rv = InflateReadTArray(aInStream, &slice1, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = InflateReadTArray(aInStream, &slice2, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = InflateReadTArray(aInStream, &slice3, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ReadTArray(aInStream, &slice4, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (!aData->SetCapacity(count)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- for (uint32_t i = 0; i < count; i++) {
- aData->AppendElement((slice1[i] << 24) | (slice2[i] << 16)
- | (slice3[i] << 8) | (slice4[i]));
- }
-
- return NS_OK;
-}
-
-nsresult
-HashStore::ReadAddPrefixes()
-{
- FallibleTArray chunks;
- uint32_t count = mHeader.numAddPrefixes;
-
- nsresult rv = ByteSliceRead(mInputStream, &chunks, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (!mAddPrefixes.SetCapacity(count)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- for (uint32_t i = 0; i < count; i++) {
- AddPrefix *add = mAddPrefixes.AppendElement();
- add->prefix.FromUint32(0);
- add->addChunk = chunks[i];
- }
-
- return NS_OK;
-}
-
-nsresult
-HashStore::ReadSubPrefixes()
-{
- FallibleTArray addchunks;
- FallibleTArray subchunks;
- FallibleTArray prefixes;
- uint32_t count = mHeader.numSubPrefixes;
-
- nsresult rv = ByteSliceRead(mInputStream, &addchunks, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ByteSliceRead(mInputStream, &subchunks, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ByteSliceRead(mInputStream, &prefixes, count);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (!mSubPrefixes.SetCapacity(count)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- for (uint32_t i = 0; i < count; i++) {
- SubPrefix *sub = mSubPrefixes.AppendElement();
- sub->addChunk = addchunks[i];
- sub->prefix.FromUint32(prefixes[i]);
- sub->subChunk = subchunks[i];
- }
-
- return NS_OK;
-}
-
-// Split up PrefixArray back into the constituents
-nsresult
-HashStore::WriteAddPrefixes(nsIOutputStream* aOut)
-{
- nsTArray chunks;
- uint32_t count = mAddPrefixes.Length();
- chunks.SetCapacity(count);
-
- for (uint32_t i = 0; i < count; i++) {
- chunks.AppendElement(mAddPrefixes[i].Chunk());
- }
-
- nsresult rv = ByteSliceWrite(aOut, chunks);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::WriteSubPrefixes(nsIOutputStream* aOut)
-{
- nsTArray addchunks;
- nsTArray subchunks;
- nsTArray prefixes;
- uint32_t count = mSubPrefixes.Length();
- addchunks.SetCapacity(count);
- subchunks.SetCapacity(count);
- prefixes.SetCapacity(count);
-
- for (uint32_t i = 0; i < count; i++) {
- addchunks.AppendElement(mSubPrefixes[i].AddChunk());
- prefixes.AppendElement(mSubPrefixes[i].PrefixHash().ToUint32());
- subchunks.AppendElement(mSubPrefixes[i].Chunk());
- }
-
- nsresult rv = ByteSliceWrite(aOut, addchunks);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ByteSliceWrite(aOut, subchunks);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ByteSliceWrite(aOut, prefixes);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-HashStore::WriteFile()
-{
- NS_ASSERTION(mInUpdate, "Must be in update to write database.");
-
- nsCOMPtr storeFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(".sbstore"));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr out;
- rv = NS_NewCheckSummedOutputStream(getter_AddRefs(out), storeFile,
- PR_WRONLY | PR_TRUNCATE | PR_CREATE_FILE);
- NS_ENSURE_SUCCESS(rv, rv);
-
- uint32_t written;
- rv = out->Write(reinterpret_cast(&mHeader), sizeof(mHeader), &written);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Write chunk numbers.
- rv = mAddChunks.Write(out);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mSubChunks.Write(out);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Write hashes.
- rv = WriteAddPrefixes(out);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = WriteSubPrefixes(out);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = WriteTArray(out, mAddCompletes);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = WriteTArray(out, mSubCompletes);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr safeOut = do_QueryInterface(out, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = safeOut->Finish();
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-template
-static void
-Erase(FallibleTArray* array, T* iterStart, T* iterEnd)
-{
- uint32_t start = iterStart - array->Elements();
- uint32_t count = iterEnd - iterStart;
-
- if (count > 0) {
- array->RemoveElementsAt(start, count);
- }
-}
-
-// Find items matching between |subs| and |adds|, and remove them,
-// recording the item from |adds| in |adds_removed|. To minimize
-// copies, the inputs are processing in parallel, so |subs| and |adds|
-// should be compatibly ordered (either by SBAddPrefixLess or
-// SBAddPrefixHashLess).
-//
-// |predAS| provides add < sub, |predSA| provides sub < add, for the
-// tightest compare appropriate (see calls in SBProcessSubs).
-template
-static void
-KnockoutSubs(FallibleTArray* aSubs, FallibleTArray* aAdds)
-{
- // Keep a pair of output iterators for writing kept items. Due to
- // deletions, these may lag the main iterators. Using erase() on
- // individual items would result in O(N^2) copies. Using a list
- // would work around that, at double or triple the memory cost.
- TAdd* addOut = aAdds->Elements();
- TAdd* addIter = aAdds->Elements();
-
- TSub* subOut = aSubs->Elements();
- TSub* subIter = aSubs->Elements();
-
- TAdd* addEnd = addIter + aAdds->Length();
- TSub* subEnd = subIter + aSubs->Length();
-
- while (addIter != addEnd && subIter != subEnd) {
- // additer compare, so it compares on add chunk
- int32_t cmp = addIter->Compare(*subIter);
- if (cmp > 0) {
- // If |*sub_iter| < |*add_iter|, retain the sub.
- *subOut = *subIter;
- ++subOut;
- ++subIter;
- } else if (cmp < 0) {
- // If |*add_iter| < |*sub_iter|, retain the add.
- *addOut = *addIter;
- ++addOut;
- ++addIter;
- } else {
- // Drop equal items
- ++addIter;
- ++subIter;
- }
- }
-
- Erase(aAdds, addOut, addIter);
- Erase(aSubs, subOut, subIter);
-}
-
-// Remove items in |removes| from |fullHashes|. |fullHashes| and
-// |removes| should be ordered by SBAddPrefix component.
-template
-static void
-RemoveMatchingPrefixes(const SubPrefixArray& aSubs, FallibleTArray* aFullHashes)
-{
- // Where to store kept items.
- T* out = aFullHashes->Elements();
- T* hashIter = out;
- T* hashEnd = aFullHashes->Elements() + aFullHashes->Length();
-
- SubPrefix const * removeIter = aSubs.Elements();
- SubPrefix const * removeEnd = aSubs.Elements() + aSubs.Length();
-
- while (hashIter != hashEnd && removeIter != removeEnd) {
- int32_t cmp = removeIter->CompareAlt(*hashIter);
- if (cmp > 0) {
- // Keep items less than |*removeIter|.
- *out = *hashIter;
- ++out;
- ++hashIter;
- } else if (cmp < 0) {
- // No hit for |*removeIter|, bump it forward.
- ++removeIter;
- } else {
- // Drop equal items, there may be multiple hits.
- do {
- ++hashIter;
- } while (hashIter != hashEnd &&
- !(removeIter->CompareAlt(*hashIter) < 0));
- ++removeIter;
- }
- }
- Erase(aFullHashes, out, hashIter);
-}
-
-static void
-RemoveDeadSubPrefixes(SubPrefixArray& aSubs, ChunkSet& aAddChunks)
-{
- SubPrefix * subIter = aSubs.Elements();
- SubPrefix * subEnd = aSubs.Elements() + aSubs.Length();
-
- for (SubPrefix * iter = subIter; iter != subEnd; iter++) {
- bool hasChunk = aAddChunks.Has(iter->AddChunk());
- // Keep the subprefix if the chunk it refers to is one
- // we haven't seen it yet.
- if (!hasChunk) {
- *subIter = *iter;
- subIter++;
- }
- }
-
- LOG(("Removed %u dead SubPrefix entries.", subEnd - subIter));
- aSubs.SetLength(subIter - aSubs.Elements());
-}
-
-#ifdef DEBUG
-template
-static void EnsureSorted(FallibleTArray* aArray)
-{
- T* start = aArray->Elements();
- T* end = aArray->Elements() + aArray->Length();
- T* iter = start;
- T* previous = start;
-
- while (iter != end) {
- previous = iter;
- ++iter;
- if (iter != end) {
- MOZ_ASSERT(iter->Compare(*previous) >= 0);
- }
- }
-
- return;
-}
-#endif
-
-nsresult
-HashStore::ProcessSubs()
-{
-#ifdef DEBUG
- EnsureSorted(&mAddPrefixes);
- EnsureSorted(&mSubPrefixes);
- EnsureSorted(&mAddCompletes);
- EnsureSorted(&mSubCompletes);
- LOG(("All databases seem to have a consistent sort order."));
-#endif
-
- RemoveMatchingPrefixes(mSubPrefixes, &mAddCompletes);
- RemoveMatchingPrefixes(mSubPrefixes, &mSubCompletes);
-
- // Remove any remaining subbed prefixes from both addprefixes
- // and addcompletes.
- KnockoutSubs(&mSubPrefixes, &mAddPrefixes);
- KnockoutSubs(&mSubCompletes, &mAddCompletes);
-
- // Remove any remaining subprefixes referring to addchunks that
- // we have (and hence have been processed above).
- RemoveDeadSubPrefixes(mSubPrefixes, mAddChunks);
-
-#ifdef DEBUG
- EnsureSorted(&mAddPrefixes);
- EnsureSorted(&mSubPrefixes);
- EnsureSorted(&mAddCompletes);
- EnsureSorted(&mSubCompletes);
- LOG(("All databases seem to have a consistent sort order."));
-#endif
-
- return NS_OK;
-}
-
-nsresult
-HashStore::AugmentAdds(const nsTArray& aPrefixes)
-{
- uint32_t cnt = aPrefixes.Length();
- if (cnt != mAddPrefixes.Length()) {
- LOG(("Amount of prefixes in cache not consistent with store (%d vs %d)",
- aPrefixes.Length(), mAddPrefixes.Length()));
- return NS_ERROR_FAILURE;
- }
- for (uint32_t i = 0; i < cnt; i++) {
- mAddPrefixes[i].prefix.FromUint32(aPrefixes[i]);
- }
- return NS_OK;
-}
-
-}
-}
diff --git a/toolkit/components/url-classifier/HashStore.h b/toolkit/components/url-classifier/HashStore.h
deleted file mode 100644
index c33323f05c..0000000000
--- a/toolkit/components/url-classifier/HashStore.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef HashStore_h__
-#define HashStore_h__
-
-#include "Entries.h"
-#include "ChunkSet.h"
-
-#include "nsString.h"
-#include "nsTArray.h"
-#include "nsIFile.h"
-#include "nsIFileStreams.h"
-#include "nsCOMPtr.h"
-
-namespace mozilla {
-namespace safebrowsing {
-
-// A table update is built from a single update chunk from the server. As the
-// protocol parser processes each chunk, it constructs a table update with the
-// new hashes.
-class TableUpdate {
-public:
- explicit TableUpdate(const nsACString& aTable)
- : mTable(aTable), mLocalUpdate(false) {}
- const nsCString& TableName() const { return mTable; }
-
- bool Empty() const {
- return mAddChunks.Length() == 0 &&
- mSubChunks.Length() == 0 &&
- mAddExpirations.Length() == 0 &&
- mSubExpirations.Length() == 0 &&
- mAddPrefixes.Length() == 0 &&
- mSubPrefixes.Length() == 0 &&
- mAddCompletes.Length() == 0 &&
- mSubCompletes.Length() == 0;
- }
-
- // Throughout, uint32_t aChunk refers only to the chunk number. Chunk data is
- // stored in the Prefix structures.
- void NewAddChunk(uint32_t aChunk) { mAddChunks.Set(aChunk); }
- void NewSubChunk(uint32_t aChunk) { mSubChunks.Set(aChunk); }
-
- void NewAddExpiration(uint32_t aChunk) { mAddExpirations.Set(aChunk); }
- void NewSubExpiration(uint32_t aChunk) { mSubExpirations.Set(aChunk); }
-
- void NewAddPrefix(uint32_t aAddChunk, const Prefix& aPrefix);
- void NewSubPrefix(uint32_t aAddChunk, const Prefix& aPrefix, uint32_t aSubChunk);
-
- void NewAddComplete(uint32_t aChunk, const Completion& aCompletion);
- void NewSubComplete(uint32_t aAddChunk, const Completion& aCompletion,
- uint32_t aSubChunk);
- void SetLocalUpdate(void) { mLocalUpdate = true; }
- bool IsLocalUpdate(void) { return mLocalUpdate; }
-
- ChunkSet& AddChunks() { return mAddChunks; }
- ChunkSet& SubChunks() { return mSubChunks; }
-
- // Expirations for chunks.
- ChunkSet& AddExpirations() { return mAddExpirations; }
- ChunkSet& SubExpirations() { return mSubExpirations; }
-
- // Hashes associated with this chunk.
- AddPrefixArray& AddPrefixes() { return mAddPrefixes; }
- SubPrefixArray& SubPrefixes() { return mSubPrefixes; }
- AddCompleteArray& AddCompletes() { return mAddCompletes; }
- SubCompleteArray& SubCompletes() { return mSubCompletes; }
-
-private:
- nsCString mTable;
- // Update not from the remote server (no freshness)
- bool mLocalUpdate;
-
- // The list of chunk numbers that we have for each of the type of chunks.
- ChunkSet mAddChunks;
- ChunkSet mSubChunks;
- ChunkSet mAddExpirations;
- ChunkSet mSubExpirations;
-
- // 4-byte sha256 prefixes.
- AddPrefixArray mAddPrefixes;
- SubPrefixArray mSubPrefixes;
-
- // 32-byte hashes.
- AddCompleteArray mAddCompletes;
- SubCompleteArray mSubCompletes;
-};
-
-// There is one hash store per table.
-class HashStore {
-public:
- HashStore(const nsACString& aTableName, nsIFile* aStoreFile);
- ~HashStore();
-
- const nsCString& TableName() const { return mTableName; }
-
- nsresult Open();
- // Add Prefixes are stored partly in the PrefixSet (contains the
- // Prefix data organized for fast lookup/low RAM usage) and partly in the
- // HashStore (Add Chunk numbers - only used for updates, slow retrieval).
- // AugmentAdds function joins the separate datasets into one complete
- // prefixes+chunknumbers dataset.
- nsresult AugmentAdds(const nsTArray& aPrefixes);
-
- ChunkSet& AddChunks() { return mAddChunks; }
- ChunkSet& SubChunks() { return mSubChunks; }
- AddPrefixArray& AddPrefixes() { return mAddPrefixes; }
- AddCompleteArray& AddCompletes() { return mAddCompletes; }
- SubPrefixArray& SubPrefixes() { return mSubPrefixes; }
- SubCompleteArray& SubCompletes() { return mSubCompletes; }
-
- // =======
- // Updates
- // =======
- // Begin the update process. Reads the store into memory.
- nsresult BeginUpdate();
-
- // Imports the data from a TableUpdate.
- nsresult ApplyUpdate(TableUpdate &aUpdate);
-
- // Process expired chunks
- nsresult Expire();
-
- // Rebuild the store, Incorporating all the applied updates.
- nsresult Rebuild();
-
- // Write the current state of the store to disk.
- // If you call between ApplyUpdate() and Rebuild(), you'll
- // have a mess on your hands.
- nsresult WriteFile();
-
- // Wipe out all Completes.
- void ClearCompletes();
-
-private:
- nsresult Reset();
-
- nsresult ReadHeader();
- nsresult SanityCheck();
- nsresult CalculateChecksum(nsAutoCString& aChecksum, uint32_t aFileSize,
- bool aChecksumPresent);
- nsresult CheckChecksum(nsIFile* aStoreFile, uint32_t aFileSize);
- void UpdateHeader();
-
- nsresult ReadChunkNumbers();
- nsresult ReadHashes();
-
- nsresult ReadAddPrefixes();
- nsresult ReadSubPrefixes();
-
- nsresult WriteAddPrefixes(nsIOutputStream* aOut);
- nsresult WriteSubPrefixes(nsIOutputStream* aOut);
-
- nsresult ProcessSubs();
-
- // This is used for checking that the database is correct and for figuring out
- // the number of chunks, etc. to read from disk on restart.
- struct Header {
- uint32_t magic;
- uint32_t version;
- uint32_t numAddChunks;
- uint32_t numSubChunks;
- uint32_t numAddPrefixes;
- uint32_t numSubPrefixes;
- uint32_t numAddCompletes;
- uint32_t numSubCompletes;
- };
-
- Header mHeader;
-
- // The name of the table (must end in -shavar or -digest256, or evidently
- // -simple for unittesting.
- nsCString mTableName;
- nsCOMPtr mStoreDirectory;
-
- bool mInUpdate;
-
- nsCOMPtr mInputStream;
-
- // Chunk numbers, stored as uint32_t arrays.
- ChunkSet mAddChunks;
- ChunkSet mSubChunks;
-
- ChunkSet mAddExpirations;
- ChunkSet mSubExpirations;
-
- // Chunk data for shavar tables. See Entries.h for format.
- AddPrefixArray mAddPrefixes;
- SubPrefixArray mSubPrefixes;
-
- // See bug 806422 for background. We must be able to distinguish between
- // updates from the completion server and updates from the regular server.
- AddCompleteArray mAddCompletes;
- SubCompleteArray mSubCompletes;
-};
-
-}
-}
-#endif
diff --git a/toolkit/components/url-classifier/LookupCache.cpp b/toolkit/components/url-classifier/LookupCache.cpp
deleted file mode 100644
index 08adf309e4..0000000000
--- a/toolkit/components/url-classifier/LookupCache.cpp
+++ /dev/null
@@ -1,699 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "LookupCache.h"
-#include "HashStore.h"
-#include "nsISeekableStream.h"
-#include "mozilla/Telemetry.h"
-#include "prlog.h"
-#include "prprf.h"
-
-// We act as the main entry point for all the real lookups,
-// so note that those are not done to the actual HashStore.
-// The latter solely exists to store the data needed to handle
-// the updates from the protocol.
-
-// This module has its own store, which stores the Completions,
-// mostly caching lookups that have happened over the net.
-// The prefixes are cached/checked by looking them up in the
-// PrefixSet.
-
-// Data format for the ".cache" files:
-// uint32_t magic Identify the file type
-// uint32_t version Version identifier for file format
-// uint32_t numCompletions Amount of completions stored
-// 0...numCompletions 256-bit Completions
-
-// Name of the lookupcomplete cache
-#define CACHE_SUFFIX ".cache"
-
-// Name of the persistent PrefixSet storage
-#define PREFIXSET_SUFFIX ".pset"
-
-// NSPR_LOG_MODULES=UrlClassifierDbService:5
-extern PRLogModuleInfo *gUrlClassifierDbServiceLog;
-#if defined(PR_LOGGING)
-#define LOG(args) PR_LOG(gUrlClassifierDbServiceLog, PR_LOG_DEBUG, args)
-#define LOG_ENABLED() PR_LOG_TEST(gUrlClassifierDbServiceLog, 4)
-#else
-#define LOG(args)
-#define LOG_ENABLED() (false)
-#endif
-
-namespace mozilla {
-namespace safebrowsing {
-
-const uint32_t LOOKUPCACHE_MAGIC = 0x1231af3e;
-const uint32_t CURRENT_VERSION = 2;
-
-LookupCache::LookupCache(const nsACString& aTableName, nsIFile* aStoreDir)
- : mPrimed(false)
- , mTableName(aTableName)
- , mStoreDirectory(aStoreDir)
-{
-}
-
-nsresult
-LookupCache::Init()
-{
- mPrefixSet = new nsUrlClassifierPrefixSet();
- nsresult rv = mPrefixSet->Init(mTableName);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-LookupCache::~LookupCache()
-{
-}
-
-nsresult
-LookupCache::Open()
-{
- nsCOMPtr storeFile;
-
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(CACHE_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr inputStream;
- rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), storeFile,
- PR_RDONLY | nsIFile::OS_READAHEAD);
-
- if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
- Reset();
- return rv;
- }
-
- if (rv == NS_ERROR_FILE_NOT_FOUND) {
- // Simply lacking a .cache file is a recoverable error,
- // as unlike the .pset/.sbstore files it is a pure cache.
- // Just create a new empty one.
- ClearCompleteCache();
- } else {
- // Read in the .cache file
- rv = ReadHeader(inputStream);
- NS_ENSURE_SUCCESS(rv, rv);
- LOG(("ReadCompletions"));
- rv = ReadCompletions(inputStream);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = inputStream->Close();
- NS_ENSURE_SUCCESS(rv, rv);
- }
-
- LOG(("Loading PrefixSet"));
- rv = LoadPrefixSet();
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-LookupCache::UpdateDirHandle(nsIFile* aStoreDirectory)
-{
- return aStoreDirectory->Clone(getter_AddRefs(mStoreDirectory));
-}
-
-nsresult
-LookupCache::Reset()
-{
- LOG(("LookupCache resetting"));
-
- nsCOMPtr storeFile;
- nsCOMPtr prefixsetFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
- rv = mStoreDirectory->Clone(getter_AddRefs(prefixsetFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(CACHE_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
- rv = prefixsetFile->AppendNative(mTableName + NS_LITERAL_CSTRING(PREFIXSET_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = storeFile->Remove(false);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = prefixsetFile->Remove(false);
- NS_ENSURE_SUCCESS(rv, rv);
-
- ClearAll();
-
- return NS_OK;
-}
-
-
-nsresult
-LookupCache::Build(AddPrefixArray& aAddPrefixes,
- AddCompleteArray& aAddCompletes)
-{
- Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_COMPLETIONS,
- static_cast(aAddCompletes.Length()));
-
- mCompletions.Clear();
- mCompletions.SetCapacity(aAddCompletes.Length());
- for (uint32_t i = 0; i < aAddCompletes.Length(); i++) {
- mCompletions.AppendElement(aAddCompletes[i].CompleteHash());
- }
- aAddCompletes.Clear();
- mCompletions.Sort();
-
- Telemetry::Accumulate(Telemetry::URLCLASSIFIER_LC_PREFIXES,
- static_cast(aAddPrefixes.Length()));
-
- nsresult rv = ConstructPrefixSet(aAddPrefixes);
- NS_ENSURE_SUCCESS(rv, rv);
- mPrimed = true;
-
- return NS_OK;
-}
-
-#if defined(DEBUG) && defined(PR_LOGGING)
-void
-LookupCache::Dump()
-{
- if (!LOG_ENABLED())
- return;
-
- for (uint32_t i = 0; i < mCompletions.Length(); i++) {
- nsAutoCString str;
- mCompletions[i].ToHexString(str);
- LOG(("Completion: %s", str.get()));
- }
-}
-#endif
-
-nsresult
-LookupCache::Has(const Completion& aCompletion,
- bool* aHas, bool* aComplete)
-{
- *aHas = *aComplete = false;
-
- uint32_t prefix = aCompletion.ToUint32();
-
- bool found;
- nsresult rv = mPrefixSet->Contains(prefix, &found);
- NS_ENSURE_SUCCESS(rv, rv);
-
- LOG(("Probe in %s: %X, found %d", mTableName.get(), prefix, found));
-
- if (found) {
- *aHas = true;
- }
-
- if (mCompletions.BinaryIndexOf(aCompletion) != nsTArray::NoIndex) {
- LOG(("Complete in %s", mTableName.get()));
- *aComplete = true;
- *aHas = true;
- }
-
- return NS_OK;
-}
-
-nsresult
-LookupCache::WriteFile()
-{
- nsCOMPtr storeFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(CACHE_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr out;
- rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(out), storeFile,
- PR_WRONLY | PR_TRUNCATE | PR_CREATE_FILE);
- NS_ENSURE_SUCCESS(rv, rv);
-
- UpdateHeader();
- LOG(("Writing %d completions", mHeader.numCompletions));
-
- uint32_t written;
- rv = out->Write(reinterpret_cast(&mHeader), sizeof(mHeader), &written);
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = WriteTArray(out, mCompletions);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr safeOut = do_QueryInterface(out);
- rv = safeOut->Finish();
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = EnsureSizeConsistent();
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr psFile;
- rv = mStoreDirectory->Clone(getter_AddRefs(psFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = psFile->AppendNative(mTableName + NS_LITERAL_CSTRING(PREFIXSET_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = mPrefixSet->StoreToFile(psFile);
- NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to store the prefixset");
-
- return NS_OK;
-}
-
-void
-LookupCache::ClearAll()
-{
- ClearCompleteCache();
- mPrefixSet->SetPrefixes(nullptr, 0);
- mPrimed = false;
-}
-
-void
-LookupCache::ClearCompleteCache()
-{
- mCompletions.Clear();
- UpdateHeader();
-}
-
-void
-LookupCache::UpdateHeader()
-{
- mHeader.magic = LOOKUPCACHE_MAGIC;
- mHeader.version = CURRENT_VERSION;
- mHeader.numCompletions = mCompletions.Length();
-}
-
-nsresult
-LookupCache::EnsureSizeConsistent()
-{
- nsCOMPtr storeFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(storeFile));
- NS_ENSURE_SUCCESS(rv, rv);
- rv = storeFile->AppendNative(mTableName + NS_LITERAL_CSTRING(CACHE_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- int64_t fileSize;
- rv = storeFile->GetFileSize(&fileSize);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (fileSize < 0) {
- return NS_ERROR_FAILURE;
- }
-
- int64_t expectedSize = sizeof(mHeader)
- + mHeader.numCompletions*sizeof(Completion);
- if (expectedSize != fileSize) {
- NS_WARNING("File length does not match. Probably corrupted.");
- Reset();
- return NS_ERROR_FILE_CORRUPTED;
- }
-
- return NS_OK;
-}
-
-nsresult
-LookupCache::ReadHeader(nsIInputStream* aInputStream)
-{
- if (!aInputStream) {
- ClearCompleteCache();
- return NS_OK;
- }
-
- nsCOMPtr seekable = do_QueryInterface(aInputStream);
- nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
- NS_ENSURE_SUCCESS(rv, rv);
-
- void *buffer = &mHeader;
- rv = NS_ReadInputStreamToBuffer(aInputStream,
- &buffer,
- sizeof(Header));
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (mHeader.magic != LOOKUPCACHE_MAGIC || mHeader.version != CURRENT_VERSION) {
- NS_WARNING("Unexpected header data in the store.");
- Reset();
- return NS_ERROR_FILE_CORRUPTED;
- }
- LOG(("%d completions present", mHeader.numCompletions));
-
- rv = EnsureSizeConsistent();
- NS_ENSURE_SUCCESS(rv, rv);
-
- return NS_OK;
-}
-
-nsresult
-LookupCache::ReadCompletions(nsIInputStream* aInputStream)
-{
- if (!mHeader.numCompletions) {
- mCompletions.Clear();
- return NS_OK;
- }
-
- nsCOMPtr seekable = do_QueryInterface(aInputStream);
- nsresult rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, sizeof(Header));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = ReadTArray(aInputStream, &mCompletions, mHeader.numCompletions);
- NS_ENSURE_SUCCESS(rv, rv);
-
- LOG(("Read %d completions", mCompletions.Length()));
-
- return NS_OK;
-}
-
-/* static */ bool
-LookupCache::IsCanonicalizedIP(const nsACString& aHost)
-{
- // The canonicalization process will have left IP addresses in dotted
- // decimal with no surprises.
- uint32_t i1, i2, i3, i4;
- char c;
- if (PR_sscanf(PromiseFlatCString(aHost).get(), "%u.%u.%u.%u%c",
- &i1, &i2, &i3, &i4, &c) == 4) {
- return (i1 <= 0xFF && i2 <= 0xFF && i3 <= 0xFF && i4 <= 0xFF);
- }
-
- return false;
-}
-
-/* static */ nsresult
-LookupCache::GetKey(const nsACString& aSpec,
- Completion* aHash,
- nsCOMPtr& aCryptoHash)
-{
- nsACString::const_iterator begin, end, iter;
- aSpec.BeginReading(begin);
- aSpec.EndReading(end);
-
- iter = begin;
- if (!FindCharInReadable('/', iter, end)) {
- return NS_OK;
- }
-
- const nsCSubstring& host = Substring(begin, iter);
-
- if (IsCanonicalizedIP(host)) {
- nsAutoCString key;
- key.Assign(host);
- key.Append('/');
- return aHash->FromPlaintext(key, aCryptoHash);
- }
-
- nsTArray hostComponents;
- ParseString(PromiseFlatCString(host), '.', hostComponents);
-
- if (hostComponents.Length() < 2)
- return NS_ERROR_FAILURE;
-
- int32_t last = int32_t(hostComponents.Length()) - 1;
- nsAutoCString lookupHost;
-
- if (hostComponents.Length() > 2) {
- lookupHost.Append(hostComponents[last - 2]);
- lookupHost.Append('.');
- }
-
- lookupHost.Append(hostComponents[last - 1]);
- lookupHost.Append('.');
- lookupHost.Append(hostComponents[last]);
- lookupHost.Append('/');
-
- return aHash->FromPlaintext(lookupHost, aCryptoHash);
-}
-
-/* static */ nsresult
-LookupCache::GetLookupFragments(const nsACString& aSpec,
- nsTArray* aFragments)
-
-{
- aFragments->Clear();
-
- nsACString::const_iterator begin, end, iter;
- aSpec.BeginReading(begin);
- aSpec.EndReading(end);
-
- iter = begin;
- if (!FindCharInReadable('/', iter, end)) {
- return NS_OK;
- }
-
- const nsCSubstring& host = Substring(begin, iter++);
- nsAutoCString path;
- path.Assign(Substring(iter, end));
-
- /**
- * From the protocol doc:
- * For the hostname, the client will try at most 5 different strings. They
- * are:
- * a) The exact hostname of the url
- * b) The 4 hostnames formed by starting with the last 5 components and
- * successivly removing the leading component. The top-level component
- * can be skipped. This is not done if the hostname is a numerical IP.
- */
- nsTArray hosts;
- hosts.AppendElement(host);
-
- if (!IsCanonicalizedIP(host)) {
- host.BeginReading(begin);
- host.EndReading(end);
- int numHostComponents = 0;
- while (RFindInReadable(NS_LITERAL_CSTRING("."), begin, end) &&
- numHostComponents < MAX_HOST_COMPONENTS) {
- // don't bother checking toplevel domains
- if (++numHostComponents >= 2) {
- host.EndReading(iter);
- hosts.AppendElement(Substring(end, iter));
- }
- end = begin;
- host.BeginReading(begin);
- }
- }
-
- /**
- * From the protocol doc:
- * For the path, the client will also try at most 6 different strings.
- * They are:
- * a) the exact path of the url, including query parameters
- * b) the exact path of the url, without query parameters
- * c) the 4 paths formed by starting at the root (/) and
- * successively appending path components, including a trailing
- * slash. This behavior should only extend up to the next-to-last
- * path component, that is, a trailing slash should never be
- * appended that was not present in the original url.
- */
- nsTArray paths;
- nsAutoCString pathToAdd;
-
- path.BeginReading(begin);
- path.EndReading(end);
- iter = begin;
- if (FindCharInReadable('?', iter, end)) {
- pathToAdd = Substring(begin, iter);
- paths.AppendElement(pathToAdd);
- end = iter;
- }
-
- int numPathComponents = 1;
- iter = begin;
- while (FindCharInReadable('/', iter, end) &&
- numPathComponents < MAX_PATH_COMPONENTS) {
- iter++;
- pathToAdd.Assign(Substring(begin, iter));
- paths.AppendElement(pathToAdd);
- numPathComponents++;
- }
-
- // If we haven't already done so, add the full path
- if (!pathToAdd.Equals(path)) {
- paths.AppendElement(path);
- }
- // Check an empty path (for whole-domain blacklist entries)
- paths.AppendElement(EmptyCString());
-
- for (uint32_t hostIndex = 0; hostIndex < hosts.Length(); hostIndex++) {
- for (uint32_t pathIndex = 0; pathIndex < paths.Length(); pathIndex++) {
- nsCString key;
- key.Assign(hosts[hostIndex]);
- key.Append('/');
- key.Append(paths[pathIndex]);
- LOG(("Checking fragment %s", key.get()));
-
- aFragments->AppendElement(key);
- }
- }
-
- return NS_OK;
-}
-
-/* static */ nsresult
-LookupCache::GetHostKeys(const nsACString& aSpec,
- nsTArray* aHostKeys)
-{
- nsACString::const_iterator begin, end, iter;
- aSpec.BeginReading(begin);
- aSpec.EndReading(end);
-
- iter = begin;
- if (!FindCharInReadable('/', iter, end)) {
- return NS_OK;
- }
-
- const nsCSubstring& host = Substring(begin, iter);
-
- if (IsCanonicalizedIP(host)) {
- nsCString *key = aHostKeys->AppendElement();
- if (!key)
- return NS_ERROR_OUT_OF_MEMORY;
-
- key->Assign(host);
- key->Append("/");
- return NS_OK;
- }
-
- nsTArray hostComponents;
- ParseString(PromiseFlatCString(host), '.', hostComponents);
-
- if (hostComponents.Length() < 2) {
- // no host or toplevel host, this won't match anything in the db
- return NS_OK;
- }
-
- // First check with two domain components
- int32_t last = int32_t(hostComponents.Length()) - 1;
- nsCString *lookupHost = aHostKeys->AppendElement();
- if (!lookupHost)
- return NS_ERROR_OUT_OF_MEMORY;
-
- lookupHost->Assign(hostComponents[last - 1]);
- lookupHost->Append(".");
- lookupHost->Append(hostComponents[last]);
- lookupHost->Append("/");
-
- // Now check with three domain components
- if (hostComponents.Length() > 2) {
- nsCString *lookupHost2 = aHostKeys->AppendElement();
- if (!lookupHost2)
- return NS_ERROR_OUT_OF_MEMORY;
- lookupHost2->Assign(hostComponents[last - 2]);
- lookupHost2->Append(".");
- lookupHost2->Append(*lookupHost);
- }
-
- return NS_OK;
-}
-
-bool LookupCache::IsPrimed()
-{
- return mPrimed;
-}
-
-#ifdef DEBUG
-template
-static void EnsureSorted(T* aArray)
-{
- typename T::elem_type* start = aArray->Elements();
- typename T::elem_type* end = aArray->Elements() + aArray->Length();
- typename T::elem_type* iter = start;
- typename T::elem_type* previous = start;
-
- while (iter != end) {
- previous = iter;
- ++iter;
- if (iter != end) {
- MOZ_ASSERT(*previous <= *iter);
- }
- }
- return;
-}
-#endif
-
-nsresult
-LookupCache::ConstructPrefixSet(AddPrefixArray& aAddPrefixes)
-{
- Telemetry::AutoTimer timer;
-
- nsTArray array;
- array.SetCapacity(aAddPrefixes.Length());
-
- for (uint32_t i = 0; i < aAddPrefixes.Length(); i++) {
- array.AppendElement(aAddPrefixes[i].PrefixHash().ToUint32());
- }
- aAddPrefixes.Clear();
-
-#ifdef DEBUG
- // PrefixSet requires sorted order
- EnsureSorted(&array);
-#endif
-
- // construct new one, replace old entries
- nsresult rv = mPrefixSet->SetPrefixes(array.Elements(), array.Length());
- if (NS_FAILED(rv)) {
- goto error_bailout;
- }
-
-#ifdef DEBUG
- uint32_t size;
- size = mPrefixSet->SizeInMemory();
- LOG(("SB tree done, size = %d bytes\n", size));
-#endif
-
- mPrimed = true;
-
- return NS_OK;
-
- error_bailout:
- Telemetry::Accumulate(Telemetry::URLCLASSIFIER_PS_FAILURE, 1);
- return rv;
-}
-
-nsresult
-LookupCache::LoadPrefixSet()
-{
- nsCOMPtr psFile;
- nsresult rv = mStoreDirectory->Clone(getter_AddRefs(psFile));
- NS_ENSURE_SUCCESS(rv, rv);
-
- rv = psFile->AppendNative(mTableName + NS_LITERAL_CSTRING(PREFIXSET_SUFFIX));
- NS_ENSURE_SUCCESS(rv, rv);
-
- bool exists;
- rv = psFile->Exists(&exists);
- NS_ENSURE_SUCCESS(rv, rv);
-
- if (exists) {
- LOG(("stored PrefixSet exists, loading from disk"));
- rv = mPrefixSet->LoadFromFile(psFile);
- if (NS_FAILED(rv)) {
- if (rv == NS_ERROR_FILE_CORRUPTED) {
- Reset();
- }
- return rv;
- }
- mPrimed = true;
- } else {
- LOG(("no (usable) stored PrefixSet found"));
- }
-
-#ifdef DEBUG
- if (mPrimed) {
- uint32_t size = mPrefixSet->SizeInMemory();
- LOG(("SB tree done, size = %d bytes\n", size));
- }
-#endif
-
- return NS_OK;
-}
-
-nsresult
-LookupCache::GetPrefixes(FallibleTArray& aAddPrefixes)
-{
- if (!mPrimed) {
- // This can happen if its a new table, so no error.
- LOG(("GetPrefixes from empty LookupCache"));
- return NS_OK;
- }
- return mPrefixSet->GetPrefixesNative(aAddPrefixes);
-}
-
-
-}
-}
diff --git a/toolkit/components/url-classifier/LookupCache.h b/toolkit/components/url-classifier/LookupCache.h
deleted file mode 100644
index ad551f6ca6..0000000000
--- a/toolkit/components/url-classifier/LookupCache.h
+++ /dev/null
@@ -1,142 +0,0 @@
-//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef LookupCache_h__
-#define LookupCache_h__
-
-#include "Entries.h"
-#include "nsString.h"
-#include "nsTArray.h"
-#include "nsCOMPtr.h"
-#include "nsIFile.h"
-#include "nsIFileStreams.h"
-#include "nsUrlClassifierPrefixSet.h"
-#include "prlog.h"
-
-namespace mozilla {
-namespace safebrowsing {
-
-#define MAX_HOST_COMPONENTS 5
-#define MAX_PATH_COMPONENTS 4
-
-class LookupResult {
-public:
- LookupResult() : mComplete(false), mNoise(false), mFresh(false), mProtocolConfirmed(false) {}
-
- // The fragment that matched in the LookupCache
- union {
- Prefix prefix;
- Completion complete;
- } hash;
-
- const Prefix &PrefixHash() { return hash.prefix; }
- const Completion &CompleteHash() { return hash.complete; }
-
- bool Confirmed() const { return (mComplete && mFresh) || mProtocolConfirmed; }
- bool Complete() const { return mComplete; }
-
- // True if we have a complete match for this hash in the table.
- bool mComplete;
-
- // True if this is a noise entry, i.e. an extra entry
- // that is inserted to mask the true URL we are requesting
- bool mNoise;
-
- // True if we've updated this table recently-enough.
- bool mFresh;
-
- bool mProtocolConfirmed;
-
- nsCString mTableName;
-};
-
-typedef nsTArray LookupResultArray;
-
-struct CacheResult {
- AddComplete entry;
- nsCString table;
-};
-typedef nsTArray CacheResultArray;
-
-class LookupCache {
-public:
- // Check for a canonicalized IP address.
- static bool IsCanonicalizedIP(const nsACString& aHost);
-
- // take a lookup string (www.hostname.com/path/to/resource.html) and
- // expand it into the set of fragments that should be searched for in an
- // entry
- static nsresult GetLookupFragments(const nsACString& aSpec,
- nsTArray* aFragments);
- // Similar to GetKey(), but if the domain contains three or more components,
- // two keys will be returned:
- // hostname.com/foo/bar -> [hostname.com]
- // mail.hostname.com/foo/bar -> [hostname.com, mail.hostname.com]
- // www.mail.hostname.com/foo/bar -> [hostname.com, mail.hostname.com]
- static nsresult GetHostKeys(const nsACString& aSpec,
- nsTArray