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

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

Issue 78053006: [oilpan] Move IDBDatabase, IDBDatabaseCallbacks, IDBDatabaseBackendInterface and other related clas… (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 IDBFactoryBackendImpl::~IDBFactoryBackendImpl() 70 IDBFactoryBackendImpl::~IDBFactoryBackendImpl()
71 { 71 {
72 } 72 }
73 73
74 void IDBFactoryBackendImpl::removeIDBDatabaseBackend(const String& uniqueIdentif ier) 74 void IDBFactoryBackendImpl::removeIDBDatabaseBackend(const String& uniqueIdentif ier)
75 { 75 {
76 ASSERT(m_databaseBackendMap.contains(uniqueIdentifier)); 76 ASSERT(m_databaseBackendMap.contains(uniqueIdentifier));
77 m_databaseBackendMap.remove(uniqueIdentifier); 77 m_databaseBackendMap.remove(uniqueIdentifier);
78 } 78 }
79 79
80 void IDBFactoryBackendImpl::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, const String& databaseIdentifier, ScriptExecutionContext*, const String& dataDi rectory) 80 void IDBFactoryBackendImpl::getDatabaseNames(IDBCallbacks* callbacks, const Stri ng& databaseIdentifier, ScriptExecutionContext*, const String& dataDirectory)
81 { 81 {
82 IDB_TRACE("IDBFactoryBackendImpl::getDatabaseNames"); 82 IDB_TRACE("IDBFactoryBackendImpl::getDatabaseNames");
83 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifier, dataDirectory); 83 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifier, dataDirectory);
84 if (!backingStore) { 84 if (!backingStore) {
85 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."));
86 return; 86 return;
87 } 87 }
88 88
89 callbacks->onSuccess(backingStore->getDatabaseNames()); 89 callbacks->onSuccess(backingStore->getDatabaseNames());
90 } 90 }
91 91
92 void IDBFactoryBackendImpl::deleteDatabase(const String& name, PassRefPtr<IDBCal lbacks> callbacks, const String& databaseIdentifier, ScriptExecutionContext*, co nst String& dataDirectory) 92 void IDBFactoryBackendImpl::deleteDatabase(const String& name, IDBCallbacks* cal lbacks, const String& databaseIdentifier, ScriptExecutionContext*, const String& dataDirectory)
93 { 93 {
94 IDB_TRACE("IDBFactoryBackendImpl::deleteDatabase"); 94 IDB_TRACE("IDBFactoryBackendImpl::deleteDatabase");
95 const String uniqueIdentifier = computeUniqueIdentifier(name, databaseIdenti fier); 95 const String uniqueIdentifier = computeUniqueIdentifier(name, databaseIdenti fier);
96 96
97 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier); 97 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier);
98 if (it != m_databaseBackendMap.end()) { 98 if (it != m_databaseBackendMap.end()) {
99 // If there are any connections to the database, directly delete the 99 // If there are any connections to the database, directly delete the
100 // database. 100 // database.
101 it->value->deleteDatabase(callbacks); 101 it->value->deleteDatabase(callbacks);
102 return; 102 return;
103 } 103 }
104 104
105 // FIXME: Everything from now on should be done on another thread. 105 // FIXME: Everything from now on should be done on another thread.
106 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifier, dataDirectory); 106 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifier, dataDirectory);
107 if (!backingStore) { 107 if (!backingStore) {
108 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."));
109 return; 109 return;
110 } 110 }
111 111
112 RefPtr<IDBDatabaseBackendImpl> databaseBackend = IDBDatabaseBackendImpl::cre ate(name, backingStore.get(), this, uniqueIdentifier); 112 IDBDatabaseBackendImpl* databaseBackend = IDBDatabaseBackendImpl::create(nam e, backingStore.get(), this, uniqueIdentifier);
113 if (databaseBackend) { 113 if (databaseBackend) {
114 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 114 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend);
115 databaseBackend->deleteDatabase(callbacks); 115 databaseBackend->deleteDatabase(callbacks);
116 m_databaseBackendMap.remove(uniqueIdentifier); 116 m_databaseBackendMap.remove(uniqueIdentifier);
117 } else 117 } else
118 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Unknow nError, "Internal error creating database backend for indexedDB.deleteDatabase." )); 118 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::Unknow nError, "Internal error creating database backend for indexedDB.deleteDatabase." ));
119 } 119 }
120 120
121 PassRefPtr<IDBBackingStore> IDBFactoryBackendImpl::openBackingStore(const String & databaseIdentifier, const String& dataDirectory) 121 PassRefPtr<IDBBackingStore> IDBFactoryBackendImpl::openBackingStore(const String & databaseIdentifier, const String& dataDirectory)
122 { 122 {
123 const String fileIdentifier = computeFileIdentifier(databaseIdentifier); 123 const String fileIdentifier = computeFileIdentifier(databaseIdentifier);
124 const bool openInMemory = dataDirectory.isEmpty(); 124 const bool openInMemory = dataDirectory.isEmpty();
(...skipping 17 matching lines...) Expand all
142 142
143 // 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.
144 ASSERT(m_sessionOnlyBackingStores.isEmpty() || openInMemory); 144 ASSERT(m_sessionOnlyBackingStores.isEmpty() || openInMemory);
145 145
146 return backingStore.release(); 146 return backingStore.release();
147 } 147 }
148 148
149 return 0; 149 return 0;
150 } 150 }
151 151
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) 152 void IDBFactoryBackendImpl::open(const String& name, int64_t version, int64_t tr ansactionId, IDBCallbacks* callbacks, IDBDatabaseCallbacks* databaseCallbacks, c onst String& databaseIdentifier, ScriptExecutionContext*, const String& dataDire ctory)
153 { 153 {
154 IDB_TRACE("IDBFactoryBackendImpl::open"); 154 IDB_TRACE("IDBFactoryBackendImpl::open");
155 const String uniqueIdentifier = computeUniqueIdentifier(name, databaseIdenti fier); 155 const String uniqueIdentifier = computeUniqueIdentifier(name, databaseIdenti fier);
156 156
157 RefPtr<IDBDatabaseBackendImpl> databaseBackend; 157 IDBDatabaseBackendImpl* databaseBackend;
158 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier); 158 IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentif ier);
159 if (it == m_databaseBackendMap.end()) { 159 if (it == m_databaseBackendMap.end()) {
160 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifi er, dataDirectory); 160 RefPtr<IDBBackingStore> backingStore = openBackingStore(databaseIdentifi er, dataDirectory);
161 if (!backingStore) { 161 if (!backingStore) {
162 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."));
163 return; 163 return;
164 } 164 }
165 165
166 databaseBackend = IDBDatabaseBackendImpl::create(name, backingStore.get( ), this, uniqueIdentifier); 166 databaseBackend = IDBDatabaseBackendImpl::create(name, backingStore.get( ), this, uniqueIdentifier);
167 if (databaseBackend) 167 if (databaseBackend)
168 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get()); 168 m_databaseBackendMap.set(uniqueIdentifier, databaseBackend);
169 else { 169 else {
170 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."));
171 return; 171 return;
172 } 172 }
173 } else 173 } else
174 databaseBackend = it->value; 174 databaseBackend = it->value;
175 175
176 databaseBackend->openConnection(callbacks, databaseCallbacks, transactionId, version); 176 databaseBackend->openConnection(callbacks, databaseCallbacks, transactionId, version);
177 } 177 }
178 178
179 } // 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