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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 ExternalFileURLRequestJob(void* profile_id, | 56 ExternalFileURLRequestJob(void* profile_id, |
57 net::URLRequest* request, | 57 net::URLRequest* request, |
58 net::NetworkDelegate* network_delegate); | 58 net::NetworkDelegate* network_delegate); |
59 | 59 |
60 // net::URLRequestJob overrides: | 60 // net::URLRequestJob overrides: |
61 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; | 61 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; |
62 void Start() override; | 62 void Start() override; |
63 void Kill() override; | 63 void Kill() override; |
64 bool GetMimeType(std::string* mime_type) const override; | 64 bool GetMimeType(std::string* mime_type) const override; |
65 bool IsRedirectResponse(GURL* location, int* http_status_code) override; | 65 bool IsRedirectResponse(GURL* location, int* http_status_code) override; |
66 int ReadRawData(net::IOBuffer* buf, int buf_size) override; | 66 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; |
67 | 67 |
68 protected: | 68 protected: |
69 ~ExternalFileURLRequestJob() override; | 69 ~ExternalFileURLRequestJob() override; |
70 | 70 |
71 private: | 71 private: |
72 // Helper method to start the job. Should be called asynchronously because | |
73 // NotifyStartError() is not legal to call synchronously in | |
74 // URLRequestJob::Start(). | |
75 void StartAsync(); | |
76 | |
77 // Called from an internal helper class defined in drive_url_request_job.cc, | 72 // Called from an internal helper class defined in drive_url_request_job.cc, |
78 // which is running on the UI thread. | 73 // which is running on the UI thread. |
79 void OnHelperResultObtained( | 74 void OnHelperResultObtained( |
80 net::Error error, | 75 net::Error error, |
81 const scoped_refptr<storage::FileSystemContext>& file_system_context, | 76 const scoped_refptr<storage::FileSystemContext>& file_system_context, |
82 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope, | 77 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope, |
83 const storage::FileSystemURL& file_system_url, | 78 const storage::FileSystemURL& file_system_url, |
84 const std::string& mime_type); | 79 const std::string& mime_type); |
85 | 80 |
86 // Called from FileSystemBackend::GetRedirectURLForContents. | 81 // Called from FileSystemBackend::GetRedirectURLForContents. |
87 void OnRedirectURLObtained(const GURL& redirect_url); | 82 void OnRedirectURLObtained(const GURL& redirect_url); |
88 | 83 |
89 // Called from DriveURLRequestJob::OnFileInfoObtained. | 84 // Called from DriveURLRequestJob::OnFileInfoObtained. |
90 void OnFileInfoObtained(base::File::Error result, | 85 void OnFileInfoObtained(base::File::Error result, |
91 const base::File::Info& file_info); | 86 const base::File::Info& file_info); |
92 | 87 |
93 // Called when DriveFileStreamReader::Read is completed. | 88 // Called when DriveFileStreamReader::Read is completed. |
94 void OnReadCompleted(int read_result); | 89 void OnReadCompleted(int read_result); |
95 | 90 |
96 void* const profile_id_; | 91 void* const profile_id_; |
97 | 92 |
98 // The range of the file to be returned. | 93 // The range of the file to be returned. |
99 net::Error range_parse_result_; | |
100 net::HttpByteRange byte_range_; | 94 net::HttpByteRange byte_range_; |
101 int64 remaining_bytes_; | 95 int64 remaining_bytes_; |
102 | 96 |
103 scoped_refptr<storage::FileSystemContext> file_system_context_; | 97 scoped_refptr<storage::FileSystemContext> file_system_context_; |
104 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope_; | 98 scoped_ptr<IsolatedFileSystemScope> isolated_file_system_scope_; |
105 storage::FileSystemURL file_system_url_; | 99 storage::FileSystemURL file_system_url_; |
106 std::string mime_type_; | 100 std::string mime_type_; |
107 scoped_ptr<storage::FileStreamReader> stream_reader_; | 101 scoped_ptr<storage::FileStreamReader> stream_reader_; |
108 GURL redirect_url_; | 102 GURL redirect_url_; |
109 | 103 |
110 // This should remain the last member so it'll be destroyed first and | 104 // This should remain the last member so it'll be destroyed first and |
111 // invalidate its weak pointers before other members are destroyed. | 105 // invalidate its weak pointers before other members are destroyed. |
112 base::WeakPtrFactory<ExternalFileURLRequestJob> weak_ptr_factory_; | 106 base::WeakPtrFactory<ExternalFileURLRequestJob> weak_ptr_factory_; |
113 DISALLOW_COPY_AND_ASSIGN(ExternalFileURLRequestJob); | 107 DISALLOW_COPY_AND_ASSIGN(ExternalFileURLRequestJob); |
114 }; | 108 }; |
115 | 109 |
116 } // namespace chromeos | 110 } // namespace chromeos |
117 | 111 |
118 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ | 112 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_EXTERNAL_FILE_URL_REQUEST_JOB_H_ |
OLD | NEW |