| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void Record(ActivityDatabase* db, scoped_refptr<Action> action) { | 144 void Record(ActivityDatabase* db, scoped_refptr<Action> action) { |
| 145 db_delegate_->Record(db, action); | 145 db_delegate_->Record(db, action); |
| 146 } | 146 } |
| 147 | 147 |
| 148 int CountActions(sql::Connection* db, const std::string& api_name_pattern) { | 148 int CountActions(sql::Connection* db, const std::string& api_name_pattern) { |
| 149 if (!db->DoesTableExist(ActivityDatabaseTestPolicy::kTableName)) | 149 if (!db->DoesTableExist(ActivityDatabaseTestPolicy::kTableName)) |
| 150 return -1; | 150 return -1; |
| 151 std::string sql_str = "SELECT COUNT(*) FROM " + | 151 std::string sql_str = "SELECT COUNT(*) FROM " + |
| 152 std::string(ActivityDatabaseTestPolicy::kTableName) + | 152 std::string(ActivityDatabaseTestPolicy::kTableName) + |
| 153 " WHERE api_name LIKE ?"; | 153 " WHERE api_name LIKE ?"; |
| 154 sql::Statement statement(db->GetUniqueStatement(sql_str.c_str())); | 154 sql::Statement statement(db->GetCachedStatement( |
| 155 sql::StatementID(SQL_FROM_HERE), sql_str.c_str())); |
| 155 statement.BindString(0, api_name_pattern); | 156 statement.BindString(0, api_name_pattern); |
| 156 if (!statement.Step()) | 157 if (!statement.Step()) |
| 157 return -1; | 158 return -1; |
| 158 return statement.ColumnInt(0); | 159 return statement.ColumnInt(0); |
| 159 } | 160 } |
| 160 | 161 |
| 161 private: | 162 private: |
| 162 #if defined OS_CHROMEOS | 163 #if defined OS_CHROMEOS |
| 163 chromeos::ScopedStubNetworkLibraryEnabler stub_network_library_enabler_; | 164 chromeos::ScopedStubNetworkLibraryEnabler stub_network_library_enabler_; |
| 164 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 165 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ActivityDatabaseTestPolicy* delegate = new ActivityDatabaseTestPolicy(); | 258 ActivityDatabaseTestPolicy* delegate = new ActivityDatabaseTestPolicy(); |
| 258 ActivityDatabase* activity_db = new ActivityDatabase(delegate); | 259 ActivityDatabase* activity_db = new ActivityDatabase(delegate); |
| 259 scoped_refptr<Action> action = new Action( | 260 scoped_refptr<Action> action = new Action( |
| 260 "punky", base::Time::Now(), Action::ACTION_API_CALL, "brewster"); | 261 "punky", base::Time::Now(), Action::ACTION_API_CALL, "brewster"); |
| 261 action->mutable_args()->AppendString("woof"); | 262 action->mutable_args()->AppendString("woof"); |
| 262 delegate->Record(activity_db, action); | 263 delegate->Record(activity_db, action); |
| 263 activity_db->Close(); | 264 activity_db->Close(); |
| 264 } | 265 } |
| 265 | 266 |
| 266 } // namespace extensions | 267 } // namespace extensions |
| OLD | NEW |