| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class NetworkDelegate; | 22 class NetworkDelegate; |
| 23 class URLRequest; | 23 class URLRequest; |
| 24 } // namespace net | 24 } // namespace net |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 // ExternalFileURLRequestJob is the gateway between network-level drive:... | 28 // ExternalFileURLRequestJob is the gateway between network-level drive:... |
| 29 // requests for drive resources and FileSystem. It exposes content URLs | 29 // requests for drive resources and FileSystem. It exposes content URLs |
| 30 // formatted as drive:<drive-file-path>. | 30 // formatted as drive:<drive-file-path>. |
| 31 // The methods should be run on IO thread. | 31 // The methods should be run on IO thread. |
| 32 // TODO(hirono): After removing MHTML support, stop to use the special |
| 33 // externalfile: scheme and use filesystem: URL directly. crbug.com/415455 |
| 32 class ExternalFileURLRequestJob : public net::URLRequestJob { | 34 class ExternalFileURLRequestJob : public net::URLRequestJob { |
| 33 public: | 35 public: |
| 36 // Scope of isolated file system. |
| 37 class IsolatedFileSystemScope { |
| 38 public: |
| 39 explicit IsolatedFileSystemScope(const std::string& file_system_id); |
| 40 ~IsolatedFileSystemScope(); |
| 41 |
| 42 private: |
| 43 std::string file_system_id_; |
| 44 DISALLOW_COPY_AND_ASSIGN(IsolatedFileSystemScope); |
| 45 }; |
| 46 |
| 34 // Callback to take results from an internal helper defined in | 47 // Callback to take results from an internal helper defined in |
| 35 // drive_url_request_job.cc. | 48 // drive_url_request_job.cc. |
| 36 typedef base::Callback< | 49 typedef base::Callback<void( |
| 37 void(net::Error, | 50 net::Error, |
| 38 const scoped_refptr<storage::FileSystemContext>& file_system_context, | 51 const scoped_refptr<storage::FileSystemContext>& file_system_context, |
| 39 const storage::FileSystemURL& file_system_url, | 52 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope, |
| 40 const std::string& mime_type)> HelperCallback; | 53 const storage::FileSystemURL& file_system_url, |
| 54 const std::string& mime_type)> HelperCallback; |
| 41 | 55 |
| 42 ExternalFileURLRequestJob(void* profile_id, | 56 ExternalFileURLRequestJob(void* profile_id, |
| 43 net::URLRequest* request, | 57 net::URLRequest* request, |
| 44 net::NetworkDelegate* network_delegate); | 58 net::NetworkDelegate* network_delegate); |
| 45 | 59 |
| 46 // net::URLRequestJob overrides: | 60 // net::URLRequestJob overrides: |
| 47 virtual void SetExtraRequestHeaders( | 61 virtual void SetExtraRequestHeaders( |
| 48 const net::HttpRequestHeaders& headers) OVERRIDE; | 62 const net::HttpRequestHeaders& headers) OVERRIDE; |
| 49 virtual void Start() OVERRIDE; | 63 virtual void Start() OVERRIDE; |
| 50 virtual void Kill() OVERRIDE; | 64 virtual void Kill() OVERRIDE; |
| 51 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 65 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 52 virtual bool IsRedirectResponse(GURL* location, | 66 virtual bool IsRedirectResponse(GURL* location, |
| 53 int* http_status_code) OVERRIDE; | 67 int* http_status_code) OVERRIDE; |
| 54 virtual bool ReadRawData(net::IOBuffer* buf, | 68 virtual bool ReadRawData(net::IOBuffer* buf, |
| 55 int buf_size, | 69 int buf_size, |
| 56 int* bytes_read) OVERRIDE; | 70 int* bytes_read) OVERRIDE; |
| 57 | 71 |
| 58 protected: | 72 protected: |
| 59 virtual ~ExternalFileURLRequestJob(); | 73 virtual ~ExternalFileURLRequestJob(); |
| 60 | 74 |
| 61 private: | 75 private: |
| 62 // Called from an internal helper class defined in drive_url_request_job.cc, | 76 // Called from an internal helper class defined in drive_url_request_job.cc, |
| 63 // which is running on the UI thread. | 77 // which is running on the UI thread. |
| 64 void OnHelperResultObtained( | 78 void OnHelperResultObtained( |
| 65 net::Error error, | 79 net::Error error, |
| 66 const scoped_refptr<storage::FileSystemContext>& file_system_context, | 80 const scoped_refptr<storage::FileSystemContext>& file_system_context, |
| 81 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope, |
| 67 const storage::FileSystemURL& file_system_url, | 82 const storage::FileSystemURL& file_system_url, |
| 68 const std::string& mime_type); | 83 const std::string& mime_type); |
| 69 | 84 |
| 70 // Called from FileSystemBackend::GetRedirectURLForContents. | 85 // Called from FileSystemBackend::GetRedirectURLForContents. |
| 71 void OnRedirectURLObtained(const GURL& redirect_url); | 86 void OnRedirectURLObtained(const GURL& redirect_url); |
| 72 | 87 |
| 73 // Called from DriveURLRequestJob::OnFileInfoObtained. | 88 // Called from DriveURLRequestJob::OnFileInfoObtained. |
| 74 void OnFileInfoObtained(base::File::Error result, | 89 void OnFileInfoObtained(base::File::Error result, |
| 75 const base::File::Info& file_info); | 90 const base::File::Info& file_info); |
| 76 | 91 |
| 77 // Called when DriveFileStreamReader::Read is completed. | 92 // Called when DriveFileStreamReader::Read is completed. |
| 78 void OnReadCompleted(int read_result); | 93 void OnReadCompleted(int read_result); |
| 79 | 94 |
| 80 void* const profile_id_; | 95 void* const profile_id_; |
| 81 | 96 |
| 82 // The range of the file to be returned. | 97 // The range of the file to be returned. |
| 83 net::HttpByteRange byte_range_; | 98 net::HttpByteRange byte_range_; |
| 84 int64 remaining_bytes_; | 99 int64 remaining_bytes_; |
| 85 | 100 |
| 86 scoped_refptr<storage::FileSystemContext> file_system_context_; | 101 scoped_refptr<storage::FileSystemContext> file_system_context_; |
| 102 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope_; |
| 87 storage::FileSystemURL file_system_url_; | 103 storage::FileSystemURL file_system_url_; |
| 88 std::string mime_type_; | 104 std::string mime_type_; |
| 89 scoped_ptr<storage::FileStreamReader> stream_reader_; | 105 scoped_ptr<storage::FileStreamReader> stream_reader_; |
| 90 GURL redirect_url_; | 106 GURL redirect_url_; |
| 91 | 107 |
| 92 // This should remain the last member so it'll be destroyed first and | 108 // This should remain the last member so it'll be destroyed first and |
| 93 // invalidate its weak pointers before other members are destroyed. | 109 // invalidate its weak pointers before other members are destroyed. |
| 94 base::WeakPtrFactory<ExternalFileURLRequestJob> weak_ptr_factory_; | 110 base::WeakPtrFactory<ExternalFileURLRequestJob> weak_ptr_factory_; |
| 95 DISALLOW_COPY_AND_ASSIGN(ExternalFileURLRequestJob); | 111 DISALLOW_COPY_AND_ASSIGN(ExternalFileURLRequestJob); |
| 96 }; | 112 }; |
| 97 | 113 |
| 98 } // namespace chromeos | 114 } // namespace chromeos |
| 99 | 115 |
| 100 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ | 116 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ |
| OLD | NEW |