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

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

Issue 313073002: Clean-up coding style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/client_side_detection_host.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 27 matching lines...) Expand all
38 #include "url/gurl.h" 38 #include "url/gurl.h"
39 39
40 using content::BrowserThread; 40 using content::BrowserThread;
41 using content::NavigationEntry; 41 using content::NavigationEntry;
42 using content::ResourceRequestDetails; 42 using content::ResourceRequestDetails;
43 using content::WebContents; 43 using content::WebContents;
44 44
45 namespace safe_browsing { 45 namespace safe_browsing {
46 46
47 const int ClientSideDetectionHost::kMaxUrlsPerIP = 20; 47 const int ClientSideDetectionHost::kMaxUrlsPerIP = 20;
48 const int ClientSideDetectionHost::kMaxIPsPerBrowse = 200; 48 const int ClientSideDetectionHost::kMaxIPsPerBrowse = 200;
Scott Hess - ex-Googler 2014/06/04 16:19:08 Perhaps just make these size_t here and in the hea
jaekyeom 2014/06/05 11:58:57 Done.
49 49
50 const char kSafeBrowsingMatchKey[] = "safe_browsing_match"; 50 const char kSafeBrowsingMatchKey[] = "safe_browsing_match";
51 51
52 typedef base::Callback<void(bool)> ShouldClassifyUrlCallback; 52 typedef base::Callback<void(bool)> ShouldClassifyUrlCallback;
53 53
54 // This class is instantiated each time a new toplevel URL loads, and 54 // This class is instantiated each time a new toplevel URL loads, and
55 // asynchronously checks whether the malware and phishing classifiers should run 55 // asynchronously checks whether the malware and phishing classifiers should run
56 // for this URL. If so, it notifies the host class by calling the provided 56 // for this URL. If so, it notifies the host class by calling the provided
57 // callback form the UI thread. Objects of this class are ref-counted and will 57 // callback form the UI thread. Objects of this class are ref-counted and will
58 // be destroyed once nobody uses it anymore. If |web_contents|, |csd_service| 58 // be destroyed once nobody uses it anymore. If |web_contents|, |csd_service|
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 const std::string& ip, 681 const std::string& ip,
682 const std::string& url, 682 const std::string& url,
683 const std::string& method, 683 const std::string& method,
684 const std::string& referrer, 684 const std::string& referrer,
685 const ResourceType::Type resource_type) { 685 const ResourceType::Type resource_type) {
686 if (ip.empty() || url.empty()) 686 if (ip.empty() || url.empty())
687 return; 687 return;
688 688
689 IPUrlMap::iterator it = browse_info_->ips.find(ip); 689 IPUrlMap::iterator it = browse_info_->ips.find(ip);
690 if (it == browse_info_->ips.end()) { 690 if (it == browse_info_->ips.end()) {
691 if (int(browse_info_->ips.size()) < kMaxIPsPerBrowse) { 691 if (static_cast<int>(browse_info_->ips.size()) < kMaxIPsPerBrowse) {
692 std::vector<IPUrlInfo> url_infos; 692 std::vector<IPUrlInfo> url_infos;
693 url_infos.push_back(IPUrlInfo(url, method, referrer, resource_type)); 693 url_infos.push_back(IPUrlInfo(url, method, referrer, resource_type));
694 browse_info_->ips.insert(make_pair(ip, url_infos)); 694 browse_info_->ips.insert(make_pair(ip, url_infos));
695 } 695 }
696 } else if (int(it->second.size()) < kMaxUrlsPerIP) { 696 } else if (static_cast<int>(it->second.size()) < kMaxUrlsPerIP) {
697 it->second.push_back(IPUrlInfo(url, method, referrer, resource_type)); 697 it->second.push_back(IPUrlInfo(url, method, referrer, resource_type));
698 } 698 }
699 } 699 }
700 700
701 void ClientSideDetectionHost::Observe( 701 void ClientSideDetectionHost::Observe(
702 int type, 702 int type,
703 const content::NotificationSource& source, 703 const content::NotificationSource& source,
704 const content::NotificationDetails& details) { 704 const content::NotificationDetails& details) {
705 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 705 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
706 DCHECK_EQ(type, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED); 706 DCHECK_EQ(type, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED);
(...skipping 30 matching lines...) Expand all
737 ui_manager_->RemoveObserver(this); 737 ui_manager_->RemoveObserver(this);
738 738
739 ui_manager_ = ui_manager; 739 ui_manager_ = ui_manager;
740 if (ui_manager) 740 if (ui_manager)
741 ui_manager_->AddObserver(this); 741 ui_manager_->AddObserver(this);
742 742
743 database_manager_ = database_manager; 743 database_manager_ = database_manager;
744 } 744 }
745 745
746 } // namespace safe_browsing 746 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698