OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 if (!isContextValid(context)) | 101 if (!isContextValid(context)) |
102 return 0; | 102 return 0; |
103 | 103 |
104 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), 0); | 104 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), 0); |
105 m_backend->getDatabaseNames(request, context->securityOrigin(), context, get
IndexedDBDatabasePath(context)); | 105 m_backend->getDatabaseNames(request, context->securityOrigin(), context, get
IndexedDBDatabasePath(context)); |
106 return request; | 106 return request; |
107 } | 107 } |
108 | 108 |
109 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, int64_t version, ExceptionCode& ec) | 109 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, int64_t version, ExceptionCode& ec) |
110 { | 110 { |
| 111 // FIXME: This should only need to check for 0 once webkit.org/b/96798 lands
. |
| 112 const int64_t maxECMAScriptInteger = 0x20000000000000LL - 1; |
| 113 if (version < 1 || version > maxECMAScriptInteger) { |
| 114 ec = NATIVE_TYPE_ERR; |
| 115 return 0; |
| 116 } |
| 117 return openInternal(context, name, version, ec); |
| 118 } |
| 119 |
| 120 PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* co
ntext, const String& name, int64_t version, ExceptionCode& ec) |
| 121 { |
| 122 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); |
111 if (name.isNull()) { | 123 if (name.isNull()) { |
112 ec = NATIVE_TYPE_ERR; | 124 ec = NATIVE_TYPE_ERR; |
113 return 0; | 125 return 0; |
114 } | 126 } |
115 // FIXME: We need to throw an error if script passes -1. Somehow refactor | |
116 // this to avoid wanting to throw an error with the sentinel. | |
117 if (!version || version < IDBDatabaseMetadata::NoIntVersion) { | |
118 ec = NATIVE_TYPE_ERR; | |
119 return 0; | |
120 } | |
121 if (!isContextValid(context)) | 127 if (!isContextValid(context)) |
122 return 0; | 128 return 0; |
123 | 129 |
124 RefPtr<IDBDatabaseCallbacksImpl> databaseCallbacks = IDBDatabaseCallbacksImp
l::create(); | 130 RefPtr<IDBDatabaseCallbacksImpl> databaseCallbacks = IDBDatabaseCallbacksImp
l::create(); |
125 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, IDBAny:
:createNull(), databaseCallbacks, version); | 131 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, IDBAny:
:createNull(), databaseCallbacks, version); |
126 m_backend->open(name, version, request, databaseCallbacks, context->security
Origin(), context, getIndexedDBDatabasePath(context)); | 132 m_backend->open(name, version, request, databaseCallbacks, context->security
Origin(), context, getIndexedDBDatabasePath(context)); |
127 return request; | 133 return request; |
128 } | 134 } |
129 | 135 |
130 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, ExceptionCode& ec) | 136 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, ExceptionCode& ec) |
131 { | 137 { |
132 return open(context, name, IDBDatabaseMetadata::NoIntVersion, ec); | 138 return openInternal(context, name, IDBDatabaseMetadata::NoIntVersion, ec); |
133 } | 139 } |
134 | 140 |
135 PassRefPtr<IDBVersionChangeRequest> IDBFactory::deleteDatabase(ScriptExecutionCo
ntext* context, const String& name, ExceptionCode& ec) | 141 PassRefPtr<IDBVersionChangeRequest> IDBFactory::deleteDatabase(ScriptExecutionCo
ntext* context, const String& name, ExceptionCode& ec) |
136 { | 142 { |
137 if (name.isNull()) { | 143 if (name.isNull()) { |
138 ec = NATIVE_TYPE_ERR; | 144 ec = NATIVE_TYPE_ERR; |
139 return 0; | 145 return 0; |
140 } | 146 } |
141 if (!isContextValid(context)) | 147 if (!isContextValid(context)) |
142 return 0; | 148 return 0; |
(...skipping 12 matching lines...) Expand all Loading... |
155 ec = IDBDatabaseException::DATA_ERR; | 161 ec = IDBDatabaseException::DATA_ERR; |
156 return 0; | 162 return 0; |
157 } | 163 } |
158 | 164 |
159 return static_cast<short>(first->compare(second.get())); | 165 return static_cast<short>(first->compare(second.get())); |
160 } | 166 } |
161 | 167 |
162 } // namespace WebCore | 168 } // namespace WebCore |
163 | 169 |
164 #endif // ENABLE(INDEXED_DATABASE) | 170 #endif // ENABLE(INDEXED_DATABASE) |
OLD | NEW |