OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_OBSERVER_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_OBSERVER_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_OBSERVER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <bitset> |
| 12 #include <set> |
| 13 |
11 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/stl_util.h" |
12 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
13 | 18 |
14 namespace content { | 19 namespace content { |
15 | 20 |
16 class CONTENT_EXPORT IndexedDBObserver { | 21 class CONTENT_EXPORT IndexedDBObserver { |
17 public: | 22 public: |
18 IndexedDBObserver(int32_t observer_id); | 23 struct Options { |
| 24 bool include_transaction; |
| 25 bool no_records; |
| 26 bool values; |
| 27 // Operation types and corresponding bits are add(0), put(1), delete(2), |
| 28 // clear(3). |
| 29 std::bitset<blink::WebIDBOperationTypeCount> operation_types; |
| 30 |
| 31 explicit Options(bool include_transaction, |
| 32 bool no_records, |
| 33 bool values, |
| 34 unsigned short types); |
| 35 Options(Options&); |
| 36 ~Options(); |
| 37 |
| 38 // TODO(palakj): Disallow copy? |
| 39 }; |
| 40 IndexedDBObserver(int32_t observer_id, |
| 41 std::set<int64_t> object_store_ids, |
| 42 Options); |
19 ~IndexedDBObserver(); | 43 ~IndexedDBObserver(); |
20 | 44 |
21 int32_t id() const { return observer_id_; } | 45 int32_t id() const { return id_; } |
| 46 const std::set<int64_t>& GetObjectStoreIds() const { |
| 47 return object_store_ids_; |
| 48 } |
| 49 bool IsRecordingType(blink::WebIDBOperationType type) const { |
| 50 DCHECK_NE(type, blink::WebIDBOperationTypeCount); |
| 51 return options_.operation_types[type]; |
| 52 } |
| 53 bool IsRecordingObjectStore(int64_t object_store_id) const { |
| 54 return ContainsValue(object_store_ids_, object_store_id); |
| 55 } |
| 56 bool include_transaction() const { return options_.include_transaction; } |
| 57 bool no_records() const { return options_.no_records; } |
| 58 bool values() const { return options_.values; } |
22 | 59 |
23 private: | 60 private: |
24 int32_t observer_id_; | 61 int32_t id_; |
| 62 std::set<int64_t> object_store_ids_; |
| 63 Options options_; |
25 | 64 |
26 DISALLOW_COPY_AND_ASSIGN(IndexedDBObserver); | 65 DISALLOW_COPY_AND_ASSIGN(IndexedDBObserver); |
27 }; | 66 }; |
28 | 67 |
29 } // namespace content | 68 } // namespace content |
30 | 69 |
31 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_OBSERVER_H_ | 70 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_OBSERVER_H_ |
OLD | NEW |