summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/SConscript.unit_tests4
-rw-r--r--chrome/browser/SConscript13
-rw-r--r--chrome/browser/automation/url_request_failed_dns_job.cc4
-rw-r--r--chrome/browser/automation/url_request_failed_dns_job.h2
-rw-r--r--chrome/browser/automation/url_request_mock_http_job.cc12
-rw-r--r--chrome/browser/automation/url_request_mock_net_error_job.cc2
-rw-r--r--chrome/browser/automation/url_request_slow_download_job.cc6
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_bloom.cc14
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_impl.cc25
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc28
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database_unittest.cc100
11 files changed, 124 insertions, 86 deletions
diff --git a/chrome/SConscript.unit_tests b/chrome/SConscript.unit_tests
index 7507fd0..6f8a472 100644
--- a/chrome/SConscript.unit_tests
+++ b/chrome/SConscript.unit_tests
@@ -138,6 +138,8 @@ if env_test['PLATFORM'] in ('posix', 'win32'):
'browser/printing/units_unittest.cc',
'browser/safe_browsing/bloom_filter_unittest.cc',
'browser/safe_browsing/chunk_range_unittest.cc',
+ 'browser/safe_browsing/safe_browsing_database_unittest.cc',
+ 'browser/safe_browsing/safe_browsing_database_impl_unittest.cc',
'browser/safe_browsing/protocol_parser_unittest.cc',
'browser/safe_browsing/safe_browsing_util_unittest.cc',
'common/animation_unittest.cc',
@@ -200,8 +202,6 @@ if env_test['PLATFORM'] == 'win32':
'browser/download_request_manager_unittest.cc',
'browser/rlz/rlz_unittest.cc',
'browser/safe_browsing/protocol_manager_unittest.cc',
- 'browser/safe_browsing/safe_browsing_database_unittest.cc',
- 'browser/safe_browsing/safe_browsing_database_impl_unittest.cc',
'browser/session_backend_unittest.cc',
'browser/session_service_test_helper.cc',
'browser/session_service_unittest.cc',
diff --git a/chrome/browser/SConscript b/chrome/browser/SConscript
index 0511345..243fffd8 100644
--- a/chrome/browser/SConscript
+++ b/chrome/browser/SConscript
@@ -60,6 +60,10 @@ input_files = []
if env['PLATFORM'] in ('posix', 'win32'):
# TODO: Port to Mac.
input_files.extend([
+ 'automation/url_request_failed_dns_job.cc',
+ 'automation/url_request_mock_http_job.cc',
+ 'automation/url_request_mock_net_error_job.cc',
+ 'automation/url_request_slow_download_job.cc',
'browser_process.cc',
'cancelable_request.cc',
'chrome_thread.cc',
@@ -92,6 +96,8 @@ if env['PLATFORM'] in ('posix', 'win32'):
'safe_browsing/chunk_range.cc',
'safe_browsing/protocol_parser.cc',
'safe_browsing/safe_browsing_database.cc',
+ 'safe_browsing/safe_browsing_database_bloom.cc',
+ 'safe_browsing/safe_browsing_database_impl.cc',
'safe_browsing/safe_browsing_service.cc',
'safe_browsing/safe_browsing_util.cc',
'session_startup_pref.cc',
@@ -117,10 +123,6 @@ if env['PLATFORM'] == 'win32':
'automation/automation_provider_list.cc',
'automation/automation_resource_tracker.cc',
'automation/ui_controls.cc',
- 'automation/url_request_failed_dns_job.cc',
- 'automation/url_request_mock_http_job.cc',
- 'automation/url_request_mock_net_error_job.cc',
- 'automation/url_request_slow_download_job.cc',
'back_forward_menu_model.cc',
'base_history_model.cc',
'bookmark_bar_context_menu_controller.cc',
@@ -249,9 +251,6 @@ if env['PLATFORM'] == 'win32':
'rlz/rlz.cc',
'safe_browsing/protocol_manager.cc',
'safe_browsing/safe_browsing_blocking_page.cc',
- 'safe_browsing/safe_browsing_database.cc',
- 'safe_browsing/safe_browsing_database_bloom.cc',
- 'safe_browsing/safe_browsing_database_impl.cc',
'safe_browsing/safe_browsing_service.cc',
'sandbox_policy.cc',
'session_backend.cc',
diff --git a/chrome/browser/automation/url_request_failed_dns_job.cc b/chrome/browser/automation/url_request_failed_dns_job.cc
index de8ff47..ce20816 100644
--- a/chrome/browser/automation/url_request_failed_dns_job.cc
+++ b/chrome/browser/automation/url_request_failed_dns_job.cc
@@ -10,8 +10,8 @@
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_filter.h"
-const wchar_t URLRequestFailedDnsJob::kTestUrl[] =
- L"http://url.handled.by.fake.dns/";
+const char URLRequestFailedDnsJob::kTestUrl[] =
+ "http://url.handled.by.fake.dns/";
void URLRequestFailedDnsJob::Start() {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
diff --git a/chrome/browser/automation/url_request_failed_dns_job.h b/chrome/browser/automation/url_request_failed_dns_job.h
index f63e2ab..52748fe 100644
--- a/chrome/browser/automation/url_request_failed_dns_job.h
+++ b/chrome/browser/automation/url_request_failed_dns_job.h
@@ -19,7 +19,7 @@ class URLRequestFailedDnsJob : public URLRequestJob {
const std::string& scheme);
// A test URL that can be used in UI tests.
- static const wchar_t kTestUrl[];
+ static const char kTestUrl[];
// For UI tests: adds the testing URLs to the URLRequestFilter.
static void AddUITestUrls();
diff --git a/chrome/browser/automation/url_request_mock_http_job.cc b/chrome/browser/automation/url_request_mock_http_job.cc
index d72b395..3a3c7d9 100644
--- a/chrome/browser/automation/url_request_mock_http_job.cc
+++ b/chrome/browser/automation/url_request_mock_http_job.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <windows.h>
-
#include "chrome/browser/automation/url_request_mock_http_job.h"
#include "base/file_util.h"
@@ -34,7 +32,7 @@ URLRequestJob* URLRequestMockHTTPJob::Factory(URLRequest* request,
// Convert the file:/// URL to a path on disk.
std::wstring file_path;
- net::FileURLToFilePath(GURL(file_url), &file_path);
+ net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
URLRequestMockHTTPJob* job = new URLRequestMockHTTPJob(request);
job->file_path_ = file_path;
return job;
@@ -52,10 +50,10 @@ void URLRequestMockHTTPJob::AddUITestUrls(const std::wstring& base_path) {
/* static */
GURL URLRequestMockHTTPJob::GetMockUrl(const std::wstring& path) {
- std::wstring url = L"http://";
- url.append(UTF8ToWide(kMockHostname));
- url.append(L"/");
- url.append(path);
+ std::string url = "http://";
+ url.append(kMockHostname);
+ url.append("/");
+ url.append(WideToUTF8(path));
return GURL(url);
}
diff --git a/chrome/browser/automation/url_request_mock_net_error_job.cc b/chrome/browser/automation/url_request_mock_net_error_job.cc
index cd633a8..1061942 100644
--- a/chrome/browser/automation/url_request_mock_net_error_job.cc
+++ b/chrome/browser/automation/url_request_mock_net_error_job.cc
@@ -58,7 +58,7 @@ URLRequestJob* URLRequestMockNetErrorJob::Factory(URLRequest* request,
file_url.append(UTF8ToWide(url.path()));
// Convert the file:/// URL to a path on disk.
std::wstring file_path;
- net::FileURLToFilePath(GURL(file_url), &file_path);
+ net::FileURLToFilePath(GURL(WideToUTF8(file_url)), &file_path);
job->file_path_ = file_path;
return job;
}
diff --git a/chrome/browser/automation/url_request_slow_download_job.cc b/chrome/browser/automation/url_request_slow_download_job.cc
index ec4d61f..e1a2c84f0 100644
--- a/chrome/browser/automation/url_request_slow_download_job.cc
+++ b/chrome/browser/automation/url_request_slow_download_job.cc
@@ -31,11 +31,11 @@ void URLRequestSlowDownloadJob::Start() {
/* static */
void URLRequestSlowDownloadJob::AddUITestUrls() {
URLRequestFilter* filter = URLRequestFilter::GetInstance();
- filter->AddUrlHandler(GURL(kUnknownSizeUrl),
+ filter->AddUrlHandler(GURL(WideToUTF8(kUnknownSizeUrl)),
&URLRequestSlowDownloadJob::Factory);
- filter->AddUrlHandler(GURL(kKnownSizeUrl),
+ filter->AddUrlHandler(GURL(WideToUTF8(kKnownSizeUrl)),
&URLRequestSlowDownloadJob::Factory);
- filter->AddUrlHandler(GURL(kFinishDownloadUrl),
+ filter->AddUrlHandler(GURL(WideToUTF8(kFinishDownloadUrl)),
&URLRequestSlowDownloadJob::Factory);
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
index 3da1d25..01d0b99 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc
@@ -4,9 +4,11 @@
#include "chrome/browser/safe_browsing/safe_browsing_database_bloom.h"
+#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/platform_thread.h"
#include "base/sha2.h"
#include "base/string_util.h"
#include "chrome/browser/safe_browsing/bloom_filter.h"
@@ -38,13 +40,11 @@ static const int kMaxStalenessMinutes = 45;
SafeBrowsingDatabaseBloom::SafeBrowsingDatabaseBloom()
: db_(NULL),
- init_(false),
transaction_count_(0),
+ init_(false),
chunk_inserted_callback_(NULL),
-#pragma warning(suppress: 4355) // can use this
- reset_factory_(this),
-#pragma warning(suppress: 4355) // can use this
- resume_factory_(this),
+ ALLOW_THIS_IN_INITIALIZER_LIST(reset_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(resume_factory_(this)),
did_resume_(false) {
}
@@ -1017,7 +1017,7 @@ void SafeBrowsingDatabaseBloom::ClearCachedHashesForChunk(int list_id,
++eit;
}
if (entries.empty())
- it = hash_cache_.erase(it);
+ hash_cache_.erase(it++);
else
++it;
}
@@ -1049,7 +1049,7 @@ void SafeBrowsingDatabaseBloom::OnResumeDone() {
void SafeBrowsingDatabaseBloom::WaitAfterResume() {
if (did_resume_) {
- Sleep(kOnResumeHoldupMs);
+ PlatformThread::Sleep(kOnResumeHoldupMs);
did_resume_ = false;
}
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_impl.cc b/chrome/browser/safe_browsing/safe_browsing_database_impl.cc
index 498ebb3..02c2d04 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_impl.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_impl.cc
@@ -4,9 +4,11 @@
#include "chrome/browser/safe_browsing/safe_browsing_database_impl.h"
+#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/platform_thread.h"
#include "base/sha2.h"
#include "base/string_util.h"
#include "chrome/browser/safe_browsing/bloom_filter.h"
@@ -56,20 +58,15 @@ static const int kMaxStalenessMinutes = 45;
SafeBrowsingDatabaseImpl::SafeBrowsingDatabaseImpl()
: db_(NULL),
- init_(false),
transaction_count_(0),
+ init_(false),
asynchronous_(true),
chunk_inserted_callback_(NULL),
-#pragma warning(suppress: 4355) // can use this
- bloom_read_factory_(this),
-#pragma warning(suppress: 4355) // can use this
- bloom_write_factory_(this),
-#pragma warning(suppress: 4355) // can use this
- process_factory_(this),
-#pragma warning(suppress: 4355) // can use this
- reset_factory_(this),
-#pragma warning(suppress: 4355) // can use this
- resume_factory_(this),
+ ALLOW_THIS_IN_INITIALIZER_LIST(process_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(bloom_read_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(bloom_write_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(reset_factory_(this)),
+ ALLOW_THIS_IN_INITIALIZER_LIST(resume_factory_(this)),
disk_delay_(kMaxThreadHoldupMs) {
}
@@ -473,7 +470,7 @@ void SafeBrowsingDatabaseImpl::RunThrottledWork() {
&SafeBrowsingDatabaseImpl::RunThrottledWork), disk_delay_);
break;
} else {
- Sleep(kMaxThreadHoldupMs);
+ PlatformThread::Sleep(kMaxThreadHoldupMs);
}
}
}
@@ -1014,7 +1011,7 @@ void SafeBrowsingDatabaseImpl::OnReadHostKeys(int start_id) {
if (asynchronous_) {
break;
} else {
- Sleep(kMaxThreadHoldupMs);
+ PlatformThread::Sleep(kMaxThreadHoldupMs);
}
}
}
@@ -1180,7 +1177,7 @@ void SafeBrowsingDatabaseImpl::ClearCachedHashesForChunk(int list_id,
++eit;
}
if (entries.empty())
- it = hash_cache_.erase(it);
+ hash_cache_.erase(it++);
else
++it;
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc
index 5e67054..3afcedc 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_impl_unittest.cc
@@ -89,7 +89,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
PathService::Get(base::DIR_TEMP, &filename);
filename.push_back(file_util::kPathSeparator);
filename.append(L"SafeBrowsingTestDatabase");
- DeleteFile(filename.c_str()); // In case it existed from a previous run.
+ file_util::Delete(filename, false); // In case it existed from a previous run.
SafeBrowsingDatabaseImpl database;
database.SetSynchronous();
@@ -98,7 +98,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
PopulateDatabaseForCacheTest(&database);
// We should have both full hashes in the cache.
- EXPECT_EQ(database.hash_cache_.size(), 2);
+ EXPECT_EQ(database.hash_cache_.size(), 2U);
// Test the cache lookup for the first prefix.
std::string list;
@@ -106,7 +106,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
std::vector<SBFullHashResult> full_hashes;
database.ContainsUrl(GURL("http://www.evil.com/phishing.html"),
&list, &prefixes, &full_hashes, Time::Now());
- EXPECT_EQ(full_hashes.size(), 1);
+ EXPECT_EQ(full_hashes.size(), 1U);
SBFullHashResult full_hash;
base::SHA256HashString("www.evil.com/phishing.html",
@@ -120,7 +120,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
// Test the cache lookup for the second prefix.
database.ContainsUrl(GURL("http://www.evil.com/malware.html"),
&list, &prefixes, &full_hashes, Time::Now());
- EXPECT_EQ(full_hashes.size(), 1);
+ EXPECT_EQ(full_hashes.size(), 1U);
base::SHA256HashString("www.evil.com/malware.html",
&full_hash.hash, sizeof(SBFullHash));
EXPECT_EQ(memcmp(&full_hashes[0].hash,
@@ -149,7 +149,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
// This prefix should still be there.
database.ContainsUrl(GURL("http://www.evil.com/malware.html"),
&list, &prefixes, &full_hashes, Time::Now());
- EXPECT_EQ(full_hashes.size(), 1);
+ EXPECT_EQ(full_hashes.size(), 1U);
base::SHA256HashString("www.evil.com/malware.html",
&full_hash.hash, sizeof(SBFullHash));
EXPECT_EQ(memcmp(&full_hashes[0].hash,
@@ -161,7 +161,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
// This prefix should be gone.
database.ContainsUrl(GURL("http://www.evil.com/phishing.html"),
&list, &prefixes, &full_hashes, Time::Now());
- EXPECT_EQ(full_hashes.size(), 0);
+ EXPECT_EQ(full_hashes.size(), 0U);
prefixes.clear();
full_hashes.clear();
@@ -170,8 +170,8 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
AddDelChunk(&database, "goog-malware-shavar", 1);
database.ContainsUrl(GURL("http://www.evil.com/malware.html"),
&list, &prefixes, &full_hashes, Time::Now());
- EXPECT_EQ(full_hashes.size(), 0);
- EXPECT_EQ(database.hash_cache_.size(), 0);
+ EXPECT_EQ(full_hashes.size(), 0U);
+ EXPECT_EQ(database.hash_cache_.size(), 0U);
prefixes.clear();
full_hashes.clear();
@@ -180,7 +180,7 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
// the cached entries' received time to make them older, since the database
// cache insert uses Time::Now(). First, store some entries.
PopulateDatabaseForCacheTest(&database);
- EXPECT_EQ(database.hash_cache_.size(), 2);
+ EXPECT_EQ(database.hash_cache_.size(), 2U);
// Now adjust one of the entries times to be in the past.
Time expired = Time::Now() - TimeDelta::FromMinutes(60);
@@ -194,15 +194,15 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
database.ContainsUrl(GURL("http://www.evil.com/malware.html"),
&list, &prefixes, &full_hashes, expired);
- EXPECT_EQ(full_hashes.size(), 0);
+ EXPECT_EQ(full_hashes.size(), 0U);
// Expired entry was dumped.
- EXPECT_EQ(database.hash_cache_.size(), 1);
+ EXPECT_EQ(database.hash_cache_.size(), 1U);
// This entry should still exist.
database.ContainsUrl(GURL("http://www.evil.com/phishing.html"),
&list, &prefixes, &full_hashes, expired);
- EXPECT_EQ(full_hashes.size(), 1);
+ EXPECT_EQ(full_hashes.size(), 1U);
// Testing prefix miss caching. First, we clear out the existing database,
@@ -217,11 +217,11 @@ TEST(SafeBrowsingDatabaseImpl, HashCaching) {
database.CacheHashResults(prefix_misses, empty_full_hash);
// Prefixes with no full results are misses.
- EXPECT_EQ(database.prefix_miss_cache_.size(), 2);
+ EXPECT_EQ(database.prefix_miss_cache_.size(), 2U);
// Update the database.
PopulateDatabaseForCacheTest(&database);
// Prefix miss cache should be cleared.
- EXPECT_EQ(database.prefix_miss_cache_.size(), 0);
+ EXPECT_EQ(database.prefix_miss_cache_.size(), 0U);
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
index 21de75a..803b0ef 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc
@@ -63,7 +63,8 @@ namespace {
SafeBrowsingDatabase* SetupTestDatabase() {
std::wstring filename = GetTestDatabaseName();
- DeleteFile(filename.c_str()); // In case it existed from a previous run.
+ // In case it existed from a previous run.
+ file_util::Delete(filename, false);
SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create();
database->SetSynchronous();
@@ -73,7 +74,7 @@ namespace {
}
void TearDownTestDatabase(SafeBrowsingDatabase* database) {
- DeleteFile(GetTestDatabaseName().c_str());
+ file_util::Delete(GetTestDatabaseName(), false);
delete database;
}
@@ -141,7 +142,7 @@ TEST(SafeBrowsingDatabase, Database) {
// Make sure they were added correctly.
std::vector<SBListChunkRanges> lists;
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].adds, "1-3");
EXPECT_TRUE(lists[0].subs.empty());
@@ -154,7 +155,7 @@ TEST(SafeBrowsingDatabase, Database) {
&matching_list, &prefix_hits,
&full_hashes, now));
EXPECT_EQ(prefix_hits[0], Sha256Prefix("www.evil.com/phishing.html"));
- EXPECT_EQ(prefix_hits.size(), 1);
+ EXPECT_EQ(prefix_hits.size(), 1U);
EXPECT_TRUE(database->ContainsUrl(GURL("http://www.evil.com/malware.html"),
&matching_list, &prefix_hits,
@@ -183,7 +184,7 @@ TEST(SafeBrowsingDatabase, Database) {
EXPECT_FALSE(database->ContainsUrl(GURL("http://www.evil.com/"),
&matching_list, &prefix_hits,
&full_hashes, now));
- EXPECT_EQ(prefix_hits.size(), 0);
+ EXPECT_EQ(prefix_hits.size(), 0U);
EXPECT_FALSE(database->ContainsUrl(GURL("http://www.evil.com/robots.txt"),
&matching_list, &prefix_hits,
@@ -211,12 +212,12 @@ TEST(SafeBrowsingDatabase, Database) {
&matching_list, &prefix_hits,
&full_hashes, now));
EXPECT_EQ(prefix_hits[0], Sha256Prefix("www.evil.com/phishing.html"));
- EXPECT_EQ(prefix_hits.size(), 1);
+ EXPECT_EQ(prefix_hits.size(), 1U);
EXPECT_FALSE(database->ContainsUrl(GURL("http://www.evil.com/notevil1.html"),
&matching_list, &prefix_hits,
&full_hashes, now));
- EXPECT_EQ(prefix_hits.size(), 0);
+ EXPECT_EQ(prefix_hits.size(), 0U);
EXPECT_TRUE(database->ContainsUrl(GURL("http://www.evil.com/notevil2.html"),
&matching_list, &prefix_hits,
@@ -231,7 +232,7 @@ TEST(SafeBrowsingDatabase, Database) {
&full_hashes, now));
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].subs, "4");
@@ -252,7 +253,7 @@ TEST(SafeBrowsingDatabase, Database) {
&full_hashes, now));
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].adds, "1,3");
EXPECT_EQ(lists[0].subs, "4");
@@ -283,7 +284,7 @@ TEST(SafeBrowsingDatabase, Database) {
database->UpdateFinished();
database->GetListsInfo(&lists);
- EXPECT_EQ(lists.size(), 1);
+ EXPECT_EQ(lists.size(), 1U);
EXPECT_EQ(lists[0].name, "goog-malware");
EXPECT_EQ(lists[0].adds, "1,3");
EXPECT_EQ(lists[0].subs, "");
@@ -461,15 +462,22 @@ TEST(SafeBrowsingDatabase, ZeroSizeChunk) {
}
void PrintStat(const wchar_t* name) {
+#if defined(OS_WIN)
int value = StatsTable::current()->GetCounterValue(name);
- std::wstring out = StringPrintf(L"%ls %d\r\n", name, value);
- OutputDebugStringW(out.c_str());
+ LOG(INFO) << StringPrintf(L"%ls %d", name, value);
+#else
+ // TODO(port): Enable when StatsTable is ported.
+ NOTIMPLEMENTED();
+#endif
}
std::wstring GetFullSBDataPath(const std::wstring& path) {
std::wstring full_path;
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &full_path));
- file_util::AppendToPath(&full_path, L"chrome\\test\\data\\safe_browsing");
+ file_util::AppendToPath(&full_path, L"chrome");
+ file_util::AppendToPath(&full_path, L"test");
+ file_util::AppendToPath(&full_path, L"data");
+ file_util::AppendToPath(&full_path, L"safe_browsing");
file_util::AppendToPath(&full_path, path);
CHECK(file_util::PathExists(full_path));
return full_path;
@@ -489,7 +497,8 @@ void PeformUpdate(const std::wstring& initial_db,
PathService::Get(base::DIR_TEMP, &filename);
filename.push_back(file_util::kPathSeparator);
filename.append(L"SafeBrowsingTestDatabase");
- DeleteFile(filename.c_str()); // In case it existed from a previous run.
+ // In case it existed from a previous run.
+ file_util::Delete(filename, false);
if (!initial_db.empty()) {
std::wstring full_initial_db = GetFullSBDataPath(initial_db);
@@ -515,16 +524,16 @@ void PeformUpdate(const std::wstring& initial_db,
CHECK(metric->GetIOCounters(&after));
- OutputDebugStringA(StringPrintf("I/O Read Bytes: %d\r\n",
- after.ReadTransferCount - before.ReadTransferCount).c_str());
- OutputDebugStringA(StringPrintf("I/O Write Bytes: %d\r\n",
- after.WriteTransferCount - before.WriteTransferCount).c_str());
- OutputDebugStringA(StringPrintf("I/O Reads: %d\r\n",
- after.ReadOperationCount - before.ReadOperationCount).c_str());
- OutputDebugStringA(StringPrintf("I/O Writes: %d\r\n",
- after.WriteOperationCount - before.WriteOperationCount).c_str());
- OutputDebugStringA(StringPrintf("Finished in %d ms\r\n",
- (Time::Now() - before_time).InMilliseconds()).c_str());
+ LOG(INFO) << StringPrintf("I/O Read Bytes: %d",
+ after.ReadTransferCount - before.ReadTransferCount);
+ LOG(INFO) << StringPrintf("I/O Write Bytes: %d",
+ after.WriteTransferCount - before.WriteTransferCount);
+ LOG(INFO) << StringPrintf("I/O Reads: %d",
+ after.ReadOperationCount - before.ReadOperationCount);
+ LOG(INFO) << StringPrintf("I/O Writes: %d",
+ after.WriteOperationCount - before.WriteOperationCount);
+ LOG(INFO) << StringPrintf("Finished in %d ms",
+ (Time::Now() - before_time).InMilliseconds());
PrintStat(L"c:SB.HostSelect");
PrintStat(L"c:SB.HostSelectForBloomFilter");
@@ -605,6 +614,28 @@ void UpdateDatabase(const std::wstring& initial_db,
PeformUpdate(initial_db, chunks, deletes);
}
+namespace {
+
+const wchar_t* GetOldSafeBrowsingPath() {
+ std::wstring path = L"old";
+ file_util::AppendToPath(&path, L"SafeBrowsing");
+ return path.c_str();
+}
+
+const wchar_t* GetOldResponsePath() {
+ std::wstring path = L"old";
+ file_util::AppendToPath(&path, L"response");
+ return path.c_str();
+}
+
+const wchar_t* GetOldUpdatesPath() {
+ std::wstring path = L"old";
+ file_util::AppendToPath(&path, L"updates");
+ return path.c_str();
+}
+
+} // namespace
+
// Counts the IO needed for the initial update of a database.
// test\data\safe_browsing\download_update.py was used to fetch the add/sub
// chunks that are read, in order to get repeatable runs.
@@ -612,23 +643,36 @@ TEST(SafeBrowsingDatabase, DISABLED_DatabaseInitialIO) {
UpdateDatabase(L"", L"", L"initial");
}
+// TODO(port): For now on Linux the test below would fail with error below:
+// [1004/201323:FATAL:browser/safe_browsing/safe_browsing_database_impl.cc(712)]
+// Check failed: false.
+//
// Counts the IO needed to update a month old database.
// The data files were generated by running "..\download_update.py postdata"
// in the "safe_browsing\old" directory.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldIO) {
- UpdateDatabase(L"old\\SafeBrowsing", L"old\\response", L"old\\updates");
+ UpdateDatabase(GetOldSafeBrowsingPath(), GetOldResponsePath(),
+ GetOldUpdatesPath());
}
+// TODO(port): For now on Linux the test below would fail with error below:
+// [1004/201323:FATAL:browser/safe_browsing/safe_browsing_database_impl.cc(712)]
+// Check failed: false.
+//
// Like DatabaseOldIO but only the deletes.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldDeletesIO) {
- UpdateDatabase(L"old\\SafeBrowsing", L"old\\response", L"");
+ UpdateDatabase(GetOldSafeBrowsingPath(), GetOldResponsePath(), L"");
}
// Like DatabaseOldIO but only the updates.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldUpdatesIO) {
- UpdateDatabase(L"old\\SafeBrowsing", L"", L"old\\updates");
+ UpdateDatabase(GetOldSafeBrowsingPath(), L"", GetOldUpdatesPath());
}
+// TODO(port): For now on Linux the test below would fail with error below:
+// [1004/201323:FATAL:browser/safe_browsing/safe_browsing_database_impl.cc(712)]
+// Check failed: false.
+//
// Does a a lot of addel's on very large chunks.
TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) {
std::vector<ChunksInfo> chunks;
@@ -638,5 +682,5 @@ TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) {
del.list_name = "goog-malware-shavar";
del.chunk_del.push_back(ChunkRange(3539, 3579));
deletes->push_back(del);
- PeformUpdate(L"old\\SafeBrowsing", chunks, deletes);
+ PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes);
}