| Index: chrome/browser/predictors/glowplug_key_value_table.cc
|
| diff --git a/chrome/browser/predictors/glowplug_key_value_table.cc b/chrome/browser/predictors/glowplug_key_value_table.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e2b4f9acac8614eb3586b87444e25b1f27ca6218
|
| --- /dev/null
|
| +++ b/chrome/browser/predictors/glowplug_key_value_table.cc
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/predictors/glowplug_key_value_table.h"
|
| +
|
| +#include "third_party/protobuf/src/google/protobuf/message_lite.h"
|
| +
|
| +namespace predictors {
|
| +
|
| +namespace internal {
|
| +
|
| +void BindDataToStatement(const std::string& key,
|
| + const google::protobuf::MessageLite& data,
|
| + sql::Statement* statement) {
|
| + int size = data.ByteSize();
|
| + DCHECK_GT(size, 0);
|
| + std::vector<char> proto_buffer(size);
|
| + data.SerializeToArray(&proto_buffer[0], size);
|
| +
|
| + statement->BindString(0, key);
|
| + statement->BindBlob(1, &proto_buffer[0], size);
|
| +}
|
| +
|
| +std::string GetSelectAllSql(const std::string& table_name) {
|
| + return base::StringPrintf("SELECT * FROM %s", table_name.c_str());
|
| +}
|
| +std::string GetInsertSql(const std::string& table_name) {
|
| + return base::StringPrintf("INSERT INTO %s (key, proto) VALUES (?,?)",
|
| + table_name.c_str());
|
| +}
|
| +std::string GetDeleteSql(const std::string& table_name) {
|
| + return base::StringPrintf("DELETE FROM %s WHERE key=?", table_name.c_str());
|
| +}
|
| +std::string GetDeleteAllSql(const std::string& table_name) {
|
| + return base::StringPrintf("DELETE FROM %s", table_name.c_str());
|
| +}
|
| +
|
| +} // namespace internal
|
| +} // namespace predictors
|
|
|