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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/weak_ptr.h" |
13 #include "net/base/file_stream.h" | 14 #include "net/base/file_stream.h" |
14 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
15 #include "net/http/http_byte_range.h" | 16 #include "net/http/http_byte_range.h" |
16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
17 #include "net/url_request/url_request_job.h" | 18 #include "net/url_request/url_request_job.h" |
18 | 19 |
19 namespace file_util { | 20 namespace file_util { |
20 struct FileInfo; | 21 struct FileInfo; |
21 } | 22 } |
22 | 23 |
(...skipping 30 matching lines...) Expand all Loading... |
53 FilePath file_path_; | 54 FilePath file_path_; |
54 | 55 |
55 private: | 56 private: |
56 // Tests to see if access to |path| is allowed. If g_allow_file_access_ is | 57 // Tests to see if access to |path| is allowed. If g_allow_file_access_ is |
57 // true, then this will return true. If the NetworkDelegate associated with | 58 // true, then this will return true. If the NetworkDelegate associated with |
58 // the |request| says it's OK, then this will also return true. | 59 // the |request| says it's OK, then this will also return true. |
59 static bool IsFileAccessAllowed(const URLRequest& request, | 60 static bool IsFileAccessAllowed(const URLRequest& request, |
60 const FilePath& path); | 61 const FilePath& path); |
61 | 62 |
62 // Callback after fetching file info on a background thread. | 63 // Callback after fetching file info on a background thread. |
63 void DidResolve(bool exists, const base::PlatformFileInfo& file_info); | 64 void DidResolveAndMimeType(const bool* exists, |
| 65 const base::PlatformFileInfo* file_info, |
| 66 const bool* mime_type_result, |
| 67 const std::string* read_mime_type); |
| 68 |
| 69 // Callback after opening file on a background thread. |
| 70 void DidOpen(int result); |
| 71 |
| 72 // Callback after seeking to necessary position in the file which is done |
| 73 // on a background thread. |
| 74 void DidSeek(int64 result); |
64 | 75 |
65 // Callback after data is asynchronously read from the file. | 76 // Callback after data is asynchronously read from the file. |
66 void DidRead(int result); | 77 void DidRead(int result); |
67 | 78 |
68 FileStream stream_; | 79 FileStream stream_; |
69 bool is_directory_; | 80 bool is_directory_; |
| 81 bool mime_type_result_; |
| 82 std::string mime_type_; |
| 83 int64 file_size_; |
70 | 84 |
71 HttpByteRange byte_range_; | 85 HttpByteRange byte_range_; |
72 int64 remaining_bytes_; | 86 int64 remaining_bytes_; |
73 | 87 |
74 // The initial file metadata is fetched on a background thread. | 88 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; |
75 // AsyncResolver runs that task. | |
76 class AsyncResolver; | |
77 friend class AsyncResolver; | |
78 scoped_refptr<AsyncResolver> async_resolver_; | |
79 | 89 |
80 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 90 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
81 }; | 91 }; |
82 | 92 |
83 } // namespace net | 93 } // namespace net |
84 | 94 |
85 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 95 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
OLD | NEW |