1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/datastore/DataStoreCursor.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "mozilla/dom/DataStore.h" 1.9 +#include "mozilla/dom/DataStoreCursor.h" 1.10 +#include "mozilla/dom/DataStoreBinding.h" 1.11 +#include "mozilla/dom/DataStoreImplBinding.h" 1.12 +#include "mozilla/dom/Promise.h" 1.13 +#include "mozilla/ErrorResult.h" 1.14 +#include "nsPIDOMWindow.h" 1.15 + 1.16 +namespace mozilla { 1.17 +namespace dom { 1.18 + 1.19 +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DataStoreCursor, AddRef) 1.20 +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DataStoreCursor, Release) 1.21 + 1.22 +NS_IMPL_CYCLE_COLLECTION(DataStoreCursor, mCursor) 1.23 + 1.24 +already_AddRefed<DataStoreCursor> 1.25 +DataStoreCursor::Constructor(GlobalObject& aGlobal, ErrorResult& aRv) 1.26 +{ 1.27 + nsRefPtr<DataStoreCursor> cursor = new DataStoreCursor(); 1.28 + return cursor.forget(); 1.29 +} 1.30 + 1.31 +JSObject* 1.32 +DataStoreCursor::WrapObject(JSContext* aCx) 1.33 +{ 1.34 + return DataStoreCursorBinding::Wrap(aCx, this); 1.35 +} 1.36 + 1.37 +already_AddRefed<DataStore> 1.38 +DataStoreCursor::GetStore(ErrorResult& aRv) 1.39 +{ 1.40 + MOZ_ASSERT(NS_IsMainThread()); 1.41 + MOZ_ASSERT(mCursor); 1.42 + 1.43 + return mCursor->GetStore(aRv); 1.44 +} 1.45 + 1.46 +already_AddRefed<Promise> 1.47 +DataStoreCursor::Next(ErrorResult& aRv) 1.48 +{ 1.49 + MOZ_ASSERT(NS_IsMainThread()); 1.50 + MOZ_ASSERT(mCursor); 1.51 + 1.52 + return mCursor->Next(aRv); 1.53 +} 1.54 + 1.55 +void 1.56 +DataStoreCursor::Close(ErrorResult& aRv) 1.57 +{ 1.58 + MOZ_ASSERT(NS_IsMainThread()); 1.59 + MOZ_ASSERT(mCursor); 1.60 + 1.61 + mCursor->Close(aRv); 1.62 +} 1.63 + 1.64 +void 1.65 +DataStoreCursor::SetDataStoreCursorImpl(DataStoreCursorImpl& aCursor) 1.66 +{ 1.67 + MOZ_ASSERT(NS_IsMainThread()); 1.68 + MOZ_ASSERT(!mCursor); 1.69 + 1.70 + mCursor = &aCursor; 1.71 +} 1.72 + 1.73 +} //namespace dom 1.74 +} //namespace mozilla 1.75 \ No newline at end of file