OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/omnibox/browser/history_test_util.h" | |
6 | |
7 #include "base/format_macros.h" | |
8 #include "base/strings/stringprintf.h" | |
9 #include "sql/connection.h" | |
10 #include "sql/statement.h" | |
11 #include "sql/transaction.h" | |
12 | |
13 namespace history { | |
14 | |
15 void AddURLToDBForTests(sql::Connection* db, | |
16 std::size_t url_id, | |
17 const std::string& url, | |
18 const std::string& title, | |
19 int visit_count, | |
20 int typed_count, | |
21 base::Time last_visit_time) { | |
22 sql::Transaction transaction(db); | |
23 transaction.Begin(); | |
24 | |
25 std::string sql_cmd_line = | |
26 base::StringPrintf("INSERT INTO \"urls\" VALUES(%" PRIuS | |
27 ", \'%s\', \'%s\', %d, %d, %" PRId64 ", 0, 0)", | |
28 url_id, url.c_str(), title.c_str(), visit_count, | |
29 typed_count, last_visit_time.ToInternalValue()); | |
Peter Kasting
2016/10/24 22:28:29
Don't use StringPrintf() to put the values directl
dyaroshev
2016/10/25 18:11:35
Haven't got around to it yet.
dyaroshev
2016/10/26 22:29:13
This was originally not my code, I just refactored
| |
30 | |
31 sql::Statement sql_stmt(db->GetUniqueStatement(sql_cmd_line.c_str())); | |
32 CHECK(sql_stmt.Run()); | |
33 transaction.Commit(); | |
34 } | |
35 | |
36 void AddVisitToDBForTests(sql::Connection* db, | |
37 std::size_t visit_id, | |
38 std::size_t url_id, | |
39 base::Time visit_time, | |
40 ui::PageTransition transition) { | |
41 sql::Transaction transaction(db); | |
42 transaction.Begin(); | |
43 | |
44 std::string sql_cmd_line = base::StringPrintf( | |
45 "INSERT INTO \"visits\" VALUES(%" PRIuS ", %" PRIuS ", %" PRId64 | |
46 ", 0, %d, 0, 1)", | |
47 visit_id, url_id, visit_time.ToInternalValue(), transition); | |
48 | |
49 sql::Statement sql_stmt(db->GetUniqueStatement(sql_cmd_line.c_str())); | |
50 CHECK(sql_stmt.Run()); | |
51 transaction.Commit(); | |
52 } | |
53 | |
54 } // namespace history | |
OLD | NEW |