OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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 CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/string16.h" | |
14 #include "content/browser/indexed_db/indexed_db.h" | |
15 #include "content/browser/indexed_db/indexed_db_database_error.h" | |
16 #include "content/common/indexed_db/indexed_db_key.h" | |
17 #include "content/common/indexed_db/indexed_db_key_path.h" | |
18 #include "content/common/indexed_db/indexed_db_key_range.h" | |
19 | |
20 namespace content { | |
21 | |
22 class IndexedDBCallbacksWrapper; | |
23 class IndexedDBDatabaseCallbacksWrapper; | |
24 struct IndexedDBDatabaseMetadata; | |
25 | |
26 // This is implemented by IndexedDBDatabaseImpl and optionally others (in order | |
27 // to proxy calls across process barriers). All calls to these classes should be | |
28 // non-blocking and trigger work on a background thread if necessary. | |
29 class IndexedDBDatabase : public base::RefCounted<IndexedDBDatabase> { | |
30 public: | |
31 virtual void CreateObjectStore(int64 transaction_id, | |
32 int64 object_store_id, | |
33 const string16& name, | |
34 const IndexedDBKeyPath& key_path, | |
35 bool auto_increment) = 0; | |
36 virtual void DeleteObjectStore(int64 transaction_id, | |
37 int64 object_store_id) = 0; | |
38 virtual void CreateTransaction( | |
39 int64 transaction_id, | |
40 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks, | |
41 const std::vector<int64>& object_store_ids, | |
42 uint16 mode) = 0; | |
43 virtual void Close( | |
44 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks) = 0; | |
45 | |
46 // Transaction-specific operations. | |
47 virtual void Commit(int64 transaction_id) = 0; | |
48 virtual void Abort(int64 transaction_id) = 0; | |
49 virtual void Abort(int64 transaction_id, | |
50 scoped_refptr<IndexedDBDatabaseError> error) = 0; | |
51 | |
52 virtual void CreateIndex(int64 transaction_id, | |
53 int64 object_store_id, | |
54 int64 index_id, | |
55 const string16& name, | |
56 const IndexedDBKeyPath& key_path, | |
57 bool unique, | |
58 bool multi_entry) = 0; | |
59 virtual void DeleteIndex(int64 transaction_id, | |
60 int64 object_store_id, | |
61 int64 index_id) = 0; | |
62 | |
63 enum TaskType { | |
64 NORMAL_TASK = 0, | |
65 PREEMPTIVE_TASK | |
66 }; | |
67 | |
68 enum PutMode { | |
69 ADD_OR_UPDATE, | |
70 ADD_ONLY, | |
71 CURSOR_UPDATE | |
72 }; | |
73 | |
74 static const int64 kMinimumIndexId = 30; | |
75 | |
76 typedef std::vector<IndexedDBKey> IndexKeys; | |
77 | |
78 virtual void Get(int64 transaction_id, | |
79 int64 object_store_id, | |
80 int64 index_id, | |
81 scoped_ptr<IndexedDBKeyRange> key_range, | |
82 bool key_only, | |
83 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) = 0; | |
84 // This will swap() with value. | |
85 virtual void Put(int64 transaction_id, | |
86 int64 object_store_id, | |
87 std::vector<char>* value, | |
88 scoped_ptr<IndexedDBKey> key, | |
89 PutMode mode, | |
90 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | |
91 const std::vector<int64>& index_ids, | |
92 const std::vector<IndexKeys>& index_keys) = 0; | |
93 virtual void SetIndexKeys(int64 transaction_id, | |
94 int64 object_store_id, | |
95 scoped_ptr<IndexedDBKey> primary_key, | |
96 const std::vector<int64>& index_ids, | |
97 const std::vector<IndexKeys>& index_keys) = 0; | |
98 virtual void SetIndexesReady(int64 transaction_id, | |
99 int64 object_store_id, | |
100 const std::vector<int64>& index_ids) = 0; | |
101 virtual void OpenCursor( | |
102 int64 transaction_id, | |
103 int64 object_store_id, | |
104 int64 index_id, | |
105 scoped_ptr<IndexedDBKeyRange> key_Range, | |
106 indexed_db::CursorDirection direction, | |
107 bool key_only, | |
108 TaskType task_type, | |
109 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) = 0; | |
110 virtual void Count(int64 transaction_id, | |
111 int64 object_store_id, | |
112 int64 index_id, | |
113 scoped_ptr<IndexedDBKeyRange> key_range, | |
114 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) = 0; | |
115 virtual void DeleteRange( | |
116 int64 transaction_id, | |
117 int64 object_store_id, | |
118 scoped_ptr<IndexedDBKeyRange> key_range, | |
119 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) = 0; | |
120 virtual void Clear(int64 transaction_id, | |
121 int64 object_store_id, | |
122 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) = 0; | |
123 | |
124 protected: | |
125 virtual ~IndexedDBDatabase() {} | |
126 friend class base::RefCounted<IndexedDBDatabase>; | |
127 }; | |
128 | |
129 } // namespace content | |
130 | |
131 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ | |
OLD | NEW |