| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 { | 95 { |
| 96 IDB_TRACE("IDBFactory::getDatabaseNames"); | 96 IDB_TRACE("IDBFactory::getDatabaseNames"); |
| 97 if (!isContextValid(context)) | 97 if (!isContextValid(context)) |
| 98 return 0; | 98 return 0; |
| 99 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { | 99 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { |
| 100 ec = SECURITY_ERR; | 100 ec = SECURITY_ERR; |
| 101 return 0; | 101 return 0; |
| 102 } | 102 } |
| 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()->databaseIden
tifier(), context, getIndexedDBDatabasePath(context)); |
| 106 return request; | 106 return request; |
| 107 } | 107 } |
| 108 | 108 |
| 109 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, unsigned long long version, ExceptionCode& ec) | 109 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, unsigned long long version, ExceptionCode& ec) |
| 110 { | 110 { |
| 111 IDB_TRACE("IDBFactory::open"); | 111 IDB_TRACE("IDBFactory::open"); |
| 112 if (!version) { | 112 if (!version) { |
| 113 ec = TypeError; | 113 ec = TypeError; |
| 114 return 0; | 114 return 0; |
| 115 } | 115 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 if (!isContextValid(context)) | 127 if (!isContextValid(context)) |
| 128 return 0; | 128 return 0; |
| 129 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { | 129 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { |
| 130 ec = SECURITY_ERR; | 130 ec = SECURITY_ERR; |
| 131 return 0; | 131 return 0; |
| 132 } | 132 } |
| 133 | 133 |
| 134 RefPtr<IDBDatabaseCallbacksImpl> databaseCallbacks = IDBDatabaseCallbacksImp
l::create(); | 134 RefPtr<IDBDatabaseCallbacksImpl> databaseCallbacks = IDBDatabaseCallbacksImp
l::create(); |
| 135 int64_t transactionId = IDBDatabase::nextTransactionId(); | 135 int64_t transactionId = IDBDatabase::nextTransactionId(); |
| 136 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); | 136 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); |
| 137 m_backend->open(name, version, transactionId, request, databaseCallbacks, co
ntext->securityOrigin(), context, getIndexedDBDatabasePath(context)); | 137 m_backend->open(name, version, transactionId, request, databaseCallbacks, co
ntext->securityOrigin()->databaseIdentifier(), context, getIndexedDBDatabasePath
(context)); |
| 138 return request; | 138 return request; |
| 139 } | 139 } |
| 140 | 140 |
| 141 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, ExceptionCode& ec) | 141 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, ExceptionCode& ec) |
| 142 { | 142 { |
| 143 IDB_TRACE("IDBFactory::open"); | 143 IDB_TRACE("IDBFactory::open"); |
| 144 return openInternal(context, name, IDBDatabaseMetadata::NoIntVersion, ec); | 144 return openInternal(context, name, IDBDatabaseMetadata::NoIntVersion, ec); |
| 145 } | 145 } |
| 146 | 146 |
| 147 PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext*
context, const String& name, ExceptionCode& ec) | 147 PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext*
context, const String& name, ExceptionCode& ec) |
| 148 { | 148 { |
| 149 IDB_TRACE("IDBFactory::deleteDatabase"); | 149 IDB_TRACE("IDBFactory::deleteDatabase"); |
| 150 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls",
IDBDeleteDatabaseCall, IDBMethodsMax); | 150 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls",
IDBDeleteDatabaseCall, IDBMethodsMax); |
| 151 if (name.isNull()) { | 151 if (name.isNull()) { |
| 152 ec = TypeError; | 152 ec = TypeError; |
| 153 return 0; | 153 return 0; |
| 154 } | 154 } |
| 155 if (!isContextValid(context)) | 155 if (!isContextValid(context)) |
| 156 return 0; | 156 return 0; |
| 157 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { | 157 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { |
| 158 ec = SECURITY_ERR; | 158 ec = SECURITY_ERR; |
| 159 return 0; | 159 return 0; |
| 160 } | 160 } |
| 161 | 161 |
| 162 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); | 162 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); |
| 163 m_backend->deleteDatabase(name, request, context->securityOrigin(), context,
getIndexedDBDatabasePath(context)); | 163 m_backend->deleteDatabase(name, request, context->securityOrigin()->database
Identifier(), context, getIndexedDBDatabasePath(context)); |
| 164 return request; | 164 return request; |
| 165 } | 165 } |
| 166 | 166 |
| 167 short IDBFactory::cmp(ScriptExecutionContext* context, const ScriptValue& firstV
alue, const ScriptValue& secondValue, ExceptionCode& ec) | 167 short IDBFactory::cmp(ScriptExecutionContext* context, const ScriptValue& firstV
alue, const ScriptValue& secondValue, ExceptionCode& ec) |
| 168 { | 168 { |
| 169 DOMRequestState requestState(context); | 169 DOMRequestState requestState(context); |
| 170 RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue); | 170 RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue); |
| 171 RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue); | 171 RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue); |
| 172 | 172 |
| 173 ASSERT(first); | 173 ASSERT(first); |
| 174 ASSERT(second); | 174 ASSERT(second); |
| 175 | 175 |
| 176 if (!first->isValid() || !second->isValid()) { | 176 if (!first->isValid() || !second->isValid()) { |
| 177 ec = IDBDatabaseException::DataError; | 177 ec = IDBDatabaseException::DataError; |
| 178 return 0; | 178 return 0; |
| 179 } | 179 } |
| 180 | 180 |
| 181 return static_cast<short>(first->compare(second.get())); | 181 return static_cast<short>(first->compare(second.get())); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace WebCore | 184 } // namespace WebCore |
| OLD | NEW |