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

Unified Diff: content/browser/indexed_db/database_impl.cc

Issue 2779433002: [IndexedDB] Abort transaction on unknown blob (Closed)
Patch Set: comments and removed tests Created 3 years, 9 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 | content/browser/indexed_db/indexed_db_connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/indexed_db/database_impl.cc
diff --git a/content/browser/indexed_db/database_impl.cc b/content/browser/indexed_db/database_impl.cc
index 922feabba842b04e0821e401a99b482e556f8bad..25435153fc69fad441ff39388b146fa8a24a010e 100644
--- a/content/browser/indexed_db/database_impl.cc
+++ b/content/browser/indexed_db/database_impl.cc
@@ -5,6 +5,7 @@
#include "content/browser/indexed_db/database_impl.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h"
@@ -20,9 +21,10 @@
using std::swap;
namespace content {
+class IndexedDBDatabaseError;
namespace {
-const char kInvalidBlobUuid[] = "Blob UUID is invalid";
+const char kInvalidBlobUuid[] = "Blob does not exist";
const char kInvalidBlobFilePath[] = "Blob file path is invalid";
} // namespace
@@ -118,6 +120,8 @@ class DatabaseImpl::IDBThreadHelper {
int64_t index_id,
const base::string16& new_name);
void Abort(int64_t transaction_id);
+ void AbortWithError(int64_t transaction_id,
+ const IndexedDBDatabaseError& error);
void Commit(int64_t transaction_id);
void OnGotUsageAndQuotaForCommit(int64_t transaction_id,
storage::QuotaStatusCode status,
@@ -258,6 +262,9 @@ void DatabaseImpl::Put(
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
+ scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks(
+ dispatcher_host_.get(), origin_, std::move(callbacks_info)));
+
std::vector<std::unique_ptr<storage::BlobDataHandle>> handles(
value->blob_or_file_info.size());
std::vector<IndexedDBBlobInfo> blob_info(value->blob_or_file_info.size());
@@ -267,10 +274,26 @@ void DatabaseImpl::Put(
std::unique_ptr<storage::BlobDataHandle> handle =
dispatcher_host_->blob_storage_context()->GetBlobDataFromUUID(
info->uuid);
+
+ // Due to known issue crbug.com/351753, blobs can die while being passed to
+ // a different process. So this case must be handled gracefully.
+ // TODO(dmurph): Revert back to using mojo::ReportBadMessage once fixed.
+ UMA_HISTOGRAM_BOOLEAN("Storage.IndexedDB.PutValidBlob",
+ handle.get() != nullptr);
if (!handle) {
- mojo::ReportBadMessage(kInvalidBlobUuid);
+ IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
+ kInvalidBlobUuid);
+ idb_runner_->PostTask(FROM_HERE, base::Bind(&IndexedDBCallbacks::OnError,
+ callbacks, error));
+ idb_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&IDBThreadHelper::AbortWithError,
+ base::Unretained(helper_), transaction_id, error));
return;
}
+ UMA_HISTOGRAM_MEMORY_KB("Storage.IndexedDB.PutBlobSizeKB",
+ handle->size() / 1024ull);
+
handles[i] = std::move(handle);
if (info->file) {
@@ -291,9 +314,6 @@ void DatabaseImpl::Put(
}
}
- scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks(
- dispatcher_host_.get(), origin_, std::move(callbacks_info)));
-
idb_runner_->PostTask(
FROM_HERE,
base::Bind(&IDBThreadHelper::Put, base::Unretained(helper_),
@@ -792,6 +812,20 @@ void DatabaseImpl::IDBThreadHelper::Abort(int64_t transaction_id) {
connection_->AbortTransaction(transaction);
}
+void DatabaseImpl::IDBThreadHelper::AbortWithError(
+ int64_t transaction_id,
+ const IndexedDBDatabaseError& error) {
+ if (!connection_->IsConnected())
+ return;
+
+ IndexedDBTransaction* transaction =
+ connection_->GetTransaction(transaction_id);
+ if (!transaction)
+ return;
+
+ connection_->AbortTransaction(transaction, error);
+}
+
void DatabaseImpl::IDBThreadHelper::Commit(int64_t transaction_id) {
if (!connection_->IsConnected())
return;
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698