Chromium Code Reviews| Index: webkit/browser/blob/blob_url_request_job_factory.cc |
| diff --git a/webkit/browser/blob/blob_url_request_job_factory.cc b/webkit/browser/blob/blob_url_request_job_factory.cc |
| index cc600d1c228aa0d7ce467d5dd2160df67f939b0a..c7d845b346131852cabe586104c8a528c53c149f 100644 |
| --- a/webkit/browser/blob/blob_url_request_job_factory.cc |
| +++ b/webkit/browser/blob/blob_url_request_job_factory.cc |
| @@ -9,42 +9,51 @@ |
| #include "base/message_loop/message_loop_proxy.h" |
| #include "net/url_request/url_request.h" |
| #include "net/url_request/url_request_job_factory.h" |
| -#include "webkit/browser/blob/blob_storage_controller.h" |
| +#include "webkit/browser/blob/blob_data_handle.h" |
| #include "webkit/browser/blob/blob_url_request_job.h" |
| #include "webkit/browser/fileapi/file_system_context.h" |
| namespace webkit_blob { |
| +namespace { |
| +int kUserDataKey; // value is not important, the addr is a key |
| + |
| +BlobDataHandle* GetRequestedBlobDataHandle(net::URLRequest* request) { |
| + return reinterpret_cast<BlobDataHandle*>( |
|
kinuko
2013/08/21 10:22:20
Doesn't static_cast work here??
michaeln
2013/08/27 23:24:06
Done.
|
| + request->GetUserData(&kUserDataKey)); |
| +} |
| +} // namespace |
|
kinuko
2013/08/21 10:22:20
nit: can you insert empty lines after line 18 and
michaeln
2013/08/27 23:24:06
Done.
|
| + |
| +// static |
| +void BlobProtocolHandler::SetRequestedBlobDataHandle( |
| + net::URLRequest* request, |
| + scoped_ptr<BlobDataHandle> blob_data_handle) { |
| + // The request takes ownership |
|
kinuko
2013/08/21 10:22:20
nit: please end comments with period
ericu
2013/08/21 23:26:09
In this case, perhaps remove the comment? It's pr
michaeln
2013/08/27 23:24:06
Done.
|
| + request->SetUserData(&kUserDataKey, blob_data_handle.release()); |
| +} |
| + |
| BlobProtocolHandler::BlobProtocolHandler( |
| - webkit_blob::BlobStorageController* blob_storage_controller, |
| fileapi::FileSystemContext* file_system_context, |
| base::MessageLoopProxy* loop_proxy) |
| - : blob_storage_controller_(blob_storage_controller), |
| - file_system_context_(file_system_context), |
| + : file_system_context_(file_system_context), |
| file_loop_proxy_(loop_proxy) { |
| - DCHECK(blob_storage_controller_); |
| - DCHECK(file_system_context_.get()); |
|
ericu
2013/08/21 23:26:09
Why remove these DCHECKs?
michaeln
2013/08/27 23:24:06
Good question. Higher level code (storagepartition
|
| - DCHECK(file_loop_proxy_.get()); |
| } |
| -BlobProtocolHandler::~BlobProtocolHandler() {} |
| +BlobProtocolHandler::~BlobProtocolHandler() { |
| +} |
| net::URLRequestJob* BlobProtocolHandler::MaybeCreateJob( |
| net::URLRequest* request, net::NetworkDelegate* network_delegate) const { |
| - scoped_refptr<webkit_blob::BlobData> data = LookupBlobData(request); |
| - if (!data.get()) { |
| - // This request is not coming through resource dispatcher host. |
| - data = blob_storage_controller_->GetBlobDataFromUrl(request->url()); |
| - } |
| - return new webkit_blob::BlobURLRequestJob(request, |
| - network_delegate, |
| - data.get(), |
| - file_system_context_.get(), |
| - file_loop_proxy_.get()); |
| + return new webkit_blob::BlobURLRequestJob( |
| + request, network_delegate, LookupBlobData(request), |
| + file_system_context_, file_loop_proxy_); |
| } |
| scoped_refptr<webkit_blob::BlobData> |
| BlobProtocolHandler::LookupBlobData(net::URLRequest* request) const { |
| + BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request); |
| + if (blob_data_handle) |
| + return blob_data_handle->data(); |
| return NULL; |
| } |