OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
12 #include "net/base/file_stream.h" | 12 #include "net/base/file_stream.h" |
13 #include "net/http/http_byte_range.h" | 13 #include "net/http/http_byte_range.h" |
14 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
15 #include "net/url_request/url_request_job.h" | 15 #include "net/url_request/url_request_job.h" |
16 | 16 |
17 namespace file_util { | 17 namespace file_util { |
18 struct FileInfo; | 18 struct FileInfo; |
19 } | 19 } |
20 | 20 |
21 // A request job that handles reading file URLs | 21 // A request job that handles reading file URLs |
22 class URLRequestFileJob : public URLRequestJob { | 22 class URLRequestFileJob : public URLRequestJob { |
23 public: | 23 public: |
24 URLRequestFileJob(URLRequest* request, const FilePath& file_path); | 24 URLRequestFileJob(URLRequest* request, const FilePath& file_path); |
25 virtual ~URLRequestFileJob(); | |
26 | 25 |
27 virtual void Start(); | 26 virtual void Start(); |
28 virtual void Kill(); | 27 virtual void Kill(); |
29 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); | 28 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read); |
30 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 29 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); |
31 virtual bool GetContentEncodings( | 30 virtual bool GetContentEncodings( |
32 std::vector<Filter::FilterType>* encoding_type); | 31 std::vector<Filter::FilterType>* encoding_type); |
33 virtual bool GetMimeType(std::string* mime_type) const; | 32 virtual bool GetMimeType(std::string* mime_type) const; |
34 virtual void SetExtraRequestHeaders(const std::string& headers); | 33 virtual void SetExtraRequestHeaders(const std::string& headers); |
35 | 34 |
36 static URLRequest::ProtocolFactory Factory; | 35 static URLRequest::ProtocolFactory Factory; |
37 | 36 |
38 protected: | 37 protected: |
| 38 virtual ~URLRequestFileJob(); |
| 39 |
39 // The OS-specific full path name of the file | 40 // The OS-specific full path name of the file |
40 FilePath file_path_; | 41 FilePath file_path_; |
41 | 42 |
42 private: | 43 private: |
43 void DidResolve(bool exists, const file_util::FileInfo& file_info); | 44 void DidResolve(bool exists, const file_util::FileInfo& file_info); |
44 void DidRead(int result); | 45 void DidRead(int result); |
45 | 46 |
46 net::CompletionCallbackImpl<URLRequestFileJob> io_callback_; | 47 net::CompletionCallbackImpl<URLRequestFileJob> io_callback_; |
47 net::FileStream stream_; | 48 net::FileStream stream_; |
48 bool is_directory_; | 49 bool is_directory_; |
49 | 50 |
50 net::HttpByteRange byte_range_; | 51 net::HttpByteRange byte_range_; |
51 int64 remaining_bytes_; | 52 int64 remaining_bytes_; |
52 | 53 |
53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
54 class AsyncResolver; | 55 class AsyncResolver; |
55 friend class AsyncResolver; | 56 friend class AsyncResolver; |
56 scoped_refptr<AsyncResolver> async_resolver_; | 57 scoped_refptr<AsyncResolver> async_resolver_; |
57 #endif | 58 #endif |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 60 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
60 }; | 61 }; |
61 | 62 |
62 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 63 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
OLD | NEW |