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

Side by Side Diff: Source/modules/indexeddb/IDBFactoryBackendImpl.cpp

Issue 13843016: Prepare to remove WebSecurityOrigin from IDB backend (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove unused static Created 7 years, 8 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:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 11 matching lines...) Expand all
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "modules/indexeddb/IDBFactoryBackendImpl.h" 30 #include "modules/indexeddb/IDBFactoryBackendImpl.h"
31 31
32 #include "core/dom/DOMStringList.h"
33 #include "core/page/SecurityOrigin.h"
34 #include "modules/indexeddb/IDBBackingStore.h" 32 #include "modules/indexeddb/IDBBackingStore.h"
35 #include "modules/indexeddb/IDBDatabaseBackendImpl.h" 33 #include "modules/indexeddb/IDBDatabaseBackendImpl.h"
36 #include "modules/indexeddb/IDBDatabaseException.h" 34 #include "modules/indexeddb/IDBDatabaseException.h"
37 #include "modules/indexeddb/IDBTracing.h" 35 #include "modules/indexeddb/IDBTracing.h"
38 #include "modules/indexeddb/IDBTransactionCoordinator.h" 36 #include "modules/indexeddb/IDBTransactionCoordinator.h"
39 #include "wtf/UnusedParam.h" 37 #include "wtf/UnusedParam.h"
40 38
41 namespace WebCore { 39 namespace WebCore {
42 40
43 template<typename K, typename M> 41 template<typename K, typename M>
(...skipping 28 matching lines...) Expand all
72 IDBFactoryBackendImpl::~IDBFactoryBackendImpl() 70 IDBFactoryBackendImpl::~IDBFactoryBackendImpl()
73 { 71 {
74 } 72 }
75 73
76 void IDBFactoryBackendImpl::removeIDBDatabaseBackend(const String& uniqueIdentif ier) 74 void IDBFactoryBackendImpl::removeIDBDatabaseBackend(const String& uniqueIdentif ier)
77 { 75 {
78 ASSERT(m_databaseBackendMap.contains(uniqueIdentifier)); 76 ASSERT(m_databaseBackendMap.contains(uniqueIdentifier));
79 m_databaseBackendMap.remove(uniqueIdentifier); 77 m_databaseBackendMap.remove(uniqueIdentifier);
80 } 78 }
81 79
82 void IDBFactoryBackendImpl::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext*, const Strin g& dataDirectory) 80 void IDBFactoryBackendImpl::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, const String& databaseIdentifier, ScriptExecutionContext*, const String& dataDi rectory)
83 { 81 {
84 IDB_TRACE("IDBFactoryBackendImpl::getDatabaseNames"); 82 IDB_TRACE("IDBFactoryBackendImpl::getDatabaseNames");
85 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin->data baseIdentifier(), dataDirectory); 83 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifier, dataDirectory);
86 if (!backingStore) { 84 if (!backingStore) {
87 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Unknow nError, "Internal error opening backing store for indexedDB.webkitGetDatabaseNam es.")); 85 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Unknow nError, "Internal error opening backing store for indexedDB.webkitGetDatabaseNam es."));
88 return; 86 return;
89 } 87 }
90 88
91 callbacks->onSuccess(backingStore->getDatabaseNames()); 89 callbacks->onSuccess(backingStore->getDatabaseNames());
92 } 90 }
93 91
94 void IDBFactoryBackendImpl::deleteDatabase(const String& name, PassRefPtr<IDBCal lbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionCon text*, const String& dataDirectory) 92 void IDBFactoryBackendImpl::deleteDatabase(const String& name, PassRefPtr<IDBCal lbacks> callbacks, const String& databaseIdentifier, ScriptExecutionContext*, co nst String& dataDirectory)
95 { 93 {
96 IDB_TRACE("IDBFactoryBackendImpl::deleteDatabase"); 94 IDB_TRACE("IDBFactoryBackendImpl::deleteDatabase");
97 const String uniqueIdentifier = computeUniqueIdentifier(name, securityOrigin ->databaseIdentifier()); 95 const String uniqueIdentifier = computeUniqueIdentifier(name, databaseIdenti fier);
98 96
99 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier); 97 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier);
100 if (it != m_databaseBackendMap.end()) { 98 if (it != m_databaseBackendMap.end()) {
101 // If there are any connections to the database, directly delete the 99 // If there are any connections to the database, directly delete the
102 // database. 100 // database.
103 it->value->deleteDatabase(callbacks); 101 it->value->deleteDatabase(callbacks);
104 return; 102 return;
105 } 103 }
106 104
107 // FIXME: Everything from now on should be done on another thread. 105 // FIXME: Everything from now on should be done on another thread.
108 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin->data baseIdentifier(), dataDirectory); 106 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifier, dataDirectory);
109 if (!backingStore) { 107 if (!backingStore) {
110 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Unknow nError, "Internal error opening backing store for indexedDB.deleteDatabase.")); 108 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Unknow nError, "Internal error opening backing store for indexedDB.deleteDatabase."));
111 return; 109 return;
112 } 110 }
113 111
114 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre ate(name, backingStore.get(), this, uniqueIdentifier); 112 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre ate(name, backingStore.get(), this, uniqueIdentifier);
115 if (databaseBackend) { 113 if (databaseBackend) {
116 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 114 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get());
117 databaseBackend->deleteDatabase(callbacks); 115 databaseBackend->deleteDatabase(callbacks);
118 m_databaseBackendMap.remove(uniqueIdentifier); 116 m_databaseBackendMap.remove(uniqueIdentifier);
(...skipping 25 matching lines...) Expand all
144 142
145 // All backing stores associated with this factory should be of the same type. 143 // All backing stores associated with this factory should be of the same type.
146 ASSERT(m_sessionOnlyBackingStores.isEmpty() || openInMemory); 144 ASSERT(m_sessionOnlyBackingStores.isEmpty() || openInMemory);
147 145
148 return backingStore.release(); 146 return backingStore.release();
149 } 147 }
150 148
151 return 0; 149 return 0;
152 } 150 }
153 151
154 void IDBFactoryBackendImpl::open(const String& name, int64_t version, int64_t tr ansactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks > databaseCallbacks, PassRefPtr<SecurityOrigin> prpSecurityOrigin, ScriptExecuti onContext*, const String& dataDirectory) 152 void IDBFactoryBackendImpl::open(const String& name, int64_t version, int64_t tr ansactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks > databaseCallbacks, const String& databaseIdentifier, ScriptExecutionContext*, const String& dataDirectory)
155 { 153 {
156 IDB_TRACE("IDBFactoryBackendImpl::open"); 154 IDB_TRACE("IDBFactoryBackendImpl::open");
157 RefPtr<SecurityOrigin> securityOrigin = prpSecurityOrigin; 155 const String uniqueIdentifier = computeUniqueIdentifier(name, databaseIdenti fier);
158 const String uniqueIdentifier = computeUniqueIdentifier(name, securityOrigin ->databaseIdentifier());
159 156
160 RefPtr<IDBDatabaseBackendImpl> databaseBackend; 157 RefPtr<IDBDatabaseBackendImpl> databaseBackend;
161 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier); 158 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier);
162 if (it == m_databaseBackendMap.end()) { 159 if (it == m_databaseBackendMap.end()) {
163 RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin-> databaseIdentifier(), dataDirectory); 160 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifi er, dataDirectory);
164 if (!backingStore) { 161 if (!backingStore) {
165 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Un knownError, "Internal error opening backing store for indexedDB.open.")); 162 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Un knownError, "Internal error opening backing store for indexedDB.open."));
166 return; 163 return;
167 } 164 }
168 165
169 databaseBackend = IDBDatabaseBackendImpl::create(name, backingStore.get( ), this, uniqueIdentifier); 166 databaseBackend = IDBDatabaseBackendImpl::create(name, backingStore.get( ), this, uniqueIdentifier);
170 if (databaseBackend) 167 if (databaseBackend)
171 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 168 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get());
172 else { 169 else {
173 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Un knownError, "Internal error creating database backend for indexeddb.open.")); 170 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Un knownError, "Internal error creating database backend for indexeddb.open."));
174 return; 171 return;
175 } 172 }
176 } else 173 } else
177 databaseBackend = it->value; 174 databaseBackend = it->value;
178 175
179 databaseBackend->openConnection(callbacks, databaseCallbacks, transactionId, version); 176 databaseBackend->openConnection(callbacks, databaseCallbacks, transactionId, version);
180 } 177 }
181 178
182 } // namespace WebCore 179 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBFactoryBackendImpl.h ('k') | Source/modules/indexeddb/IDBFactoryBackendInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698