license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 5 | #ifndef NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
6 | #define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 7 | |
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 8 | #include "base/file_util.h" |
9 | #include "net/base/completion_callback.h" | ||||
[email protected] | 21da6eb | 2008-11-03 17:18:14 | [diff] [blame^] | 10 | #include "net/base/file_stream.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 11 | #include "net/url_request/url_request.h" |
12 | #include "net/url_request/url_request_job.h" | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 13 | |
14 | // A request job that handles reading file URLs | ||||
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 15 | class URLRequestFileJob : public URLRequestJob { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 16 | public: |
17 | URLRequestFileJob(URLRequest* request); | ||||
18 | virtual ~URLRequestFileJob(); | ||||
19 | |||||
20 | virtual void Start(); | ||||
21 | virtual void Kill(); | ||||
22 | virtual bool ReadRawData(char* buf, int buf_size, int *bytes_read); | ||||
23 | virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 24 | virtual bool GetMimeType(std::string* mime_type); |
25 | |||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 26 | static URLRequest::ProtocolFactory Factory; |
27 | |||||
28 | protected: | ||||
29 | // The OS-specific full path name of the file | ||||
30 | std::wstring file_path_; | ||||
31 | |||||
32 | private: | ||||
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 33 | void DidResolve(bool exists, const file_util::FileInfo& file_info); |
34 | void DidRead(int result); | ||||
[email protected] | 243f86a7 | 2008-08-09 08:35:25 | [diff] [blame] | 35 | |
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 36 | net::CompletionCallbackImpl<URLRequestFileJob> io_callback_; |
[email protected] | 21da6eb | 2008-11-03 17:18:14 | [diff] [blame^] | 37 | net::FileStream stream_; |
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 38 | bool is_directory_; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 39 | |
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 40 | #if defined(OS_WIN) |
41 | class AsyncResolver; | ||||
42 | friend class AsyncResolver; | ||||
43 | scoped_refptr<AsyncResolver> async_resolver_; | ||||
44 | #endif | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 45 | |
[email protected] | 9396b25 | 2008-09-29 17:29:38 | [diff] [blame] | 46 | DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 47 | }; |
48 | |||||
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 49 | #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |