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