Shaka Player Embedded
request.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_REQUEST_H_
16 #define SHAKA_EMBEDDED_JS_IDB_REQUEST_H_
17 
18 #include "shaka/optional.h"
19 #include "shaka/variant.h"
20 #include "src/core/member.h"
21 #include "src/core/ref_ptr.h"
23 #include "src/js/idb/sqlite.h"
24 #include "src/js/js_error.h"
25 #include "src/mapping/any.h"
28 
29 namespace shaka {
30 namespace js {
31 
32 namespace dom {
33 class DOMException;
34 } // namespace dom
35 
36 namespace idb {
37 
38 class IDBCursor;
39 class IDBObjectStore;
40 class IDBTransaction;
41 
43  PENDING,
44  DONE,
45 };
46 
49 
50  public:
51  IDBRequest(
53  RefPtr<IDBTransaction> transaction);
54 
55  void Trace(memory::HeapTracer* tracer) const override;
56 
61  virtual void PerformOperation(SqliteTransaction* transaction) = 0;
62 
67  void OnAbort();
68 
69  ExceptionOr<Any> Result() const;
70  ExceptionOr<Any> Error() const;
71 
74  IDBRequestReadyState ready_state = IDBRequestReadyState::PENDING;
75 
76  Listener on_success;
77  Listener on_error;
78 
79  protected:
84  void CompleteSuccess(Any result);
85 
90  void CompleteError(JsError error);
91  void CompleteError(DatabaseStatus status);
92 
95 };
96 
98  : public BackingObjectFactory<IDBRequest, events::EventTarget> {
99  public:
101 };
102 
103 } // namespace idb
104 } // namespace js
105 } // namespace shaka
106 
108  AddMapping(Enum::PENDING, "pending");
109  AddMapping(Enum::DONE, "done");
110 }
111 
112 #endif // SHAKA_EMBEDDED_JS_IDB_REQUEST_H_
DEFINE_ENUM_MAPPING(shaka::js::idb, IDBRequestReadyState)
Definition: request.h:107
Definition: any.h:31
optional< variant< Member< IDBObjectStore >, Member< IDBCursor > > > source
Definition: request.h:72
const char * source
Definition: media_utils.cc:30
IDBRequestReadyState
Definition: request.h:42
Member< IDBTransaction > transaction
Definition: request.h:73
#define DECLARE_TYPE_INFO(type)