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

Side by Side Diff: Source/modules/webdatabase/DatabaseBackendBase.cpp

Issue 332393002: [oilpan]: Add SafePointAwareMutexLocker to allow GC when waiting for lock. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback Created 6 years, 6 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
« no previous file with comments | « no previous file | Source/modules/webdatabase/sqlite/SQLiteFileSystem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 , m_isSyncDatabase(databaseType == DatabaseType::Sync) 213 , m_isSyncDatabase(databaseType == DatabaseType::Sync)
214 { 214 {
215 m_contextThreadSecurityOrigin = m_databaseContext->securityOrigin()->isolate dCopy(); 215 m_contextThreadSecurityOrigin = m_databaseContext->securityOrigin()->isolate dCopy();
216 216
217 m_databaseAuthorizer = DatabaseAuthorizer::create(infoTableName); 217 m_databaseAuthorizer = DatabaseAuthorizer::create(infoTableName);
218 218
219 if (m_name.isNull()) 219 if (m_name.isNull())
220 m_name = ""; 220 m_name = "";
221 221
222 { 222 {
223 MutexLocker locker(guidMutex()); 223 SafePointAwareMutexLocker locker(guidMutex());
224 m_guid = guidForOriginAndName(securityOrigin()->toString(), name); 224 m_guid = guidForOriginAndName(securityOrigin()->toString(), name);
225 HashSet<DatabaseBackendBase*>* hashSet = guidToDatabaseMap().get(m_guid) ; 225 HashSet<DatabaseBackendBase*>* hashSet = guidToDatabaseMap().get(m_guid) ;
226 if (!hashSet) { 226 if (!hashSet) {
227 hashSet = new HashSet<DatabaseBackendBase*>; 227 hashSet = new HashSet<DatabaseBackendBase*>;
228 guidToDatabaseMap().set(m_guid, hashSet); 228 guidToDatabaseMap().set(m_guid, hashSet);
229 } 229 }
230 230
231 hashSet->add(this); 231 hashSet->add(this);
232 } 232 }
233 233
(...skipping 25 matching lines...) Expand all
259 { 259 {
260 if (!m_opened) 260 if (!m_opened)
261 return; 261 return;
262 262
263 m_sqliteDatabase.close(); 263 m_sqliteDatabase.close();
264 m_opened = false; 264 m_opened = false;
265 databaseContext()->didCloseDatabase(*this); 265 databaseContext()->didCloseDatabase(*this);
266 // See comment at the top this file regarding calling removeOpenDatabase(). 266 // See comment at the top this file regarding calling removeOpenDatabase().
267 DatabaseTracker::tracker().removeOpenDatabase(this); 267 DatabaseTracker::tracker().removeOpenDatabase(this);
268 { 268 {
269 MutexLocker locker(guidMutex()); 269 SafePointAwareMutexLocker locker(guidMutex());
270 270
271 HashSet<DatabaseBackendBase*>* hashSet = guidToDatabaseMap().get(m_guid) ; 271 HashSet<DatabaseBackendBase*>* hashSet = guidToDatabaseMap().get(m_guid) ;
272 ASSERT(hashSet); 272 ASSERT(hashSet);
273 ASSERT(hashSet->contains(this)); 273 ASSERT(hashSet->contains(this));
274 hashSet->remove(this); 274 hashSet->remove(this);
275 if (hashSet->isEmpty()) { 275 if (hashSet->isEmpty()) {
276 guidToDatabaseMap().remove(m_guid); 276 guidToDatabaseMap().remove(m_guid);
277 delete hashSet; 277 delete hashSet;
278 guidToVersionMap().remove(m_guid); 278 guidToVersionMap().remove(m_guid);
279 } 279 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 errorMessage = formatErrorMessage("unable to open database", m_sqliteDat abase.lastError(), m_sqliteDatabase.lastErrorMsg()); 322 errorMessage = formatErrorMessage("unable to open database", m_sqliteDat abase.lastError(), m_sqliteDatabase.lastErrorMsg());
323 return false; 323 return false;
324 } 324 }
325 if (!m_sqliteDatabase.turnOnIncrementalAutoVacuum()) 325 if (!m_sqliteDatabase.turnOnIncrementalAutoVacuum())
326 WTF_LOG_ERROR("Unable to turn on incremental auto-vacuum (%d %s)", m_sql iteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg()); 326 WTF_LOG_ERROR("Unable to turn on incremental auto-vacuum (%d %s)", m_sql iteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
327 327
328 m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime); 328 m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime);
329 329
330 String currentVersion; 330 String currentVersion;
331 { 331 {
332 MutexLocker locker(guidMutex()); 332 SafePointAwareMutexLocker locker(guidMutex());
333 333
334 GuidVersionMap::iterator entry = guidToVersionMap().find(m_guid); 334 GuidVersionMap::iterator entry = guidToVersionMap().find(m_guid);
335 if (entry != guidToVersionMap().end()) { 335 if (entry != guidToVersionMap().end()) {
336 // Map null string to empty string (see updateGuidVersionMap()). 336 // Map null string to empty string (see updateGuidVersionMap()).
337 currentVersion = entry->value.isNull() ? emptyString() : entry->valu e.isolatedCopy(); 337 currentVersion = entry->value.isNull() ? emptyString() : entry->valu e.isolatedCopy();
338 WTF_LOG(StorageAPI, "Current cached version for guid %i is %s", m_gu id, currentVersion.ascii().data()); 338 WTF_LOG(StorageAPI, "Current cached version for guid %i is %s", m_gu id, currentVersion.ascii().data());
339 339
340 // Note: In multi-process browsers the cached value may be inaccurat e, but 340 // Note: In multi-process browsers the cached value may be inaccurat e, but
341 // we cannot read the actual version from the database without poten tially 341 // we cannot read the actual version from the database without poten tially
342 // inducing a form of deadlock, a busytimeout error when trying to 342 // inducing a form of deadlock, a busytimeout error when trying to
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return result; 499 return result;
500 } 500 }
501 501
502 void DatabaseBackendBase::setExpectedVersion(const String& version) 502 void DatabaseBackendBase::setExpectedVersion(const String& version)
503 { 503 {
504 m_expectedVersion = version.isolatedCopy(); 504 m_expectedVersion = version.isolatedCopy();
505 } 505 }
506 506
507 String DatabaseBackendBase::getCachedVersion() const 507 String DatabaseBackendBase::getCachedVersion() const
508 { 508 {
509 MutexLocker locker(guidMutex()); 509 SafePointAwareMutexLocker locker(guidMutex());
510 return guidToVersionMap().get(m_guid).isolatedCopy(); 510 return guidToVersionMap().get(m_guid).isolatedCopy();
511 } 511 }
512 512
513 void DatabaseBackendBase::setCachedVersion(const String& actualVersion) 513 void DatabaseBackendBase::setCachedVersion(const String& actualVersion)
514 { 514 {
515 // Update the in memory database version map. 515 // Update the in memory database version map.
516 MutexLocker locker(guidMutex()); 516 SafePointAwareMutexLocker locker(guidMutex());
517 updateGuidVersionMap(m_guid, actualVersion); 517 updateGuidVersionMap(m_guid, actualVersion);
518 } 518 }
519 519
520 bool DatabaseBackendBase::getActualVersionForTransaction(String &actualVersion) 520 bool DatabaseBackendBase::getActualVersionForTransaction(String &actualVersion)
521 { 521 {
522 ASSERT(m_sqliteDatabase.transactionInProgress()); 522 ASSERT(m_sqliteDatabase.transactionInProgress());
523 // Note: In multi-process browsers the cached value may be inaccurate. 523 // Note: In multi-process browsers the cached value may be inaccurate.
524 // So we retrieve the value from the database and update the cached value he re. 524 // So we retrieve the value from the database and update the cached value he re.
525 return getVersionFromDatabase(actualVersion, true); 525 return getVersionFromDatabase(actualVersion, true);
526 } 526 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 { 666 {
667 executionContext()->addConsoleMessage(StorageMessageSource, ErrorMessageLeve l, message); 667 executionContext()->addConsoleMessage(StorageMessageSource, ErrorMessageLeve l, message);
668 } 668 }
669 669
670 ExecutionContext* DatabaseBackendBase::executionContext() const 670 ExecutionContext* DatabaseBackendBase::executionContext() const
671 { 671 {
672 return databaseContext()->executionContext(); 672 return databaseContext()->executionContext();
673 } 673 }
674 674
675 } // namespace WebCore 675 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/modules/webdatabase/sqlite/SQLiteFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698