OLD | NEW |
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 #ifndef WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 5 #ifndef WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ |
6 #define WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 6 #define WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/url_request/url_request.h" |
10 #include "net/url_request/url_request_job_factory.h" | 12 #include "net/url_request/url_request_job_factory.h" |
11 #include "webkit/browser/webkit_storage_browser_export.h" | 13 #include "webkit/browser/webkit_storage_browser_export.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 class MessageLoopProxy; | 16 class MessageLoopProxy; |
15 } // namespace base | 17 } // namespace base |
16 | 18 |
17 namespace fileapi { | 19 namespace fileapi { |
18 class FileSystemContext; | 20 class FileSystemContext; |
19 } // namespace fileapi | 21 } // namespace fileapi |
20 | 22 |
21 namespace net { | 23 namespace net { |
22 class URLRequest; | 24 class URLRequestContext; |
23 } // namespace net | 25 } // namespace net |
24 | 26 |
25 namespace webkit_blob { | 27 namespace webkit_blob { |
26 | 28 |
27 class BlobData; | 29 class BlobData; |
28 class BlobStorageController; | 30 class BlobDataHandle; |
29 | 31 |
30 class WEBKIT_STORAGE_BROWSER_EXPORT BlobProtocolHandler | 32 class WEBKIT_STORAGE_BROWSER_EXPORT BlobProtocolHandler |
31 : public net::URLRequestJobFactory::ProtocolHandler { | 33 : public net::URLRequestJobFactory::ProtocolHandler { |
32 public: | 34 public: |
33 // |controller|'s lifetime should exceed the lifetime of the ProtocolHandler. | 35 // A helper to manufacture an URLRequest to retrieve the given blob. |
34 BlobProtocolHandler(BlobStorageController* blob_storage_controller, | 36 static net::URLRequest* CreateBlobRequest( |
35 fileapi::FileSystemContext* file_system_context, | 37 scoped_ptr<BlobDataHandle> blob_data_handle, |
| 38 const net::URLRequestContext* request_context, |
| 39 net::URLRequest::Delegate* request_delegate); |
| 40 |
| 41 // This class ignores the request's URL and uses the value given |
| 42 // to SetRequestedBlobDataHandle instead. |
| 43 static void SetRequestedBlobDataHandle( |
| 44 net::URLRequest* request, |
| 45 scoped_ptr<BlobDataHandle> blob_data_handle); |
| 46 |
| 47 BlobProtocolHandler(fileapi::FileSystemContext* file_system_context, |
36 base::MessageLoopProxy* file_loop_proxy); | 48 base::MessageLoopProxy* file_loop_proxy); |
37 virtual ~BlobProtocolHandler(); | 49 virtual ~BlobProtocolHandler(); |
38 | 50 |
39 virtual net::URLRequestJob* MaybeCreateJob( | 51 virtual net::URLRequestJob* MaybeCreateJob( |
40 net::URLRequest* request, | 52 net::URLRequest* request, |
41 net::NetworkDelegate* network_delegate) const OVERRIDE; | 53 net::NetworkDelegate* network_delegate) const OVERRIDE; |
42 | 54 |
43 private: | 55 private: |
44 virtual scoped_refptr<BlobData> LookupBlobData( | 56 scoped_refptr<BlobData> LookupBlobData( |
45 net::URLRequest* request) const; | 57 net::URLRequest* request) const; |
46 | 58 |
47 // No scoped_refptr because |blob_storage_controller_| is owned by the | |
48 // ProfileIOData, which also owns this ProtocolHandler. | |
49 BlobStorageController* const blob_storage_controller_; | |
50 const scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 59 const scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
51 const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_; | 60 const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_; |
52 | 61 |
53 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); | 62 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); |
54 }; | 63 }; |
55 | 64 |
56 } // namespace webkit_blob | 65 } // namespace webkit_blob |
57 | 66 |
58 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 67 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ |
OLD | NEW |