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

Side by Side Diff: components/safe_browsing_db/v4_database.cc

Issue 2447443002: Log the size of each of the stores and complete DB on launch and after each (Closed)
Patch Set: Add to histograms.xml Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/leak_annotations.h" 8 #include "base/debug/leak_annotations.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "components/safe_browsing_db/v4_database.h" 13 #include "components/safe_browsing_db/v4_database.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 15
15 using content::BrowserThread; 16 using content::BrowserThread;
16 17
17 namespace safe_browsing { 18 namespace safe_browsing {
18 19
20 namespace {
21
22 const char kV4DatabaseSizeMetric[] = "SafeBrowsing.V4Database.Size";
23
24 } // namespace
25
19 // static 26 // static
20 V4StoreFactory* V4Database::factory_ = NULL; 27 V4StoreFactory* V4Database::factory_ = NULL;
21 28
22 // static 29 // static
23 void V4Database::Create( 30 void V4Database::Create(
24 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 31 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
25 const base::FilePath& base_path, 32 const base::FilePath& base_path,
26 const ListInfos& list_infos, 33 const ListInfos& list_infos,
27 NewDatabaseReadyCallback new_db_callback) { 34 NewDatabaseReadyCallback new_db_callback) {
28 DCHECK(base_path.IsAbsolute()); 35 DCHECK(base_path.IsAbsolute());
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 for (const auto& store_map_iter : *store_map_) { 214 for (const auto& store_map_iter : *store_map_) {
208 if (!store_map_iter.second->VerifyChecksum()) { 215 if (!store_map_iter.second->VerifyChecksum()) {
209 stores_to_reset.push_back(store_map_iter.first); 216 stores_to_reset.push_back(store_map_iter.first);
210 } 217 }
211 } 218 }
212 219
213 callback_task_runner->PostTask( 220 callback_task_runner->PostTask(
214 FROM_HERE, base::Bind(db_ready_for_updates_callback, stores_to_reset)); 221 FROM_HERE, base::Bind(db_ready_for_updates_callback, stores_to_reset));
215 } 222 }
216 223
224 void V4Database::RecordFileSizeHistograms() {
225 int db_size = 0;
Scott Hess - ex-Googler 2016/10/21 23:36:45 These ints should all be int64_t to match FileSize
vakh (use Gerrit instead) 2016/10/24 19:39:32 Done.
226 for (const auto& store_map_iter : *store_map_) {
227 const int size =
228 store_map_iter.second->RecordAndReturnFileSize(kV4DatabaseSizeMetric);
229 db_size += size;
230 }
231 const int db_size_kilobytes = static_cast<int>(db_size / 1024);
232 UMA_HISTOGRAM_COUNTS(kV4DatabaseSizeMetric, db_size_kilobytes);
233 }
234
217 ListInfo::ListInfo(const bool fetch_updates, 235 ListInfo::ListInfo(const bool fetch_updates,
218 const std::string& filename, 236 const std::string& filename,
219 const ListIdentifier& list_id, 237 const ListIdentifier& list_id,
220 const SBThreatType sb_threat_type) 238 const SBThreatType sb_threat_type)
221 : fetch_updates_(fetch_updates), 239 : fetch_updates_(fetch_updates),
222 filename_(filename), 240 filename_(filename),
223 list_id_(list_id), 241 list_id_(list_id),
224 sb_threat_type_(sb_threat_type) { 242 sb_threat_type_(sb_threat_type) {
225 DCHECK(!fetch_updates_ || !filename_.empty()); 243 DCHECK(!fetch_updates_ || !filename_.empty());
226 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_); 244 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_);
227 } 245 }
228 246
229 ListInfo::~ListInfo() {} 247 ListInfo::~ListInfo() {}
230 248
231 } // namespace safe_browsing 249 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698