| 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 "webkit/browser/blob/blob_storage_context.h" | 5 #include "webkit/browser/blob/blob_storage_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 data->items().begin(); | 87 data->items().begin(); |
| 88 iter != data->items().end(); ++iter) { | 88 iter != data->items().end(); ++iter) { |
| 89 AppendBlobDataItem(data->uuid(), *iter); | 89 AppendBlobDataItem(data->uuid(), *iter); |
| 90 } | 90 } |
| 91 FinishBuildingBlob(data->uuid(), data->content_type()); | 91 FinishBuildingBlob(data->uuid(), data->content_type()); |
| 92 scoped_ptr<BlobDataHandle> handle = GetBlobDataFromUUID(data->uuid()); | 92 scoped_ptr<BlobDataHandle> handle = GetBlobDataFromUUID(data->uuid()); |
| 93 DecrementBlobRefCount(data->uuid()); | 93 DecrementBlobRefCount(data->uuid()); |
| 94 return handle.Pass(); | 94 return handle.Pass(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 std::string BlobStorageContext::LookupUuidFromDeprecatedURL( |
| 98 const GURL& url) { |
| 99 BlobURLMap::const_iterator found = deprecated_blob_urls_.find(url); |
| 100 if (found == deprecated_blob_urls_.end()) |
| 101 return std::string(); |
| 102 return found->second; |
| 103 } |
| 104 |
| 97 void BlobStorageContext::StartBuildingBlob(const std::string& uuid) { | 105 void BlobStorageContext::StartBuildingBlob(const std::string& uuid) { |
| 98 DCHECK(!IsInUse(uuid) && !uuid.empty()); | 106 DCHECK(!IsInUse(uuid) && !uuid.empty()); |
| 99 blob_map_[uuid] = BlobMapEntry(1, BEING_BUILT, new BlobData(uuid)); | 107 blob_map_[uuid] = BlobMapEntry(1, BEING_BUILT, new BlobData(uuid)); |
| 100 } | 108 } |
| 101 | 109 |
| 102 void BlobStorageContext::AppendBlobDataItem( | 110 void BlobStorageContext::AppendBlobDataItem( |
| 103 const std::string& uuid, const BlobData::Item& item) { | 111 const std::string& uuid, const BlobData::Item& item) { |
| 104 DCHECK(IsBeingBuilt(uuid)); | 112 DCHECK(IsBeingBuilt(uuid)); |
| 105 BlobMap::iterator found = blob_map_.find(uuid); | 113 BlobMap::iterator found = blob_map_.find(uuid); |
| 106 if (found == blob_map_.end()) | 114 if (found == blob_map_.end()) |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 223 } |
| 216 | 224 |
| 217 void BlobStorageContext::RevokePublicBlobURL(const GURL& blob_url) { | 225 void BlobStorageContext::RevokePublicBlobURL(const GURL& blob_url) { |
| 218 DCHECK(!BlobUrlHasRef(blob_url)); | 226 DCHECK(!BlobUrlHasRef(blob_url)); |
| 219 if (!IsUrlRegistered(blob_url)) | 227 if (!IsUrlRegistered(blob_url)) |
| 220 return; | 228 return; |
| 221 DecrementBlobRefCount(public_blob_urls_[blob_url]); | 229 DecrementBlobRefCount(public_blob_urls_[blob_url]); |
| 222 public_blob_urls_.erase(blob_url); | 230 public_blob_urls_.erase(blob_url); |
| 223 } | 231 } |
| 224 | 232 |
| 233 void BlobStorageContext::DeprecatedRegisterPrivateBlobURL( |
| 234 const GURL& url, const std::string& uuid) { |
| 235 if (!IsInUse(uuid)) |
| 236 return; |
| 237 IncrementBlobRefCount(uuid); |
| 238 deprecated_blob_urls_[url] = uuid; |
| 239 } |
| 240 |
| 241 void BlobStorageContext::DeprecatedRevokePrivateBlobURL(const GURL& url) { |
| 242 if (deprecated_blob_urls_.find(url) == deprecated_blob_urls_.end()) |
| 243 return; |
| 244 DecrementBlobRefCount(deprecated_blob_urls_[url]); |
| 245 deprecated_blob_urls_.erase(url); |
| 246 } |
| 247 |
| 225 bool BlobStorageContext::ExpandStorageItems( | 248 bool BlobStorageContext::ExpandStorageItems( |
| 226 BlobData* target_blob_data, BlobData* src_blob_data, | 249 BlobData* target_blob_data, BlobData* src_blob_data, |
| 227 uint64 offset, uint64 length) { | 250 uint64 offset, uint64 length) { |
| 228 DCHECK(target_blob_data && src_blob_data && | 251 DCHECK(target_blob_data && src_blob_data && |
| 229 length != static_cast<uint64>(-1)); | 252 length != static_cast<uint64>(-1)); |
| 230 | 253 |
| 231 std::vector<BlobData::Item>::const_iterator iter = | 254 std::vector<BlobData::Item>::const_iterator iter = |
| 232 src_blob_data->items().begin(); | 255 src_blob_data->items().begin(); |
| 233 if (offset) { | 256 if (offset) { |
| 234 for (; iter != src_blob_data->items().end(); ++iter) { | 257 for (; iter != src_blob_data->items().end(); ++iter) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (found == blob_map_.end()) | 336 if (found == blob_map_.end()) |
| 314 return false; | 337 return false; |
| 315 return found->second.flags & BEING_BUILT; | 338 return found->second.flags & BEING_BUILT; |
| 316 } | 339 } |
| 317 | 340 |
| 318 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { | 341 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { |
| 319 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); | 342 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); |
| 320 } | 343 } |
| 321 | 344 |
| 322 } // namespace webkit_blob | 345 } // namespace webkit_blob |
| OLD | NEW |