OLD | NEW |
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 "webkit/browser/blob/blob_url_request_job_factory.h" | 5 #include "webkit/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 scoped_refptr<webkit_blob::BlobData> | 69 scoped_refptr<webkit_blob::BlobData> |
70 BlobProtocolHandler::LookupBlobData(net::URLRequest* request) const { | 70 BlobProtocolHandler::LookupBlobData(net::URLRequest* request) const { |
71 BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request); | 71 BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request); |
72 if (blob_data_handle) | 72 if (blob_data_handle) |
73 return blob_data_handle->data(); | 73 return blob_data_handle->data(); |
74 if (!context_.get()) | 74 if (!context_.get()) |
75 return NULL; | 75 return NULL; |
76 | 76 |
77 // Retain support for looking up based on deprecated blob urls for now. | |
78 // The FeedbackExtensionAPI relies on this. | |
79 scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID( | |
80 context_->LookupUuidFromDeprecatedURL(request->url())); | |
81 if (handle) | |
82 return handle->data(); | |
83 | |
84 // Support looking up based on uuid, the FeedbackExtensionAPI relies on this. | 77 // Support looking up based on uuid, the FeedbackExtensionAPI relies on this. |
85 // TODO(michaeln): Replace this use case and others like it with a BlobReader | 78 // TODO(michaeln): Replace this use case and others like it with a BlobReader |
86 // impl that does not depend on urlfetching to perform this function. | 79 // impl that does not depend on urlfetching to perform this function. |
87 const std::string kPrefix("blob:uuid/"); | 80 const std::string kPrefix("blob:uuid/"); |
88 if (!StartsWithASCII(request->url().spec(), kPrefix, true)) | 81 if (!StartsWithASCII(request->url().spec(), kPrefix, true)) |
89 return NULL; | 82 return NULL; |
90 std::string uuid = request->url().spec().substr(kPrefix.length()); | 83 std::string uuid = request->url().spec().substr(kPrefix.length()); |
91 handle = context_->GetBlobDataFromUUID(uuid); | 84 scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid); |
92 return handle.get() ? handle->data() : NULL; | 85 return handle.get() ? handle->data() : NULL; |
93 } | 86 } |
94 | 87 |
95 } // namespace webkit_blob | 88 } // namespace webkit_blob |
OLD | NEW |