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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_
6 #define WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "net/url_request/url_request.h"
12 #include "net/url_request/url_request_job_factory.h"
13 #include "webkit/browser/webkit_storage_browser_export.h"
16 class MessageLoopProxy;
20 class FileSystemContext;
21 } // namespace fileapi
24 class URLRequestContext;
27 namespace webkit_blob {
31 class BlobStorageContext;
33 class WEBKIT_STORAGE_BROWSER_EXPORT BlobProtocolHandler
34 : public net::URLRequestJobFactory::ProtocolHandler {
36 // A helper to manufacture an URLRequest to retrieve the given blob.
37 static scoped_ptr<net::URLRequest> CreateBlobRequest(
38 scoped_ptr<BlobDataHandle> blob_data_handle,
39 const net::URLRequestContext* request_context,
40 net::URLRequest::Delegate* request_delegate);
42 // This class ignores the request's URL and uses the value given
43 // to SetRequestedBlobDataHandle instead.
44 static void SetRequestedBlobDataHandle(
45 net::URLRequest* request,
46 scoped_ptr<BlobDataHandle> blob_data_handle);
48 BlobProtocolHandler(BlobStorageContext* context,
49 fileapi::FileSystemContext* file_system_context,
50 base::MessageLoopProxy* file_loop_proxy);
51 virtual ~BlobProtocolHandler();
53 virtual net::URLRequestJob* MaybeCreateJob(
54 net::URLRequest* request,
55 net::NetworkDelegate* network_delegate) const OVERRIDE;
58 scoped_refptr<BlobData> LookupBlobData(
59 net::URLRequest* request) const;
61 base::WeakPtr<BlobStorageContext> context_;
62 const scoped_refptr<fileapi::FileSystemContext> file_system_context_;
63 const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_;
65 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler);
68 } // namespace webkit_blob
70 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_