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

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

Issue 18248: CommandLine API rework (Closed)
Patch Set: fixes 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
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 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sha2.h" 10 #include "base/sha2.h"
11 #include "chrome/browser/safe_browsing/safe_browsing_database_impl.h" 11 #include "chrome/browser/safe_browsing/safe_browsing_database_impl.h"
12 #include "chrome/browser/safe_browsing/safe_browsing_database_bloom.h" 12 #include "chrome/browser/safe_browsing/safe_browsing_database_bloom.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 15
16 using base::Time; 16 using base::Time;
17 17
18 // Filename suffix for the bloom filter. 18 // Filename suffix for the bloom filter.
19 static const wchar_t kBloomFilterFile[] = L" Filter"; 19 static const wchar_t kBloomFilterFile[] = L" Filter";
20 20
21 // Factory method. 21 // Factory method.
22 SafeBrowsingDatabase* SafeBrowsingDatabase::Create() { 22 SafeBrowsingDatabase* SafeBrowsingDatabase::Create() {
23 if (CommandLine().HasSwitch(switches::kUseOldSafeBrowsing)) 23 if (CommandLine::ForCurrentProcess()->HasSwitch(
24 switches::kUseOldSafeBrowsing)) {
24 return new SafeBrowsingDatabaseImpl; 25 return new SafeBrowsingDatabaseImpl;
26 }
25 return new SafeBrowsingDatabaseBloom; 27 return new SafeBrowsingDatabaseBloom;
26 } 28 }
27 29
28 bool SafeBrowsingDatabase::NeedToCheckUrl(const GURL& url) { 30 bool SafeBrowsingDatabase::NeedToCheckUrl(const GURL& url) {
29 // Keep a reference to the current bloom filter in case the database rebuilds 31 // Keep a reference to the current bloom filter in case the database rebuilds
30 // it while we're accessing it. 32 // it while we're accessing it.
31 scoped_refptr<BloomFilter> filter = bloom_filter_; 33 scoped_refptr<BloomFilter> filter = bloom_filter_;
32 if (!filter.get()) 34 if (!filter.get())
33 return true; 35 return true;
34 36
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (!bloom_filter_.get()) 95 if (!bloom_filter_.get())
94 return; 96 return;
95 97
96 Time before = Time::Now(); 98 Time before = Time::Now();
97 file_util::WriteFile(bloom_filter_filename_, 99 file_util::WriteFile(bloom_filter_filename_,
98 bloom_filter_->data(), 100 bloom_filter_->data(),
99 bloom_filter_->size()); 101 bloom_filter_->size());
100 SB_DLOG(INFO) << "SafeBrowsingDatabase wrote bloom filter in " << 102 SB_DLOG(INFO) << "SafeBrowsingDatabase wrote bloom filter in " <<
101 (Time::Now() - before).InMilliseconds() << " ms"; 103 (Time::Now() - before).InMilliseconds() << " ms";
102 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698