OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 379 |
380 protocol_manager_ = new SafeBrowsingProtocolManager(this, | 380 protocol_manager_ = new SafeBrowsingProtocolManager(this, |
381 client_name, | 381 client_name, |
382 client_key, | 382 client_key, |
383 wrapped_key, | 383 wrapped_key, |
384 request_context_getter, | 384 request_context_getter, |
385 info_url_prefix, | 385 info_url_prefix, |
386 mackey_url_prefix, | 386 mackey_url_prefix, |
387 disable_auto_update); | 387 disable_auto_update); |
388 | 388 |
| 389 // Balance the reference added by Start(). |
| 390 request_context_getter->Release(); |
| 391 |
389 protocol_manager_->Initialize(); | 392 protocol_manager_->Initialize(); |
390 } | 393 } |
391 | 394 |
392 void SafeBrowsingService::OnIOShutdown() { | 395 void SafeBrowsingService::OnIOShutdown() { |
393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
394 if (!enabled_) | 397 if (!enabled_) |
395 return; | 398 return; |
396 | 399 |
397 enabled_ = false; | 400 enabled_ = false; |
398 | 401 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 PrefService* local_state = g_browser_process->local_state(); | 641 PrefService* local_state = g_browser_process->local_state(); |
639 std::string client_key, wrapped_key; | 642 std::string client_key, wrapped_key; |
640 if (local_state) { | 643 if (local_state) { |
641 client_key = | 644 client_key = |
642 local_state->GetString(prefs::kSafeBrowsingClientKey); | 645 local_state->GetString(prefs::kSafeBrowsingClientKey); |
643 wrapped_key = | 646 wrapped_key = |
644 local_state->GetString(prefs::kSafeBrowsingWrappedKey); | 647 local_state->GetString(prefs::kSafeBrowsingWrappedKey); |
645 } | 648 } |
646 | 649 |
647 // We will issue network fetches using the default profile's request context. | 650 // We will issue network fetches using the default profile's request context. |
648 scoped_refptr<URLRequestContextGetter> request_context_getter = | 651 URLRequestContextGetter* request_context_getter = |
649 GetDefaultProfile()->GetRequestContext(); | 652 GetDefaultProfile()->GetRequestContext(); |
| 653 request_context_getter->AddRef(); // Balanced in OnIOInitialize. |
650 | 654 |
651 BrowserThread::PostTask( | 655 BrowserThread::PostTask( |
652 BrowserThread::IO, FROM_HERE, | 656 BrowserThread::IO, FROM_HERE, |
653 NewRunnableMethod( | 657 NewRunnableMethod( |
654 this, | 658 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, |
655 &SafeBrowsingService::OnIOInitialize, | |
656 client_key, | |
657 wrapped_key, | |
658 request_context_getter)); | 659 request_context_getter)); |
659 } | 660 } |
660 | 661 |
661 void SafeBrowsingService::OnCloseDatabase() { | 662 void SafeBrowsingService::OnCloseDatabase() { |
662 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); | 663 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); |
663 DCHECK(closing_database_); | 664 DCHECK(closing_database_); |
664 | 665 |
665 // Because |closing_database_| is true, nothing on the IO thread will be | 666 // Because |closing_database_| is true, nothing on the IO thread will be |
666 // accessing the database, so it's safe to delete and then NULL the pointer. | 667 // accessing the database, so it's safe to delete and then NULL the pointer. |
667 delete database_; | 668 delete database_; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 if (!enabled_) | 805 if (!enabled_) |
805 return; | 806 return; |
806 | 807 |
807 DLOG(INFO) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url | 808 DLOG(INFO) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url |
808 << " " << referrer_url << " " << is_subresource | 809 << " " << referrer_url << " " << is_subresource |
809 << " " << threat_type; | 810 << " " << threat_type; |
810 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, | 811 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, |
811 referrer_url, is_subresource, | 812 referrer_url, is_subresource, |
812 threat_type); | 813 threat_type); |
813 } | 814 } |
OLD | NEW |