Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: webkit/browser/blob/blob_storage_context.cc

Issue 23223003: Chromium Blob hacking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 item.expected_modification_time()); 147 item.expected_modification_time());
140 break; 148 break;
141 case BlobData::Item::TYPE_FILE_FILESYSTEM: 149 case BlobData::Item::TYPE_FILE_FILESYSTEM:
142 AppendFileSystemFileItem(target_blob_data, 150 AppendFileSystemFileItem(target_blob_data,
143 item.filesystem_url(), 151 item.filesystem_url(),
144 item.offset(), 152 item.offset(),
145 item.length(), 153 item.length(),
146 item.expected_modification_time()); 154 item.expected_modification_time());
147 break; 155 break;
148 case BlobData::Item::TYPE_BLOB: { 156 case BlobData::Item::TYPE_BLOB: {
149 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid()); 157 scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(
158 item.blob_uuid().empty()
159 ? LookupUuidFromDeprecatedURL(item.blob_url())
160 : item.blob_uuid());
150 if (src) 161 if (src)
151 exceeded_memory = !ExpandStorageItems(target_blob_data, 162 exceeded_memory = !ExpandStorageItems(target_blob_data,
152 src->data(), 163 src->data(),
153 item.offset(), 164 item.offset(),
154 item.length()); 165 item.length());
155 break; 166 break;
156 } 167 }
157 default: 168 default:
158 NOTREACHED(); 169 NOTREACHED();
159 break; 170 break;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 226 }
216 227
217 void BlobStorageContext::RevokePublicBlobURL(const GURL& blob_url) { 228 void BlobStorageContext::RevokePublicBlobURL(const GURL& blob_url) {
218 DCHECK(!BlobUrlHasRef(blob_url)); 229 DCHECK(!BlobUrlHasRef(blob_url));
219 if (!IsUrlRegistered(blob_url)) 230 if (!IsUrlRegistered(blob_url))
220 return; 231 return;
221 DecrementBlobRefCount(public_blob_urls_[blob_url]); 232 DecrementBlobRefCount(public_blob_urls_[blob_url]);
222 public_blob_urls_.erase(blob_url); 233 public_blob_urls_.erase(blob_url);
223 } 234 }
224 235
236 void BlobStorageContext::DeprecatedRegisterPrivateBlobURL(
237 const GURL& url, const std::string& uuid) {
238 if (!IsInUse(uuid))
239 return;
240 IncrementBlobRefCount(uuid);
241 deprecated_blob_urls_[url] = uuid;
242 }
243
244 void BlobStorageContext::DeprecatedRevokePrivateBlobURL(const GURL& url) {
245 if (deprecated_blob_urls_.find(url) == deprecated_blob_urls_.end())
246 return;
247 DecrementBlobRefCount(deprecated_blob_urls_[url]);
248 deprecated_blob_urls_.erase(url);
249 }
250
225 bool BlobStorageContext::ExpandStorageItems( 251 bool BlobStorageContext::ExpandStorageItems(
226 BlobData* target_blob_data, BlobData* src_blob_data, 252 BlobData* target_blob_data, BlobData* src_blob_data,
227 uint64 offset, uint64 length) { 253 uint64 offset, uint64 length) {
228 DCHECK(target_blob_data && src_blob_data && 254 DCHECK(target_blob_data && src_blob_data &&
229 length != static_cast<uint64>(-1)); 255 length != static_cast<uint64>(-1));
230 256
231 std::vector<BlobData::Item>::const_iterator iter = 257 std::vector<BlobData::Item>::const_iterator iter =
232 src_blob_data->items().begin(); 258 src_blob_data->items().begin();
233 if (offset) { 259 if (offset) {
234 for (; iter != src_blob_data->items().end(); ++iter) { 260 for (; iter != src_blob_data->items().end(); ++iter) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (found == blob_map_.end()) 339 if (found == blob_map_.end())
314 return false; 340 return false;
315 return found->second.flags & BEING_BUILT; 341 return found->second.flags & BEING_BUILT;
316 } 342 }
317 343
318 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) { 344 bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) {
319 return public_blob_urls_.find(blob_url) != public_blob_urls_.end(); 345 return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
320 } 346 }
321 347
322 } // namespace webkit_blob 348 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/browser/blob/blob_storage_context.h ('k') | webkit/browser/blob/blob_storage_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698