OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/net/blob_url_request_job_factory.h" | 5 #include "chrome/browser/net/blob_url_request_job_factory.h" |
6 | 6 |
7 #include "chrome/browser/chrome_blob_storage_context.h" | 7 #include "chrome/browser/chrome_blob_storage_context.h" |
8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
9 #include "chrome/browser/net/chrome_url_request_context.h" | 9 #include "chrome/browser/net/chrome_url_request_context.h" |
| 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 11 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
10 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
11 #include "webkit/blob/blob_storage_controller.h" | 13 #include "webkit/blob/blob_storage_controller.h" |
12 #include "webkit/blob/blob_url_request_job.h" | 14 #include "webkit/blob/blob_url_request_job.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 URLRequestJob* BlobURLRequestJobFactory(URLRequest* request, | 18 URLRequestJob* BlobURLRequestJobFactory(URLRequest* request, |
17 const std::string& scheme) { | 19 const std::string& scheme) { |
18 webkit_blob::BlobStorageController* blob_storage_controller = | 20 scoped_refptr<webkit_blob::BlobData> data; |
19 static_cast<ChromeURLRequestContext*>(request->context())-> | 21 ResourceDispatcherHostRequestInfo* info = |
20 blob_storage_context()->controller(); | 22 ResourceDispatcherHost::InfoForRequest(request); |
| 23 if (info) { |
| 24 // Resource dispatcher host already looked up the blob data. |
| 25 data = info->requested_blob_data(); |
| 26 } else { |
| 27 // This request is not coming thru resource dispatcher host. |
| 28 data = static_cast<ChromeURLRequestContext*>(request->context())-> |
| 29 blob_storage_context()-> |
| 30 controller()->GetBlobDataFromUrl(request->url()); |
| 31 } |
21 return new webkit_blob::BlobURLRequestJob( | 32 return new webkit_blob::BlobURLRequestJob( |
22 request, | 33 request, data, |
23 blob_storage_controller->GetBlobDataFromUrl(request->url()), | |
24 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); | 34 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); |
25 } | 35 } |
26 | 36 |
27 } | 37 } |
28 | 38 |
29 void RegisterBlobURLRequestJobFactory() { | 39 void RegisterBlobURLRequestJobFactory() { |
30 URLRequest::RegisterProtocolFactory(chrome::kBlobScheme, | 40 URLRequest::RegisterProtocolFactory(chrome::kBlobScheme, |
31 &BlobURLRequestJobFactory); | 41 &BlobURLRequestJobFactory); |
32 } | 42 } |
OLD | NEW |