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

Side by Side Diff: chrome/browser/webdata/keyword_table.cc

Issue 8430027: Added histogram on successful check. Safe verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/webdata/keyword_table.h" 5 #include "chrome/browser/webdata/keyword_table.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 // Signs search provider id and returns its signature. 74 // Signs search provider id and returns its signature.
75 std::string GetSearchProviderIDSignature(int64 id) { 75 std::string GetSearchProviderIDSignature(int64 id) {
76 return protector::SignSetting(base::Int64ToString(id)); 76 return protector::SignSetting(base::Int64ToString(id));
77 } 77 }
78 78
79 // Checks if signature for search provider id is correct and returns the 79 // Checks if signature for search provider id is correct and returns the
80 // result. 80 // result.
81 bool IsSearchProviderIDValid(int64 id, const std::string& signature) { 81 bool IsSearchProviderIDValid(int64 id, const std::string& signature) {
82 return signature == GetSearchProviderIDSignature(id); 82 return protector::IsSettingValid(base::Int64ToString(id), signature);
83 } 83 }
84 84
85 } // anonymous namespace 85 } // anonymous namespace
86 86
87 KeywordTable::~KeywordTable() {} 87 KeywordTable::~KeywordTable() {}
88 88
89 bool KeywordTable::Init() { 89 bool KeywordTable::Init() {
90 if (!db_->DoesTableExist("keywords")) { 90 if (!db_->DoesTableExist("keywords")) {
91 if (!db_->Execute("CREATE TABLE keywords (" 91 if (!db_->Execute("CREATE TABLE keywords ("
92 "id INTEGER PRIMARY KEY," 92 "id INTEGER PRIMARY KEY,"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 protector::kProtectorErrorBackupInvalid, 282 protector::kProtectorErrorBackupInvalid,
283 protector::kProtectorErrorCount); 283 protector::kProtectorErrorCount);
284 return true; 284 return true;
285 } else if (backup_value != GetDefaultSearchProviderID()) { 285 } else if (backup_value != GetDefaultSearchProviderID()) {
286 UMA_HISTOGRAM_ENUMERATION( 286 UMA_HISTOGRAM_ENUMERATION(
287 protector::kProtectorHistogramDefaultSearchProvider, 287 protector::kProtectorHistogramDefaultSearchProvider,
288 protector::kProtectorErrorValueChanged, 288 protector::kProtectorErrorValueChanged,
289 protector::kProtectorErrorCount); 289 protector::kProtectorErrorCount);
290 return true; 290 return true;
291 } 291 }
292 UMA_HISTOGRAM_ENUMERATION(
293 protector::kProtectorHistogramDefaultSearchProvider,
294 protector::kProtectorErrorNoError,
295 protector::kProtectorErrorCount);
292 return false; 296 return false;
293 } 297 }
294 298
295 bool KeywordTable::SetBuiltinKeywordVersion(int version) { 299 bool KeywordTable::SetBuiltinKeywordVersion(int version) {
296 return meta_table_->SetValue(kBuiltinKeywordVersion, version); 300 return meta_table_->SetValue(kBuiltinKeywordVersion, version);
297 } 301 }
298 302
299 int KeywordTable::GetBuiltinKeywordVersion() { 303 int KeywordTable::GetBuiltinKeywordVersion() {
300 int version = 0; 304 int version = 0;
301 if (!meta_table_->GetValue(kBuiltinKeywordVersion, &version)) 305 if (!meta_table_->GetValue(kBuiltinKeywordVersion, &version))
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return 394 return
391 meta_table_->SetValue(kDefaultSearchProviderBackupKey, id) && 395 meta_table_->SetValue(kDefaultSearchProviderBackupKey, id) &&
392 SetDefaultSearchProviderBackupIDSignature(id); 396 SetDefaultSearchProviderBackupIDSignature(id);
393 } 397 }
394 398
395 bool KeywordTable::SetDefaultSearchProviderBackupIDSignature(int64 id) { 399 bool KeywordTable::SetDefaultSearchProviderBackupIDSignature(int64 id) {
396 return meta_table_->SetValue( 400 return meta_table_->SetValue(
397 kDefaultSearchProviderBackupSignatureKey, 401 kDefaultSearchProviderBackupSignatureKey,
398 GetSearchProviderIDSignature(id)); 402 GetSearchProviderIDSignature(id));
399 } 403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698