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

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

Issue 1323323002: IndexedDB: Various C++11isms and cleanup (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: True, false, whatever Created 5 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 /* 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 IDBDatabase* IDBDatabase::create(ExecutionContext* context, PassOwnPtr<WebIDBDat abase> database, IDBDatabaseCallbacks* callbacks) 71 IDBDatabase* IDBDatabase::create(ExecutionContext* context, PassOwnPtr<WebIDBDat abase> database, IDBDatabaseCallbacks* callbacks)
72 { 72 {
73 IDBDatabase* idbDatabase = new IDBDatabase(context, database, callbacks); 73 IDBDatabase* idbDatabase = new IDBDatabase(context, database, callbacks);
74 idbDatabase->suspendIfNeeded(); 74 idbDatabase->suspendIfNeeded();
75 return idbDatabase; 75 return idbDatabase;
76 } 76 }
77 77
78 IDBDatabase::IDBDatabase(ExecutionContext* context, PassOwnPtr<WebIDBDatabase> b ackend, IDBDatabaseCallbacks* callbacks) 78 IDBDatabase::IDBDatabase(ExecutionContext* context, PassOwnPtr<WebIDBDatabase> b ackend, IDBDatabaseCallbacks* callbacks)
79 : ActiveDOMObject(context) 79 : ActiveDOMObject(context)
80 , m_backend(backend) 80 , m_backend(backend)
81 , m_closePending(false)
82 , m_contextStopped(false)
83 , m_databaseCallbacks(callbacks) 81 , m_databaseCallbacks(callbacks)
84 { 82 {
85 m_databaseCallbacks->connect(this); 83 m_databaseCallbacks->connect(this);
86 } 84 }
87 85
88 IDBDatabase::~IDBDatabase() 86 IDBDatabase::~IDBDatabase()
89 { 87 {
90 if (!m_closePending && m_backend) 88 if (!m_closePending && m_backend)
91 m_backend->close(); 89 m_backend->close();
92 } 90 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 157
160 void IDBDatabase::onComplete(int64_t transactionId) 158 void IDBDatabase::onComplete(int64_t transactionId)
161 { 159 {
162 ASSERT(m_transactions.contains(transactionId)); 160 ASSERT(m_transactions.contains(transactionId));
163 m_transactions.get(transactionId)->onComplete(); 161 m_transactions.get(transactionId)->onComplete();
164 } 162 }
165 163
166 PassRefPtrWillBeRawPtr<DOMStringList> IDBDatabase::objectStoreNames() const 164 PassRefPtrWillBeRawPtr<DOMStringList> IDBDatabase::objectStoreNames() const
167 { 165 {
168 RefPtrWillBeRawPtr<DOMStringList> objectStoreNames = DOMStringList::create(D OMStringList::IndexedDB); 166 RefPtrWillBeRawPtr<DOMStringList> objectStoreNames = DOMStringList::create(D OMStringList::IndexedDB);
169 for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator it = m_metadata.obj ectStores.begin(); it != m_metadata.objectStores.end(); ++it) 167 for (const auto& it : m_metadata.objectStores)
170 objectStoreNames->append(it->value.name); 168 objectStoreNames->append(it.value.name);
171 objectStoreNames->sort(); 169 objectStoreNames->sort();
172 return objectStoreNames.release(); 170 return objectStoreNames.release();
173 } 171 }
174 172
175 void IDBDatabase::version(UnsignedLongLongOrString& result) const 173 void IDBDatabase::version(UnsignedLongLongOrString& result) const
176 { 174 {
177 if (m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion) 175 if (m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion)
178 result.setString(m_metadata.version); 176 result.setString(m_metadata.version);
179 else 177 else
180 result.setUnsignedLongLong(m_metadata.intVersion); 178 result.setUnsignedLongLong(m_metadata.intVersion);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 319 }
322 320
323 int64_t transactionId = nextTransactionId(); 321 int64_t transactionId = nextTransactionId();
324 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode); 322 m_backend->createTransaction(transactionId, WebIDBDatabaseCallbacksImpl::cre ate(m_databaseCallbacks).leakPtr(), objectStoreIds, mode);
325 323
326 return IDBTransaction::create(scriptState, transactionId, scope, mode, this) ; 324 return IDBTransaction::create(scriptState, transactionId, scope, mode, this) ;
327 } 325 }
328 326
329 void IDBDatabase::forceClose() 327 void IDBDatabase::forceClose()
330 { 328 {
331 for (TransactionMap::const_iterator::Values it = m_transactions.begin().valu es(), end = m_transactions.end().values(); it != end; ++it) 329 for (const auto& it : m_transactions)
332 (*it)->abort(IGNORE_EXCEPTION); 330 it.value->abort(IGNORE_EXCEPTION);
333 this->close(); 331 this->close();
334 enqueueEvent(Event::create(EventTypeNames::close)); 332 enqueueEvent(Event::create(EventTypeNames::close));
335 } 333 }
336 334
337 void IDBDatabase::close() 335 void IDBDatabase::close()
338 { 336 {
339 IDB_TRACE("IDBDatabase::close"); 337 IDB_TRACE("IDBDatabase::close");
340 if (m_closePending) 338 if (m_closePending)
341 return; 339 return;
342 340
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 408 }
411 409
412 bool result = EventTarget::dispatchEventInternal(event.get()); 410 bool result = EventTarget::dispatchEventInternal(event.get());
413 if (event->type() == EventTypeNames::versionchange && !m_closePending && m_b ackend) 411 if (event->type() == EventTypeNames::versionchange && !m_closePending && m_b ackend)
414 m_backend->versionChangeIgnored(); 412 m_backend->versionChangeIgnored();
415 return result; 413 return result;
416 } 414 }
417 415
418 int64_t IDBDatabase::findObjectStoreId(const String& name) const 416 int64_t IDBDatabase::findObjectStoreId(const String& name) const
419 { 417 {
420 for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator it = m_metadata.obj ectStores.begin(); it != m_metadata.objectStores.end(); ++it) { 418 for (const auto& it : m_metadata.objectStores) {
421 if (it->value.name == name) { 419 if (it.value.name == name) {
422 ASSERT(it->key != IDBObjectStoreMetadata::InvalidId); 420 ASSERT(it.key != IDBObjectStoreMetadata::InvalidId);
423 return it->key; 421 return it.key;
424 } 422 }
425 } 423 }
426 return IDBObjectStoreMetadata::InvalidId; 424 return IDBObjectStoreMetadata::InvalidId;
427 } 425 }
428 426
429 bool IDBDatabase::hasPendingActivity() const 427 bool IDBDatabase::hasPendingActivity() const
430 { 428 {
431 // The script wrapper must not be collected before the object is closed or 429 // The script wrapper must not be collected before the object is closed or
432 // we can't fire a "versionchange" event to let script manually close the co nnection. 430 // we can't fire a "versionchange" event to let script manually close the co nnection.
433 return !m_closePending && hasEventListeners() && !m_contextStopped; 431 return !m_closePending && hasEventListeners() && !m_contextStopped;
(...skipping 16 matching lines...) Expand all
450 { 448 {
451 return EventTargetNames::IDBDatabase; 449 return EventTargetNames::IDBDatabase;
452 } 450 }
453 451
454 ExecutionContext* IDBDatabase::executionContext() const 452 ExecutionContext* IDBDatabase::executionContext() const
455 { 453 {
456 return ActiveDOMObject::executionContext(); 454 return ActiveDOMObject::executionContext();
457 } 455 }
458 456
459 } // namespace blink 457 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698