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