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

Unified Diff: storage/browser/blob/blob_data_handle.cc

Issue 2448353002: [BlobAsync] Moving async handling into BlobStorageContext & quota out. (Closed)
Patch Set: comments from Marijn Created 4 years, 1 month 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
Index: storage/browser/blob/blob_data_handle.cc
diff --git a/storage/browser/blob/blob_data_handle.cc b/storage/browser/blob/blob_data_handle.cc
index a2165ad1edb0133a28cfcb2ad617ea8585fb8a10..8d29cca76f383d8c9ccc65f603a721292111ad43 100644
--- a/storage/browser/blob/blob_data_handle.cc
+++ b/storage/browser/blob/blob_data_handle.cc
@@ -26,8 +26,6 @@
#include "url/gurl.h"
namespace storage {
-using BlobState = BlobStorageRegistry::BlobState;
-
namespace {
class FileStreamReaderProviderImpl
@@ -67,10 +65,12 @@ BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared(
const std::string& uuid,
const std::string& content_type,
const std::string& content_disposition,
+ uint64_t size,
BlobStorageContext* context)
: uuid_(uuid),
content_type_(content_type),
content_disposition_(content_disposition),
+ size_(size),
context_(context->AsWeakPtr()) {
context_->IncrementBlobRefCount(uuid);
}
@@ -92,12 +92,14 @@ BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() {
BlobDataHandle::BlobDataHandle(const std::string& uuid,
const std::string& content_type,
const std::string& content_disposition,
+ uint64_t size,
BlobStorageContext* context,
base::SequencedTaskRunner* io_task_runner)
: io_task_runner_(io_task_runner),
shared_(new BlobDataHandleShared(uuid,
content_type,
content_disposition,
+ size,
context)) {
DCHECK(io_task_runner_.get());
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
@@ -121,21 +123,24 @@ bool BlobDataHandle::IsBeingBuilt() const {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
if (!shared_->context_)
return false;
- return shared_->context_->IsBeingBuilt(shared_->uuid_);
+ return BlobStatusIsPending(GetBlobStatus());
}
bool BlobDataHandle::IsBroken() const {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
if (!shared_->context_)
return true;
- return shared_->context_->IsBroken(shared_->uuid_);
+ return BlobStatusIsError(GetBlobStatus());
+}
+
+BlobStatus BlobDataHandle::GetBlobStatus() const {
+ return shared_->context_->GetBlobStatus(shared_->uuid_);
}
-void BlobDataHandle::RunOnConstructionComplete(
- const BlobConstructedCallback& done) {
+void BlobDataHandle::RunOnConstructionComplete(const BlobStatusCallback& done) {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
if (!shared_->context_.get()) {
- done.Run(false, IPCBlobCreationCancelCode::UNKNOWN);
+ done.Run(BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS);
return;
}
shared_->context_->RunOnConstructionComplete(shared_->uuid_, done);
@@ -160,4 +165,8 @@ const std::string& BlobDataHandle::content_disposition() const {
return shared_->content_disposition_;
}
+uint64_t BlobDataHandle::size() const {
+ return shared_->size_;
+}
+
} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698