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

Side by Side Diff: chrome/browser/history/android/android_cache_database.h

Issue 9549031: The implementation of AndroidCacheDatabase. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Sync and remove the Created 8 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
« no previous file with comments | « no previous file | chrome/browser/history/android/android_cache_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 CHROME_BROWSER_HISTORY_ANDROID_ANDROID_CACHE_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_CACHE_DATABASE_H_
7 #pragma once
8
9 #include "base/file_path.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/time.h"
12 #include "chrome/browser/history/android/android_history_types.h"
13 #include "sql/connection.h"
14 #include "sql/init_status.h"
15
16 namespace history {
17
18 // This database is used to support Android ContentProvider APIs.
19 // It will be created only when it used, and deleted by HistoryBackend when
20 // history system shutdown.
21 class AndroidCacheDatabase {
22 public:
23 AndroidCacheDatabase();
24 virtual ~AndroidCacheDatabase();
25
26 // Creates the database, deletes existing one if any; Also attach it to the
27 // database returned by GetDB(). Returns sql::INIT_OK on success, otherwise
28 // sql::INIT_FAILURE returned.
29 sql::InitStatus InitAndroidCacheDatabase(const FilePath& db_name);
30
31 // Adds a row to the bookmark_cache table. Returns true on success.
32 bool AddBookmarkCacheRow(const base::Time& created_time,
33 const base::Time& last_visit_time,
34 URLID url_id);
35
36 // Clears all rows in the bookmark_cache table; Returns true on success.
37 bool ClearAllBookmarkCache();
38
39 // Marks the given |url_ids| as bookmarked; Returns true on success.
40 bool MarkURLsAsBookmarked(const std::vector<URLID>& url_id);
41
42 // Set the given |url_id|'s favicon column to |favicon_id|. Returns true on
43 // success.
44 bool SetFaviconID(URLID url_id, FaviconID favicon_id);
45
46 protected:
47 // Returns the database for the functions in this interface. The decendent of
48 // this class implements these functions to return its objects.
49 virtual sql::Connection& GetDB() = 0;
50
51 private:
52 FRIEND_TEST_ALL_PREFIXES(AndroidCacheDatabaseTest,
53 CreateDatabase);
54
55 // Creates the database and make it ready for attaching; Returns true on
56 // success.
57 bool CreateDatabase(const FilePath& db_name);
58
59 // Creates the bookmark_cache table in attached DB; Returns true on success.
60 // The created_time, last_visit_time, favicon_id and bookmark are stored.
61 //
62 // The created_time and last_visit_time are cached because Android use the
63 // millisecond for the time unit, and we don't want to convert it in the
64 // runtime for it requires to parsing the SQL.
65 //
66 // The favicon_id is also cached because it is in thumbnail database. Its
67 // default value is set to null as the type of favicon column in Android APIs
68 // is blob. To use default value null, we can support client query by
69 // 'WHERE favicon IS NULL'.
70 //
71 // Bookmark column is used to indicate whether the url is bookmarked.
72 bool CreateBookmarkCacheTable();
73
74 // Attachs to history database; Returns true on success.
75 bool Attach();
76
77 // Does the real attach. Returns true on success.
78 bool DoAttach();
79
80 FilePath db_name_;
81
82 DISALLOW_COPY_AND_ASSIGN(AndroidCacheDatabase);
83 };
84
85 } // namespace history
86
87 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_CACHE_DATABASE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/android/android_cache_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698