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

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: Fix Windows release builds (COMDAT folding combined static functions being used for keys. 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 int table_key = 0;
120 120
121 KeywordTable::KeywordTable(sql::Connection* db, sql::MetaTable* meta_table) 121 WebDatabaseTable::TypeKey GetKey() {
122 : WebDatabaseTable(db, meta_table) { 122 return reinterpret_cast<void*>(&table_key);
123 }
124
125 } // namespace
126
127 KeywordTable::KeywordTable() {
123 } 128 }
124 129
125 KeywordTable::~KeywordTable() {} 130 KeywordTable::~KeywordTable() {}
126 131
127 bool KeywordTable::Init() { 132 KeywordTable* KeywordTable::FromWebDatabase(WebDatabase* db) {
133 return static_cast<KeywordTable*>(db->GetTable(GetKey()));
134 }
135
136 WebDatabaseTable::TypeKey KeywordTable::GetTypeKey() const {
137 return GetKey();
138 }
139
140 bool KeywordTable::Init(sql::Connection* db, sql::MetaTable* meta_table) {
141 WebDatabaseTable::Init(db, meta_table);
128 return db_->DoesTableExist("keywords") || 142 return db_->DoesTableExist("keywords") ||
129 db_->Execute("CREATE TABLE keywords (" 143 db_->Execute("CREATE TABLE keywords ("
130 "id INTEGER PRIMARY KEY," 144 "id INTEGER PRIMARY KEY,"
131 "short_name VARCHAR NOT NULL," 145 "short_name VARCHAR NOT NULL,"
132 "keyword VARCHAR NOT NULL," 146 "keyword VARCHAR NOT NULL,"
133 "favicon_url VARCHAR NOT NULL," 147 "favicon_url VARCHAR NOT NULL,"
134 "url VARCHAR NOT NULL," 148 "url VARCHAR NOT NULL,"
135 "safe_for_autoreplace INTEGER," 149 "safe_for_autoreplace INTEGER,"
136 "originating_url VARCHAR," 150 "originating_url VARCHAR,"
137 "date_created INTEGER DEFAULT 0," 151 "date_created INTEGER DEFAULT 0,"
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 608 }
595 } 609 }
596 610
597 // Replace the old table with the new one. 611 // Replace the old table with the new one.
598 sql = "DROP TABLE " + name; 612 sql = "DROP TABLE " + name;
599 if (!db_->Execute(sql.c_str())) 613 if (!db_->Execute(sql.c_str()))
600 return false; 614 return false;
601 sql = "ALTER TABLE keywords_temp RENAME TO " + name; 615 sql = "ALTER TABLE keywords_temp RENAME TO " + name;
602 return db_->Execute(sql.c_str()); 616 return db_->Execute(sql.c_str());
603 } 617 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/keyword_table.h ('k') | chrome/browser/webdata/keyword_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698