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