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

Unified Diff: chrome/browser/extensions/activity_actions.cc

Issue 12262025: Alter the ActivityLog db table schemas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/activity_actions.h ('k') | chrome/browser/extensions/activity_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/activity_actions.cc
diff --git a/chrome/browser/extensions/activity_actions.cc b/chrome/browser/extensions/activity_actions.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0d197fa0919e5c4fa1b4851aa6385fbb203e51e4
--- /dev/null
+++ b/chrome/browser/extensions/activity_actions.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+#include "base/logging.h"
+#include "base/stringprintf.h"
+#include "chrome/browser/extensions/api_actions.h"
+
+namespace extensions {
+
+// static
+bool Action::InitializeTableInternal(sql::Connection* db,
+ const char* table_name,
+ const char* basic_fields,
+ const char* content_fields[],
+ const int num_content_fields) {
+ if (!db->DoesTableExist(table_name)) {
+ std::string table_creator = base::StringPrintf(
+ "CREATE TABLE %s (%s", table_name, basic_fields);
+ for (int i = 0; i < num_content_fields; i++) {
+ table_creator += base::StringPrintf(", %s LONGVARCHAR",
+ content_fields[i]);
+ }
+ table_creator += ")";
+ if (!db->Execute(table_creator.c_str()))
+ return false;
+ } else {
+ // In case we ever want to add new fields, this initializes them to be
+ // empty strings.
+ for (int i = 0; i < num_content_fields; i++) {
+ if (!db->DoesColumnExist(table_name, content_fields[i])) {
+ std::string table_updater = base::StringPrintf(
+ "ALTER TABLE %s ADD COLUMN %s LONGVARCHAR; ",
+ table_name,
+ content_fields[i]);
+ if (!db->Execute(table_updater.c_str()))
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+} // namespace extensions
+
« no previous file with comments | « chrome/browser/extensions/activity_actions.h ('k') | chrome/browser/extensions/activity_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698