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

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: git rebase Created 4 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 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/metrics/histogram_macros.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "components/safe_browsing_db/v4_database.h" 13 #include "components/safe_browsing_db/v4_database.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 15
16 using content::BrowserThread; 16 using content::BrowserThread;
17 using base::TimeTicks; 17 using base::TimeTicks;
18 18
19 namespace safe_browsing { 19 namespace safe_browsing {
20 20
21 namespace {
22
23 const char kV4DatabaseSizeMetric[] = "SafeBrowsing.V4Database.Size";
24
25 } // namespace
26
21 // static 27 // static
22 V4StoreFactory* V4Database::factory_ = NULL; 28 V4StoreFactory* V4Database::factory_ = NULL;
23 29
24 // static 30 // static
25 void V4Database::Create( 31 void V4Database::Create(
26 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 32 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
27 const base::FilePath& base_path, 33 const base::FilePath& base_path,
28 const ListInfos& list_infos, 34 const ListInfos& list_infos,
29 NewDatabaseReadyCallback new_db_callback) { 35 NewDatabaseReadyCallback new_db_callback) {
30 DCHECK(base_path.IsAbsolute()); 36 DCHECK(base_path.IsAbsolute());
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 for (const auto& store_map_iter : *store_map_) { 219 for (const auto& store_map_iter : *store_map_) {
214 if (!store_map_iter.second->VerifyChecksum()) { 220 if (!store_map_iter.second->VerifyChecksum()) {
215 stores_to_reset.push_back(store_map_iter.first); 221 stores_to_reset.push_back(store_map_iter.first);
216 } 222 }
217 } 223 }
218 224
219 callback_task_runner->PostTask( 225 callback_task_runner->PostTask(
220 FROM_HERE, base::Bind(db_ready_for_updates_callback, stores_to_reset)); 226 FROM_HERE, base::Bind(db_ready_for_updates_callback, stores_to_reset));
221 } 227 }
222 228
229 void V4Database::RecordFileSizeHistograms() {
230 int64_t db_size = 0;
231 for (const auto& store_map_iter : *store_map_) {
232 const int64_t size =
233 store_map_iter.second->RecordAndReturnFileSize(kV4DatabaseSizeMetric);
234 db_size += size;
235 }
236 const int64_t db_size_kilobytes = static_cast<int64_t>(db_size / 1024);
237 UMA_HISTOGRAM_COUNTS(kV4DatabaseSizeMetric, db_size_kilobytes);
238 }
239
223 ListInfo::ListInfo(const bool fetch_updates, 240 ListInfo::ListInfo(const bool fetch_updates,
224 const std::string& filename, 241 const std::string& filename,
225 const ListIdentifier& list_id, 242 const ListIdentifier& list_id,
226 const SBThreatType sb_threat_type) 243 const SBThreatType sb_threat_type)
227 : fetch_updates_(fetch_updates), 244 : fetch_updates_(fetch_updates),
228 filename_(filename), 245 filename_(filename),
229 list_id_(list_id), 246 list_id_(list_id),
230 sb_threat_type_(sb_threat_type) { 247 sb_threat_type_(sb_threat_type) {
231 DCHECK(!fetch_updates_ || !filename_.empty()); 248 DCHECK(!fetch_updates_ || !filename_.empty());
232 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_); 249 DCHECK_NE(SB_THREAT_TYPE_SAFE, sb_threat_type_);
233 } 250 }
234 251
235 ListInfo::~ListInfo() {} 252 ListInfo::~ListInfo() {}
236 253
237 } // namespace safe_browsing 254 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_database.h ('k') | components/safe_browsing_db/v4_local_database_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698