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

Unified Diff: content/browser/media/webrtc_identity_store_backend.cc

Issue 289343005: Do not CHECK on the result of Sql::Statement::Run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/webrtc_identity_store_backend.cc
diff --git a/content/browser/media/webrtc_identity_store_backend.cc b/content/browser/media/webrtc_identity_store_backend.cc
index d599dcda742d08d3ffb80598acabdf432bb5a3d0..1ecb5afe89e07151e33696f89c9705e4e15bf8e1 100644
--- a/content/browser/media/webrtc_identity_store_backend.cc
+++ b/content/browser/media/webrtc_identity_store_backend.cc
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/strings/string_util.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/net_errors.h"
#include "sql/error_delegate_util.h"
@@ -343,7 +344,7 @@ void WebRTCIdentityStoreBackend::OnLoaded(scoped_ptr<IdentityMap> out_map) {
if (state_ != LOADING)
return;
- DVLOG(2) << "WebRTC identity store has loaded.";
+ DVLOG(3) << "WebRTC identity store has loaded.";
state_ = LOADED;
identities_.swap(*out_map);
@@ -370,7 +371,7 @@ void WebRTCIdentityStoreBackend::SqlLiteStorage::Load(IdentityMap* out_map) {
// from it.
const base::FilePath dir = path_.DirName();
if (!base::PathExists(dir) && !base::CreateDirectory(dir)) {
- DLOG(ERROR) << "Unable to open DB file path.";
+ DVLOG(2) << "Unable to open DB file path.";
return;
}
@@ -379,13 +380,13 @@ void WebRTCIdentityStoreBackend::SqlLiteStorage::Load(IdentityMap* out_map) {
db_->set_error_callback(base::Bind(&SqlLiteStorage::OnDatabaseError, this));
if (!db_->Open(path_)) {
- DLOG(ERROR) << "Unable to open DB.";
+ DVLOG(2) << "Unable to open DB.";
Scott Hess - ex-Googler 2014/05/24 05:06:41 For all of these log lines, please verify that you
jiayl 2014/05/27 18:18:31 I don't think it's redundant with the sql/ logs, w
db_.reset();
return;
}
if (!InitDB(db_.get())) {
- DLOG(ERROR) << "Unable to init DB.";
+ DVLOG(2) << "Unable to init DB.";
db_.reset();
return;
}
@@ -470,21 +471,37 @@ void WebRTCIdentityStoreBackend::SqlLiteStorage::DeleteBetween(
sql::Transaction transaction(db_.get());
if (!transaction.Begin()) {
- DLOG(ERROR) << "Failed to begin the transaction.";
+ DVLOG(2) << "Failed to begin the transaction.";
return;
}
- CHECK(del_stmt.Run());
- transaction.Commit();
+ if (!del_stmt.Run()) {
+ DVLOG(2) << "Failed to run the delete statement.";
+ return;
+ }
+
+ if (!transaction.Commit())
+ DVLOG(2) << "Failed to commit the transaction.";
}
void WebRTCIdentityStoreBackend::SqlLiteStorage::OnDatabaseError(
int error,
sql::Statement* stmt) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
- if (!sql::IsErrorCatastrophic(error))
+
+ std::string statement(stmt->GetSQLStatement());
+
+ // "DELETE" failures are always non-recoverable, because we don't want to keep
+ // unwanted identities (e.g. expired, or user requested to delete) in the
+ // database.
+ if (!sql::IsErrorCatastrophic(error) &&
+ !StartsWithASCII(statement, "DELETE", false)) {
Ami GONE FROM CHROMIUM 2014/05/23 23:30:30 ಠ_ಠ What about "dElEte"? (should you ToLower() t
jiayl 2014/05/23 23:34:54 The comparison is case insensitive. DB corruption
Ami GONE FROM CHROMIUM 2014/05/23 23:47:01 So it is! (I missed the "false")
jiayl 2014/05/23 23:53:25 The expectations of this class and not expressed i
Scott Hess - ex-Googler 2014/05/24 05:06:41 If you're going to use this kind of assumption to
jiayl 2014/05/27 18:18:31 Now all DB errors will trigger RazeAndClose. A tes
return;
+ }
+
+ DVLOG(2) << "Database error " << error << " for statement " << statement;
db_->RazeAndClose();
+ db_.reset();
}
void WebRTCIdentityStoreBackend::SqlLiteStorage::BatchOperation(
@@ -542,7 +559,7 @@ void WebRTCIdentityStoreBackend::SqlLiteStorage::Commit() {
sql::Transaction transaction(db_.get());
if (!transaction.Begin()) {
- DLOG(ERROR) << "Failed to begin the transaction.";
+ DVLOG(2) << "Failed to begin the transaction.";
return;
}
@@ -561,14 +578,20 @@ void WebRTCIdentityStoreBackend::SqlLiteStorage::Commit() {
const std::string& private_key = po->identity.private_key;
add_stmt.BindBlob(4, private_key.data(), private_key.size());
add_stmt.BindInt64(5, po->identity.creation_time);
- CHECK(add_stmt.Run());
+ if (!add_stmt.Run()) {
+ DVLOG(2) << "Failed to add the identity to DB.";
+ return;
+ }
break;
}
case DELETE_IDENTITY:
del_stmt.Reset(true);
del_stmt.BindString(0, po->origin.spec());
del_stmt.BindString(1, po->identity_name);
- CHECK(del_stmt.Run());
+ if (!del_stmt.Run()) {
+ DVLOG(2) << "Failed to delete the identity from DB.";
+ return;
+ }
break;
default:
@@ -576,7 +599,12 @@ void WebRTCIdentityStoreBackend::SqlLiteStorage::Commit() {
break;
}
}
- transaction.Commit();
+
+ if (!transaction.Commit()) {
+ DVLOG(2) << "Failed to commit the transaction.";
+ return;
+ }
+
pending_operations_.clear();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698