| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "storage/browser/blob/blob_data_handle.h" | 5 #include "storage/browser/blob/blob_data_handle.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 scoped_refptr<FileSystemContext> file_system_context_; | 60 scoped_refptr<FileSystemContext> file_system_context_; |
| 61 DISALLOW_COPY_AND_ASSIGN(FileStreamReaderProviderImpl); | 61 DISALLOW_COPY_AND_ASSIGN(FileStreamReaderProviderImpl); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared( | 66 BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared( |
| 67 const std::string& uuid, | 67 const std::string& uuid, |
| 68 const std::string& content_type, | 68 const std::string& content_type, |
| 69 const std::string& content_disposition, | 69 const std::string& content_disposition, |
| 70 uint64_t size, |
| 70 BlobStorageContext* context) | 71 BlobStorageContext* context) |
| 71 : uuid_(uuid), | 72 : uuid_(uuid), |
| 72 content_type_(content_type), | 73 content_type_(content_type), |
| 73 content_disposition_(content_disposition), | 74 content_disposition_(content_disposition), |
| 75 size_(size), |
| 74 context_(context->AsWeakPtr()) { | 76 context_(context->AsWeakPtr()) { |
| 75 context_->IncrementBlobRefCount(uuid); | 77 context_->IncrementBlobRefCount(uuid); |
| 76 } | 78 } |
| 77 | 79 |
| 78 std::unique_ptr<BlobReader> BlobDataHandle::CreateReader( | 80 std::unique_ptr<BlobReader> BlobDataHandle::CreateReader( |
| 79 FileSystemContext* file_system_context, | 81 FileSystemContext* file_system_context, |
| 80 base::SequencedTaskRunner* file_task_runner) const { | 82 base::SequencedTaskRunner* file_task_runner) const { |
| 81 return std::unique_ptr<BlobReader>(new BlobReader( | 83 return std::unique_ptr<BlobReader>(new BlobReader( |
| 82 this, std::unique_ptr<BlobReader::FileStreamReaderProvider>( | 84 this, std::unique_ptr<BlobReader::FileStreamReaderProvider>( |
| 83 new FileStreamReaderProviderImpl(file_system_context)), | 85 new FileStreamReaderProviderImpl(file_system_context)), |
| 84 file_task_runner)); | 86 file_task_runner)); |
| 85 } | 87 } |
| 86 | 88 |
| 87 BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() { | 89 BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() { |
| 88 if (context_.get()) | 90 if (context_.get()) |
| 89 context_->DecrementBlobRefCount(uuid_); | 91 context_->DecrementBlobRefCount(uuid_); |
| 90 } | 92 } |
| 91 | 93 |
| 92 BlobDataHandle::BlobDataHandle(const std::string& uuid, | 94 BlobDataHandle::BlobDataHandle(const std::string& uuid, |
| 93 const std::string& content_type, | 95 const std::string& content_type, |
| 94 const std::string& content_disposition, | 96 const std::string& content_disposition, |
| 97 uint64_t size, |
| 95 BlobStorageContext* context, | 98 BlobStorageContext* context, |
| 96 base::SequencedTaskRunner* io_task_runner) | 99 base::SequencedTaskRunner* io_task_runner) |
| 97 : io_task_runner_(io_task_runner), | 100 : io_task_runner_(io_task_runner), |
| 98 shared_(new BlobDataHandleShared(uuid, | 101 shared_(new BlobDataHandleShared(uuid, |
| 99 content_type, | 102 content_type, |
| 100 content_disposition, | 103 content_disposition, |
| 104 size, |
| 101 context)) { | 105 context)) { |
| 102 DCHECK(io_task_runner_.get()); | 106 DCHECK(io_task_runner_.get()); |
| 103 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 107 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
| 104 } | 108 } |
| 105 | 109 |
| 106 BlobDataHandle::BlobDataHandle(const BlobDataHandle& other) { | 110 BlobDataHandle::BlobDataHandle(const BlobDataHandle& other) { |
| 107 io_task_runner_ = other.io_task_runner_; | 111 io_task_runner_ = other.io_task_runner_; |
| 108 shared_ = other.shared_; | 112 shared_ = other.shared_; |
| 109 } | 113 } |
| 110 | 114 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 157 } |
| 154 | 158 |
| 155 const std::string& BlobDataHandle::content_type() const { | 159 const std::string& BlobDataHandle::content_type() const { |
| 156 return shared_->content_type_; | 160 return shared_->content_type_; |
| 157 } | 161 } |
| 158 | 162 |
| 159 const std::string& BlobDataHandle::content_disposition() const { | 163 const std::string& BlobDataHandle::content_disposition() const { |
| 160 return shared_->content_disposition_; | 164 return shared_->content_disposition_; |
| 161 } | 165 } |
| 162 | 166 |
| 167 uint64_t BlobDataHandle::size() const { |
| 168 return shared_->size_; |
| 169 } |
| 170 |
| 163 } // namespace storage | 171 } // namespace storage |
| OLD | NEW |