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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6 #include "base/logging.h"
7 #include "base/stringprintf.h"
8 #include "chrome/browser/extensions/api_actions.h"
9
10 namespace extensions {
11
12 // static
13 bool Action::InitializeTableInternal(sql::Connection* db,
14 const char* table_name,
15 const char* basic_fields,
16 const char* content_fields[],
17 const int num_content_fields) {
18 if (!db->DoesTableExist(table_name)) {
19 std::string table_creator = base::StringPrintf(
20 "CREATE TABLE %s (%s", table_name, basic_fields);
21 for (int i = 0; i < num_content_fields; i++) {
22 table_creator += base::StringPrintf(", %s LONGVARCHAR",
23 content_fields[i]);
24 }
25 table_creator += ")";
26 if (!db->Execute(table_creator.c_str()))
27 return false;
28 } else {
29 // In case we ever want to add new fields, this initializes them to be
30 // empty strings.
31 for (int i = 0; i < num_content_fields; i++) {
32 if (!db->DoesColumnExist(table_name, content_fields[i])) {
33 std::string table_updater = base::StringPrintf(
34 "ALTER TABLE %s ADD COLUMN %s LONGVARCHAR; ",
35 table_name,
36 content_fields[i]);
37 if (!db->Execute(table_updater.c_str()))
38 return false;
39 }
40 }
41 }
42 return true;
43 }
44
45 } // namespace extensions
46
OLDNEW
« 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