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

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

Issue 3951001: Use scoped_refptr for refcounted param in SafeBrowsingService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 339
340 SafeBrowsingService::~SafeBrowsingService() { 340 SafeBrowsingService::~SafeBrowsingService() {
341 // We should have already been shut down. If we're still enabled, then the 341 // We should have already been shut down. If we're still enabled, then the
342 // database isn't going to be closed properly, which could lead to corruption. 342 // database isn't going to be closed properly, which could lead to corruption.
343 DCHECK(!enabled_); 343 DCHECK(!enabled_);
344 } 344 }
345 345
346 void SafeBrowsingService::OnIOInitialize( 346 void SafeBrowsingService::OnIOInitialize(
347 const std::string& client_key, 347 const std::string& client_key,
348 const std::string& wrapped_key, 348 const std::string& wrapped_key,
349 URLRequestContextGetter* request_context_getter) { 349 URLRequestContextGetter* request_context_getter) {
lzheng 2010/10/20 18:03:55 Should this become scoped_refptr<URLRequestContext
willchan no longer on Chromium 2010/10/20 18:06:49 Not necessary, and there was a chromium-dev discus
350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
351 enabled_ = true; 351 enabled_ = true;
352 MakeDatabaseAvailable(); 352 MakeDatabaseAvailable();
353 353
354 // On Windows, get the safe browsing client name from the browser 354 // On Windows, get the safe browsing client name from the browser
355 // distribution classes in installer util. These classes don't yet have 355 // distribution classes in installer util. These classes don't yet have
356 // an analog on non-Windows builds so just keep the name specified here. 356 // an analog on non-Windows builds so just keep the name specified here.
357 #if defined(OS_WIN) 357 #if defined(OS_WIN)
358 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 358 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
359 std::string client_name(dist->GetSafeBrowsingName()); 359 std::string client_name(dist->GetSafeBrowsingName());
(...skipping 19 matching lines...) Expand all
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
392 protocol_manager_->Initialize(); 389 protocol_manager_->Initialize();
393 } 390 }
394 391
395 void SafeBrowsingService::OnIOShutdown() { 392 void SafeBrowsingService::OnIOShutdown() {
396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
397 if (!enabled_) 394 if (!enabled_)
398 return; 395 return;
399 396
400 enabled_ = false; 397 enabled_ = false;
401 398
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 PrefService* local_state = g_browser_process->local_state(); 638 PrefService* local_state = g_browser_process->local_state();
642 std::string client_key, wrapped_key; 639 std::string client_key, wrapped_key;
643 if (local_state) { 640 if (local_state) {
644 client_key = 641 client_key =
645 local_state->GetString(prefs::kSafeBrowsingClientKey); 642 local_state->GetString(prefs::kSafeBrowsingClientKey);
646 wrapped_key = 643 wrapped_key =
647 local_state->GetString(prefs::kSafeBrowsingWrappedKey); 644 local_state->GetString(prefs::kSafeBrowsingWrappedKey);
648 } 645 }
649 646
650 // We will issue network fetches using the default profile's request context. 647 // We will issue network fetches using the default profile's request context.
651 URLRequestContextGetter* request_context_getter = 648 scoped_refptr<URLRequestContextGetter> request_context_getter =
652 GetDefaultProfile()->GetRequestContext(); 649 GetDefaultProfile()->GetRequestContext();
653 request_context_getter->AddRef(); // Balanced in OnIOInitialize.
654 650
655 BrowserThread::PostTask( 651 BrowserThread::PostTask(
656 BrowserThread::IO, FROM_HERE, 652 BrowserThread::IO, FROM_HERE,
657 NewRunnableMethod( 653 NewRunnableMethod(
658 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, 654 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key,
659 request_context_getter)); 655 request_context_getter));
660 } 656 }
661 657
662 void SafeBrowsingService::OnCloseDatabase() { 658 void SafeBrowsingService::OnCloseDatabase() {
663 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop()); 659 DCHECK_EQ(MessageLoop::current(), safe_browsing_thread_->message_loop());
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 if (!enabled_) 801 if (!enabled_)
806 return; 802 return;
807 803
808 DLOG(INFO) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url 804 DLOG(INFO) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url
809 << " " << referrer_url << " " << is_subresource 805 << " " << referrer_url << " " << is_subresource
810 << " " << threat_type; 806 << " " << threat_type;
811 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, 807 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url,
812 referrer_url, is_subresource, 808 referrer_url, is_subresource,
813 threat_type); 809 threat_type);
814 } 810 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698