| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_HISTORY_CORE_ANDROID_ANDROID_URLS_DATABASE_H_ | |
| 6 #define COMPONENTS_HISTORY_CORE_ANDROID_ANDROID_URLS_DATABASE_H_ | |
| 7 | |
| 8 #include "components/history/core/android/android_history_types.h" | |
| 9 | |
| 10 namespace history { | |
| 11 | |
| 12 // The table is used to stores the raw url which was passed in from | |
| 13 // ContentProvider APIs' client. | |
| 14 // | |
| 15 // Android BookmarmkCoulmns API allows the url without protocol like | |
| 16 // "www.bookmarks.com", but Chrome requires the url to be unique, like | |
| 17 // "http://www.bookmarks.com/". To support client queries by the orignal URL, | |
| 18 // the raw URL and corresponding URLID is stored in this table. | |
| 19 // | |
| 20 // Though the raw URL is stored. The 'www.bookmark.com' and | |
| 21 // 'http://www.bookmark.com' are still treated as the same URL, which means | |
| 22 // if adding these two urls, the later one will fail. | |
| 23 class AndroidURLsDatabase { | |
| 24 public: | |
| 25 AndroidURLsDatabase(); | |
| 26 virtual ~AndroidURLsDatabase(); | |
| 27 | |
| 28 // Creates the android_urls table if it doesn't exist. Returns true if the | |
| 29 // table was created or already exists. | |
| 30 bool CreateAndroidURLsTable(); | |
| 31 | |
| 32 // Adds a new mapping between |raw_url| and |url_id|, returns the id if it | |
| 33 // succeeds, otherwise 0 is returned. | |
| 34 AndroidURLID AddAndroidURLRow(const std::string& raw_url, URLID url_id); | |
| 35 | |
| 36 // Looks up the given |url_id| in android_urls table. Returns true if success, | |
| 37 // and fill in the |row| if it not NULL, returns false if the |url_id| is not | |
| 38 // found. | |
| 39 bool GetAndroidURLRow(URLID url_id, AndroidURLRow* row); | |
| 40 | |
| 41 // Deletes the rows whose url_id is in |url_ids|. Returns true if all | |
| 42 // |url_ids| were found and deleted, otherwise false is returned. | |
| 43 bool DeleteAndroidURLRows(const std::vector<URLID>& url_ids); | |
| 44 | |
| 45 // Deletes all the rows whose url_id doesn't exist in urls table. Returns true | |
| 46 // on success. | |
| 47 bool DeleteUnusedAndroidURLs(); | |
| 48 | |
| 49 // Updates the row of |id| with the given |raw_url| and |url_id|. Returns true | |
| 50 // on success. | |
| 51 bool UpdateAndroidURLRow(AndroidURLID id, | |
| 52 const std::string&raw_url, | |
| 53 URLID url_id); | |
| 54 | |
| 55 // Clears all the rows in android_urls table, returns true on success, false | |
| 56 // on error. | |
| 57 bool ClearAndroidURLRows(); | |
| 58 | |
| 59 // Migrate from version 21 to 22. | |
| 60 bool MigrateToVersion22(); | |
| 61 | |
| 62 protected: | |
| 63 // Returns the database for the functions in this interface. The decendent of | |
| 64 // this class implements these functions to return its objects. | |
| 65 virtual sql::Connection& GetDB() = 0; | |
| 66 | |
| 67 private: | |
| 68 DISALLOW_COPY_AND_ASSIGN(AndroidURLsDatabase); | |
| 69 }; | |
| 70 | |
| 71 } // namespace history | |
| 72 | |
| 73 #endif // COMPONENTS_HISTORY_CORE_ANDROID_ANDROID_URLS_DATABASE_H_ | |
| OLD | NEW |