| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 arraysize(kTableContentFields)); | 79 arraysize(kTableContentFields)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool ActivityDatabaseTestPolicy::FlushDatabase(sql::Connection* db) { | 82 bool ActivityDatabaseTestPolicy::FlushDatabase(sql::Connection* db) { |
| 83 std::string sql_str = | 83 std::string sql_str = |
| 84 "INSERT INTO " + std::string(kTableName) + | 84 "INSERT INTO " + std::string(kTableName) + |
| 85 " (extension_id, time, action_type, api_name) VALUES (?,?,?,?)"; | 85 " (extension_id, time, action_type, api_name) VALUES (?,?,?,?)"; |
| 86 | 86 |
| 87 std::vector<scoped_refptr<Action> >::size_type i; | 87 std::vector<scoped_refptr<Action> >::size_type i; |
| 88 for (i = 0; i < queue_.size(); i++) { | 88 for (i = 0; i < queue_.size(); i++) { |
| 89 const Action& action = *queue_[i].get(); | 89 const Action& action = *queue_[i]; |
| 90 sql::Statement statement(db->GetCachedStatement( | 90 sql::Statement statement(db->GetCachedStatement( |
| 91 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); | 91 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); |
| 92 statement.BindString(0, action.extension_id()); | 92 statement.BindString(0, action.extension_id()); |
| 93 statement.BindInt64(1, action.time().ToInternalValue()); | 93 statement.BindInt64(1, action.time().ToInternalValue()); |
| 94 statement.BindInt(2, static_cast<int>(action.action_type())); | 94 statement.BindInt(2, static_cast<int>(action.action_type())); |
| 95 statement.BindString(3, action.api_name()); | 95 statement.BindString(3, action.api_name()); |
| 96 if (!statement.Run()) { | 96 if (!statement.Run()) { |
| 97 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; | 97 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 ActivityDatabaseTestPolicy* delegate = new ActivityDatabaseTestPolicy(); | 281 ActivityDatabaseTestPolicy* delegate = new ActivityDatabaseTestPolicy(); |
| 282 ActivityDatabase* activity_db = new ActivityDatabase(delegate); | 282 ActivityDatabase* activity_db = new ActivityDatabase(delegate); |
| 283 scoped_refptr<Action> action = new Action( | 283 scoped_refptr<Action> action = new Action( |
| 284 "punky", base::Time::Now(), Action::ACTION_API_CALL, "brewster"); | 284 "punky", base::Time::Now(), Action::ACTION_API_CALL, "brewster"); |
| 285 action->mutable_args()->AppendString("woof"); | 285 action->mutable_args()->AppendString("woof"); |
| 286 delegate->Record(activity_db, action); | 286 delegate->Record(activity_db, action); |
| 287 activity_db->Close(); | 287 activity_db->Close(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace extensions | 290 } // namespace extensions |
| OLD | NEW |