| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 uint64_t size, | 95 uint64_t size, |
| 96 BlobStorageContext* context, | 96 BlobStorageContext* context, |
| 97 base::SequencedTaskRunner* io_task_runner) | 97 base::SequencedTaskRunner* io_task_runner) |
| 98 : io_task_runner_(io_task_runner), | 98 : io_task_runner_(io_task_runner), |
| 99 shared_(new BlobDataHandleShared(uuid, | 99 shared_(new BlobDataHandleShared(uuid, |
| 100 content_type, | 100 content_type, |
| 101 content_disposition, | 101 content_disposition, |
| 102 size, | 102 size, |
| 103 context)) { | 103 context)) { |
| 104 DCHECK(io_task_runner_.get()); | 104 DCHECK(io_task_runner_.get()); |
| 105 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 105 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 BlobDataHandle::BlobDataHandle(const BlobDataHandle& other) = default; | 108 BlobDataHandle::BlobDataHandle(const BlobDataHandle& other) = default; |
| 109 | 109 |
| 110 BlobDataHandle::~BlobDataHandle() { | 110 BlobDataHandle::~BlobDataHandle() { |
| 111 if (!io_task_runner_->RunsTasksOnCurrentThread()) { | 111 if (!io_task_runner_->RunsTasksInCurrentSequence()) { |
| 112 BlobDataHandleShared* raw = shared_.get(); | 112 BlobDataHandleShared* raw = shared_.get(); |
| 113 raw->AddRef(); | 113 raw->AddRef(); |
| 114 shared_ = nullptr; | 114 shared_ = nullptr; |
| 115 io_task_runner_->ReleaseSoon(FROM_HERE, raw); | 115 io_task_runner_->ReleaseSoon(FROM_HERE, raw); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 BlobDataHandle& BlobDataHandle::operator=( | 119 BlobDataHandle& BlobDataHandle::operator=( |
| 120 const BlobDataHandle& other) = default; | 120 const BlobDataHandle& other) = default; |
| 121 | 121 |
| 122 bool BlobDataHandle::IsBeingBuilt() const { | 122 bool BlobDataHandle::IsBeingBuilt() const { |
| 123 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 123 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
| 124 if (!shared_->context_) | 124 if (!shared_->context_) |
| 125 return false; | 125 return false; |
| 126 return BlobStatusIsPending(GetBlobStatus()); | 126 return BlobStatusIsPending(GetBlobStatus()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool BlobDataHandle::IsBroken() const { | 129 bool BlobDataHandle::IsBroken() const { |
| 130 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 130 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
| 131 if (!shared_->context_) | 131 if (!shared_->context_) |
| 132 return true; | 132 return true; |
| 133 return BlobStatusIsError(GetBlobStatus()); | 133 return BlobStatusIsError(GetBlobStatus()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 BlobStatus BlobDataHandle::GetBlobStatus() const { | 136 BlobStatus BlobDataHandle::GetBlobStatus() const { |
| 137 return shared_->context_->GetBlobStatus(shared_->uuid_); | 137 return shared_->context_->GetBlobStatus(shared_->uuid_); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void BlobDataHandle::RunOnConstructionComplete(const BlobStatusCallback& done) { | 140 void BlobDataHandle::RunOnConstructionComplete(const BlobStatusCallback& done) { |
| 141 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 141 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
| 142 if (!shared_->context_.get()) { | 142 if (!shared_->context_.get()) { |
| 143 done.Run(BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS); | 143 done.Run(BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS); |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 shared_->context_->RunOnConstructionComplete(shared_->uuid_, done); | 146 shared_->context_->RunOnConstructionComplete(shared_->uuid_, done); |
| 147 } | 147 } |
| 148 | 148 |
| 149 std::unique_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const { | 149 std::unique_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const { |
| 150 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 150 DCHECK(io_task_runner_->RunsTasksInCurrentSequence()); |
| 151 if (!shared_->context_.get()) | 151 if (!shared_->context_.get()) |
| 152 return nullptr; | 152 return nullptr; |
| 153 return shared_->context_->CreateSnapshot(shared_->uuid_); | 153 return shared_->context_->CreateSnapshot(shared_->uuid_); |
| 154 } | 154 } |
| 155 | 155 |
| 156 const std::string& BlobDataHandle::uuid() const { | 156 const std::string& BlobDataHandle::uuid() const { |
| 157 return shared_->uuid_; | 157 return shared_->uuid_; |
| 158 } | 158 } |
| 159 | 159 |
| 160 const std::string& BlobDataHandle::content_type() const { | 160 const std::string& BlobDataHandle::content_type() const { |
| 161 return shared_->content_type_; | 161 return shared_->content_type_; |
| 162 } | 162 } |
| 163 | 163 |
| 164 const std::string& BlobDataHandle::content_disposition() const { | 164 const std::string& BlobDataHandle::content_disposition() const { |
| 165 return shared_->content_disposition_; | 165 return shared_->content_disposition_; |
| 166 } | 166 } |
| 167 | 167 |
| 168 uint64_t BlobDataHandle::size() const { | 168 uint64_t BlobDataHandle::size() const { |
| 169 return shared_->size_; | 169 return shared_->size_; |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace storage | 172 } // namespace storage |
| OLD | NEW |