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

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

Issue 9467016: Get rid of WebKitContext. Only two out of six HTML5 related objects were in it and it was just a gl… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix bug Created 8 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 template <class T> 54 template <class T>
55 void DeleteOnWebKitThread(T* obj) { 55 void DeleteOnWebKitThread(T* obj) {
56 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED, 56 if (!BrowserThread::DeleteSoon(BrowserThread::WEBKIT_DEPRECATED,
57 FROM_HERE, obj)) 57 FROM_HERE, obj))
58 delete obj; 58 delete obj;
59 } 59 }
60 60
61 } 61 }
62 62
63 IndexedDBDispatcherHost::IndexedDBDispatcherHost( 63 IndexedDBDispatcherHost::IndexedDBDispatcherHost(
64 int process_id, WebKitContext* webkit_context) 64 int process_id, IndexedDBContextImpl* indexed_db_context)
65 : webkit_context_(webkit_context), 65 : indexed_db_context_(indexed_db_context),
66 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_( 66 ALLOW_THIS_IN_INITIALIZER_LIST(database_dispatcher_host_(
67 new DatabaseDispatcherHost(this))), 67 new DatabaseDispatcherHost(this))),
68 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_( 68 ALLOW_THIS_IN_INITIALIZER_LIST(index_dispatcher_host_(
69 new IndexDispatcherHost(this))), 69 new IndexDispatcherHost(this))),
70 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_( 70 ALLOW_THIS_IN_INITIALIZER_LIST(object_store_dispatcher_host_(
71 new ObjectStoreDispatcherHost(this))), 71 new ObjectStoreDispatcherHost(this))),
72 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( 72 ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_(
73 new CursorDispatcherHost(this))), 73 new CursorDispatcherHost(this))),
74 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( 74 ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_(
75 new TransactionDispatcherHost(this))), 75 new TransactionDispatcherHost(this))),
76 process_id_(process_id) { 76 process_id_(process_id) {
77 DCHECK(webkit_context_.get()); 77 DCHECK(indexed_db_context_.get());
78 } 78 }
79 79
80 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() { 80 IndexedDBDispatcherHost::~IndexedDBDispatcherHost() {
81 } 81 }
82 82
83 void IndexedDBDispatcherHost::OnChannelClosing() { 83 void IndexedDBDispatcherHost::OnChannelClosing() {
84 BrowserMessageFilter::OnChannelClosing(); 84 BrowserMessageFilter::OnChannelClosing();
85 85
86 bool success = BrowserThread::PostTask( 86 bool success = BrowserThread::PostTask(
87 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 87 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) { 201 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) {
202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
203 return cursor_dispatcher_host_->map_.Lookup(cursor_id); 203 return cursor_dispatcher_host_->map_.Lookup(cursor_id);
204 } 204 }
205 205
206 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( 206 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
207 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { 207 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
209 FilePath base_path = webkit_context_->data_path(); 209 FilePath base_path = indexed_db_context_->data_path();
210 FilePath indexed_db_path; 210 FilePath indexed_db_path;
211 if (!base_path.empty()) { 211 if (!base_path.empty()) {
212 indexed_db_path = base_path.Append( 212 indexed_db_path = base_path.Append(
213 IndexedDBContextImpl::kIndexedDBDirectory); 213 IndexedDBContextImpl::kIndexedDBDirectory);
214 } 214 }
215 215
216 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need 216 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
217 // to add some toString method to WebSecurityOrigin that doesn't 217 // to add some toString method to WebSecurityOrigin that doesn't
218 // return null for them. Look at 218 // return null for them. Look at
219 // DatabaseUtil::GetOriginFromIdentifier. 219 // DatabaseUtil::GetOriginFromIdentifier.
220 WebSecurityOrigin origin( 220 WebSecurityOrigin origin(
221 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 221 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
222 GURL origin_url(origin.toString()); 222 GURL origin_url(origin.toString());
223 223
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
225 225
226 Context()->GetIDBFactory()->getDatabaseNames( 226 Context()->GetIDBFactory()->getDatabaseNames(
227 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id, 227 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id,
228 params.response_id), origin, NULL, 228 params.response_id), origin, NULL,
229 webkit_glue::FilePathToWebString(indexed_db_path)); 229 webkit_glue::FilePathToWebString(indexed_db_path));
230 } 230 }
231 231
232 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 232 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
233 const IndexedDBHostMsg_FactoryOpen_Params& params) { 233 const IndexedDBHostMsg_FactoryOpen_Params& params) {
234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
235 FilePath base_path = webkit_context_->data_path(); 235 FilePath base_path = indexed_db_context_->data_path();
236 FilePath indexed_db_path; 236 FilePath indexed_db_path;
237 if (!base_path.empty()) { 237 if (!base_path.empty()) {
238 indexed_db_path = base_path.Append( 238 indexed_db_path = base_path.Append(
239 IndexedDBContextImpl::kIndexedDBDirectory); 239 IndexedDBContextImpl::kIndexedDBDirectory);
240 } 240 }
241 241
242 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need 242 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
243 // to add some toString method to WebSecurityOrigin that doesn't 243 // to add some toString method to WebSecurityOrigin that doesn't
244 // return null for them. Look at 244 // return null for them. Look at
245 // DatabaseUtil::GetOriginFromIdentifier. 245 // DatabaseUtil::GetOriginFromIdentifier.
246 WebSecurityOrigin origin( 246 WebSecurityOrigin origin(
247 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 247 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
248 GURL origin_url(origin.toString()); 248 GURL origin_url(origin.toString());
249 249
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
251 251
252 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore 252 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
253 // created) if this origin is already over quota. 253 // created) if this origin is already over quota.
254 Context()->GetIDBFactory()->open( 254 Context()->GetIDBFactory()->open(
255 params.name, 255 params.name,
256 new IndexedDBCallbacks<WebIDBDatabase>(this, params.thread_id, 256 new IndexedDBCallbacks<WebIDBDatabase>(this, params.thread_id,
257 params.response_id, origin_url), 257 params.response_id, origin_url),
258 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path)); 258 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path));
259 } 259 }
260 260
261 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 261 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
262 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 262 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
263 FilePath base_path = webkit_context_->data_path(); 263 FilePath base_path = indexed_db_context_->data_path();
264 FilePath indexed_db_path; 264 FilePath indexed_db_path;
265 if (!base_path.empty()) { 265 if (!base_path.empty()) {
266 indexed_db_path = base_path.Append( 266 indexed_db_path = base_path.Append(
267 IndexedDBContextImpl::kIndexedDBDirectory); 267 IndexedDBContextImpl::kIndexedDBDirectory);
268 } 268 }
269 269
270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
271 Context()->GetIDBFactory()->deleteDatabase( 271 Context()->GetIDBFactory()->deleteDatabase(
272 params.name, 272 params.name,
273 new IndexedDBCallbacks<WebSerializedScriptValue>(this, 273 new IndexedDBCallbacks<WebSerializedScriptValue>(this,
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 } 1216 }
1217 idb_transaction->didCompleteTaskEvents(); 1217 idb_transaction->didCompleteTaskEvents();
1218 } 1218 }
1219 1219
1220 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1220 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1221 int32 object_id) { 1221 int32 object_id) {
1222 transaction_size_map_.erase(object_id); 1222 transaction_size_map_.erase(object_id);
1223 transaction_url_map_.erase(object_id); 1223 transaction_url_map_.erase(object_id);
1224 parent_->DestroyObject(&map_, object_id); 1224 parent_->DestroyObject(&map_, object_id);
1225 } 1225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698