• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "config.h"
29 
30 #if ENABLE(INDEXED_DATABASE)
31 
32 #include "V8IDBAny.h"
33 
34 #include "SerializedScriptValue.h"
35 #include "V8IDBCursor.h"
36 #include "V8IDBCursorWithValue.h"
37 #include "V8IDBDatabase.h"
38 #include "V8IDBFactory.h"
39 #include "V8IDBIndex.h"
40 #include "V8IDBKey.h"
41 #include "V8IDBObjectStore.h"
42 #include "V8IDBTransaction.h"
43 
44 namespace WebCore {
45 
toV8(IDBAny * impl)46 v8::Handle<v8::Value> toV8(IDBAny* impl)
47 {
48     if (!impl)
49         return v8::Null();
50 
51     switch (impl->type()) {
52     case IDBAny::UndefinedType:
53         return v8::Undefined();
54     case IDBAny::NullType:
55         return v8::Null();
56     case IDBAny::IDBCursorType:
57         return toV8(impl->idbCursor());
58     case IDBAny::IDBCursorWithValueType:
59         return toV8(impl->idbCursorWithValue());
60     case IDBAny::IDBDatabaseType:
61         return toV8(impl->idbDatabase());
62     case IDBAny::IDBFactoryType:
63         return toV8(impl->idbFactory());
64     case IDBAny::IDBIndexType:
65         return toV8(impl->idbIndex());
66     case IDBAny::IDBKeyType:
67         return toV8(impl->idbKey());
68     case IDBAny::IDBObjectStoreType:
69         return toV8(impl->idbObjectStore());
70     case IDBAny::IDBTransactionType:
71         return toV8(impl->idbTransaction());
72     case IDBAny::SerializedScriptValueType:
73         return impl->serializedScriptValue()->deserialize();
74     }
75 
76     ASSERT_NOT_REACHED();
77     return v8::Undefined();
78 }
79 
80 } // namespace WebCore
81 
82 #endif // ENABLE(INDEXED_DATABASE)
83