OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
19 #include "net/http/http_byte_range.h" | 20 #include "net/http/http_byte_range.h" |
(...skipping 17 matching lines...) Expand all Loading... |
37 URLRequestFileJob(URLRequest* request, | 38 URLRequestFileJob(URLRequest* request, |
38 NetworkDelegate* network_delegate, | 39 NetworkDelegate* network_delegate, |
39 const base::FilePath& file_path, | 40 const base::FilePath& file_path, |
40 const scoped_refptr<base::TaskRunner>& file_task_runner); | 41 const scoped_refptr<base::TaskRunner>& file_task_runner); |
41 | 42 |
42 // URLRequestJob: | 43 // URLRequestJob: |
43 void Start() override; | 44 void Start() override; |
44 void Kill() override; | 45 void Kill() override; |
45 int ReadRawData(IOBuffer* buf, int buf_size) override; | 46 int ReadRawData(IOBuffer* buf, int buf_size) override; |
46 bool IsRedirectResponse(GURL* location, int* http_status_code) override; | 47 bool IsRedirectResponse(GURL* location, int* http_status_code) override; |
47 std::unique_ptr<Filter> SetupFilter() const override; | |
48 bool GetMimeType(std::string* mime_type) const override; | 48 bool GetMimeType(std::string* mime_type) const override; |
49 void SetExtraRequestHeaders(const HttpRequestHeaders& headers) override; | 49 void SetExtraRequestHeaders(const HttpRequestHeaders& headers) override; |
50 | 50 |
51 // An interface for subclasses who wish to monitor read operations. | 51 // An interface for subclasses who wish to monitor read operations. |
52 virtual void OnSeekComplete(int64_t result); | 52 virtual void OnSeekComplete(int64_t result); |
53 virtual void OnReadComplete(IOBuffer* buf, int result); | 53 virtual void OnReadComplete(IOBuffer* buf, int result); |
54 | 54 |
55 protected: | 55 protected: |
56 ~URLRequestFileJob() override; | 56 ~URLRequestFileJob() override; |
57 | 57 |
| 58 // URLRequestJob implementation. |
| 59 std::unique_ptr<SourceStream> SetUpSourceStream() override; |
| 60 |
58 int64_t remaining_bytes() const { return remaining_bytes_; } | 61 int64_t remaining_bytes() const { return remaining_bytes_; } |
59 | 62 |
60 // The OS-specific full path name of the file | 63 // The OS-specific full path name of the file |
61 base::FilePath file_path_; | 64 base::FilePath file_path_; |
62 | 65 |
63 private: | 66 private: |
64 // Meta information about the file. It's used as a member in the | 67 // Meta information about the file. It's used as a member in the |
65 // URLRequestFileJob and also passed between threads because disk access is | 68 // URLRequestFileJob and also passed between threads because disk access is |
66 // necessary to obtain it. | 69 // necessary to obtain it. |
67 struct FileMetaInfo { | 70 struct FileMetaInfo { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 Error range_parse_result_; | 111 Error range_parse_result_; |
109 | 112 |
110 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; | 113 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; |
111 | 114 |
112 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 115 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
113 }; | 116 }; |
114 | 117 |
115 } // namespace net | 118 } // namespace net |
116 | 119 |
117 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 120 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
OLD | NEW |