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

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

Issue 1337153002: [Blob] BlobReader class & tests, and removal of all redundant reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed prod/debug flakiness Created 5 years, 3 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 | « storage/browser/blob/blob_data_handle.h ('k') | storage/browser/blob/blob_data_snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e3a4be944fe36eeedaed8cfb16cdf5a159f595c0..3e864fa1cdf9bcdb0caba7096522b16a0c32193d 100644
--- a/storage/browser/blob/blob_data_handle.cc
+++ b/storage/browser/blob/blob_data_handle.cc
@@ -8,38 +8,98 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/sequenced_task_runner.h"
+#include "base/task_runner.h"
+#include "base/time/time.h"
#include "storage/browser/blob/blob_data_snapshot.h"
+#include "storage/browser/blob/blob_reader.h"
#include "storage/browser/blob/blob_storage_context.h"
+#include "storage/browser/fileapi/file_stream_reader.h"
+#include "storage/browser/fileapi/file_system_context.h"
+#include "storage/browser/fileapi/file_system_url.h"
+#include "url/gurl.h"
namespace storage {
+namespace {
+
+class FileStreamReaderProviderImpl
+ : public BlobReader::FileStreamReaderProvider {
+ public:
+ FileStreamReaderProviderImpl(FileSystemContext* file_system_context)
+ : file_system_context_(file_system_context) {}
+ ~FileStreamReaderProviderImpl() override {}
+
+ scoped_ptr<FileStreamReader> CreateForLocalFile(
+ base::TaskRunner* task_runner,
+ const base::FilePath& file_path,
+ int64_t initial_offset,
+ const base::Time& expected_modification_time) override {
+ return make_scoped_ptr(FileStreamReader::CreateForLocalFile(
+ task_runner, file_path, initial_offset, expected_modification_time));
+ }
+
+ scoped_ptr<FileStreamReader> CreateFileStreamReader(
+ const GURL& filesystem_url,
+ int64_t offset,
+ int64_t max_bytes_to_read,
+ const base::Time& expected_modification_time) override {
+ return file_system_context_->CreateFileStreamReader(
+ storage::FileSystemURL(
+ file_system_context_->CrackURL(
+ filesystem_url)),
+ offset, max_bytes_to_read,
+ expected_modification_time)
+ .Pass();
+ }
+
+ private:
+ scoped_refptr<FileSystemContext> file_system_context_;
+ DISALLOW_COPY_AND_ASSIGN(FileStreamReaderProviderImpl);
+};
+
+} // namespace
+
BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared(
const std::string& uuid,
- BlobStorageContext* context,
- base::SequencedTaskRunner* task_runner)
- : uuid_(uuid), context_(context->AsWeakPtr()) {
+ const std::string& content_type,
+ const std::string& content_disposition,
+ BlobStorageContext* context)
+ : uuid_(uuid),
+ content_type_(content_type),
+ content_disposition_(content_disposition),
+ context_(context->AsWeakPtr()) {
context_->IncrementBlobRefCount(uuid);
}
+scoped_ptr<BlobReader> BlobDataHandle::CreateReader(
+ FileSystemContext* file_system_context,
+ base::SequencedTaskRunner* file_task_runner) const {
+ return scoped_ptr<BlobReader>(new BlobReader(
+ this, scoped_ptr<BlobReader::FileStreamReaderProvider>(
+ new FileStreamReaderProviderImpl(file_system_context)),
+ file_task_runner));
+}
+
scoped_ptr<BlobDataSnapshot>
BlobDataHandle::BlobDataHandleShared::CreateSnapshot() const {
return context_->CreateSnapshot(uuid_).Pass();
}
-const std::string& BlobDataHandle::BlobDataHandleShared::uuid() const {
- return uuid_;
-}
-
BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() {
if (context_.get())
context_->DecrementBlobRefCount(uuid_);
}
BlobDataHandle::BlobDataHandle(const std::string& uuid,
+ const std::string& content_type,
+ const std::string& content_disposition,
BlobStorageContext* context,
- base::SequencedTaskRunner* task_runner)
- : io_task_runner_(task_runner),
- shared_(new BlobDataHandleShared(uuid, context, task_runner)) {
+ base::SequencedTaskRunner* io_task_runner)
+ : io_task_runner_(io_task_runner),
+ shared_(new BlobDataHandleShared(uuid,
+ content_type,
+ content_disposition,
+ context)) {
DCHECK(io_task_runner_.get());
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
}
@@ -62,7 +122,15 @@ scoped_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const {
}
const std::string& BlobDataHandle::uuid() const {
- return shared_->uuid();
+ return shared_->uuid_;
+}
+
+const std::string& BlobDataHandle::content_type() const {
+ return shared_->content_type_;
+}
+
+const std::string& BlobDataHandle::content_disposition() const {
+ return shared_->content_disposition_;
}
} // namespace storage
« no previous file with comments | « storage/browser/blob/blob_data_handle.h ('k') | storage/browser/blob/blob_data_snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698