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

Side by Side Diff: chrome/browser/webdata/keyword_table.cc

Issue 12543034: Move creation of the various WebDatabaseTable types out of WebDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review. Created 7 years, 9 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
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 "chrome/browser/webdata/keyword_table.h" 5 #include "chrome/browser/webdata/keyword_table.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 s->BindString(starting_column + 10, data.suggestions_url); 109 s->BindString(starting_column + 10, data.suggestions_url);
110 s->BindInt(starting_column + 11, data.prepopulate_id); 110 s->BindInt(starting_column + 11, data.prepopulate_id);
111 s->BindBool(starting_column + 12, data.created_by_policy); 111 s->BindBool(starting_column + 12, data.created_by_policy);
112 s->BindString(starting_column + 13, data.instant_url); 112 s->BindString(starting_column + 13, data.instant_url);
113 s->BindInt64(starting_column + 14, data.last_modified.ToTimeT()); 113 s->BindInt64(starting_column + 14, data.last_modified.ToTimeT());
114 s->BindString(starting_column + 15, data.sync_guid); 114 s->BindString(starting_column + 15, data.sync_guid);
115 s->BindString(starting_column + 16, alternate_urls); 115 s->BindString(starting_column + 16, alternate_urls);
116 s->BindString(starting_column + 17, data.search_terms_replacement_key); 116 s->BindString(starting_column + 17, data.search_terms_replacement_key);
117 } 117 }
118 118
119 } // anonymous namespace 119 WebDatabaseTable::TypeKey GetKey() {
120 return reinterpret_cast<void*>(&KeywordTable::FromWebDatabase);
121 }
120 122
121 KeywordTable::KeywordTable(sql::Connection* db, sql::MetaTable* meta_table) 123 } // namespace
122 : WebDatabaseTable(db, meta_table) { 124
125 KeywordTable::KeywordTable() {
123 } 126 }
124 127
125 KeywordTable::~KeywordTable() {} 128 KeywordTable::~KeywordTable() {}
126 129
127 bool KeywordTable::Init() { 130 KeywordTable* KeywordTable::FromWebDatabase(WebDatabase* db) {
131 return static_cast<KeywordTable*>(db->GetTable(GetKey()));
132 }
133
134 WebDatabaseTable::TypeKey KeywordTable::GetTypeKey() const {
135 return GetKey();
136 }
137
138 bool KeywordTable::Init(sql::Connection* db, sql::MetaTable* meta_table) {
139 WebDatabaseTable::Init(db, meta_table);
128 return db_->DoesTableExist("keywords") || 140 return db_->DoesTableExist("keywords") ||
129 db_->Execute("CREATE TABLE keywords (" 141 db_->Execute("CREATE TABLE keywords ("
130 "id INTEGER PRIMARY KEY," 142 "id INTEGER PRIMARY KEY,"
131 "short_name VARCHAR NOT NULL," 143 "short_name VARCHAR NOT NULL,"
132 "keyword VARCHAR NOT NULL," 144 "keyword VARCHAR NOT NULL,"
133 "favicon_url VARCHAR NOT NULL," 145 "favicon_url VARCHAR NOT NULL,"
134 "url VARCHAR NOT NULL," 146 "url VARCHAR NOT NULL,"
135 "safe_for_autoreplace INTEGER," 147 "safe_for_autoreplace INTEGER,"
136 "originating_url VARCHAR," 148 "originating_url VARCHAR,"
137 "date_created INTEGER DEFAULT 0," 149 "date_created INTEGER DEFAULT 0,"
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 606 }
595 } 607 }
596 608
597 // Replace the old table with the new one. 609 // Replace the old table with the new one.
598 sql = "DROP TABLE " + name; 610 sql = "DROP TABLE " + name;
599 if (!db_->Execute(sql.c_str())) 611 if (!db_->Execute(sql.c_str()))
600 return false; 612 return false;
601 sql = "ALTER TABLE keywords_temp RENAME TO " + name; 613 sql = "ALTER TABLE keywords_temp RENAME TO " + name;
602 return db_->Execute(sql.c_str()); 614 return db_->Execute(sql.c_str());
603 } 615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698