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

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor_table.cc

Issue 10540003: Move guid generation from chrome/common/ to base/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: installer Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/predictors/autocomplete_action_predictor_table.h" 5 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h"
6 6
7 #include "base/guid.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
9 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/common/guid.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "sql/statement.h" 13 #include "sql/statement.h"
14 14
15 namespace { 15 namespace {
16 16
17 // TODO(shishir): Rename the table for consistency. 17 // TODO(shishir): Rename the table for consistency.
18 const char kAutocompletePredictorTableName[] = "network_action_predictor"; 18 const char kAutocompletePredictorTableName[] = "network_action_predictor";
19 19
20 // The maximum length allowed for strings in the database. 20 // The maximum length allowed for strings in the database.
21 const size_t kMaxDataLength = 2048; 21 const size_t kMaxDataLength = 2048;
22 22
23 void BindRowToStatement( 23 void BindRowToStatement(
24 const predictors::AutocompleteActionPredictorTable::Row& row, 24 const predictors::AutocompleteActionPredictorTable::Row& row,
25 sql::Statement* statement) { 25 sql::Statement* statement) {
26 DCHECK(guid::IsValidGUID(row.id)); 26 DCHECK(base::IsValidGUID(row.id));
27 statement->BindString(0, row.id); 27 statement->BindString(0, row.id);
28 statement->BindString16(1, row.user_text.substr(0, kMaxDataLength)); 28 statement->BindString16(1, row.user_text.substr(0, kMaxDataLength));
29 statement->BindString(2, row.url.spec().substr(0, kMaxDataLength)); 29 statement->BindString(2, row.url.spec().substr(0, kMaxDataLength));
30 statement->BindInt(3, row.number_of_hits); 30 statement->BindInt(3, row.number_of_hits);
31 statement->BindInt(4, row.number_of_misses); 31 statement->BindInt(4, row.number_of_misses);
32 } 32 }
33 33
34 bool StepAndInitializeRow( 34 bool StepAndInitializeRow(
35 sql::Statement* statement, 35 sql::Statement* statement,
36 predictors::AutocompleteActionPredictorTable::Row* row) { 36 predictors::AutocompleteActionPredictorTable::Row* row) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 sql::Statement count_statement(DB()->GetUniqueStatement( 251 sql::Statement count_statement(DB()->GetUniqueStatement(
252 base::StringPrintf("SELECT count(id) FROM %s", 252 base::StringPrintf("SELECT count(id) FROM %s",
253 kAutocompletePredictorTableName).c_str())); 253 kAutocompletePredictorTableName).c_str()));
254 if (!count_statement.is_valid() || !count_statement.Step()) 254 if (!count_statement.is_valid() || !count_statement.Step())
255 return; 255 return;
256 UMA_HISTOGRAM_COUNTS("AutocompleteActionPredictor.DatabaseRowCount", 256 UMA_HISTOGRAM_COUNTS("AutocompleteActionPredictor.DatabaseRowCount",
257 count_statement.ColumnInt(0)); 257 count_statement.ColumnInt(0));
258 } 258 }
259 259
260 } // namespace predictors 260 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698