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

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 Created 5 years 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 3e864fa1cdf9bcdb0caba7096522b16a0c32193d..6900a76cc798885a081d01d13cad6fd824ae976d 100644
--- a/storage/browser/blob/blob_data_handle.cc
+++ b/storage/browser/blob/blob_data_handle.cc
@@ -5,6 +5,7 @@
#include "storage/browser/blob/blob_data_handle.h"
#include "base/bind.h"
+#include "base/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/sequenced_task_runner.h"
@@ -19,13 +20,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 {}
@@ -71,6 +73,21 @@ BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared(
context_->IncrementBlobRefCount(uuid);
}
+bool BlobDataHandle::BlobDataHandleShared::IsAsyncConstructing() const {
+ if (!context_.get())
+ return false;
+ return context_->IsBeingBuilt(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 {
@@ -82,6 +99,8 @@ scoped_ptr<BlobReader> BlobDataHandle::CreateReader(
scoped_ptr<BlobDataSnapshot>
BlobDataHandle::BlobDataHandleShared::CreateSnapshot() const {
+ if (!context_.get())
+ return nullptr;
return context_->CreateSnapshot(uuid_).Pass();
}
@@ -116,6 +135,17 @@ BlobDataHandle::~BlobDataHandle() {
io_task_runner_->ReleaseSoon(FROM_HERE, raw);
}
+bool BlobDataHandle::IsAsyncConstructing() const {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ return shared_->IsAsyncConstructing();
+}
+
+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().Pass();

Powered by Google App Engine
This is Rietveld 408576698