Shaka Player Embedded
shaka
src
js
idb
cursor.h
Go to the documentation of this file.
1
// Copyright 2016 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef SHAKA_EMBEDDED_JS_IDB_CURSOR_H_
16
#define SHAKA_EMBEDDED_JS_IDB_CURSOR_H_
17
18
#include "
shaka/optional.h
"
19
#include "
src/core/member.h
"
20
#include "
src/js/idb/idb_utils.h
"
21
#include "
src/mapping/any.h
"
22
#include "
src/mapping/backing_object.h
"
23
#include "
src/mapping/backing_object_factory.h
"
24
#include "
src/mapping/enum.h
"
25
#include "
src/mapping/exception_or.h
"
26
27
namespace
shaka
{
28
namespace
js {
29
namespace
idb {
30
31
class
IDBObjectStore;
32
class
IDBRequest;
33
class
IDBIterateCursorRequest;
34
35
enum class
IDBCursorDirection
{
36
NEXT
,
37
NEXT_UNIQUE
,
38
PREV
,
39
PREV_UNIQUE
,
40
};
41
42
class
IDBCursor
:
public
BackingObject
{
43
DECLARE_TYPE_INFO
(
IDBCursor
);
44
45
public
:
46
IDBCursor
(
RefPtr<IDBObjectStore>
source
,
IDBCursorDirection
dir);
47
48
void
Trace(
memory::HeapTracer
* tracer)
const override
;
49
50
const
Member<IDBObjectStore>
source
;
51
Member<IDBIterateCursorRequest>
request
;
52
const
IDBCursorDirection
direction
;
53
// This is the key of the current record (aka position). We only iterate on
54
// object stores, so this is also the "effective key" and the primaryKey
55
// property.
56
optional<IdbKeyType>
key
;
57
Any
value
;
58
bool
got_value =
false
;
59
60
ExceptionOr<void>
Continue(
optional<Any>
key);
61
ExceptionOr<RefPtr<IDBRequest>
> Delete();
62
};
63
64
class
IDBCursorFactory
:
public
BackingObjectFactory
<IDBCursor> {
65
public
:
66
IDBCursorFactory
();
67
};
68
69
}
// namespace idb
70
}
// namespace js
71
}
// namespace shaka
72
73
DEFINE_ENUM_MAPPING
(
shaka::js::idb
,
IDBCursorDirection
) {
74
AddMapping(
Enum::NEXT
,
"next"
);
75
AddMapping(
Enum::NEXT_UNIQUE
,
"nextunique"
);
76
AddMapping(
Enum::PREV
,
"prev"
);
77
AddMapping(
Enum::PREV_UNIQUE
,
"prevunique"
);
78
}
79
80
#endif // SHAKA_EMBEDDED_JS_IDB_CURSOR_H_
shaka::ExceptionOr
Definition:
exception_or.h:36
shaka::js::idb::IDBCursor
Definition:
cursor.h:42
shaka::Any
Definition:
any.h:31
optional.h
shaka::js::idb::IDBCursor::direction
const IDBCursorDirection direction
Definition:
cursor.h:52
shaka::js::idb::IDBCursorDirection::PREV_UNIQUE
shaka::js::idb::IDBCursorDirection
IDBCursorDirection
Definition:
cursor.h:35
shaka::Member
Definition:
member.h:40
shaka::js::idb
Definition:
cursor.cc:26
shaka::optional< IdbKeyType >
source
const char * source
Definition:
media_utils.cc:30
shaka::BackingObjectFactory
Definition:
backing_object_factory.h:406
shaka::js::idb::IDBCursor::source
const Member< IDBObjectStore > source
Definition:
cursor.h:50
shaka
Definition:
async_results.h:25
shaka::js::idb::IDBCursor::key
optional< IdbKeyType > key
Definition:
cursor.h:56
exception_or.h
enum.h
shaka::js::idb::IDBCursorDirection::PREV
shaka::memory::HeapTracer
Definition:
heap_tracer.h:85
shaka::js::idb::IDBCursor::value
Any value
Definition:
cursor.h:57
backing_object.h
any.h
shaka::js::idb::IDBCursor::request
Member< IDBIterateCursorRequest > request
Definition:
cursor.h:51
backing_object_factory.h
shaka::ExceptionOr< void >
Definition:
exception_or.h:41
member.h
shaka::RefPtr
Definition:
ref_ptr.h:43
DEFINE_ENUM_MAPPING
DEFINE_ENUM_MAPPING(shaka::js::idb, IDBCursorDirection)
Definition:
cursor.h:73
shaka::BackingObject
Definition:
backing_object.h:56
idb_utils.h
shaka::js::idb::IDBCursorDirection::NEXT
shaka::js::idb::IDBCursorFactory
Definition:
cursor.h:64
DECLARE_TYPE_INFO
#define DECLARE_TYPE_INFO(type)
Definition:
backing_object.h:39
shaka::js::idb::IDBCursorDirection::NEXT_UNIQUE
Generated by
1.8.13