|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "mozilla/dom/DataStore.h" |
|
6 #include "mozilla/dom/DataStoreCursor.h" |
|
7 #include "mozilla/dom/DataStoreBinding.h" |
|
8 #include "mozilla/dom/DataStoreImplBinding.h" |
|
9 #include "mozilla/dom/Promise.h" |
|
10 #include "mozilla/ErrorResult.h" |
|
11 #include "nsPIDOMWindow.h" |
|
12 |
|
13 namespace mozilla { |
|
14 namespace dom { |
|
15 |
|
16 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DataStoreCursor, AddRef) |
|
17 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DataStoreCursor, Release) |
|
18 |
|
19 NS_IMPL_CYCLE_COLLECTION(DataStoreCursor, mCursor) |
|
20 |
|
21 already_AddRefed<DataStoreCursor> |
|
22 DataStoreCursor::Constructor(GlobalObject& aGlobal, ErrorResult& aRv) |
|
23 { |
|
24 nsRefPtr<DataStoreCursor> cursor = new DataStoreCursor(); |
|
25 return cursor.forget(); |
|
26 } |
|
27 |
|
28 JSObject* |
|
29 DataStoreCursor::WrapObject(JSContext* aCx) |
|
30 { |
|
31 return DataStoreCursorBinding::Wrap(aCx, this); |
|
32 } |
|
33 |
|
34 already_AddRefed<DataStore> |
|
35 DataStoreCursor::GetStore(ErrorResult& aRv) |
|
36 { |
|
37 MOZ_ASSERT(NS_IsMainThread()); |
|
38 MOZ_ASSERT(mCursor); |
|
39 |
|
40 return mCursor->GetStore(aRv); |
|
41 } |
|
42 |
|
43 already_AddRefed<Promise> |
|
44 DataStoreCursor::Next(ErrorResult& aRv) |
|
45 { |
|
46 MOZ_ASSERT(NS_IsMainThread()); |
|
47 MOZ_ASSERT(mCursor); |
|
48 |
|
49 return mCursor->Next(aRv); |
|
50 } |
|
51 |
|
52 void |
|
53 DataStoreCursor::Close(ErrorResult& aRv) |
|
54 { |
|
55 MOZ_ASSERT(NS_IsMainThread()); |
|
56 MOZ_ASSERT(mCursor); |
|
57 |
|
58 mCursor->Close(aRv); |
|
59 } |
|
60 |
|
61 void |
|
62 DataStoreCursor::SetDataStoreCursorImpl(DataStoreCursorImpl& aCursor) |
|
63 { |
|
64 MOZ_ASSERT(NS_IsMainThread()); |
|
65 MOZ_ASSERT(!mCursor); |
|
66 |
|
67 mCursor = &aCursor; |
|
68 } |
|
69 |
|
70 } //namespace dom |
|
71 } //namespace mozilla |