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

Side by Side Diff: content/browser/blob_storage/chrome_blob_storage_context.cc

Issue 2829923004: Fail when uploading blob is non-existant (Closed)
Patch Set: fixed Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_blob_storage_context.h" 5 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 delete this; 190 delete this;
191 } 191 }
192 192
193 storage::BlobStorageContext* GetBlobStorageContext( 193 storage::BlobStorageContext* GetBlobStorageContext(
194 ChromeBlobStorageContext* blob_storage_context) { 194 ChromeBlobStorageContext* blob_storage_context) {
195 if (!blob_storage_context) 195 if (!blob_storage_context)
196 return NULL; 196 return NULL;
197 return blob_storage_context->context(); 197 return blob_storage_context->context();
198 } 198 }
199 199
200 void AttachRequestBodyBlobDataHandles(ResourceRequestBodyImpl* body, 200 bool AttachRequestBodyBlobDataHandles(ResourceRequestBodyImpl* body,
201 ResourceContext* resource_context) { 201 ResourceContext* resource_context) {
202 storage::BlobStorageContext* blob_context = GetBlobStorageContext( 202 storage::BlobStorageContext* blob_context = GetBlobStorageContext(
203 GetChromeBlobStorageContextForResourceContext(resource_context)); 203 GetChromeBlobStorageContextForResourceContext(resource_context));
204 204
205 DCHECK(blob_context); 205 DCHECK(blob_context);
206 for (size_t i = 0; i < body->elements()->size(); ++i) { 206 for (size_t i = 0; i < body->elements()->size(); ++i) {
207 const ResourceRequestBodyImpl::Element& element = (*body->elements())[i]; 207 const ResourceRequestBodyImpl::Element& element = (*body->elements())[i];
208 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB) 208 if (element.type() != ResourceRequestBodyImpl::Element::TYPE_BLOB)
209 continue; 209 continue;
210 std::unique_ptr<storage::BlobDataHandle> handle = 210 std::unique_ptr<storage::BlobDataHandle> handle =
211 blob_context->GetBlobDataFromUUID(element.blob_uuid()); 211 blob_context->GetBlobDataFromUUID(element.blob_uuid());
212 DCHECK(handle);
213 if (!handle) 212 if (!handle)
214 continue; 213 return false;
215 // Ensure the blob and any attached shareable files survive until 214 // Ensure the blob and any attached shareable files survive until
216 // upload completion. The |body| takes ownership of |handle|. 215 // upload completion. The |body| takes ownership of |handle|.
217 const void* key = handle.get(); 216 const void* key = handle.get();
218 body->SetUserData(key, std::move(handle)); 217 body->SetUserData(key, std::move(handle));
219 } 218 }
219 return true;
220 } 220 }
221 221
222 } // namespace content 222 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/blob_storage/chrome_blob_storage_context.h ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698