| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 scoped_ptr<net::URLRequest> BlobProtocolHandler::CreateBlobRequest( | 32 scoped_ptr<net::URLRequest> BlobProtocolHandler::CreateBlobRequest( |
| 33 scoped_ptr<BlobDataHandle> blob_data_handle, | 33 scoped_ptr<BlobDataHandle> blob_data_handle, |
| 34 const net::URLRequestContext* request_context, | 34 const net::URLRequestContext* request_context, |
| 35 net::URLRequest::Delegate* request_delegate) { | 35 net::URLRequest::Delegate* request_delegate) { |
| 36 const GURL kBlobUrl("blob://see_user_data/"); | 36 const GURL kBlobUrl("blob://see_user_data/"); |
| 37 scoped_ptr<net::URLRequest> request = request_context->CreateRequest( | 37 scoped_ptr<net::URLRequest> request = request_context->CreateRequest( |
| 38 kBlobUrl, net::DEFAULT_PRIORITY, request_delegate, NULL); | 38 kBlobUrl, net::DEFAULT_PRIORITY, request_delegate); |
| 39 SetRequestedBlobDataHandle(request.get(), blob_data_handle.Pass()); | 39 SetRequestedBlobDataHandle(request.get(), blob_data_handle.Pass()); |
| 40 return request.Pass(); | 40 return request.Pass(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 void BlobProtocolHandler::SetRequestedBlobDataHandle( | 44 void BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 45 net::URLRequest* request, | 45 net::URLRequest* request, |
| 46 scoped_ptr<BlobDataHandle> blob_data_handle) { | 46 scoped_ptr<BlobDataHandle> blob_data_handle) { |
| 47 request->SetUserData(&kUserDataKey, blob_data_handle.release()); | 47 request->SetUserData(&kUserDataKey, blob_data_handle.release()); |
| 48 } | 48 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // impl that does not depend on urlfetching to perform this function. | 80 // impl that does not depend on urlfetching to perform this function. |
| 81 const std::string kPrefix("blob:uuid/"); | 81 const std::string kPrefix("blob:uuid/"); |
| 82 if (!StartsWithASCII(request->url().spec(), kPrefix, true)) | 82 if (!StartsWithASCII(request->url().spec(), kPrefix, true)) |
| 83 return NULL; | 83 return NULL; |
| 84 std::string uuid = request->url().spec().substr(kPrefix.length()); | 84 std::string uuid = request->url().spec().substr(kPrefix.length()); |
| 85 scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid); | 85 scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid); |
| 86 return handle.get() ? handle->data() : NULL; | 86 return handle.get() ? handle->data() : NULL; |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace webkit_blob | 89 } // namespace webkit_blob |
| OLD | NEW |