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

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

Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 years, 1 month 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 // 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/logging.h" 9 #include "base/logging.h"
9 #include "base/path_service.h" 10 #include "base/path_service.h"
10 #include "base/process_util.h" 11 #include "base/process_util.h"
11 #include "base/sha2.h" 12 #include "base/sha2.h"
12 #include "base/stats_counters.h" 13 #include "base/stats_counters.h"
13 #include "base/string_util.h" 14 #include "base/string_util.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "chrome/browser/safe_browsing/protocol_parser.h" 16 #include "chrome/browser/safe_browsing/protocol_parser.h"
16 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 17 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
17 #include "chrome/test/file_test_utils.h" 18 #include "chrome/test/file_test_utils.h"
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 } 1052 }
1052 1053
1053 struct ChunksInfo { 1054 struct ChunksInfo {
1054 std::deque<SBChunk>* chunks; 1055 std::deque<SBChunk>* chunks;
1055 std::string listname; 1056 std::string listname;
1056 }; 1057 };
1057 1058
1058 void PeformUpdate(const std::wstring& initial_db, 1059 void PeformUpdate(const std::wstring& initial_db,
1059 const std::vector<ChunksInfo>& chunks, 1060 const std::vector<ChunksInfo>& chunks,
1060 std::vector<SBChunkDelete>* deletes) { 1061 std::vector<SBChunkDelete>* deletes) {
1061 // TODO(pinkerton): I don't think posix has any concept of IO counters, but
1062 // we can uncomment this when we implement ProcessMetrics::GetIOCounters
1063 IoCounters before, after; 1062 IoCounters before, after;
1064 1063
1065 FilePath path; 1064 FilePath path;
1066 PathService::Get(base::DIR_TEMP, &path); 1065 PathService::Get(base::DIR_TEMP, &path);
1067 path = path.AppendASCII("SafeBrowsingTestDatabase"); 1066 path = path.AppendASCII("SafeBrowsingTestDatabase");
1068 1067
1069 // In case it existed from a previous run. 1068 // In case it existed from a previous run.
1070 file_util::Delete(path, false); 1069 file_util::Delete(path, false);
1071 1070
1072 if (!initial_db.empty()) { 1071 if (!initial_db.empty()) {
(...skipping 16 matching lines...) Expand all
1089 database->GetListsInfo(&lists); 1088 database->GetListsInfo(&lists);
1090 database->DeleteChunks(deletes); 1089 database->DeleteChunks(deletes);
1091 for (size_t i = 0; i < chunks.size(); ++i) 1090 for (size_t i = 0; i < chunks.size(); ++i)
1092 database->InsertChunks(chunks[i].listname, chunks[i].chunks); 1091 database->InsertChunks(chunks[i].listname, chunks[i].chunks);
1093 1092
1094 database->UpdateFinished(true); 1093 database->UpdateFinished(true);
1095 lists.clear(); 1094 lists.clear();
1096 1095
1097 CHECK(metric->GetIOCounters(&after)); 1096 CHECK(metric->GetIOCounters(&after));
1098 1097
1099 LOG(INFO) << StringPrintf("I/O Read Bytes: %d", 1098 LOG(INFO) << StringPrintf("I/O Read Bytes: %"PRIu64,
Mark Mentovai 2009/11/18 20:55:27 "I/O Read Bytes: %" PRIu64, (with the space)
1100 after.ReadTransferCount - before.ReadTransferCount); 1099 after.ReadTransferCount - before.ReadTransferCount);
1101 LOG(INFO) << StringPrintf("I/O Write Bytes: %d", 1100 LOG(INFO) << StringPrintf("I/O Write Bytes: %"PRIu64,
1102 after.WriteTransferCount - before.WriteTransferCount); 1101 after.WriteTransferCount - before.WriteTransferCount);
1103 LOG(INFO) << StringPrintf("I/O Reads: %d", 1102 LOG(INFO) << StringPrintf("I/O Reads: %"PRIu64,
1104 after.ReadOperationCount - before.ReadOperationCount); 1103 after.ReadOperationCount - before.ReadOperationCount);
1105 LOG(INFO) << StringPrintf("I/O Writes: %d", 1104 LOG(INFO) << StringPrintf("I/O Writes: %"PRIu64,
1106 after.WriteOperationCount - before.WriteOperationCount); 1105 after.WriteOperationCount - before.WriteOperationCount);
1107 LOG(INFO) << StringPrintf("Finished in %d ms", 1106 LOG(INFO) << StringPrintf("Finished in %"PRId64" ms",
1108 (Time::Now() - before_time).InMilliseconds()); 1107 (Time::Now() - before_time).InMilliseconds());
1109 1108
1110 PrintStat("c:SB.HostSelect"); 1109 PrintStat("c:SB.HostSelect");
1111 PrintStat("c:SB.HostSelectForBloomFilter"); 1110 PrintStat("c:SB.HostSelectForBloomFilter");
1112 PrintStat("c:SB.HostReplace"); 1111 PrintStat("c:SB.HostReplace");
1113 PrintStat("c:SB.HostInsert"); 1112 PrintStat("c:SB.HostInsert");
1114 PrintStat("c:SB.HostDelete"); 1113 PrintStat("c:SB.HostDelete");
1115 PrintStat("c:SB.ChunkSelect"); 1114 PrintStat("c:SB.ChunkSelect");
1116 PrintStat("c:SB.ChunkInsert"); 1115 PrintStat("c:SB.ChunkInsert");
1117 PrintStat("c:SB.ChunkDelete"); 1116 PrintStat("c:SB.ChunkDelete");
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) { 1248 TEST(SafeBrowsingDatabase, DISABLED_DatabaseOldLotsofDeletesIO) {
1250 std::vector<ChunksInfo> chunks; 1249 std::vector<ChunksInfo> chunks;
1251 std::vector<SBChunkDelete>* deletes = new std::vector<SBChunkDelete>; 1250 std::vector<SBChunkDelete>* deletes = new std::vector<SBChunkDelete>;
1252 SBChunkDelete del; 1251 SBChunkDelete del;
1253 del.is_sub_del = false; 1252 del.is_sub_del = false;
1254 del.list_name = safe_browsing_util::kMalwareList; 1253 del.list_name = safe_browsing_util::kMalwareList;
1255 del.chunk_del.push_back(ChunkRange(3539, 3579)); 1254 del.chunk_del.push_back(ChunkRange(3539, 3579));
1256 deletes->push_back(del); 1255 deletes->push_back(del);
1257 PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes); 1256 PeformUpdate(GetOldSafeBrowsingPath(), chunks, deletes);
1258 } 1257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698