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

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

Issue 19610: Safe browsing cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 48 base::SystemMonitor* monitor = base::SystemMonitor::Get();
49 if (monitor) 49 if (monitor)
50 monitor->RemoveObserver(this); 50 monitor->RemoveObserver(this);
51 } 51 }
52 52
53 // Only called on the UI thread. 53 // Only called on the UI thread.
54 void SafeBrowsingService::Initialize(MessageLoop* io_loop) { 54 void SafeBrowsingService::Initialize(MessageLoop* io_loop) {
55 io_loop_ = io_loop; 55 io_loop_ = io_loop;
56 56
57 // Get the profile's preference for SafeBrowsing. 57 // Get the profile's preference for SafeBrowsing.
58 std::wstring user_data_dir; 58 FilePath user_data_dir;
59 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 59 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
60 ProfileManager* profile_manager = g_browser_process->profile_manager(); 60 ProfileManager* profile_manager = g_browser_process->profile_manager();
61 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); 61 Profile* profile = profile_manager->GetDefaultProfile(
62 user_data_dir.ToWStringHack());
62 PrefService* pref_service = profile->GetPrefs(); 63 PrefService* pref_service = profile->GetPrefs();
63 if (pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)) 64 if (pref_service->GetBoolean(prefs::kSafeBrowsingEnabled))
64 Start(); 65 Start();
65 } 66 }
66 67
67 // Start up SafeBrowsing objects. This can be called at browser start, or when 68 // Start up SafeBrowsing objects. This can be called at browser start, or when
68 // the user checks the "Enable SafeBrowsing" option in the Advanced options UI. 69 // the user checks the "Enable SafeBrowsing" option in the Advanced options UI.
69 void SafeBrowsingService::Start() { 70 void SafeBrowsingService::Start() {
70 DCHECK(!db_thread_.get()); 71 DCHECK(!db_thread_.get());
71 db_thread_.reset(new base::Thread("Chrome_SafeBrowsingThread")); 72 db_thread_.reset(new base::Thread("Chrome_SafeBrowsingThread"));
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // We may have cached results for previous GetHash queries. 388 // We may have cached results for previous GetHash queries.
388 HandleOneCheck(check, check->full_hits); 389 HandleOneCheck(check, check->full_hits);
389 } 390 }
390 } 391 }
391 392
392 SafeBrowsingDatabase* SafeBrowsingService::GetDatabase() { 393 SafeBrowsingDatabase* SafeBrowsingService::GetDatabase() {
393 DCHECK(MessageLoop::current() == db_thread_->message_loop()); 394 DCHECK(MessageLoop::current() == db_thread_->message_loop());
394 if (database_) 395 if (database_)
395 return database_; 396 return database_;
396 397
397 std::wstring path; 398 FilePath path;
398 bool result = PathService::Get(chrome::DIR_USER_DATA, &path); 399 bool result = PathService::Get(chrome::DIR_USER_DATA, &path);
399 DCHECK(result); 400 DCHECK(result);
400 401 path = path.Append(chrome::kSafeBrowsingFilename);
401 path.append(L"\\");
402 path.append(chrome::kSafeBrowsingFilename);
403 402
404 Time before = Time::Now(); 403 Time before = Time::Now();
405 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create(); 404 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create();
406 Callback0::Type* chunk_callback = 405 Callback0::Type* chunk_callback =
407 NewCallback(this, &SafeBrowsingService::ChunkInserted); 406 NewCallback(this, &SafeBrowsingService::ChunkInserted);
408 bool init_success = database->Init(path, chunk_callback); 407 bool init_success = database->Init(path, chunk_callback);
409 408
410 io_loop_->PostTask(FROM_HERE, NewRunnableMethod( 409 io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
411 this, &SafeBrowsingService::DatabaseLoadComplete, !init_success)); 410 this, &SafeBrowsingService::DatabaseLoadComplete, !init_success));
412 411
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 DCHECK(MessageLoop::current() == io_loop_); 722 DCHECK(MessageLoop::current() == io_loop_);
724 HISTOGRAM_COUNTS(L"SB.QueueDepth", queued_checks_.size()); 723 HISTOGRAM_COUNTS(L"SB.QueueDepth", queued_checks_.size());
725 while (!queued_checks_.empty()) { 724 while (!queued_checks_.empty()) {
726 QueuedCheck check = queued_checks_.front(); 725 QueuedCheck check = queued_checks_.front();
727 HISTOGRAM_TIMES(L"SB.QueueDelay", Time::Now() - check.start); 726 HISTOGRAM_TIMES(L"SB.QueueDelay", Time::Now() - check.start);
728 CheckUrl(check.url, check.client); 727 CheckUrl(check.url, check.client);
729 queued_checks_.pop_front(); 728 queued_checks_.pop_front();
730 } 729 }
731 } 730 }
732 731
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_database_unittest.cc ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698