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

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

Issue 1420123003: Move more declarations from c/b/sb/sb_util.h to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_components
Patch Set: Minor: Replace safe_browsing_util:: with safe_browsing:: and use safe_browsing:: namespace prefix Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/protocol_manager.h" 5 #include "chrome/browser/safe_browsing/protocol_manager.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/sparse_histogram.h" 11 #include "base/metrics/sparse_histogram.h"
12 #include "base/profiler/scoped_tracker.h" 12 #include "base/profiler/scoped_tracker.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
19 #include "chrome/browser/safe_browsing/protocol_parser.h" 19 #include "chrome/browser/safe_browsing/protocol_parser.h"
20 #include "chrome/common/env_vars.h" 20 #include "chrome/common/env_vars.h"
21 #include "components/safe_browsing_db/util.h"
21 #include "components/variations/variations_associated_data.h" 22 #include "components/variations/variations_associated_data.h"
22 #include "google_apis/google_api_keys.h" 23 #include "google_apis/google_api_keys.h"
23 #include "net/base/escape.h" 24 #include "net/base/escape.h"
24 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
25 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
26 #include "net/http/http_response_headers.h" 27 #include "net/http/http_response_headers.h"
27 #include "net/http/http_status_code.h" 28 #include "net/http/http_status_code.h"
28 #include "net/url_request/url_fetcher.h" 29 #include "net/url_request/url_fetcher.h"
29 #include "net/url_request/url_request_context_getter.h" 30 #include "net/url_request/url_request_context_getter.h"
30 #include "net/url_request/url_request_status.h" 31 #include "net/url_request/url_request_status.h"
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // The update was not successful, but don't back off. 625 // The update was not successful, but don't back off.
625 UpdateFinished(false, false); 626 UpdateFinished(false, false);
626 return; 627 return;
627 } 628 }
628 629
629 // Format our stored chunks: 630 // Format our stored chunks:
630 bool found_malware = false; 631 bool found_malware = false;
631 bool found_phishing = false; 632 bool found_phishing = false;
632 for (size_t i = 0; i < lists.size(); ++i) { 633 for (size_t i = 0; i < lists.size(); ++i) {
633 update_list_data_.append(safe_browsing::FormatList(lists[i])); 634 update_list_data_.append(safe_browsing::FormatList(lists[i]));
634 if (lists[i].name == safe_browsing_util::kPhishingList) 635 if (lists[i].name == safe_browsing::kPhishingList)
635 found_phishing = true; 636 found_phishing = true;
636 637
637 if (lists[i].name == safe_browsing_util::kMalwareList) 638 if (lists[i].name == safe_browsing::kMalwareList)
638 found_malware = true; 639 found_malware = true;
639 } 640 }
640 641
641 // If we have an empty database, let the server know we want data for these 642 // If we have an empty database, let the server know we want data for these
642 // lists. 643 // lists.
643 // TODO(shess): These cases never happen because the database fills in the 644 // TODO(shess): These cases never happen because the database fills in the
644 // lists in GetChunks(). Refactor the unit tests so that this code can be 645 // lists in GetChunks(). Refactor the unit tests so that this code can be
645 // removed. 646 // removed.
646 if (!found_phishing) { 647 if (!found_phishing) {
647 update_list_data_.append(safe_browsing::FormatList( 648 update_list_data_.append(safe_browsing::FormatList(
648 SBListChunkRanges(safe_browsing_util::kPhishingList))); 649 SBListChunkRanges(safe_browsing::kPhishingList)));
649 } 650 }
650 if (!found_malware) { 651 if (!found_malware) {
651 update_list_data_.append(safe_browsing::FormatList( 652 update_list_data_.append(safe_browsing::FormatList(
652 SBListChunkRanges(safe_browsing_util::kMalwareList))); 653 SBListChunkRanges(safe_browsing::kMalwareList)));
653 } 654 }
654 655
655 // Large requests are (probably) a sign of database corruption. 656 // Large requests are (probably) a sign of database corruption.
656 // Record stats to inform decisions about whether to automate 657 // Record stats to inform decisions about whether to automate
657 // deletion of such databases. http://crbug.com/120219 658 // deletion of such databases. http://crbug.com/120219
658 UMA_HISTOGRAM_COUNTS("SB2.UpdateRequestSize", update_list_data_.size()); 659 UMA_HISTOGRAM_COUNTS("SB2.UpdateRequestSize", update_list_data_.size());
659 660
660 GURL update_url = UpdateUrl(is_extended_reporting); 661 GURL update_url = UpdateUrl(is_extended_reporting);
661 request_ = net::URLFetcher::Create(url_fetcher_id_++, update_url, 662 request_ = net::URLFetcher::Create(url_fetcher_id_++, update_url,
662 net::URLFetcher::POST, this); 663 net::URLFetcher::POST, this);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 FullHashCallback callback, bool is_download) 793 FullHashCallback callback, bool is_download)
793 : callback(callback), 794 : callback(callback),
794 is_download(is_download) { 795 is_download(is_download) {
795 } 796 }
796 797
797 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { 798 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() {
798 } 799 }
799 800
800 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { 801 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() {
801 } 802 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698