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 <memory> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // URLRequestJob implementation. | 66 // URLRequestJob implementation. |
67 std::unique_ptr<SourceStream> SetUpSourceStream() override; | 67 std::unique_ptr<SourceStream> SetUpSourceStream() override; |
68 | 68 |
69 int64_t remaining_bytes() const { return remaining_bytes_; } | 69 int64_t remaining_bytes() const { return remaining_bytes_; } |
70 | 70 |
71 // The OS-specific full path name of the file | 71 // The OS-specific full path name of the file |
72 base::FilePath file_path_; | 72 base::FilePath file_path_; |
73 | 73 |
74 private: | 74 private: |
| 75 // This class checks if a path is accessible via file: scheme, with |
| 76 // NetworkDelegate. Subclasses can disable the check if needed. |
| 77 virtual bool CanAccessFile(const base::FilePath& original_path, |
| 78 const base::FilePath& absolute_path); |
| 79 |
75 // Meta information about the file. It's used as a member in the | 80 // Meta information about the file. It's used as a member in the |
76 // URLRequestFileJob and also passed between threads because disk access is | 81 // URLRequestFileJob and also passed between threads because disk access is |
77 // necessary to obtain it. | 82 // necessary to obtain it. |
78 struct FileMetaInfo { | 83 struct FileMetaInfo { |
79 FileMetaInfo(); | 84 FileMetaInfo(); |
80 | 85 |
81 // Size of the file. | 86 // Size of the file. |
82 int64_t file_size; | 87 int64_t file_size; |
83 // Mime type associated with the file. | 88 // Mime type associated with the file. |
84 std::string mime_type; | 89 std::string mime_type; |
85 // Result returned from GetMimeTypeFromFile(), i.e. flag showing whether | 90 // Result returned from GetMimeTypeFromFile(), i.e. flag showing whether |
86 // obtaining of the mime type was successful. | 91 // obtaining of the mime type was successful. |
87 bool mime_type_result; | 92 bool mime_type_result; |
88 // Flag showing whether the file exists. | 93 // Flag showing whether the file exists. |
89 bool file_exists; | 94 bool file_exists; |
90 // Flag showing whether the file name actually refers to a directory. | 95 // Flag showing whether the file name actually refers to a directory. |
91 bool is_directory; | 96 bool is_directory; |
| 97 // Absolute path of the file (i.e. symbolic link is resolved). |
| 98 base::FilePath absolute_path; |
92 }; | 99 }; |
93 | 100 |
94 // Fetches file info on a background thread. | 101 // Fetches file info on a background thread. |
95 static void FetchMetaInfo(const base::FilePath& file_path, | 102 static void FetchMetaInfo(const base::FilePath& file_path, |
96 FileMetaInfo* meta_info); | 103 FileMetaInfo* meta_info); |
97 | 104 |
98 // Callback after fetching file info on a background thread. | 105 // Callback after fetching file info on a background thread. |
99 void DidFetchMetaInfo(const FileMetaInfo* meta_info); | 106 void DidFetchMetaInfo(const FileMetaInfo* meta_info); |
100 | 107 |
101 // Callback after opening file on a background thread. | 108 // Callback after opening file on a background thread. |
(...skipping 17 matching lines...) Expand all Loading... |
119 Error range_parse_result_; | 126 Error range_parse_result_; |
120 | 127 |
121 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; | 128 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; |
122 | 129 |
123 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 130 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
124 }; | 131 }; |
125 | 132 |
126 } // namespace net | 133 } // namespace net |
127 | 134 |
128 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 135 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
OLD | NEW |