Chromium Code Reviews| Index: webkit/browser/blob/blob_storage_host.cc |
| diff --git a/webkit/browser/blob/blob_storage_host.cc b/webkit/browser/blob/blob_storage_host.cc |
| index eebf3fbace720170519a33de841bd7792ca38c81..0eda6e8dd2214297adda264e20f71384f6adb8b3 100644 |
| --- a/webkit/browser/blob/blob_storage_host.cc |
| +++ b/webkit/browser/blob/blob_storage_host.cc |
| @@ -5,6 +5,7 @@ |
| #include "webkit/browser/blob/blob_storage_host.h" |
| #include "base/sequenced_task_runner.h" |
| +#include "base/strings/string_util.h" |
| #include "url/gurl.h" |
| #include "webkit/browser/blob/blob_data_handle.h" |
| #include "webkit/browser/blob/blob_storage_context.h" |
| @@ -27,6 +28,10 @@ BlobStorageHost::~BlobStorageHost() { |
| for (int i = 0; i < iter->second; ++i) |
| context_->DecrementBlobRefCount(iter->first); |
| } |
| + for (std::set<GURL>::iterator iter = private_blob_urls_.begin(); |
| + iter != private_blob_urls_.end(); ++iter) { |
| + context_->DeprecatedRevokePrivateBlobURL(*iter); |
| + } |
| } |
| bool BlobStorageHost::StartBuildingBlob(const std::string& uuid) { |
| @@ -98,6 +103,54 @@ bool BlobStorageHost::RevokePublicBlobURL(const GURL& blob_url) { |
| return true; |
| } |
| +namespace { |
| +bool IsPrivateBlobURL(const GURL& url) { |
| + return StartsWithASCII(url.spec(), "blob:blobinternal", true); |
| +} |
| +} |
| + |
| +void BlobStorageHost::DeprecatedRegisterBlobURL( |
| + const GURL& private_url, const std::string& uuid) { |
| + DCHECK(IsPrivateBlobURL(private_url)); |
| + if (!context_.get()) |
| + return; |
| + context_->DeprecatedRegisterPrivateBlobURL(private_url, uuid); |
| + private_blob_urls_.insert(private_url); |
| +} |
| + |
| +void BlobStorageHost::DeprecatedCloneBlobURL( |
| + const GURL& url, const GURL& src_private_url) { |
| + // This method is used in two ways. |
| + // 1. During serialization/deserialization to 'clone' an existing blob. |
| + // In this case the src and dest urls are 'private' blob urls. |
| + // 2. To register public blob urls. In this case the dest url is a |
| + // 'public' blob url. |
| + DCHECK(IsPrivateBlobURL(src_private_url)); |
| + if (!context_.get()) |
| + return; |
| + std::string uuid = context_->LookupUuidFromDeprecatedURL(src_private_url); |
| + if (uuid.empty()) |
| + return; |
| + if (IsPrivateBlobURL(url)) { |
| + DeprecatedRegisterBlobURL(url, uuid); |
| + } else { |
| + ignore_result(IncrementBlobRefCount(uuid)); |
| + ignore_result(RegisterPublicBlobURL(url, uuid)); |
| + ignore_result(DecrementBlobRefCount(uuid)); |
|
kinuko
2013/08/28 17:24:31
I'm lost here... do we need to surround RegisterPu
michaeln
2013/08/28 20:21:34
Sorry for the confusion. Yes it is needed, but not
kinuko
2013/08/29 02:33:03
I see, thanks for the explanation. Could you note
|
| + } |
| +} |
| + |
| +void BlobStorageHost::DeprecatedRevokeBlobURL(const GURL& url) { |
| + if (!context_.get()) |
| + return; |
| + if (IsPrivateBlobURL(url)) { |
| + context_->DeprecatedRevokePrivateBlobURL(url); |
| + private_blob_urls_.erase(url); |
| + } else { |
| + ignore_result(RevokePublicBlobURL(url)); |
| + } |
| +} |
| + |
| bool BlobStorageHost::IsInUseInHost(const std::string& uuid) { |
| return blobs_inuse_map_.find(uuid) != blobs_inuse_map_.end(); |
| } |