| 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 STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ |
| 6 #define STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 6 #define STORAGE_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" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
| 12 #include "net/url_request/url_request_job_factory.h" | 12 #include "net/url_request/url_request_job_factory.h" |
| 13 #include "storage/browser/storage_browser_export.h" | 13 #include "storage/browser/storage_browser_export.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
| 17 } // namespace base | 17 } // namespace base |
| 18 | 18 |
| 19 namespace storage { | 19 namespace storage { |
| 20 class FileSystemContext; | 20 class FileSystemContext; |
| 21 } // namespace storage | 21 } // namespace storage |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 class URLRequestContext; | 24 class URLRequestContext; |
| 25 } // namespace net | 25 } // namespace net |
| 26 | 26 |
| 27 namespace storage { | 27 namespace storage { |
| 28 | 28 |
| 29 class BlobDataSnapshot; |
| 29 class BlobDataHandle; | 30 class BlobDataHandle; |
| 30 class BlobStorageContext; | 31 class BlobStorageContext; |
| 31 | 32 |
| 32 class STORAGE_EXPORT BlobProtocolHandler | 33 class STORAGE_EXPORT BlobProtocolHandler |
| 33 : public net::URLRequestJobFactory::ProtocolHandler { | 34 : public net::URLRequestJobFactory::ProtocolHandler { |
| 34 public: | 35 public: |
| 35 // A helper to manufacture an URLRequest to retrieve the given blob. | 36 // A helper to manufacture an URLRequest to retrieve the given blob. |
| 36 static scoped_ptr<net::URLRequest> CreateBlobRequest( | 37 static scoped_ptr<net::URLRequest> CreateBlobRequest( |
| 37 scoped_ptr<BlobDataHandle> blob_data_handle, | 38 scoped_ptr<BlobDataHandle> blob_data_handle, |
| 38 const net::URLRequestContext* request_context, | 39 const net::URLRequestContext* request_context, |
| 39 net::URLRequest::Delegate* request_delegate); | 40 net::URLRequest::Delegate* request_delegate); |
| 40 | 41 |
| 41 // This class ignores the request's URL and uses the value given | 42 // This class ignores the request's URL and uses the value given |
| 42 // to SetRequestedBlobDataHandle instead. | 43 // to SetRequestedBlobDataHandle instead. |
| 43 static void SetRequestedBlobDataHandle( | 44 static void SetRequestedBlobDataHandle( |
| 44 net::URLRequest* request, | 45 net::URLRequest* request, |
| 45 scoped_ptr<BlobDataHandle> blob_data_handle); | 46 scoped_ptr<BlobDataHandle> blob_data_handle); |
| 46 | 47 |
| 47 // This gets the handle on the request if it exists. | |
| 48 static BlobDataHandle* GetRequestBlobDataHandle(net::URLRequest* request); | |
| 49 | |
| 50 BlobProtocolHandler( | 48 BlobProtocolHandler( |
| 51 BlobStorageContext* context, | 49 BlobStorageContext* context, |
| 52 storage::FileSystemContext* file_system_context, | 50 storage::FileSystemContext* file_system_context, |
| 53 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); | 51 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); |
| 54 ~BlobProtocolHandler() override; | 52 ~BlobProtocolHandler() override; |
| 55 | 53 |
| 56 net::URLRequestJob* MaybeCreateJob( | 54 net::URLRequestJob* MaybeCreateJob( |
| 57 net::URLRequest* request, | 55 net::URLRequest* request, |
| 58 net::NetworkDelegate* network_delegate) const override; | 56 net::NetworkDelegate* network_delegate) const override; |
| 59 | 57 |
| 60 private: | 58 private: |
| 61 BlobDataHandle* LookupBlobHandle(net::URLRequest* request) const; | 59 scoped_ptr<BlobDataSnapshot> LookupBlobData(net::URLRequest* request) const; |
| 62 | 60 |
| 63 base::WeakPtr<BlobStorageContext> context_; | 61 base::WeakPtr<BlobStorageContext> context_; |
| 64 const scoped_refptr<storage::FileSystemContext> file_system_context_; | 62 const scoped_refptr<storage::FileSystemContext> file_system_context_; |
| 65 const scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 63 const scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 66 | 64 |
| 67 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); | 65 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); |
| 68 }; | 66 }; |
| 69 | 67 |
| 70 } // namespace storage | 68 } // namespace storage |
| 71 | 69 |
| 72 #endif // STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 70 #endif // STORAGE_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ |
| OLD | NEW |