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

Side by Side Diff: chrome/browser/loader/safe_browsing_resource_throttle.cc

Issue 2381963003: Revert of Small: Start checking URLs using PVer4. Verdict not returned to client yet. (Closed)
Patch Set: Created 4 years, 2 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/loader/safe_browsing_resource_throttle.h" 5 #include "chrome/browser/loader/safe_browsing_resource_throttle.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/prerender/prerender_contents.h" 15 #include "chrome/browser/prerender/prerender_contents.h"
16 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 16 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
17 #include "components/safe_browsing_db/util.h" 17 #include "components/safe_browsing_db/util.h"
18 #include "components/safe_browsing_db/v4_feature_list.h"
19 #include "components/safe_browsing_db/v4_local_database_manager.h"
20 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h" 18 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
21 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/resource_controller.h" 21 #include "content/public/browser/resource_controller.h"
24 #include "content/public/browser/resource_request_info.h" 22 #include "content/public/browser/resource_request_info.h"
25 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
26 #include "net/base/load_flags.h" 24 #include "net/base/load_flags.h"
27 #include "net/log/net_log.h" 25 #include "net/log/net_log.h"
28 #include "net/log/net_log_source_type.h" 26 #include "net/log/net_log_source_type.h"
29 #include "net/url_request/redirect_info.h" 27 #include "net/url_request/redirect_info.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 safe_browsing::SafeBrowsingService* sb_service) 89 safe_browsing::SafeBrowsingService* sb_service)
92 : state_(STATE_NONE), 90 : state_(STATE_NONE),
93 defer_state_(DEFERRED_NONE), 91 defer_state_(DEFERRED_NONE),
94 threat_type_(safe_browsing::SB_THREAT_TYPE_SAFE), 92 threat_type_(safe_browsing::SB_THREAT_TYPE_SAFE),
95 database_manager_(sb_service->database_manager()), 93 database_manager_(sb_service->database_manager()),
96 ui_manager_(sb_service->ui_manager()), 94 ui_manager_(sb_service->ui_manager()),
97 request_(request), 95 request_(request),
98 resource_type_(resource_type), 96 resource_type_(resource_type),
99 net_log_with_source_( 97 net_log_with_source_(
100 net::NetLogWithSource::Make(request->net_log().net_log(), 98 net::NetLogWithSource::Make(request->net_log().net_log(),
101 NetLogSourceType::SAFE_BROWSING)), 99 NetLogSourceType::SAFE_BROWSING)) {}
102 v4_local_database_manager_(sb_service->v4_local_database_manager()) {}
103 100
104 SafeBrowsingResourceThrottle::~SafeBrowsingResourceThrottle() { 101 SafeBrowsingResourceThrottle::~SafeBrowsingResourceThrottle() {
105 if (defer_state_ != DEFERRED_NONE) { 102 if (defer_state_ != DEFERRED_NONE) {
106 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr); 103 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, nullptr, nullptr);
107 } 104 }
108 105
109 if (state_ == STATE_CHECKING_URL) { 106 if (state_ == STATE_CHECKING_URL) {
110 database_manager_->CancelCheck(this); 107 database_manager_->CancelCheck(this);
111 if (safe_browsing::V4FeatureList::IsParallelCheckEnabled()) {
112 v4_local_database_manager_->CancelCheck(this);
113 }
114
115 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, "result", 108 EndNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, "result",
116 "request_canceled"); 109 "request_canceled");
117 } 110 }
118 } 111 }
119 112
120 // Note on net_log calls: SAFE_BROWSING_DEFERRED events must be wholly 113 // Note on net_log calls: SAFE_BROWSING_DEFERRED events must be wholly
121 // nested within SAFE_BROWSING_CHECKING_URL events. Synchronous checks 114 // nested within SAFE_BROWSING_CHECKING_URL events. Synchronous checks
122 // are not logged at all. 115 // are not logged at all.
123 void SafeBrowsingResourceThrottle::BeginNetLogEvent(NetLogEventType type, 116 void SafeBrowsingResourceThrottle::BeginNetLogEvent(NetLogEventType type,
124 const GURL& url, 117 const GURL& url,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (!database_manager_->CanCheckResourceType(resource_type_)) { 366 if (!database_manager_->CanCheckResourceType(resource_type_)) {
374 UMA_HISTOGRAM_ENUMERATION("SB2.ResourceTypes2.Skipped", resource_type_, 367 UMA_HISTOGRAM_ENUMERATION("SB2.ResourceTypes2.Skipped", resource_type_,
375 content::RESOURCE_TYPE_LAST_TYPE); 368 content::RESOURCE_TYPE_LAST_TYPE);
376 return true; 369 return true;
377 } 370 }
378 371
379 bool succeeded_synchronously = database_manager_->CheckBrowseUrl(url, this); 372 bool succeeded_synchronously = database_manager_->CheckBrowseUrl(url, this);
380 UMA_HISTOGRAM_ENUMERATION("SB2.ResourceTypes2.Checked", resource_type_, 373 UMA_HISTOGRAM_ENUMERATION("SB2.ResourceTypes2.Checked", resource_type_,
381 content::RESOURCE_TYPE_LAST_TYPE); 374 content::RESOURCE_TYPE_LAST_TYPE);
382 375
383 if (safe_browsing::V4FeatureList::IsParallelCheckEnabled() &&
384 v4_local_database_manager_->CanCheckResourceType(resource_type_)) {
385 v4_local_database_manager_->CheckBrowseUrl(url, this);
386 }
387
388 if (succeeded_synchronously) { 376 if (succeeded_synchronously) {
389 threat_type_ = safe_browsing::SB_THREAT_TYPE_SAFE; 377 threat_type_ = safe_browsing::SB_THREAT_TYPE_SAFE;
390 ui_manager_->LogPauseDelay(base::TimeDelta()); // No delay. 378 ui_manager_->LogPauseDelay(base::TimeDelta()); // No delay.
391 return true; 379 return true;
392 } 380 }
393 381
394 state_ = STATE_CHECKING_URL; 382 state_ = STATE_CHECKING_URL;
395 url_being_checked_ = url; 383 url_being_checked_ = url;
396 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, url, nullptr, 384 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_CHECKING_URL, url, nullptr,
397 nullptr); 385 nullptr);
398 386
399 // Start a timer to abort the check if it takes too long. 387 // Start a timer to abort the check if it takes too long.
400 // TODO(nparker): Set this only when we defer, based on remaining time, 388 // TODO(nparker): Set this only when we defer, based on remaining time,
401 // so we don't cancel earlier than necessary. 389 // so we don't cancel earlier than necessary.
402 timer_.Start(FROM_HERE, 390 timer_.Start(FROM_HERE,
403 base::TimeDelta::FromMilliseconds(kCheckUrlTimeoutMs), 391 base::TimeDelta::FromMilliseconds(kCheckUrlTimeoutMs),
404 this, &SafeBrowsingResourceThrottle::OnCheckUrlTimeout); 392 this, &SafeBrowsingResourceThrottle::OnCheckUrlTimeout);
405 393
406 return false; 394 return false;
407 } 395 }
408 396
409 void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() { 397 void SafeBrowsingResourceThrottle::OnCheckUrlTimeout() {
410 CHECK_EQ(state_, STATE_CHECKING_URL); 398 CHECK_EQ(state_, STATE_CHECKING_URL);
411 399
412 database_manager_->CancelCheck(this); 400 database_manager_->CancelCheck(this);
413 if (safe_browsing::V4FeatureList::IsParallelCheckEnabled()) {
414 v4_local_database_manager_->CancelCheck(this);
415 }
416 OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE, 401 OnCheckBrowseUrlResult(url_being_checked_, safe_browsing::SB_THREAT_TYPE_SAFE,
417 safe_browsing::ThreatMetadata()); 402 safe_browsing::ThreatMetadata());
418 } 403 }
419 404
420 void SafeBrowsingResourceThrottle::ResumeRequest() { 405 void SafeBrowsingResourceThrottle::ResumeRequest() {
421 CHECK_EQ(state_, STATE_NONE); 406 CHECK_EQ(state_, STATE_NONE);
422 CHECK_NE(defer_state_, DEFERRED_NONE); 407 CHECK_NE(defer_state_, DEFERRED_NONE);
423 408
424 bool resume = true; 409 bool resume = true;
425 if (defer_state_ == DEFERRED_UNCHECKED_REDIRECT) { 410 if (defer_state_ == DEFERRED_UNCHECKED_REDIRECT) {
426 // Save the redirect urls for possible malware detail reporting later. 411 // Save the redirect urls for possible malware detail reporting later.
427 redirect_urls_.push_back(unchecked_redirect_url_); 412 redirect_urls_.push_back(unchecked_redirect_url_);
428 if (!CheckUrl(unchecked_redirect_url_)) { 413 if (!CheckUrl(unchecked_redirect_url_)) {
429 // We're now waiting for the unchecked_redirect_url_. 414 // We're now waiting for the unchecked_redirect_url_.
430 defer_state_ = DEFERRED_REDIRECT; 415 defer_state_ = DEFERRED_REDIRECT;
431 resume = false; 416 resume = false;
432 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED, 417 BeginNetLogEvent(NetLogEventType::SAFE_BROWSING_DEFERRED,
433 unchecked_redirect_url_, "defer_reason", 418 unchecked_redirect_url_, "defer_reason",
434 "resumed_redirect"); 419 "resumed_redirect");
435 } 420 }
436 } 421 }
437 422
438 if (resume) { 423 if (resume) {
439 defer_state_ = DEFERRED_NONE; 424 defer_state_ = DEFERRED_NONE;
440 controller()->Resume(); 425 controller()->Resume();
441 } 426 }
442 } 427 }
OLDNEW
« no previous file with comments | « chrome/browser/loader/safe_browsing_resource_throttle.h ('k') | chrome/browser/safe_browsing/safe_browsing_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698