| 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 does not lookup based on the request's url value. |
| 42 static void SetRequestedBlobDataHandle( |
| 43 net::URLRequest* request, |
| 44 scoped_ptr<BlobDataHandle> blob_data_handle); |
| 45 |
| 46 BlobProtocolHandler(fileapi::FileSystemContext* file_system_context, |
| 36 base::MessageLoopProxy* file_loop_proxy); | 47 base::MessageLoopProxy* file_loop_proxy); |
| 37 virtual ~BlobProtocolHandler(); | 48 virtual ~BlobProtocolHandler(); |
| 38 | 49 |
| 39 virtual net::URLRequestJob* MaybeCreateJob( | 50 virtual net::URLRequestJob* MaybeCreateJob( |
| 40 net::URLRequest* request, | 51 net::URLRequest* request, |
| 41 net::NetworkDelegate* network_delegate) const OVERRIDE; | 52 net::NetworkDelegate* network_delegate) const OVERRIDE; |
| 42 | 53 |
| 43 private: | 54 private: |
| 44 virtual scoped_refptr<BlobData> LookupBlobData( | 55 scoped_refptr<BlobData> LookupBlobData( |
| 45 net::URLRequest* request) const; | 56 net::URLRequest* request) const; |
| 46 | 57 |
| 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_; | 58 const scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
| 51 const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_; | 59 const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_; |
| 52 | 60 |
| 53 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); | 61 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); |
| 54 }; | 62 }; |
| 55 | 63 |
| 56 } // namespace webkit_blob | 64 } // namespace webkit_blob |
| 57 | 65 |
| 58 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ | 66 #endif // WEBKIT_BROWSER_BLOB_BLOB_URL_REQUEST_JOB_FACTORY_H_ |
| OLD | NEW |