Shaka Player Embedded
version_change_event.h
Go to the documentation of this file.
1 // Copyright 2019 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_EVENTS_VERSION_CHANGE_EVENT_H_
16 #define SHAKA_EMBEDDED_JS_EVENTS_VERSION_CHANGE_EVENT_H_
17 
18 #include <memory>
19 #include <string>
20 
21 #include "shaka/optional.h"
22 #include "src/js/events/event.h"
24 #include "src/mapping/struct.h"
25 
26 namespace shaka {
27 namespace js {
28 namespace events {
29 
32 
33  ADD_DICT_FIELD(oldVersion, uint64_t);
35 };
36 
40 class IDBVersionChangeEvent final : public Event {
42 
43  public:
44  IDBVersionChangeEvent(EventType event_type, uint64_t old_version,
45  optional<uint64_t> new_version);
46 
48  const std::string& event_type,
50  if (init_data.has_value()) {
51  return new IDBVersionChangeEvent(event_type, init_data->oldVersion,
52  init_data->newVersion.value());
53  } else {
54  return new IDBVersionChangeEvent(event_type, 0, nullopt);
55  }
56  }
57 
58  const uint64_t old_version;
60 
61  private:
62  IDBVersionChangeEvent(const std::string& event_type, uint64_t old_version,
63  optional<uint64_t> new_version);
64 };
65 
67  : public BackingObjectFactory<IDBVersionChangeEvent, Event> {
68  public:
70 };
71 
72 } // namespace events
73 } // namespace js
74 } // namespace shaka
75 
76 #endif // SHAKA_EMBEDDED_JS_EVENTS_VERSION_CHANGE_EVENT_H_
static IDBVersionChangeEvent * Create(const std::string &event_type, optional< IDBVersionChangeEventInit > init_data)
const nullopt_t nullopt
Definition: optional.cc:22
const T & value() const &
Definition: optional.h:147
DECLARE_STRUCT_SPECIAL_METHODS_COPYABLE(IDBVersionChangeEventInit)
#define DECLARE_TYPE_INFO(type)
bool has_value() const
Definition: optional.h:143