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

Side by Side Diff: components/history/core/android/sql_handler.h

Issue 849323002: Componentize HistoryDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android compilation Created 5 years, 11 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
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 COMPONENTS_HISTORY_CORE_ANDROID_SQL_HANDLER_H_
6 #define COMPONENTS_HISTORY_CORE_ANDROID_SQL_HANDLER_H_
7
8 #include "components/history/core/android/android_history_types.h"
9
10 namespace history {
11
12 // This is a wrapper of information needed for Insert/Update/Delete
13 // method in SQLHandler. Refer to SQLHandler's comment below for how
14 // it is used.
15 struct TableIDRow {
16 TableIDRow();
17 ~TableIDRow();
18
19 URLID url_id;
20 GURL url;
21 // Whether the URL was bookmarked.
22 bool bookmarked;
23 };
24
25 typedef std::vector<TableIDRow> TableIDRows;
26
27 // This base class is used by AndroidProviderBackend to manipulate the indvidual
28 // table or BookmarkModel in its Insert/Update/Delete method.
29 //
30 // The implementation needs to provides an array of columns. Once the columns
31 // are inserted or updated, the corresponding Insert() or Update() method will
32 // be invoked. The Delete() method is called to delete rows.
33 //
34 // The HistoryAndBookmarkRow given in Insert() or Update() provide the data for
35 // insert or update. No all the data in HistoryAndBookmarkRow maybe valid, using
36 // HistoryAndBookmarkRow::is_value_set_explicitly() method to see if the data
37 // need be inserted or updated.
38 class SQLHandler {
39 public:
40 // |columns| is the implementation's columns.
41 // |column_count| is the number of column in |columns|.
42 SQLHandler(const HistoryAndBookmarkRow::ColumnID columns[], int column_count);
43 virtual ~SQLHandler();
44
45 // Updates the rows whose URLID or URL is in the given |ids_set| with new
46 // value stored in |row|. Return true if the update succeeds.
47 virtual bool Update(const HistoryAndBookmarkRow& row,
48 const TableIDRows& ids_set) = 0;
49
50 // Inserts the given |row|, return true on success; The id of insertted row
51 // should be set in |row|, so other implemnetations could use it to complete
52 // the insert.
53 virtual bool Insert(HistoryAndBookmarkRow* row) = 0;
54
55 // Deletes the rows whose id is in |ids_set|, returns false if any deletion
56 // failed, otherwise return true even all/some of rows are not found.
57 virtual bool Delete(const TableIDRows& ids_set) = 0;
58
59 // Return true if |row| has a value explicitly set for at least one of the
60 // columns in |row| that are known to this class.
61 bool HasColumnIn(const HistoryAndBookmarkRow& row);
62
63 // Returns true if |id| is one of the columns known to this class.
64 bool HasColumn(HistoryAndBookmarkRow::ColumnID id);
65
66 private:
67 // The columns of this handler.
68 const std::set<HistoryAndBookmarkRow::ColumnID> columns_;
69
70 DISALLOW_COPY_AND_ASSIGN(SQLHandler);
71 };
72
73 } // namespace history.
74
75 #endif // COMPONENTS_HISTORY_CORE_ANDROID_SQL_HANDLER_H_
OLDNEW
« no previous file with comments | « components/history/core/android/favicon_sql_handler.cc ('k') | components/history/core/android/sql_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698