OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/extensions/activity_log/api_actions.h" | 9 #include "chrome/browser/extensions/activity_log/api_actions.h" |
10 #include "chrome/browser/extensions/activity_log/api_name_constants.h" | 10 #include "chrome/browser/extensions/activity_log/api_name_constants.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 } | 180 } |
181 // Now initialize the table. | 181 // Now initialize the table. |
182 return InitializeTableInternal(db, | 182 return InitializeTableInternal(db, |
183 kTableName, | 183 kTableName, |
184 kTableContentFields, | 184 kTableContentFields, |
185 kTableFieldTypes, | 185 kTableFieldTypes, |
186 arraysize(kTableContentFields)); | 186 arraysize(kTableContentFields)); |
187 } | 187 } |
188 | 188 |
189 void APIAction::Record(sql::Connection* db) { | 189 bool APIAction::Record(sql::Connection* db) { |
190 std::string sql_str = "INSERT INTO " + std::string(kTableName) | 190 std::string sql_str = "INSERT INTO " + std::string(kTableName) |
191 + " (extension_id, time, api_type, api_call, args, extra) VALUES" | 191 + " (extension_id, time, api_type, api_call, args, extra) VALUES" |
192 " (?,?,?,?,?,?)"; | 192 " (?,?,?,?,?,?)"; |
193 sql::Statement statement(db->GetCachedStatement( | 193 sql::Statement statement(db->GetCachedStatement( |
194 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); | 194 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); |
195 statement.BindString(0, extension_id()); | 195 statement.BindString(0, extension_id()); |
196 statement.BindInt64(1, time().ToInternalValue()); | 196 statement.BindInt64(1, time().ToInternalValue()); |
197 statement.BindInt(2, static_cast<int>(type_)); | 197 statement.BindInt(2, static_cast<int>(type_)); |
198 statement.BindString(3, APINameMap::GetInstance()->ApiToShortname(api_call_)); | 198 statement.BindString(3, APINameMap::GetInstance()->ApiToShortname(api_call_)); |
199 statement.BindString(4, args_); | 199 statement.BindString(4, args_); |
200 statement.BindString(5, extra_); | 200 statement.BindString(5, extra_); |
201 if (!statement.Run()) | 201 if (!statement.Run()) { |
202 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; | 202 LOG(ERROR) << "Activity log database I/O failed: " << sql_str; |
| 203 statement.Clear(); |
| 204 return false; |
| 205 } |
| 206 return true; |
203 } | 207 } |
204 | 208 |
205 // static | 209 // static |
206 void APIAction::LookupTabId(const std::string& api_call, | 210 void APIAction::LookupTabId(const std::string& api_call, |
207 ListValue* args, | 211 ListValue* args, |
208 Profile* profile) { | 212 Profile* profile) { |
209 if (api_call == "tabs.get" || // api calls, ID as int | 213 if (api_call == "tabs.get" || // api calls, ID as int |
210 api_call == "tabs.connect" || | 214 api_call == "tabs.connect" || |
211 api_call == "tabs.sendMessage" || | 215 api_call == "tabs.sendMessage" || |
212 api_call == "tabs.duplicate" || | 216 api_call == "tabs.duplicate" || |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return "call"; | 259 return "call"; |
256 case EVENT_CALLBACK: | 260 case EVENT_CALLBACK: |
257 return "event_callback"; | 261 return "event_callback"; |
258 default: | 262 default: |
259 return "unknown_type"; | 263 return "unknown_type"; |
260 } | 264 } |
261 } | 265 } |
262 | 266 |
263 } // namespace extensions | 267 } // namespace extensions |
264 | 268 |
OLD | NEW |