diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 21:10:14 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 21:10:14 +0000 |
commit | e5f908e13979f34afe955e8c6d40c18c4aa1ad42 (patch) | |
tree | cc1b4909a8d75e6adeb1a8e95819c0cd3da852c6 /chrome/browser/webdata/keyword_table.h | |
parent | 1a2145b860591d2e868ab98147ea4f162636d7eb (diff) | |
download | chromium_src-e5f908e13979f34afe955e8c6d40c18c4aa1ad42.zip chromium_src-e5f908e13979f34afe955e8c6d40c18c4aa1ad42.tar.gz chromium_src-e5f908e13979f34afe955e8c6d40c18c4aa1ad42.tar.bz2 |
Lots of cleanup of chrome/browser/webdata in preparation for real changes as part of TemplateURL refactoring.
* Exposes some key names so tests can refer to them as named constants
* More pervasive use of string constants to specify column lists
* Introduces a "Keywords" typedef to make changing that type easier later
* Shortened lots of code
* 0 -> kInvalidTemplateURLID
* Eliminated some test redundancy
etc.
Some of the renaming/moving of things isn't terribly compelling in this change but will make my future changes have smaller diffs.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9663039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126465 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata/keyword_table.h')
-rw-r--r-- | chrome/browser/webdata/keyword_table.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/chrome/browser/webdata/keyword_table.h b/chrome/browser/webdata/keyword_table.h index bfa6b3e..910e7b5 100644 --- a/chrome/browser/webdata/keyword_table.h +++ b/chrome/browser/webdata/keyword_table.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_WEBDATA_KEYWORD_TABLE_H_ #pragma once +#include <string> #include <vector> #include "base/compiler_specific.h" @@ -80,6 +81,20 @@ class Statement; // class KeywordTable : public WebDatabaseTable { public: + typedef std::vector<TemplateURL*> Keywords; + + // Constants exposed for the benefit of test code: + + static const char kDefaultSearchProviderKey[]; + // Meta table key to store backup value for the default search provider id. + static const char kDefaultSearchIDBackupKey[]; + // Meta table key to store backup value signature for the default search + // provider. The default search provider ID and the |keywords_backup| table + // are signed. + static const char kBackupSignatureKey[]; + // Comma-separated list of keyword table column names, in order. + static const char kKeywordColumns[]; + KeywordTable(sql::Connection* db, sql::MetaTable* meta_table) : WebDatabaseTable(db, meta_table) {} virtual ~KeywordTable(); @@ -97,7 +112,7 @@ class KeywordTable : public WebDatabaseTable { // Loads the keywords into the specified vector. It's up to the caller to // delete the returned objects. // Returns true on success. - bool GetKeywords(std::vector<TemplateURL*>* urls); + bool GetKeywords(Keywords* keywords); // Updates the database values for the specified url. // Returns true on success. @@ -111,9 +126,9 @@ class KeywordTable : public WebDatabaseTable { // returned TemplateURL is owned by the caller. TemplateURL* GetDefaultSearchProviderBackup(); - // Returns true if the default search provider has been changed out under - // us. This can happen if another process modifies our database or the - // file was corrupted. + // Returns true if the default search provider has been changed out from under + // us. This can happen if another process modifies our database or the file + // was corrupted. bool DidDefaultSearchProviderChange(); // Version of the built-in keywords. @@ -135,6 +150,10 @@ class KeywordTable : public WebDatabaseTable { FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContents); FRIEND_TEST_ALL_PREFIXES(KeywordTableTest, GetTableContentsOrdering); + // Returns a new TemplateURL from the data in |s|. The caller owns the + // returned pointer. + static TemplateURL* GetKeywordDataFromStatement(const sql::Statement& s); + // Returns contents of |keywords_backup| table and default search provider // id backup as a string through |data|. Return value is true on success, // false otherwise. @@ -152,9 +171,6 @@ class KeywordTable : public WebDatabaseTable { // if signature is valid, false otherwise. bool IsBackupSignatureValid(); - // Parses TemplateURL out of SQL statement result. - void GetURLFromStatement(const sql::Statement& s, TemplateURL* url); - // Gets a string representation for keyword with id specified. // Used to store its result in |meta| table or to compare with another // keyword. Returns true on success, false otherwise. @@ -166,13 +182,6 @@ class KeywordTable : public WebDatabaseTable { // true on success. The id is returned back via |id| parameter. bool UpdateDefaultSearchProviderIDBackup(TemplateURLID* id); - // Updates default search provider backup with TemplateURL data with - // specified id. Returns true on success. - // If id is 0, sets an empty string as a backup. - // Returns the result through |backup| parameter. - bool UpdateDefaultSearchProviderBackup(TemplateURLID id, - std::string* backup); - DISALLOW_COPY_AND_ASSIGN(KeywordTable); }; |