OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/blob_storage/blob_dispatcher_host.h" | 5 #include "content/browser/blob_storage/blob_dispatcher_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "content/browser/bad_message.h" | 10 #include "content/browser/bad_message.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid); | 181 const BlobStorageRegistry::Entry* entry = context->registry().GetEntry(uuid); |
182 if (!entry || entry->state == BlobStorageRegistry::BlobState::BROKEN) { | 182 if (!entry || entry->state == BlobStorageRegistry::BlobState::BROKEN) { |
183 // We ignore messages for blobs that don't exist to handle the case where | 183 // We ignore messages for blobs that don't exist to handle the case where |
184 // the renderer de-refs a blob that we're still constructing, and there are | 184 // the renderer de-refs a blob that we're still constructing, and there are |
185 // no references to that blob. We ignore broken as well, in the case where | 185 // no references to that blob. We ignore broken as well, in the case where |
186 // we decided to break a blob and the renderer also decided to cancel. | 186 // we decided to break a blob and the renderer also decided to cancel. |
187 // Note: if a blob is broken, then it can't be in the async_builder. | 187 // Note: if a blob is broken, then it can't be in the async_builder. |
188 // Second, if the last dereference of the blob happened on a different host, | 188 // Second, if the last dereference of the blob happened on a different host, |
189 // then we still haven't gotten rid of the 'building' state in the original | 189 // then we still haven't gotten rid of the 'building' state in the original |
190 // host. So we call cancel just in case this happens. | 190 // host. So we call cancel just in case this happens. |
191 async_builder_.CancelBuildingBlob( | 191 if (async_builder_.IsBeingBuilt(uuid)) { |
192 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, | 192 async_builder_.CancelBuildingBlob( |
193 context); | 193 uuid, IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING, |
| 194 context); |
| 195 } |
194 return; | 196 return; |
195 } | 197 } |
196 if (!async_builder_.IsBeingBuilt(uuid)) { | 198 if (!async_builder_.IsBeingBuilt(uuid)) { |
197 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); | 199 SendIPCResponse(uuid, BlobTransportResult::BAD_IPC); |
198 return; | 200 return; |
199 } | 201 } |
200 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. " | 202 VLOG(1) << "Blob construction of " << uuid << " cancelled by renderer. " |
201 << " Reason: " << static_cast<int>(code) << "."; | 203 << " Reason: " << static_cast<int>(code) << "."; |
202 async_builder_.CancelBuildingBlob(uuid, code, context); | 204 async_builder_.CancelBuildingBlob(uuid, code, context); |
203 } | 205 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 context->RevokePublicBlobURL(url); | 326 context->RevokePublicBlobURL(url); |
325 } | 327 } |
326 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { | 328 for (const auto& uuid_refnum_pair : blobs_inuse_map_) { |
327 for (int i = 0; i < uuid_refnum_pair.second; ++i) | 329 for (int i = 0; i < uuid_refnum_pair.second; ++i) |
328 context->DecrementBlobRefCount(uuid_refnum_pair.first); | 330 context->DecrementBlobRefCount(uuid_refnum_pair.first); |
329 } | 331 } |
330 async_builder_.CancelAll(context); | 332 async_builder_.CancelAll(context); |
331 } | 333 } |
332 | 334 |
333 } // namespace content | 335 } // namespace content |
OLD | NEW |