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