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

Side by Side Diff: storage/browser/blob/blob_url_request_job_factory.cc

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed copyright Created 5 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "storage/browser/blob/blob_url_request_job_factory.h" 5 #include "storage/browser/blob/blob_url_request_job_factory.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 net::URLRequestJob* BlobProtocolHandler::MaybeCreateJob( 62 net::URLRequestJob* BlobProtocolHandler::MaybeCreateJob(
63 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { 63 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
64 return new storage::BlobURLRequestJob(request, 64 return new storage::BlobURLRequestJob(request,
65 network_delegate, 65 network_delegate,
66 LookupBlobData(request), 66 LookupBlobData(request),
67 file_system_context_.get(), 67 file_system_context_.get(),
68 file_loop_proxy_.get()); 68 file_loop_proxy_.get());
69 } 69 }
70 70
71 scoped_refptr<storage::BlobData> BlobProtocolHandler::LookupBlobData( 71 scoped_ptr<BlobDataSnapshot> BlobProtocolHandler::LookupBlobData(
72 net::URLRequest* request) const { 72 net::URLRequest* request) const {
73 BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request); 73 BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request);
74 if (blob_data_handle) 74 if (blob_data_handle)
75 return blob_data_handle->data(); 75 return blob_data_handle->CreateSnapshot().Pass();
76 if (!context_.get()) 76 if (!context_.get())
77 return NULL; 77 return NULL;
78 78
79 // Support looking up based on uuid, the FeedbackExtensionAPI relies on this. 79 // Support looking up based on uuid, the FeedbackExtensionAPI relies on this.
80 // TODO(michaeln): Replace this use case and others like it with a BlobReader 80 // TODO(michaeln): Replace this use case and others like it with a BlobReader
81 // impl that does not depend on urlfetching to perform this function. 81 // impl that does not depend on urlfetching to perform this function.
82 const std::string kPrefix("blob:uuid/"); 82 const std::string kPrefix("blob:uuid/");
83 if (!StartsWithASCII(request->url().spec(), kPrefix, true)) 83 if (!StartsWithASCII(request->url().spec(), kPrefix, true))
84 return NULL; 84 return NULL;
85 std::string uuid = request->url().spec().substr(kPrefix.length()); 85 std::string uuid = request->url().spec().substr(kPrefix.length());
86 scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid); 86 scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid);
87 return handle.get() ? handle->data() : NULL; 87 scoped_ptr<BlobDataSnapshot> snapshot;
88 if (handle) {
89 snapshot = handle->CreateSnapshot().Pass();
90 SetRequestedBlobDataHandle(request, handle.Pass());
91 }
92 return snapshot.Pass();
88 } 93 }
89 94
90 } // namespace storage 95 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698