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

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

Issue 1234813004: [BlobAsync] Asynchronous Blob Construction Final Patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blob-protocol-change
Patch Set: comments/fixes Created 4 years, 11 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
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 efe13b16ea5eceaa51fab1d078c205d92dae81c4..e96494231950bfec46f08c531f47ee2d01e469da 100644
--- a/storage/browser/blob/blob_data_handle.cc
+++ b/storage/browser/blob/blob_data_handle.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include "base/bind.h"
+#include "base/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -22,13 +23,14 @@
#include "url/gurl.h"
namespace storage {
+using BlobState = BlobStorageRegistry::BlobState;
namespace {
class FileStreamReaderProviderImpl
: public BlobReader::FileStreamReaderProvider {
public:
- FileStreamReaderProviderImpl(FileSystemContext* file_system_context)
+ explicit FileStreamReaderProviderImpl(FileSystemContext* file_system_context)
: file_system_context_(file_system_context) {}
~FileStreamReaderProviderImpl() override {}
@@ -70,6 +72,27 @@ BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared(
context_->IncrementBlobRefCount(uuid);
}
+bool BlobDataHandle::BlobDataHandleShared::IsBeingBuilt() const {
+ if (!context_.get())
+ return false;
+ return context_->IsBeingBuilt(uuid_);
+}
+
+bool BlobDataHandle::BlobDataHandleShared::IsBroken() const {
+ if (!context_.get())
+ return true;
+ return context_->IsBroken(uuid_);
+}
+
+void BlobDataHandle::BlobDataHandleShared::RunOnConstructionComplete(
+ const base::Callback<void(bool)>& done) {
+ if (!context_.get()) {
+ done.Run(false);
+ return;
+ }
+ context_->RunOnConstructionComplete(uuid_, done);
+}
+
scoped_ptr<BlobReader> BlobDataHandle::CreateReader(
FileSystemContext* file_system_context,
base::SequencedTaskRunner* file_task_runner) const {
@@ -81,6 +104,8 @@ scoped_ptr<BlobReader> BlobDataHandle::CreateReader(
scoped_ptr<BlobDataSnapshot>
BlobDataHandle::BlobDataHandleShared::CreateSnapshot() const {
+ if (!context_.get())
+ return nullptr;
return context_->CreateSnapshot(uuid_);
}
@@ -115,6 +140,22 @@ BlobDataHandle::~BlobDataHandle() {
io_task_runner_->ReleaseSoon(FROM_HERE, raw);
}
+bool BlobDataHandle::IsBeingBuilt() const {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
michaeln 2016/02/06 00:08:39 you could inline these and but move the dchecks in
dmurph 2016/02/09 00:52:25 ? Not sure what you mean. I could remove the share
+ return shared_->IsBeingBuilt();
+}
+
+bool BlobDataHandle::IsBroken() const {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ return shared_->IsBroken();
+}
+
+void BlobDataHandle::RunOnConstructionComplete(
+ const base::Callback<void(bool)>& done) {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ shared_->RunOnConstructionComplete(done);
+}
+
scoped_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
return shared_->CreateSnapshot();

Powered by Google App Engine
This is Rietveld 408576698