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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 7889024: Implementation of IDBFactory::getDatabaseNames (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 3 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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "content/browser/browser_thread.h" 9 #include "content/browser/browser_thread.h"
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) || 118 database_dispatcher_host_->OnMessageReceived(message, message_was_ok) ||
119 index_dispatcher_host_->OnMessageReceived(message, message_was_ok) || 119 index_dispatcher_host_->OnMessageReceived(message, message_was_ok) ||
120 object_store_dispatcher_host_->OnMessageReceived( 120 object_store_dispatcher_host_->OnMessageReceived(
121 message, message_was_ok) || 121 message, message_was_ok) ||
122 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) || 122 cursor_dispatcher_host_->OnMessageReceived(message, message_was_ok) ||
123 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok); 123 transaction_dispatcher_host_->OnMessageReceived(message, message_was_ok);
124 124
125 if (!handled) { 125 if (!handled) {
126 handled = true; 126 handled = true;
127 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok) 127 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, *message_was_ok)
128 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDatabaseNames,
129 OnIDBFactoryDatabaseNames)
128 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen) 130 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryOpen, OnIDBFactoryOpen)
129 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase, 131 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_FactoryDeleteDatabase,
130 OnIDBFactoryDeleteDatabase) 132 OnIDBFactoryDeleteDatabase)
131 IPC_MESSAGE_UNHANDLED(handled = false) 133 IPC_MESSAGE_UNHANDLED(handled = false)
132 IPC_END_MESSAGE_MAP() 134 IPC_END_MESSAGE_MAP()
133 } 135 }
134 136
135 return handled; 137 return handled;
136 } 138 }
137 139
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (!transaction_dispatcher_host_.get()) { 182 if (!transaction_dispatcher_host_.get()) {
181 delete idb_transaction; 183 delete idb_transaction;
182 return 0; 184 return 0;
183 } 185 }
184 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); 186 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction);
185 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); 187 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id));
186 transaction_dispatcher_host_->transaction_url_map_[id] = url; 188 transaction_dispatcher_host_->transaction_url_map_[id] = url;
187 return id; 189 return id;
188 } 190 }
189 191
192 void IndexedDBDispatcherHost::OnIDBFactoryDatabaseNames(
193 const IndexedDBHostMsg_FactoryDatabaseNames_Params& params,
194 std::vector<string16>* database_names) {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
196
197 FilePath base_path = webkit_context_->data_path();
198 FilePath indexed_db_path;
199 if (!base_path.empty()) {
200 indexed_db_path = base_path.Append(
201 IndexedDBContext::kIndexedDBDirectory);
202 }
203
204 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
205 // to add some toString method to WebSecurityOrigin that doesn't
206 // return null for them. Look at
207 // DatabaseUtil::GetOriginFromIdentifier.
208 WebSecurityOrigin origin(
209 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
210 GURL origin_url(origin.toString());
211
212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
213
214 WebKit::WebIDBFactory::BackingStoreType backingStoreType =
215 WebKit::WebIDBFactory::LevelDBBackingStore;
216
217 if (CommandLine::ForCurrentProcess()->HasSwitch(
218 switches::kSQLiteIndexedDatabase)) {
219 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore;
220 }
221
222 // TODO(dgrogan): Delete this magic constant once we've removed sqlite.
223 static const uint64 kIncognitoSqliteBackendQuota = 50 * 1024 * 1024;
dgrogan 2011/09/14 01:25:20 Get rid of this quota stuff, as elsewhere.
224
225 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
dgrogan 2011/09/14 01:25:20 And this comment.
226 // created) if this origin is already over quota.
227 WebDOMStringList web_db_names = Context()->GetIDBFactory()->databaseNames(
228 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path),
229 kIncognitoSqliteBackendQuota, backingStoreType);
230
231 database_names->reserve(web_db_names.length());
232 for (unsigned i = 0; i < web_db_names.length(); ++i)
233 database_names->push_back(web_db_names.item(i));
234 }
235
190 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 236 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
191 const IndexedDBHostMsg_FactoryOpen_Params& params) { 237 const IndexedDBHostMsg_FactoryOpen_Params& params) {
192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
193 FilePath base_path = webkit_context_->data_path(); 239 FilePath base_path = webkit_context_->data_path();
194 FilePath indexed_db_path; 240 FilePath indexed_db_path;
195 if (!base_path.empty()) { 241 if (!base_path.empty()) {
196 indexed_db_path = base_path.Append( 242 indexed_db_path = base_path.Append(
197 IndexedDBContext::kIndexedDBDirectory); 243 IndexedDBContext::kIndexedDBDirectory);
198 } 244 }
199 245
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 } 1099 }
1054 idb_transaction->didCompleteTaskEvents(); 1100 idb_transaction->didCompleteTaskEvents();
1055 } 1101 }
1056 1102
1057 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1103 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1058 int32 object_id) { 1104 int32 object_id) {
1059 transaction_size_map_.erase(object_id); 1105 transaction_size_map_.erase(object_id);
1060 transaction_url_map_.erase(object_id); 1106 transaction_url_map_.erase(object_id);
1061 parent_->DestroyObject(&map_, object_id); 1107 parent_->DestroyObject(&map_, object_id);
1062 } 1108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698