OLD | NEW |
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 // Unit tests for the SafeBrowsing storage system. | 5 // Unit tests for the SafeBrowsing storage system. |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 FilePath full_initial_db = GetFullSBDataPath(initial_db); | 1071 FilePath full_initial_db = GetFullSBDataPath(initial_db); |
1072 ASSERT_TRUE(file_util::CopyFile(full_initial_db, path)); | 1072 ASSERT_TRUE(file_util::CopyFile(full_initial_db, path)); |
1073 } | 1073 } |
1074 | 1074 |
1075 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create(); | 1075 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create(); |
1076 database->Init(path, NULL); | 1076 database->Init(path, NULL); |
1077 | 1077 |
1078 Time before_time = Time::Now(); | 1078 Time before_time = Time::Now(); |
1079 base::ProcessHandle handle = base::Process::Current().handle(); | 1079 base::ProcessHandle handle = base::Process::Current().handle(); |
1080 scoped_ptr<base::ProcessMetrics> metric( | 1080 scoped_ptr<base::ProcessMetrics> metric( |
1081 #if !defined(OS_MACOSX) | |
1082 base::ProcessMetrics::CreateProcessMetrics(handle)); | 1081 base::ProcessMetrics::CreateProcessMetrics(handle)); |
1083 #else | |
1084 // Getting stats only for the current process is enough, so NULL is fine. | |
1085 base::ProcessMetrics::CreateProcessMetrics(handle, NULL)); | |
1086 #endif | |
1087 CHECK(metric->GetIOCounters(&before)); | 1082 CHECK(metric->GetIOCounters(&before)); |
1088 | 1083 |
1089 std::vector<SBListChunkRanges> lists; | 1084 std::vector<SBListChunkRanges> lists; |
1090 database->UpdateStarted(); | 1085 database->UpdateStarted(); |
1091 database->GetListsInfo(&lists); | 1086 database->GetListsInfo(&lists); |
1092 database->DeleteChunks(deletes); | 1087 database->DeleteChunks(deletes); |
1093 for (size_t i = 0; i < chunks.size(); ++i) | 1088 for (size_t i = 0; i < chunks.size(); ++i) |
1094 database->InsertChunks(chunks[i].listname, chunks[i].chunks); | 1089 database->InsertChunks(chunks[i].listname, chunks[i].chunks); |
1095 | 1090 |
1096 database->UpdateFinished(true); | 1091 database->UpdateFinished(true); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) { | 1246 TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) { |
1252 std::vector<ChunksInfo> chunks; | 1247 std::vector<ChunksInfo> chunks; |
1253 std::vector<SBChunkDelete>* deletes = new std::vector<SBChunkDelete>; | 1248 std::vector<SBChunkDelete>* deletes = new std::vector<SBChunkDelete>; |
1254 SBChunkDelete del; | 1249 SBChunkDelete del; |
1255 del.is_sub_del = false; | 1250 del.is_sub_del = false; |
1256 del.list_name = safe_browsing_util::kMalwareList; | 1251 del.list_name = safe_browsing_util::kMalwareList; |
1257 del.chunk_del.push_back(ChunkRange(3539, 3579)); | 1252 del.chunk_del.push_back(ChunkRange(3539, 3579)); |
1258 deletes->push_back(del); | 1253 deletes->push_back(del); |
1259 PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes); | 1254 PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes); |
1260 } | 1255 } |
OLD | NEW |