OLD | NEW |
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/database_manager.h" | 5 #include "chrome/browser/safe_browsing/database_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 check_type(check_type), | 200 check_type(check_type), |
201 expected_threats(expected_threats) { | 201 expected_threats(expected_threats) { |
202 DCHECK_EQ(urls.empty(), !full_hashes.empty()) | 202 DCHECK_EQ(urls.empty(), !full_hashes.empty()) |
203 << "Exactly one of urls and full_hashes must be set"; | 203 << "Exactly one of urls and full_hashes must be set"; |
204 } | 204 } |
205 | 205 |
206 SafeBrowsingDatabaseManager::SafeBrowsingCheck::~SafeBrowsingCheck() {} | 206 SafeBrowsingDatabaseManager::SafeBrowsingCheck::~SafeBrowsingCheck() {} |
207 | 207 |
208 void SafeBrowsingDatabaseManager::Client::OnSafeBrowsingResult( | 208 void SafeBrowsingDatabaseManager::Client::OnSafeBrowsingResult( |
209 const SafeBrowsingCheck& check) { | 209 const SafeBrowsingCheck& check) { |
| 210 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 211 |
210 DCHECK_EQ(check.urls.size(), check.url_results.size()); | 212 DCHECK_EQ(check.urls.size(), check.url_results.size()); |
211 DCHECK_EQ(check.full_hashes.size(), check.full_hash_results.size()); | 213 DCHECK_EQ(check.full_hashes.size(), check.full_hash_results.size()); |
212 if (!check.urls.empty()) { | 214 if (!check.urls.empty()) { |
213 DCHECK(check.full_hashes.empty()); | 215 DCHECK(check.full_hashes.empty()); |
214 switch (check.check_type) { | 216 switch (check.check_type) { |
215 case safe_browsing_util::MALWARE: | 217 case safe_browsing_util::MALWARE: |
216 case safe_browsing_util::PHISH: | 218 case safe_browsing_util::PHISH: |
217 case safe_browsing_util::UNWANTEDURL: | 219 case safe_browsing_util::UNWANTEDURL: |
218 DCHECK_EQ(1u, check.urls.size()); | 220 DCHECK_EQ(1u, check.urls.size()); |
219 OnCheckBrowseUrlResult( | 221 OnCheckBrowseUrlResult( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 enable_csd_whitelist_(false), | 261 enable_csd_whitelist_(false), |
260 enable_download_whitelist_(false), | 262 enable_download_whitelist_(false), |
261 enable_extension_blacklist_(false), | 263 enable_extension_blacklist_(false), |
262 enable_side_effect_free_whitelist_(false), | 264 enable_side_effect_free_whitelist_(false), |
263 enable_ip_blacklist_(false), | 265 enable_ip_blacklist_(false), |
264 enable_unwanted_software_blacklist_(false), | 266 enable_unwanted_software_blacklist_(false), |
265 update_in_progress_(false), | 267 update_in_progress_(false), |
266 database_update_in_progress_(false), | 268 database_update_in_progress_(false), |
267 closing_database_(false), | 269 closing_database_(false), |
268 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { | 270 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { |
| 271 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
269 DCHECK(sb_service_.get() != NULL); | 272 DCHECK(sb_service_.get() != NULL); |
270 | 273 |
271 // Android only supports a subset of FULL_SAFE_BROWSING. | 274 // Android only supports a subset of FULL_SAFE_BROWSING. |
272 // TODO(shess): This shouldn't be OS-driven <http://crbug.com/394379> | 275 // TODO(shess): This shouldn't be OS-driven <http://crbug.com/394379> |
273 #if !defined(OS_ANDROID) | 276 #if !defined(OS_ANDROID) |
274 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 277 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
275 enable_download_protection_ = | 278 enable_download_protection_ = |
276 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); | 279 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); |
277 | 280 |
278 // We only download the csd-whitelist if client-side phishing detection is | 281 // We only download the csd-whitelist if client-side phishing detection is |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 enable_side_effect_free_whitelist_ ? SIDE_EFFECT_FREE_WHITELIST_ENABLED : | 315 enable_side_effect_free_whitelist_ ? SIDE_EFFECT_FREE_WHITELIST_ENABLED : |
313 SIDE_EFFECT_FREE_WHITELIST_DISABLED; | 316 SIDE_EFFECT_FREE_WHITELIST_DISABLED; |
314 | 317 |
315 UMA_HISTOGRAM_ENUMERATION("SB2.SideEffectFreeWhitelistStatus", | 318 UMA_HISTOGRAM_ENUMERATION("SB2.SideEffectFreeWhitelistStatus", |
316 side_effect_free_whitelist_status, | 319 side_effect_free_whitelist_status, |
317 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX); | 320 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX); |
318 #endif | 321 #endif |
319 } | 322 } |
320 | 323 |
321 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { | 324 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { |
| 325 // The DCHECK is disabled due to crbug.com/438754. |
| 326 // DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 327 |
322 // We should have already been shut down. If we're still enabled, then the | 328 // We should have already been shut down. If we're still enabled, then the |
323 // database isn't going to be closed properly, which could lead to corruption. | 329 // database isn't going to be closed properly, which could lead to corruption. |
324 DCHECK(!enabled_); | 330 DCHECK(!enabled_); |
325 } | 331 } |
326 | 332 |
327 bool SafeBrowsingDatabaseManager::CanCheckUrl(const GURL& url) const { | 333 bool SafeBrowsingDatabaseManager::CanCheckUrl(const GURL& url) const { |
328 return url.SchemeIs(url::kFtpScheme) || | 334 return url.SchemeIs(url::kFtpScheme) || |
329 url.SchemeIs(url::kHttpScheme) || | 335 url.SchemeIs(url::kHttpScheme) || |
330 url.SchemeIs(url::kHttpsScheme); | 336 url.SchemeIs(url::kHttpsScheme); |
331 } | 337 } |
332 | 338 |
333 bool SafeBrowsingDatabaseManager::CheckDownloadUrl( | 339 bool SafeBrowsingDatabaseManager::CheckDownloadUrl( |
334 const std::vector<GURL>& url_chain, | 340 const std::vector<GURL>& url_chain, |
335 Client* client) { | 341 Client* client) { |
336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 342 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
337 if (!enabled_ || !enable_download_protection_) | 343 if (!enabled_ || !enable_download_protection_) |
338 return true; | 344 return true; |
339 | 345 |
340 // We need to check the database for url prefix, and later may fetch the url | 346 // We need to check the database for url prefix, and later may fetch the url |
341 // from the safebrowsing backends. These need to be asynchronous. | 347 // from the safebrowsing backends. These need to be asynchronous. |
342 SafeBrowsingCheck* check = | 348 SafeBrowsingCheck* check = |
343 new SafeBrowsingCheck(url_chain, | 349 new SafeBrowsingCheck(url_chain, |
344 std::vector<SBFullHash>(), | 350 std::vector<SBFullHash>(), |
345 client, | 351 client, |
346 safe_browsing_util::BINURL, | 352 safe_browsing_util::BINURL, |
347 std::vector<SBThreatType>(1, | 353 std::vector<SBThreatType>(1, |
348 SB_THREAT_TYPE_BINARY_MALWARE_URL)); | 354 SB_THREAT_TYPE_BINARY_MALWARE_URL)); |
349 StartSafeBrowsingCheck( | 355 StartSafeBrowsingCheck( |
350 check, | 356 check, |
351 base::Bind(&SafeBrowsingDatabaseManager::CheckDownloadUrlOnSBThread, this, | 357 base::Bind(&SafeBrowsingDatabaseManager::CheckDownloadUrlOnSBThread, this, |
352 check)); | 358 check)); |
353 return false; | 359 return false; |
354 } | 360 } |
355 | 361 |
356 bool SafeBrowsingDatabaseManager::CheckExtensionIDs( | 362 bool SafeBrowsingDatabaseManager::CheckExtensionIDs( |
357 const std::set<std::string>& extension_ids, | 363 const std::set<std::string>& extension_ids, |
358 Client* client) { | 364 Client* client) { |
359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 365 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
360 | 366 |
361 if (!enabled_ || !enable_extension_blacklist_) | 367 if (!enabled_ || !enable_extension_blacklist_) |
362 return true; | 368 return true; |
363 | 369 |
364 std::vector<SBFullHash> extension_id_hashes; | 370 std::vector<SBFullHash> extension_id_hashes; |
365 std::transform(extension_ids.begin(), extension_ids.end(), | 371 std::transform(extension_ids.begin(), extension_ids.end(), |
366 std::back_inserter(extension_id_hashes), | 372 std::back_inserter(extension_id_hashes), |
367 safe_browsing_util::StringToSBFullHash); | 373 safe_browsing_util::StringToSBFullHash); |
368 | 374 |
369 SafeBrowsingCheck* check = new SafeBrowsingCheck( | 375 SafeBrowsingCheck* check = new SafeBrowsingCheck( |
(...skipping 17 matching lines...) Expand all Loading... |
387 return false; | 393 return false; |
388 | 394 |
389 if (!CanCheckUrl(url)) | 395 if (!CanCheckUrl(url)) |
390 return false; | 396 return false; |
391 | 397 |
392 return database_->ContainsSideEffectFreeWhitelistUrl(url); | 398 return database_->ContainsSideEffectFreeWhitelistUrl(url); |
393 } | 399 } |
394 | 400 |
395 bool SafeBrowsingDatabaseManager::MatchMalwareIP( | 401 bool SafeBrowsingDatabaseManager::MatchMalwareIP( |
396 const std::string& ip_address) { | 402 const std::string& ip_address) { |
397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 403 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
398 if (!enabled_ || !enable_ip_blacklist_ || !MakeDatabaseAvailable()) { | 404 if (!enabled_ || !enable_ip_blacklist_ || !MakeDatabaseAvailable()) { |
399 return false; // Fail open. | 405 return false; // Fail open. |
400 } | 406 } |
401 return database_->ContainsMalwareIP(ip_address); | 407 return database_->ContainsMalwareIP(ip_address); |
402 } | 408 } |
403 | 409 |
404 bool SafeBrowsingDatabaseManager::MatchCsdWhitelistUrl(const GURL& url) { | 410 bool SafeBrowsingDatabaseManager::MatchCsdWhitelistUrl(const GURL& url) { |
405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 411 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
406 if (!enabled_ || !enable_csd_whitelist_ || !MakeDatabaseAvailable()) { | 412 if (!enabled_ || !enable_csd_whitelist_ || !MakeDatabaseAvailable()) { |
407 // There is something funky going on here -- for example, perhaps the user | 413 // There is something funky going on here -- for example, perhaps the user |
408 // has not restarted since enabling metrics reporting, so we haven't | 414 // has not restarted since enabling metrics reporting, so we haven't |
409 // enabled the csd whitelist yet. Just to be safe we return true in this | 415 // enabled the csd whitelist yet. Just to be safe we return true in this |
410 // case. | 416 // case. |
411 return true; | 417 return true; |
412 } | 418 } |
413 return database_->ContainsCsdWhitelistedUrl(url); | 419 return database_->ContainsCsdWhitelistedUrl(url); |
414 } | 420 } |
415 | 421 |
416 bool SafeBrowsingDatabaseManager::MatchDownloadWhitelistUrl(const GURL& url) { | 422 bool SafeBrowsingDatabaseManager::MatchDownloadWhitelistUrl(const GURL& url) { |
417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 423 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
418 if (!enabled_ || !enable_download_whitelist_ || !MakeDatabaseAvailable()) { | 424 if (!enabled_ || !enable_download_whitelist_ || !MakeDatabaseAvailable()) { |
419 return true; | 425 return true; |
420 } | 426 } |
421 return database_->ContainsDownloadWhitelistedUrl(url); | 427 return database_->ContainsDownloadWhitelistedUrl(url); |
422 } | 428 } |
423 | 429 |
424 bool SafeBrowsingDatabaseManager::MatchDownloadWhitelistString( | 430 bool SafeBrowsingDatabaseManager::MatchDownloadWhitelistString( |
425 const std::string& str) { | 431 const std::string& str) { |
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 432 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
427 if (!enabled_ || !enable_download_whitelist_ || !MakeDatabaseAvailable()) { | 433 if (!enabled_ || !enable_download_whitelist_ || !MakeDatabaseAvailable()) { |
428 return true; | 434 return true; |
429 } | 435 } |
430 return database_->ContainsDownloadWhitelistedString(str); | 436 return database_->ContainsDownloadWhitelistedString(str); |
431 } | 437 } |
432 | 438 |
433 bool SafeBrowsingDatabaseManager::IsMalwareKillSwitchOn() { | 439 bool SafeBrowsingDatabaseManager::IsMalwareKillSwitchOn() { |
434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 440 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
435 if (!enabled_ || !MakeDatabaseAvailable()) { | 441 if (!enabled_ || !MakeDatabaseAvailable()) { |
436 return true; | 442 return true; |
437 } | 443 } |
438 return database_->IsMalwareIPMatchKillSwitchOn(); | 444 return database_->IsMalwareIPMatchKillSwitchOn(); |
439 } | 445 } |
440 | 446 |
441 bool SafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 447 bool SafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 448 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
443 if (!enabled_ || !MakeDatabaseAvailable()) { | 449 if (!enabled_ || !MakeDatabaseAvailable()) { |
444 return true; | 450 return true; |
445 } | 451 } |
446 return database_->IsCsdWhitelistKillSwitchOn(); | 452 return database_->IsCsdWhitelistKillSwitchOn(); |
447 } | 453 } |
448 | 454 |
449 bool SafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, | 455 bool SafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, |
450 Client* client) { | 456 Client* client) { |
451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 457 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
452 if (!enabled_) | 458 if (!enabled_) |
453 return true; | 459 return true; |
454 | 460 |
455 if (!CanCheckUrl(url)) | 461 if (!CanCheckUrl(url)) |
456 return true; | 462 return true; |
457 | 463 |
458 std::vector<SBThreatType> expected_threats; | 464 std::vector<SBThreatType> expected_threats; |
459 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); | 465 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); |
460 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); | 466 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); |
461 expected_threats.push_back(SB_THREAT_TYPE_URL_UNWANTED); | 467 expected_threats.push_back(SB_THREAT_TYPE_URL_UNWANTED); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 checks_.insert(check); | 527 checks_.insert(check); |
522 | 528 |
523 BrowserThread::PostTask( | 529 BrowserThread::PostTask( |
524 BrowserThread::IO, FROM_HERE, | 530 BrowserThread::IO, FROM_HERE, |
525 base::Bind(&SafeBrowsingDatabaseManager::OnCheckDone, this, check)); | 531 base::Bind(&SafeBrowsingDatabaseManager::OnCheckDone, this, check)); |
526 | 532 |
527 return false; | 533 return false; |
528 } | 534 } |
529 | 535 |
530 void SafeBrowsingDatabaseManager::CancelCheck(Client* client) { | 536 void SafeBrowsingDatabaseManager::CancelCheck(Client* client) { |
531 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 537 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
532 for (CurrentChecks::iterator i = checks_.begin(); i != checks_.end(); ++i) { | 538 for (CurrentChecks::iterator i = checks_.begin(); i != checks_.end(); ++i) { |
533 // We can't delete matching checks here because the db thread has a copy of | 539 // We can't delete matching checks here because the db thread has a copy of |
534 // the pointer. Instead, we simply NULL out the client, and when the db | 540 // the pointer. Instead, we simply NULL out the client, and when the db |
535 // thread calls us back, we'll clean up the check. | 541 // thread calls us back, we'll clean up the check. |
536 if ((*i)->client == client) | 542 if ((*i)->client == client) |
537 (*i)->client = NULL; | 543 (*i)->client = NULL; |
538 } | 544 } |
539 | 545 |
540 // Scan the queued clients store. Clients may be here if they requested a URL | 546 // Scan the queued clients store. Clients may be here if they requested a URL |
541 // check before the database has finished loading. | 547 // check before the database has finished loading. |
542 for (std::deque<QueuedCheck>::iterator it(queued_checks_.begin()); | 548 for (std::deque<QueuedCheck>::iterator it(queued_checks_.begin()); |
543 it != queued_checks_.end(); ) { | 549 it != queued_checks_.end(); ) { |
544 // In this case it's safe to delete matches entirely since nothing has a | 550 // In this case it's safe to delete matches entirely since nothing has a |
545 // pointer to them. | 551 // pointer to them. |
546 if (it->client == client) | 552 if (it->client == client) |
547 it = queued_checks_.erase(it); | 553 it = queued_checks_.erase(it); |
548 else | 554 else |
549 ++it; | 555 ++it; |
550 } | 556 } |
551 } | 557 } |
552 | 558 |
553 void SafeBrowsingDatabaseManager::HandleGetHashResults( | 559 void SafeBrowsingDatabaseManager::HandleGetHashResults( |
554 SafeBrowsingCheck* check, | 560 SafeBrowsingCheck* check, |
555 const std::vector<SBFullHashResult>& full_hashes, | 561 const std::vector<SBFullHashResult>& full_hashes, |
556 const base::TimeDelta& cache_lifetime) { | 562 const base::TimeDelta& cache_lifetime) { |
557 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 563 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
558 | 564 |
559 if (!enabled_) | 565 if (!enabled_) |
560 return; | 566 return; |
561 | 567 |
562 // If the service has been shut down, |check| should have been deleted. | 568 // If the service has been shut down, |check| should have been deleted. |
563 DCHECK(checks_.find(check) != checks_.end()); | 569 DCHECK(checks_.find(check) != checks_.end()); |
564 | 570 |
565 // |start| is set before calling |GetFullHash()|, which should be | 571 // |start| is set before calling |GetFullHash()|, which should be |
566 // the only path which gets to here. | 572 // the only path which gets to here. |
567 DCHECK(!check->start.is_null()); | 573 DCHECK(!check->start.is_null()); |
568 UMA_HISTOGRAM_LONG_TIMES("SB2.Network", | 574 UMA_HISTOGRAM_LONG_TIMES("SB2.Network", |
569 base::TimeTicks::Now() - check->start); | 575 base::TimeTicks::Now() - check->start); |
570 | 576 |
571 std::vector<SBPrefix> prefixes = check->prefix_hits; | 577 std::vector<SBPrefix> prefixes = check->prefix_hits; |
572 OnHandleGetHashResults(check, full_hashes); // 'check' is deleted here. | 578 OnHandleGetHashResults(check, full_hashes); // 'check' is deleted here. |
573 | 579 |
574 // Cache the GetHash results. | 580 // Cache the GetHash results. |
575 if (cache_lifetime != base::TimeDelta() && MakeDatabaseAvailable()) | 581 if (cache_lifetime != base::TimeDelta() && MakeDatabaseAvailable()) |
576 database_->CacheHashResults(prefixes, full_hashes, cache_lifetime); | 582 database_->CacheHashResults(prefixes, full_hashes, cache_lifetime); |
577 } | 583 } |
578 | 584 |
579 void SafeBrowsingDatabaseManager::GetChunks(GetChunksCallback callback) { | 585 void SafeBrowsingDatabaseManager::GetChunks(GetChunksCallback callback) { |
580 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 586 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
581 DCHECK(enabled_); | 587 DCHECK(enabled_); |
582 DCHECK(!callback.is_null()); | 588 DCHECK(!callback.is_null()); |
583 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( | 589 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( |
584 &SafeBrowsingDatabaseManager::GetAllChunksFromDatabase, this, callback)); | 590 &SafeBrowsingDatabaseManager::GetAllChunksFromDatabase, this, callback)); |
585 } | 591 } |
586 | 592 |
587 void SafeBrowsingDatabaseManager::AddChunks( | 593 void SafeBrowsingDatabaseManager::AddChunks( |
588 const std::string& list, | 594 const std::string& list, |
589 scoped_ptr<ScopedVector<SBChunkData> > chunks, | 595 scoped_ptr<ScopedVector<SBChunkData> > chunks, |
590 AddChunksCallback callback) { | 596 AddChunksCallback callback) { |
591 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 597 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
592 DCHECK(enabled_); | 598 DCHECK(enabled_); |
593 DCHECK(!callback.is_null()); | 599 DCHECK(!callback.is_null()); |
594 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( | 600 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( |
595 &SafeBrowsingDatabaseManager::AddDatabaseChunks, this, list, | 601 &SafeBrowsingDatabaseManager::AddDatabaseChunks, this, list, |
596 base::Passed(&chunks), callback)); | 602 base::Passed(&chunks), callback)); |
597 } | 603 } |
598 | 604 |
599 void SafeBrowsingDatabaseManager::DeleteChunks( | 605 void SafeBrowsingDatabaseManager::DeleteChunks( |
600 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) { | 606 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) { |
601 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 607 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
602 DCHECK(enabled_); | 608 DCHECK(enabled_); |
603 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( | 609 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( |
604 &SafeBrowsingDatabaseManager::DeleteDatabaseChunks, this, | 610 &SafeBrowsingDatabaseManager::DeleteDatabaseChunks, this, |
605 base::Passed(&chunk_deletes))); | 611 base::Passed(&chunk_deletes))); |
606 } | 612 } |
607 | 613 |
608 void SafeBrowsingDatabaseManager::UpdateStarted() { | 614 void SafeBrowsingDatabaseManager::UpdateStarted() { |
609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 615 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
610 DCHECK(enabled_); | 616 DCHECK(enabled_); |
611 DCHECK(!update_in_progress_); | 617 DCHECK(!update_in_progress_); |
612 update_in_progress_ = true; | 618 update_in_progress_ = true; |
613 } | 619 } |
614 | 620 |
615 void SafeBrowsingDatabaseManager::UpdateFinished(bool update_succeeded) { | 621 void SafeBrowsingDatabaseManager::UpdateFinished(bool update_succeeded) { |
616 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 622 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
617 DCHECK(enabled_); | 623 DCHECK(enabled_); |
618 if (update_in_progress_) { | 624 if (update_in_progress_) { |
619 update_in_progress_ = false; | 625 update_in_progress_ = false; |
620 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, | 626 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, |
621 base::Bind(&SafeBrowsingDatabaseManager::DatabaseUpdateFinished, | 627 base::Bind(&SafeBrowsingDatabaseManager::DatabaseUpdateFinished, |
622 this, update_succeeded)); | 628 this, update_succeeded)); |
623 } | 629 } |
624 } | 630 } |
625 | 631 |
626 void SafeBrowsingDatabaseManager::ResetDatabase() { | 632 void SafeBrowsingDatabaseManager::ResetDatabase() { |
627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 633 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
628 DCHECK(enabled_); | 634 DCHECK(enabled_); |
629 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( | 635 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, base::Bind( |
630 &SafeBrowsingDatabaseManager::OnResetDatabase, this)); | 636 &SafeBrowsingDatabaseManager::OnResetDatabase, this)); |
631 } | 637 } |
632 | 638 |
633 void SafeBrowsingDatabaseManager::StartOnIOThread() { | 639 void SafeBrowsingDatabaseManager::StartOnIOThread() { |
634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 640 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
635 if (enabled_) | 641 if (enabled_) |
636 return; | 642 return; |
637 | 643 |
638 DCHECK(!safe_browsing_thread_.get()); | 644 DCHECK(!safe_browsing_thread_.get()); |
639 safe_browsing_thread_.reset(new base::Thread("Chrome_SafeBrowsingThread")); | 645 safe_browsing_thread_.reset(new base::Thread("Chrome_SafeBrowsingThread")); |
640 if (!safe_browsing_thread_->Start()) | 646 if (!safe_browsing_thread_->Start()) |
641 return; | 647 return; |
642 enabled_ = true; | 648 enabled_ = true; |
643 | 649 |
644 MakeDatabaseAvailable(); | 650 MakeDatabaseAvailable(); |
645 } | 651 } |
646 | 652 |
647 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { | 653 void SafeBrowsingDatabaseManager::StopOnIOThread(bool shutdown) { |
648 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 654 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
649 | 655 |
650 DoStopOnIOThread(); | 656 DoStopOnIOThread(); |
651 if (shutdown) { | 657 if (shutdown) { |
652 sb_service_ = NULL; | 658 sb_service_ = NULL; |
653 } | 659 } |
654 } | 660 } |
655 | 661 |
656 void SafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( | 662 void SafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( |
657 bool update_succeeded) { | 663 bool update_succeeded) { |
| 664 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
658 content::NotificationService::current()->Notify( | 665 content::NotificationService::current()->Notify( |
659 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 666 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
660 content::Source<SafeBrowsingDatabaseManager>(this), | 667 content::Source<SafeBrowsingDatabaseManager>(this), |
661 content::Details<bool>(&update_succeeded)); | 668 content::Details<bool>(&update_succeeded)); |
662 } | 669 } |
663 | 670 |
664 SafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( | 671 SafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( |
665 const safe_browsing_util::ListType check_type, | 672 const safe_browsing_util::ListType check_type, |
666 Client* client, | 673 Client* client, |
667 const GURL& url, | 674 const GURL& url, |
668 const std::vector<SBThreatType>& expected_threats, | 675 const std::vector<SBThreatType>& expected_threats, |
669 const base::TimeTicks& start) | 676 const base::TimeTicks& start) |
670 : check_type(check_type), | 677 : check_type(check_type), |
671 client(client), | 678 client(client), |
672 url(url), | 679 url(url), |
673 expected_threats(expected_threats), | 680 expected_threats(expected_threats), |
674 start(start) { | 681 start(start) { |
675 } | 682 } |
676 | 683 |
677 SafeBrowsingDatabaseManager::QueuedCheck::~QueuedCheck() { | 684 SafeBrowsingDatabaseManager::QueuedCheck::~QueuedCheck() { |
678 } | 685 } |
679 | 686 |
680 void SafeBrowsingDatabaseManager::DoStopOnIOThread() { | 687 void SafeBrowsingDatabaseManager::DoStopOnIOThread() { |
| 688 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 689 |
681 if (!enabled_) | 690 if (!enabled_) |
682 return; | 691 return; |
683 | 692 |
684 enabled_ = false; | 693 enabled_ = false; |
685 | 694 |
686 // Delete queued checks, calling back any clients with 'SB_THREAT_TYPE_SAFE'. | 695 // Delete queued checks, calling back any clients with 'SB_THREAT_TYPE_SAFE'. |
687 while (!queued_checks_.empty()) { | 696 while (!queued_checks_.empty()) { |
688 QueuedCheck queued = queued_checks_.front(); | 697 QueuedCheck queued = queued_checks_.front(); |
689 if (queued.client) { | 698 if (queued.client) { |
690 SafeBrowsingCheck sb_check(std::vector<GURL>(1, queued.url), | 699 SafeBrowsingCheck sb_check(std::vector<GURL>(1, queued.url), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 753 |
745 gethash_requests_.clear(); | 754 gethash_requests_.clear(); |
746 } | 755 } |
747 | 756 |
748 bool SafeBrowsingDatabaseManager::DatabaseAvailable() const { | 757 bool SafeBrowsingDatabaseManager::DatabaseAvailable() const { |
749 base::AutoLock lock(database_lock_); | 758 base::AutoLock lock(database_lock_); |
750 return !closing_database_ && (database_ != NULL); | 759 return !closing_database_ && (database_ != NULL); |
751 } | 760 } |
752 | 761 |
753 bool SafeBrowsingDatabaseManager::MakeDatabaseAvailable() { | 762 bool SafeBrowsingDatabaseManager::MakeDatabaseAvailable() { |
754 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 763 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
755 DCHECK(enabled_); | 764 DCHECK(enabled_); |
756 if (DatabaseAvailable()) | 765 if (DatabaseAvailable()) |
757 return true; | 766 return true; |
758 safe_browsing_thread_->message_loop()->PostTask( | 767 safe_browsing_thread_->message_loop()->PostTask( |
759 FROM_HERE, | 768 FROM_HERE, |
760 base::Bind(base::IgnoreResult(&SafeBrowsingDatabaseManager::GetDatabase), | 769 base::Bind(base::IgnoreResult(&SafeBrowsingDatabaseManager::GetDatabase), |
761 this)); | 770 this)); |
762 return false; | 771 return false; |
763 } | 772 } |
764 | 773 |
(...skipping 11 matching lines...) Expand all Loading... |
776 enable_csd_whitelist_, | 785 enable_csd_whitelist_, |
777 enable_download_whitelist_, | 786 enable_download_whitelist_, |
778 enable_extension_blacklist_, | 787 enable_extension_blacklist_, |
779 enable_side_effect_free_whitelist_, | 788 enable_side_effect_free_whitelist_, |
780 enable_ip_blacklist_, | 789 enable_ip_blacklist_, |
781 enable_unwanted_software_blacklist_); | 790 enable_unwanted_software_blacklist_); |
782 | 791 |
783 database->Init(SafeBrowsingService::GetBaseFilename()); | 792 database->Init(SafeBrowsingService::GetBaseFilename()); |
784 { | 793 { |
785 // Acquiring the lock here guarantees correct ordering between the writes to | 794 // Acquiring the lock here guarantees correct ordering between the writes to |
786 // the new database object above, and the setting of |databse_| below. | 795 // the new database object above, and the setting of |database_| below. |
787 base::AutoLock lock(database_lock_); | 796 base::AutoLock lock(database_lock_); |
788 database_ = database; | 797 database_ = database; |
789 } | 798 } |
790 | 799 |
791 BrowserThread::PostTask( | 800 BrowserThread::PostTask( |
792 BrowserThread::IO, FROM_HERE, | 801 BrowserThread::IO, FROM_HERE, |
793 base::Bind(&SafeBrowsingDatabaseManager::DatabaseLoadComplete, this)); | 802 base::Bind(&SafeBrowsingDatabaseManager::DatabaseLoadComplete, this)); |
794 | 803 |
795 UMA_HISTOGRAM_TIMES("SB2.DatabaseOpen", base::TimeTicks::Now() - before); | 804 UMA_HISTOGRAM_TIMES("SB2.DatabaseOpen", base::TimeTicks::Now() - before); |
796 return database_; | 805 return database_; |
797 } | 806 } |
798 | 807 |
799 void SafeBrowsingDatabaseManager::OnCheckDone(SafeBrowsingCheck* check) { | 808 void SafeBrowsingDatabaseManager::OnCheckDone(SafeBrowsingCheck* check) { |
800 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 809 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
801 | 810 |
802 if (!enabled_) | 811 if (!enabled_) |
803 return; | 812 return; |
804 | 813 |
805 // If the service has been shut down, |check| should have been deleted. | 814 // If the service has been shut down, |check| should have been deleted. |
806 DCHECK(checks_.find(check) != checks_.end()); | 815 DCHECK(checks_.find(check) != checks_.end()); |
807 | 816 |
808 if (check->client && check->need_get_hash) { | 817 if (check->client && check->need_get_hash) { |
809 // We have a partial match so we need to query Google for the full hash. | 818 // We have a partial match so we need to query Google for the full hash. |
810 // Clean up will happen in HandleGetHashResults. | 819 // Clean up will happen in HandleGetHashResults. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 875 |
867 BrowserThread::PostTask( | 876 BrowserThread::PostTask( |
868 BrowserThread::IO, FROM_HERE, | 877 BrowserThread::IO, FROM_HERE, |
869 base::Bind(&SafeBrowsingDatabaseManager::OnGetAllChunksFromDatabase, | 878 base::Bind(&SafeBrowsingDatabaseManager::OnGetAllChunksFromDatabase, |
870 this, lists, database_error, callback)); | 879 this, lists, database_error, callback)); |
871 } | 880 } |
872 | 881 |
873 void SafeBrowsingDatabaseManager::OnGetAllChunksFromDatabase( | 882 void SafeBrowsingDatabaseManager::OnGetAllChunksFromDatabase( |
874 const std::vector<SBListChunkRanges>& lists, bool database_error, | 883 const std::vector<SBListChunkRanges>& lists, bool database_error, |
875 GetChunksCallback callback) { | 884 GetChunksCallback callback) { |
876 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 885 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
877 if (enabled_) | 886 if (enabled_) |
878 callback.Run(lists, database_error); | 887 callback.Run(lists, database_error); |
879 } | 888 } |
880 | 889 |
881 void SafeBrowsingDatabaseManager::OnAddChunksComplete( | 890 void SafeBrowsingDatabaseManager::OnAddChunksComplete( |
882 AddChunksCallback callback) { | 891 AddChunksCallback callback) { |
883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 892 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
884 if (enabled_) | 893 if (enabled_) |
885 callback.Run(); | 894 callback.Run(); |
886 } | 895 } |
887 | 896 |
888 void SafeBrowsingDatabaseManager::DatabaseLoadComplete() { | 897 void SafeBrowsingDatabaseManager::DatabaseLoadComplete() { |
889 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 898 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
890 if (!enabled_) | 899 if (!enabled_) |
891 return; | 900 return; |
892 | 901 |
893 LOCAL_HISTOGRAM_COUNTS("SB.QueueDepth", queued_checks_.size()); | 902 LOCAL_HISTOGRAM_COUNTS("SB.QueueDepth", queued_checks_.size()); |
894 if (queued_checks_.empty()) | 903 if (queued_checks_.empty()) |
895 return; | 904 return; |
896 | 905 |
897 // If the database isn't already available, calling CheckUrl() in the loop | 906 // If the database isn't already available, calling CheckUrl() in the loop |
898 // below will add the check back to the queue, and we'll infinite-loop. | 907 // below will add the check back to the queue, and we'll infinite-loop. |
899 DCHECK(DatabaseAvailable()); | 908 DCHECK(DatabaseAvailable()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 | 981 |
973 void SafeBrowsingDatabaseManager::OnResetDatabase() { | 982 void SafeBrowsingDatabaseManager::OnResetDatabase() { |
974 DCHECK_EQ(base::MessageLoop::current(), | 983 DCHECK_EQ(base::MessageLoop::current(), |
975 safe_browsing_thread_->message_loop()); | 984 safe_browsing_thread_->message_loop()); |
976 GetDatabase()->ResetDatabase(); | 985 GetDatabase()->ResetDatabase(); |
977 } | 986 } |
978 | 987 |
979 void SafeBrowsingDatabaseManager::OnHandleGetHashResults( | 988 void SafeBrowsingDatabaseManager::OnHandleGetHashResults( |
980 SafeBrowsingCheck* check, | 989 SafeBrowsingCheck* check, |
981 const std::vector<SBFullHashResult>& full_hashes) { | 990 const std::vector<SBFullHashResult>& full_hashes) { |
982 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 991 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
983 safe_browsing_util::ListType check_type = check->check_type; | 992 safe_browsing_util::ListType check_type = check->check_type; |
984 SBPrefix prefix = check->prefix_hits[0]; | 993 SBPrefix prefix = check->prefix_hits[0]; |
985 GetHashRequests::iterator it = gethash_requests_.find(prefix); | 994 GetHashRequests::iterator it = gethash_requests_.find(prefix); |
986 if (check->prefix_hits.size() > 1 || it == gethash_requests_.end()) { | 995 if (check->prefix_hits.size() > 1 || it == gethash_requests_.end()) { |
987 const bool hit = HandleOneCheck(check, full_hashes); | 996 const bool hit = HandleOneCheck(check, full_hashes); |
988 RecordGetHashCheckStatus(hit, check_type, full_hashes); | 997 RecordGetHashCheckStatus(hit, check_type, full_hashes); |
989 return; | 998 return; |
990 } | 999 } |
991 | 1000 |
992 // Call back all interested parties, noting if any has a hit. | 1001 // Call back all interested parties, noting if any has a hit. |
993 GetHashRequestors& requestors = it->second; | 1002 GetHashRequestors& requestors = it->second; |
994 bool hit = false; | 1003 bool hit = false; |
995 for (GetHashRequestors::iterator r = requestors.begin(); | 1004 for (GetHashRequestors::iterator r = requestors.begin(); |
996 r != requestors.end(); ++r) { | 1005 r != requestors.end(); ++r) { |
997 if (HandleOneCheck(*r, full_hashes)) | 1006 if (HandleOneCheck(*r, full_hashes)) |
998 hit = true; | 1007 hit = true; |
999 } | 1008 } |
1000 RecordGetHashCheckStatus(hit, check_type, full_hashes); | 1009 RecordGetHashCheckStatus(hit, check_type, full_hashes); |
1001 | 1010 |
1002 gethash_requests_.erase(it); | 1011 gethash_requests_.erase(it); |
1003 } | 1012 } |
1004 | 1013 |
1005 bool SafeBrowsingDatabaseManager::HandleOneCheck( | 1014 bool SafeBrowsingDatabaseManager::HandleOneCheck( |
1006 SafeBrowsingCheck* check, | 1015 SafeBrowsingCheck* check, |
1007 const std::vector<SBFullHashResult>& full_hashes) { | 1016 const std::vector<SBFullHashResult>& full_hashes) { |
1008 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1017 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1009 DCHECK(check); | 1018 DCHECK(check); |
1010 | 1019 |
1011 bool is_threat = false; | 1020 bool is_threat = false; |
1012 | 1021 |
1013 // TODO(shess): GetHashSeverestThreadListType() contains a loop, | 1022 // TODO(shess): GetHashSeverestThreadListType() contains a loop, |
1014 // GetUrlSeverestThreatListType() a loop around that loop. Having another | 1023 // GetUrlSeverestThreatListType() a loop around that loop. Having another |
1015 // loop out here concerns me. It is likely that SAFE is an expected outcome, | 1024 // loop out here concerns me. It is likely that SAFE is an expected outcome, |
1016 // which means all of those loops run to completion. Refactoring this to | 1025 // which means all of those loops run to completion. Refactoring this to |
1017 // generate a set of sorted items to compare in sequence would probably | 1026 // generate a set of sorted items to compare in sequence would probably |
1018 // improve things. | 1027 // improve things. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 // Some prefixes matched, we need to ask Google whether they're legit. | 1109 // Some prefixes matched, we need to ask Google whether they're legit. |
1101 check->need_get_hash = true; | 1110 check->need_get_hash = true; |
1102 BrowserThread::PostTask( | 1111 BrowserThread::PostTask( |
1103 BrowserThread::IO, | 1112 BrowserThread::IO, |
1104 FROM_HERE, | 1113 FROM_HERE, |
1105 base::Bind(&SafeBrowsingDatabaseManager::OnCheckDone, this, check)); | 1114 base::Bind(&SafeBrowsingDatabaseManager::OnCheckDone, this, check)); |
1106 } | 1115 } |
1107 } | 1116 } |
1108 | 1117 |
1109 void SafeBrowsingDatabaseManager::TimeoutCallback(SafeBrowsingCheck* check) { | 1118 void SafeBrowsingDatabaseManager::TimeoutCallback(SafeBrowsingCheck* check) { |
1110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1119 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1111 DCHECK(check); | 1120 DCHECK(check); |
1112 | 1121 |
1113 if (!enabled_) | 1122 if (!enabled_) |
1114 return; | 1123 return; |
1115 | 1124 |
1116 DCHECK(checks_.find(check) != checks_.end()); | 1125 DCHECK(checks_.find(check) != checks_.end()); |
1117 if (check->client) { | 1126 if (check->client) { |
1118 check->client->OnSafeBrowsingResult(*check); | 1127 check->client->OnSafeBrowsingResult(*check); |
1119 check->client = NULL; | 1128 check->client = NULL; |
1120 } | 1129 } |
1121 } | 1130 } |
1122 | 1131 |
1123 void SafeBrowsingDatabaseManager::CheckDownloadUrlDone( | 1132 void SafeBrowsingDatabaseManager::CheckDownloadUrlDone( |
1124 SafeBrowsingCheck* check) { | 1133 SafeBrowsingCheck* check) { |
| 1134 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1125 DCHECK(enable_download_protection_); | 1135 DCHECK(enable_download_protection_); |
1126 SafeBrowsingCheckDone(check); | 1136 SafeBrowsingCheckDone(check); |
1127 } | 1137 } |
1128 | 1138 |
1129 void SafeBrowsingDatabaseManager::SafeBrowsingCheckDone( | 1139 void SafeBrowsingDatabaseManager::SafeBrowsingCheckDone( |
1130 SafeBrowsingCheck* check) { | 1140 SafeBrowsingCheck* check) { |
1131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1141 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1132 DCHECK(check); | 1142 DCHECK(check); |
1133 | 1143 |
1134 if (!enabled_) | 1144 if (!enabled_) |
1135 return; | 1145 return; |
1136 | 1146 |
1137 DVLOG(1) << "SafeBrowsingCheckDone"; | 1147 DVLOG(1) << "SafeBrowsingCheckDone"; |
1138 DCHECK(checks_.find(check) != checks_.end()); | 1148 DCHECK(checks_.find(check) != checks_.end()); |
1139 if (check->client) | 1149 if (check->client) |
1140 check->client->OnSafeBrowsingResult(*check); | 1150 check->client->OnSafeBrowsingResult(*check); |
1141 checks_.erase(check); | 1151 checks_.erase(check); |
1142 delete check; | 1152 delete check; |
1143 } | 1153 } |
1144 | 1154 |
1145 void SafeBrowsingDatabaseManager::StartSafeBrowsingCheck( | 1155 void SafeBrowsingDatabaseManager::StartSafeBrowsingCheck( |
1146 SafeBrowsingCheck* check, | 1156 SafeBrowsingCheck* check, |
1147 const base::Closure& task) { | 1157 const base::Closure& task) { |
1148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1158 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1149 check->timeout_factory_.reset( | 1159 check->timeout_factory_.reset( |
1150 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); | 1160 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); |
1151 checks_.insert(check); | 1161 checks_.insert(check); |
1152 | 1162 |
1153 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1163 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
1154 | 1164 |
1155 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1165 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1156 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, | 1166 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, |
1157 check->timeout_factory_->GetWeakPtr(), check), | 1167 check->timeout_factory_->GetWeakPtr(), check), |
1158 check_timeout_); | 1168 check_timeout_); |
1159 } | 1169 } |
OLD | NEW |