本文整理汇总了C++中DatabaseSet::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseSet::begin方法的具体用法?C++ DatabaseSet::begin怎么用?C++ DatabaseSet::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseSet
的用法示例。
在下文中一共展示了DatabaseSet::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interruptAllDatabasesForContext
void DatabaseTracker::interruptAllDatabasesForContext(const ScriptExecutionContext* context)
{
Vector<RefPtr<AbstractDatabase> > openDatabases;
{
MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
if (!m_openDatabaseMap)
return;
DatabaseNameMap* nameMap = m_openDatabaseMap->get(context->securityOrigin());
if (!nameMap)
return;
DatabaseNameMap::const_iterator dbNameMapEndIt = nameMap->end();
for (DatabaseNameMap::const_iterator dbNameMapIt = nameMap->begin(); dbNameMapIt != dbNameMapEndIt; ++dbNameMapIt) {
DatabaseSet* databaseSet = dbNameMapIt->second;
DatabaseSet::const_iterator dbSetEndIt = databaseSet->end();
for (DatabaseSet::const_iterator dbSetIt = databaseSet->begin(); dbSetIt != dbSetEndIt; ++dbSetIt) {
if ((*dbSetIt)->scriptExecutionContext() == context)
openDatabases.append(*dbSetIt);
}
}
}
Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesEndIt = openDatabases.end();
for (Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesIt = openDatabases.begin(); openDatabasesIt != openDatabasesEndIt; ++openDatabasesIt)
(*openDatabasesIt)->interrupt();
}
示例2: getOpenDatabases
void DatabaseTracker::getOpenDatabases(SecurityOrigin* origin, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases)
{
MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
if (!m_openDatabaseMap)
return;
DatabaseNameMap* nameMap = m_openDatabaseMap->get(origin);
if (!nameMap)
return;
DatabaseSet* databaseSet = nameMap->get(name);
if (!databaseSet)
return;
for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end(); ++it)
databases->add(*it);
}
示例3: databaseThread
void* DatabaseThread::databaseThread()
{
{
// Wait for DatabaseThread::start() to complete.
MutexLocker lock(m_threadCreationMutex);
LOG(StorageAPI, "Started DatabaseThread %p", this);
}
AutodrainedPool pool;
while (OwnPtr<DatabaseTask> task = m_queue.waitForMessage()) {
task->performTask();
pool.cycle();
}
// Clean up the list of all pending transactions on this database thread
m_transactionCoordinator->shutdown();
LOG(StorageAPI, "About to detach thread %i and clear the ref to DatabaseThread %p, which currently has %i ref(s)", m_threadID, this, refCount());
// Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an
// inconsistent or locked state.
if (m_openDatabaseSet.size() > 0) {
// As the call to close will modify the original set, we must take a copy to iterate over.
DatabaseSet openSetCopy;
openSetCopy.swap(m_openDatabaseSet);
DatabaseSet::iterator end = openSetCopy.end();
for (DatabaseSet::iterator it = openSetCopy.begin(); it != end; ++it)
(*it)->close(Database::RemoveDatabaseFromContext);
}
// Detach the thread so its resources are no longer of any concern to anyone else
detachThread(m_threadID);
DatabaseTaskSynchronizer* cleanupSync = m_cleanupSync;
// Clear the self refptr, possibly resulting in deletion
m_selfRef = 0;
if (cleanupSync) // Someone wanted to know when we were done cleaning up.
cleanupSync->taskCompleted();
return 0;
}
示例4: closeDatabasesImmediately
void DatabaseTracker::closeDatabasesImmediately(SecurityOrigin* origin, const String& name)
{
String originString = origin->toRawString();
MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
if (!m_openDatabaseMap)
return;
DatabaseNameMap* nameMap = m_openDatabaseMap->get(originString);
if (!nameMap)
return;
DatabaseSet* databaseSet = nameMap->get(name);
if (!databaseSet)
return;
// We have to call closeImmediately() on the context thread.
for (DatabaseSet::iterator it = databaseSet->begin(); it != databaseSet->end(); ++it)
(*it)->getDatabaseContext()->getExecutionContext()->postTask(BLINK_FROM_HERE, createCrossThreadTask(&DatabaseTracker::closeOneDatabaseImmediately, crossThreadUnretained(this), originString, name, *it));
}
示例5: deleteDatabaseFile
// deleteDatabaseFile has to release locks between looking up the list of databases to close and closing them. While this is in progress, the caller
// is responsible for making sure no new databases are opened in the file to be deleted.
bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& name)
{
String fullPath = fullPathForDatabase(origin, name, false);
if (fullPath.isEmpty())
return true;
#ifndef NDEBUG
{
MutexLocker lockDatabase(m_databaseGuard);
ASSERT(isDeletingDatabaseOrOriginFor(origin, name));
}
#endif
Vector<RefPtr<DatabaseBackendBase>> deletedDatabases;
// Make sure not to hold the any locks when calling
// Database::markAsDeletedAndClose(), since that can cause a deadlock
// during the synchronous DatabaseThread call it triggers.
{
MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
if (m_openDatabaseMap) {
// There are some open databases, lets check if they are for this origin.
DatabaseNameMap* nameMap = m_openDatabaseMap->get(origin);
if (nameMap && nameMap->size()) {
// There are some open databases for this origin, let's check
// if they are this database by name.
DatabaseSet* databaseSet = nameMap->get(name);
if (databaseSet && databaseSet->size()) {
// We have some database open with this name. Mark them as deleted.
DatabaseSet::const_iterator end = databaseSet->end();
for (DatabaseSet::const_iterator it = databaseSet->begin(); it != end; ++it)
deletedDatabases.append(*it);
}
}
}
}
for (unsigned i = 0; i < deletedDatabases.size(); ++i)
deletedDatabases[i]->markAsDeletedAndClose();
return SQLiteFileSystem::deleteDatabaseFile(fullPath);
}
示例6: databaseThread
void* DatabaseThread::databaseThread()
{
{
// Wait for DatabaseThread::start() to complete.
MutexLocker lock(m_threadCreationMutex);
LOG(StorageAPI, "Started DatabaseThread %p", this);
}
AutodrainedPool pool;
while (true) {
RefPtr<DatabaseTask> task;
if (!m_queue.waitForMessage(task))
break;
task->performTask();
pool.cycle();
}
LOG(StorageAPI, "About to detach thread %i and clear the ref to DatabaseThread %p, which currently has %i ref(s)", m_threadID, this, refCount());
// Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an
// inconsistent or locked state.
if (m_openDatabaseSet.size() > 0) {
// As the call to close will modify the original set, we must take a copy to iterate over.
DatabaseSet openSetCopy;
openSetCopy.swap(m_openDatabaseSet);
DatabaseSet::iterator end = openSetCopy.end();
for (DatabaseSet::iterator it = openSetCopy.begin(); it != end; ++it)
(*it)->close();
}
// Detach the thread so its resources are no longer of any concern to anyone else
detachThread(m_threadID);
// Clear the self refptr, possibly resulting in deletion
m_selfRef = 0;
return 0;
}