Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Unified Diff: lib/html/frog/html_frog.dart

Issue 10540016: indexedDB work (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: lib/html/frog/html_frog.dart
diff --git a/lib/html/frog/html_frog.dart b/lib/html/frog/html_frog.dart
index 9af8edf4f18fb43f00e6334e6e9640d628d295ac..b1fede9e86fe84d05256fffbf034e7138cd16b88 100644
--- a/lib/html/frog/html_frog.dart
+++ b/lib/html/frog/html_frog.dart
@@ -7478,9 +7478,55 @@ class _IDBCursorWithValueImpl extends _IDBCursorImpl implements IDBCursorWithVal
final Dynamic value;
}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
class _IDBDatabaseImpl extends _EventTargetImpl implements IDBDatabase native "*IDBDatabase" {
+ _IDBTransactionImpl transaction(storeName_OR_storeNames, String mode) {
+ if (mode != 'readonly' && mode != 'readwrite') {
+ throw new IllegalArgumentException(mode);
+ }
+
+ // TODO(sra): Ensure storeName_OR_storeNames is a string, List<String> or
+ // DOMStringList, and copy to JavaScript array if necessary.
+
+ if (_transaction_fn != null) {
+ return _transaction_fn(this, storeName_OR_storeNames, mode);
+ }
+
+ // Try and create a transaction with a string mode. Browsers that expect a
+ // numeric mode tend to convert the string into a number. This fails
+ // silently, resulting in zero ('readonly').
+ var txn = _transaction(storeName_OR_storeNames, mode);
+ if (_hasNumericMode(txn)) {
+ _transaction_fn = _transaction_numeric_mode;
+ txn = _transaction_fn(this, storeName_OR_storeNames, mode);
+ } else {
+ _transaction_fn = _transaction_string_mode;
+ }
+ return txn;
+ }
+
+ static var _transaction_fn; // Assigned one of the following:
+
+ static _IDBTransactionImpl _transaction_string_mode(_IDBDatabaseImpl db, stores, mode) {
+ return db._transaction(stores, mode);
+ }
+
+ static _IDBTransactionImpl _transaction_numeric_mode(_IDBDatabaseImpl db, stores, mode) {
+ int intMode;
+ if (mode == 'readonly') intMode = IDBTransaction.READ_ONLY;
+ if (mode == 'readwrite') intMode = IDBTransaction.READ_WRITE;
+ return db._transaction(stores, intMode);
+ }
+
+ _IDBTransactionImpl _transaction(stores, mode) native 'transaction';
+
+ static bool _hasNumericMode(txn) native 'return typeof(txn.mode) === "number"';
+
+
_IDBDatabaseEventsImpl get on() =>
new _IDBDatabaseEventsImpl(this);
@@ -7503,8 +7549,6 @@ class _IDBDatabaseImpl extends _EventTargetImpl implements IDBDatabase native "*
void $dom_removeEventListener(String type, EventListener listener, [bool useCapture = null]) native "removeEventListener";
_IDBVersionChangeRequestImpl setVersion(String version) native;
-
- _IDBTransactionImpl transaction(storeName_OR_storeNames, mode) native;
}
class _IDBDatabaseEventsImpl extends _EventsImpl implements IDBDatabaseEvents {
@@ -16331,6 +16375,12 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
''';
+ _IDBFactoryImpl get indexedDB() => _get_indexedDB();
+
+ _IDBFactoryImpl _get_indexedDB() native
+ 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB';
+
+
_WindowEventsImpl get on() =>
new _WindowEventsImpl(this);
@@ -24587,7 +24637,7 @@ interface IDBDatabase extends EventTarget {
IDBVersionChangeRequest setVersion(String version);
/** @domName IDBDatabase.transaction */
- IDBTransaction transaction(storeName_OR_storeNames, mode);
+ IDBTransaction transaction(storeName_OR_storeNames, String mode);
}
interface IDBDatabaseEvents extends Events {
@@ -34908,6 +34958,8 @@ interface Window extends EventTarget {
void cancelAnimationFrame(int id);
+ IDBFactory get indexedDB();
+
/**
* @domName EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent
@@ -36535,6 +36587,28 @@ class _XMLHttpRequestUtils {
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// IDBOpenRequest is not in WebKit but is needed for FireFox. Dartium will not
+// implement this interface until it appears in the WebKit IDL.
+//
+// See:
+// http://www.w3.org/TR/IndexedDB/#request-api
+// http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#request-api
+
+interface IDBOpenDBRequest extends IDBRequest {
+
+ IDBOpenDBRequestEvents get on();
+}
+
+interface IDBOpenDBRequestEvents extends IDBRequestEvents {
+
+ EventListenerList get blocked();
+
+ EventListenerList get upgradeneeded();
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
typedef Object ComputeValue();
class _MeasurementRequest<T> {
@@ -36890,6 +36964,33 @@ class _IDBKeyRangeFactoryProvider {
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+// IDBOpenDBRequest. IDBFactory.open returns a plain IDBRequest on Chrome and
+// Dartium but an IDBOpenDBRequest on Firefox. Chrome/Dartium is expected to
+// change at some point as IDBOpenDBRequest is more standard. When it appears
+// in the WebKit IDL we can remove this hand-written file.
+//
+// See:
+// http://www.w3.org/TR/IndexedDB/#request-api
+// http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#request-api
+
+class _IDBOpenDBRequestImpl extends _IDBRequestImpl implements IDBOpenDBRequest
+ native "*IDBOpenDBRequest" {
+
+ _IDBOpenDBRequestEventsImpl get on() =>
+ new _IDBOpenDBRequestEventsImpl(this);
+}
+
+class _IDBOpenDBRequestEventsImpl extends _IDBRequestEventsImpl implements IDBOpenDBRequestEvents {
+ _IDBOpenDBRequestEventsImpl(_ptr) : super(_ptr);
+
+ EventListenerList get blocked() => _get('blocked');
+
+ EventListenerList get upgradeneeded() => _get('upgradeneeded');
+}
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
class _TypedArrayFactoryProvider {
factory Float32Array(int length) => _F32(length);

Powered by Google App Engine
This is Rietveld 408576698