Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Side by Side Diff: webkit/blob/blob_url_request_job_factory.cc

Issue 11410019: ********** Chromium Blob hacking (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/blob/blob_url_request_job_factory.h ('k') | webkit/blob/view_blob_internals_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/blob/blob_url_request_job_factory.h" 5 #include "webkit/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_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "net/url_request/url_request.h" 10 #include "net/url_request/url_request.h"
11 #include "net/url_request/url_request_job_factory.h" 11 #include "net/url_request/url_request_job_factory.h"
12 #include "webkit/blob/blob_storage_controller.h" 12 #include "webkit/blob/blob_storage_context.h"
13 #include "webkit/blob/blob_url_request_job.h" 13 #include "webkit/blob/blob_url_request_job.h"
14 #include "webkit/fileapi/file_system_context.h" 14 #include "webkit/fileapi/file_system_context.h"
15 15
16 namespace webkit_blob { 16 namespace webkit_blob {
17 17
18 namespace {
19 int kUserDataKey;
20
21 BlobDataHandle* GetRequestedBlobDataHandle(net::URLRequest* request) {
22 return reinterpret_cast<BlobDataHandle*>(
23 request->GetUserData(&kUserDataKey));
24 }
25 } // namespace
26
27 void BlobProtocolHandler::SetRequestedBlobDataHandle(
28 net::URLRequest* request,
29 scoped_ptr<BlobDataHandle> blob_data_handle) {
30 // The request takes ownership
31 request->SetUserData(&kUserDataKey, blob_data_handle.release());
32 }
33
18 BlobProtocolHandler::BlobProtocolHandler( 34 BlobProtocolHandler::BlobProtocolHandler(
19 webkit_blob::BlobStorageController* blob_storage_controller, 35 webkit_blob::BlobStorageContext* blob_storage_context,
20 fileapi::FileSystemContext* file_system_context, 36 fileapi::FileSystemContext* file_system_context,
21 base::MessageLoopProxy* loop_proxy) 37 base::MessageLoopProxy* loop_proxy)
22 : blob_storage_controller_(blob_storage_controller), 38 : file_system_context_(file_system_context),
23 file_system_context_(file_system_context),
24 file_loop_proxy_(loop_proxy) { 39 file_loop_proxy_(loop_proxy) {
25 DCHECK(blob_storage_controller_);
26 DCHECK(file_system_context_);
27 DCHECK(file_loop_proxy_);
28 } 40 }
29 41
30 BlobProtocolHandler::~BlobProtocolHandler() {} 42 BlobProtocolHandler::~BlobProtocolHandler() {}
31 43
32 net::URLRequestJob* BlobProtocolHandler::MaybeCreateJob( 44 net::URLRequestJob* BlobProtocolHandler::MaybeCreateJob(
33 net::URLRequest* request, net::NetworkDelegate* network_delegate) const { 45 net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
34 scoped_refptr<webkit_blob::BlobData> data = LookupBlobData(request);
35 if (!data) {
36 // This request is not coming through resource dispatcher host.
37 data = blob_storage_controller_->GetBlobDataFromUrl(request->url());
38 }
39 return new webkit_blob::BlobURLRequestJob( 46 return new webkit_blob::BlobURLRequestJob(
40 request, network_delegate, data, file_system_context_, file_loop_proxy_); 47 request, network_delegate, LookupBlobData(request), file_system_context_, file_loop_proxy_);
41 } 48 }
42 49
43 scoped_refptr<webkit_blob::BlobData> 50 scoped_refptr<webkit_blob::BlobData>
44 BlobProtocolHandler::LookupBlobData(net::URLRequest* request) const { 51 BlobProtocolHandler::LookupBlobData(net::URLRequest* request) const {
52 // We don't lookup based on the requested url. The caller is responsible for
53 // Setting up what blob to retrieve by calling SetRequestedBlobDataHandle prio r
54 // to starting the URLRequest.
55 BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request);
56 if (blob_data_handle)
57 return blob_data_handle->data();
45 return NULL; 58 return NULL;
46 } 59 }
47 60
48 } // namespace webkit_blob 61 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/blob_url_request_job_factory.h ('k') | webkit/blob/view_blob_internals_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698