Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: chrome/browser/extensions/activity_log/activity_database_unittest.cc

Issue 21646004: Compressed activity log database storage (Closed) Base URL: http://git.chromium.org/chromium/src.git@refactor-cleanups
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698