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