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

Unified Diff: Source/modules/webdatabase/Database.cpp

Issue 1178593002: WebSQL: Added database open time statistics reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webdatabase/Database.h ('k') | public/platform/WebDatabaseObserver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webdatabase/Database.cpp
diff --git a/Source/modules/webdatabase/Database.cpp b/Source/modules/webdatabase/Database.cpp
index 43a93deeb58982c49ad3377603a4a7105e2b7f68..e4a3a79d5c223be74ef15c05c1b56cbb55eb6a06 100644
--- a/Source/modules/webdatabase/Database.cpp
+++ b/Source/modules/webdatabase/Database.cpp
@@ -425,6 +425,7 @@ private:
bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, DatabaseError& error, String& errorMessage)
{
+ double callStartTime = WTF::monotonicallyIncreasingTime();
DoneCreatingDatabaseOnExitCaller onExitCaller(this);
ASSERT(errorMessage.isEmpty());
ASSERT(error == DatabaseError::None); // Better not have any errors already.
@@ -434,7 +435,7 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
const int maxSqliteBusyWaitTime = 30000;
if (!m_sqliteDatabase.open(m_filename)) {
- reportOpenDatabaseResult(1, InvalidStateError, m_sqliteDatabase.lastError());
+ reportOpenDatabaseResult(1, InvalidStateError, m_sqliteDatabase.lastError(), WTF::monotonicallyIncreasingTime() - callStartTime);
errorMessage = formatErrorMessage("unable to open database", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
return false;
}
@@ -474,7 +475,7 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
SQLiteTransaction transaction(m_sqliteDatabase);
transaction.begin();
if (!transaction.inProgress()) {
- reportOpenDatabaseResult(2, InvalidStateError, m_sqliteDatabase.lastError());
+ reportOpenDatabaseResult(2, InvalidStateError, m_sqliteDatabase.lastError(), WTF::monotonicallyIncreasingTime() - callStartTime);
errorMessage = formatErrorMessage("unable to open database, failed to start transaction", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
m_sqliteDatabase.close();
return false;
@@ -485,14 +486,14 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
m_new = true;
if (!m_sqliteDatabase.executeCommand("CREATE TABLE " + tableName + " (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,value TEXT NOT NULL ON CONFLICT FAIL);")) {
- reportOpenDatabaseResult(3, InvalidStateError, m_sqliteDatabase.lastError());
+ reportOpenDatabaseResult(3, InvalidStateError, m_sqliteDatabase.lastError(), WTF::monotonicallyIncreasingTime() - callStartTime);
errorMessage = formatErrorMessage("unable to open database, failed to create 'info' table", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
transaction.rollback();
m_sqliteDatabase.close();
return false;
}
} else if (!getVersionFromDatabase(currentVersion, false)) {
- reportOpenDatabaseResult(4, InvalidStateError, m_sqliteDatabase.lastError());
+ reportOpenDatabaseResult(4, InvalidStateError, m_sqliteDatabase.lastError(), WTF::monotonicallyIncreasingTime() - callStartTime);
errorMessage = formatErrorMessage("unable to open database, failed to read current version", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
transaction.rollback();
m_sqliteDatabase.close();
@@ -504,7 +505,7 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
} else if (!m_new || shouldSetVersionInNewDatabase) {
WTF_LOG(StorageAPI, "Setting version %s in database %s that was just created", m_expectedVersion.ascii().data(), databaseDebugName().ascii().data());
if (!setVersionInDatabase(m_expectedVersion, false)) {
- reportOpenDatabaseResult(5, InvalidStateError, m_sqliteDatabase.lastError());
+ reportOpenDatabaseResult(5, InvalidStateError, m_sqliteDatabase.lastError(), WTF::monotonicallyIncreasingTime() - callStartTime);
errorMessage = formatErrorMessage("unable to open database, failed to write current version", m_sqliteDatabase.lastError(), m_sqliteDatabase.lastErrorMsg());
transaction.rollback();
m_sqliteDatabase.close();
@@ -528,7 +529,7 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
// If the expected version is the empty string, then we always return with
// whatever version of the database we have.
if ((!m_new || shouldSetVersionInNewDatabase) && m_expectedVersion.length() && m_expectedVersion != currentVersion) {
- reportOpenDatabaseResult(6, InvalidStateError, 0);
+ reportOpenDatabaseResult(6, InvalidStateError, 0, WTF::monotonicallyIncreasingTime() - callStartTime);
errorMessage = "unable to open database, version mismatch, '" + m_expectedVersion + "' does not match the currentVersion of '" + currentVersion + "'";
m_sqliteDatabase.close();
return false;
@@ -551,7 +552,7 @@ bool Database::performOpenAndVerify(bool shouldSetVersionInNewDatabase, Database
m_expectedVersion = "";
}
- reportOpenDatabaseResult(0, -1, 0); // OK
+ reportOpenDatabaseResult(0, -1, 0, WTF::monotonicallyIncreasingTime() - callStartTime); // OK
if (databaseContext()->databaseThread())
databaseContext()->databaseThread()->recordDatabaseOpen(this);
@@ -715,12 +716,13 @@ void Database::incrementalVacuumIfNeeded()
// These are used to generate histograms of errors seen with websql.
// See about:histograms in chromium.
-void Database::reportOpenDatabaseResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode)
+void Database::reportOpenDatabaseResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode, double duration)
{
if (Platform::current()->databaseObserver()) {
Platform::current()->databaseObserver()->reportOpenDatabaseResult(
createDatabaseIdentifierFromSecurityOrigin(securityOrigin()),
- stringIdentifier(), errorSite, webSqlErrorCode, sqliteErrorCode);
+ stringIdentifier(), errorSite, webSqlErrorCode, sqliteErrorCode,
+ duration);
}
}
« no previous file with comments | « Source/modules/webdatabase/Database.h ('k') | public/platform/WebDatabaseObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698