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" | |
12 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
13 #include "webkit/blob/blob_storage_controller.h" | 11 #include "webkit/blob/blob_storage_controller.h" |
14 #include "webkit/blob/blob_url_request_job.h" | 12 #include "webkit/blob/blob_url_request_job.h" |
15 | 13 |
16 namespace { | 14 namespace { |
17 | 15 |
18 URLRequestJob* BlobURLRequestJobFactory(URLRequest* request, | 16 URLRequestJob* BlobURLRequestJobFactory(URLRequest* request, |
19 const std::string& scheme) { | 17 const std::string& scheme) { |
20 scoped_refptr<webkit_blob::BlobData> data; | 18 webkit_blob::BlobStorageController* blob_storage_controller = |
21 ResourceDispatcherHostRequestInfo* info = | 19 static_cast<ChromeURLRequestContext*>(request->context())-> |
22 ResourceDispatcherHost::InfoForRequest(request); | 20 blob_storage_context()->controller(); |
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 } | |
32 return new webkit_blob::BlobURLRequestJob( | 21 return new webkit_blob::BlobURLRequestJob( |
33 request, data, | 22 request, |
| 23 blob_storage_controller->GetBlobDataFromUrl(request->url()), |
34 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); | 24 ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)); |
35 } | 25 } |
36 | 26 |
37 } | 27 } |
38 | 28 |
39 void RegisterBlobURLRequestJobFactory() { | 29 void RegisterBlobURLRequestJobFactory() { |
40 URLRequest::RegisterProtocolFactory(chrome::kBlobScheme, | 30 URLRequest::RegisterProtocolFactory(chrome::kBlobScheme, |
41 &BlobURLRequestJobFactory); | 31 &BlobURLRequestJobFactory); |
42 } | 32 } |
OLD | NEW |