| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Document* document = static_cast<Document*>(context); | 83 Document* document = static_cast<Document*>(context); |
| 84 return document->page()->group().groupSettings()->indexedDBDatabasePath(
); | 84 return document->page()->group().groupSettings()->indexedDBDatabasePath(
); |
| 85 } | 85 } |
| 86 const GroupSettings* groupSettings = static_cast<WorkerContext*>(context)->g
roupSettings(); | 86 const GroupSettings* groupSettings = static_cast<WorkerContext*>(context)->g
roupSettings(); |
| 87 if (groupSettings) | 87 if (groupSettings) |
| 88 return groupSettings->indexedDBDatabasePath(); | 88 return groupSettings->indexedDBDatabasePath(); |
| 89 return String(); | 89 return String(); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* cont
ext, ExceptionCode& ec) | 93 IDBRequest* IDBFactory::getDatabaseNames(ScriptExecutionContext* context, Except
ionCode& ec) |
| 94 { | 94 { |
| 95 IDB_TRACE("IDBFactory::getDatabaseNames"); | 95 IDB_TRACE("IDBFactory::getDatabaseNames"); |
| 96 if (!isContextValid(context)) | 96 if (!isContextValid(context)) |
| 97 return 0; | 97 return 0; |
| 98 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { | 98 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { |
| 99 ec = SECURITY_ERR; | 99 ec = SECURITY_ERR; |
| 100 return 0; | 100 return 0; |
| 101 } | 101 } |
| 102 | 102 |
| 103 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), 0); | 103 IDBRequest* request = IDBRequest::create(context, IDBAny::create(this), 0); |
| 104 m_backend->getDatabaseNames(request, context->securityOrigin()->databaseIden
tifier(), context, getIndexedDBDatabasePath(context)); | 104 m_backend->getDatabaseNames(request, context->securityOrigin()->databaseIden
tifier(), context, getIndexedDBDatabasePath(context)); |
| 105 return request; | 105 return request; |
| 106 } | 106 } |
| 107 | 107 |
| 108 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, unsigned long long version, ExceptionCode& ec) | 108 IDBOpenDBRequest* IDBFactory::open(ScriptExecutionContext* context, const String
& name, unsigned long long version, ExceptionCode& ec) |
| 109 { | 109 { |
| 110 IDB_TRACE("IDBFactory::open"); | 110 IDB_TRACE("IDBFactory::open"); |
| 111 if (!version) { | 111 if (!version) { |
| 112 ec = TypeError; | 112 ec = TypeError; |
| 113 return 0; | 113 return 0; |
| 114 } | 114 } |
| 115 return openInternal(context, name, version, ec); | 115 return openInternal(context, name, version, ec); |
| 116 } | 116 } |
| 117 | 117 |
| 118 PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* co
ntext, const String& name, int64_t version, ExceptionCode& ec) | 118 IDBOpenDBRequest* IDBFactory::openInternal(ScriptExecutionContext* context, cons
t String& name, int64_t version, ExceptionCode& ec) |
| 119 { | 119 { |
| 120 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls",
IDBOpenCall, IDBMethodsMax); | 120 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls",
IDBOpenCall, IDBMethodsMax); |
| 121 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); | 121 ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoIntVersion); |
| 122 if (name.isNull()) { | 122 if (name.isNull()) { |
| 123 ec = TypeError; | 123 ec = TypeError; |
| 124 return 0; | 124 return 0; |
| 125 } | 125 } |
| 126 if (!isContextValid(context)) | 126 if (!isContextValid(context)) |
| 127 return 0; | 127 return 0; |
| 128 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { | 128 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { |
| 129 ec = SECURITY_ERR; | 129 ec = SECURITY_ERR; |
| 130 return 0; | 130 return 0; |
| 131 } | 131 } |
| 132 | 132 |
| 133 RefPtr<IDBDatabaseCallbacksImpl> databaseCallbacks = IDBDatabaseCallbacksImp
l::create(); | 133 IDBDatabaseCallbacksImpl* databaseCallbacks = IDBDatabaseCallbacksImpl::crea
te(); |
| 134 int64_t transactionId = IDBDatabase::nextTransactionId(); | 134 int64_t transactionId = IDBDatabase::nextTransactionId(); |
| 135 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databas
eCallbacks, transactionId, version); | 135 IDBOpenDBRequest* request = IDBOpenDBRequest::create(context, databaseCallba
cks, transactionId, version); |
| 136 m_backend->open(name, version, transactionId, request, databaseCallbacks, co
ntext->securityOrigin()->databaseIdentifier(), context, getIndexedDBDatabasePath
(context)); | 136 m_backend->open(name, version, transactionId, request, databaseCallbacks, co
ntext->securityOrigin()->databaseIdentifier(), context, getIndexedDBDatabasePath
(context)); |
| 137 return request; | 137 return request; |
| 138 } | 138 } |
| 139 | 139 |
| 140 PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, c
onst String& name, ExceptionCode& ec) | 140 IDBOpenDBRequest* IDBFactory::open(ScriptExecutionContext* context, const String
& name, ExceptionCode& ec) |
| 141 { | 141 { |
| 142 IDB_TRACE("IDBFactory::open"); | 142 IDB_TRACE("IDBFactory::open"); |
| 143 return openInternal(context, name, IDBDatabaseMetadata::NoIntVersion, ec); | 143 return openInternal(context, name, IDBDatabaseMetadata::NoIntVersion, ec); |
| 144 } | 144 } |
| 145 | 145 |
| 146 PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext*
context, const String& name, ExceptionCode& ec) | 146 IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptExecutionContext* context, co
nst String& name, ExceptionCode& ec) |
| 147 { | 147 { |
| 148 IDB_TRACE("IDBFactory::deleteDatabase"); | 148 IDB_TRACE("IDBFactory::deleteDatabase"); |
| 149 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls",
IDBDeleteDatabaseCall, IDBMethodsMax); | 149 HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls",
IDBDeleteDatabaseCall, IDBMethodsMax); |
| 150 if (name.isNull()) { | 150 if (name.isNull()) { |
| 151 ec = TypeError; | 151 ec = TypeError; |
| 152 return 0; | 152 return 0; |
| 153 } | 153 } |
| 154 if (!isContextValid(context)) | 154 if (!isContextValid(context)) |
| 155 return 0; | 155 return 0; |
| 156 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { | 156 if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) { |
| 157 ec = SECURITY_ERR; | 157 ec = SECURITY_ERR; |
| 158 return 0; | 158 return 0; |
| 159 } | 159 } |
| 160 | 160 |
| 161 RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, I
DBDatabaseMetadata::DefaultIntVersion); | 161 IDBOpenDBRequest* request = IDBOpenDBRequest::create(context, 0, 0, IDBDatab
aseMetadata::DefaultIntVersion); |
| 162 m_backend->deleteDatabase(name, request, context->securityOrigin()->database
Identifier(), context, getIndexedDBDatabasePath(context)); | 162 m_backend->deleteDatabase(name, request, context->securityOrigin()->database
Identifier(), context, getIndexedDBDatabasePath(context)); |
| 163 return request; | 163 return request; |
| 164 } | 164 } |
| 165 | 165 |
| 166 short IDBFactory::cmp(ScriptExecutionContext* context, const ScriptValue& firstV
alue, const ScriptValue& secondValue, ExceptionCode& ec) | 166 short IDBFactory::cmp(ScriptExecutionContext* context, const ScriptValue& firstV
alue, const ScriptValue& secondValue, ExceptionCode& ec) |
| 167 { | 167 { |
| 168 DOMRequestState requestState(context); | 168 DOMRequestState requestState(context); |
| 169 RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue); | 169 RefPtr<IDBKey> first = scriptValueToIDBKey(&requestState, firstValue); |
| 170 RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue); | 170 RefPtr<IDBKey> second = scriptValueToIDBKey(&requestState, secondValue); |
| 171 | 171 |
| 172 ASSERT(first); | 172 ASSERT(first); |
| 173 ASSERT(second); | 173 ASSERT(second); |
| 174 | 174 |
| 175 if (!first->isValid() || !second->isValid()) { | 175 if (!first->isValid() || !second->isValid()) { |
| 176 ec = IDBDatabaseException::DataError; | 176 ec = IDBDatabaseException::DataError; |
| 177 return 0; | 177 return 0; |
| 178 } | 178 } |
| 179 | 179 |
| 180 return static_cast<short>(first->compare(second.get())); | 180 return static_cast<short>(first->compare(second.get())); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void IDBFactory::trace(Visitor* visitor) | 183 void IDBFactory::trace(Visitor* visitor) |
| 184 { | 184 { |
| 185 visitor->trace(m_backend); | 185 visitor->trace(m_backend); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace WebCore | 188 } // namespace WebCore |
| OLD | NEW |