OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/file_input_stream.h" | 10 #include "net/base/file_stream.h" |
11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
12 #include "net/url_request/url_request_job.h" | 12 #include "net/url_request/url_request_job.h" |
13 | 13 |
14 // A request job that handles reading file URLs | 14 // A request job that handles reading file URLs |
15 class URLRequestFileJob : public URLRequestJob { | 15 class URLRequestFileJob : public URLRequestJob { |
16 public: | 16 public: |
17 URLRequestFileJob(URLRequest* request); | 17 URLRequestFileJob(URLRequest* request); |
18 virtual ~URLRequestFileJob(); | 18 virtual ~URLRequestFileJob(); |
19 | 19 |
20 virtual void Start(); | 20 virtual void Start(); |
21 virtual void Kill(); | 21 virtual void Kill(); |
22 virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); | 22 virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); |
23 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 23 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); |
24 virtual bool GetMimeType(std::string* mime_type); | 24 virtual bool GetMimeType(std::string* mime_type); |
25 | 25 |
26 static URLRequest::ProtocolFactory Factory; | 26 static URLRequest::ProtocolFactory Factory; |
27 | 27 |
28 protected: | 28 protected: |
29 // The OS-specific full path name of the file | 29 // The OS-specific full path name of the file |
30 std::wstring file_path_; | 30 std::wstring file_path_; |
31 | 31 |
32 private: | 32 private: |
33 void DidResolve(bool exists, const file_util::FileInfo& file_info); | 33 void DidResolve(bool exists, const file_util::FileInfo& file_info); |
34 void DidRead(int result); | 34 void DidRead(int result); |
35 | 35 |
36 net::CompletionCallbackImpl<URLRequestFileJob> io_callback_; | 36 net::CompletionCallbackImpl<URLRequestFileJob> io_callback_; |
37 net::FileInputStream stream_; | 37 net::FileStream stream_; |
38 bool is_directory_; | 38 bool is_directory_; |
39 | 39 |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 class AsyncResolver; | 41 class AsyncResolver; |
42 friend class AsyncResolver; | 42 friend class AsyncResolver; |
43 scoped_refptr<AsyncResolver> async_resolver_; | 43 scoped_refptr<AsyncResolver> async_resolver_; |
44 #endif | 44 #endif |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 46 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
47 }; | 47 }; |
48 | 48 |
49 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 49 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
OLD | NEW |