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_DIR_JOB_H__ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ |
6 #define NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ | 6 #define NET_URL_REQUEST_URL_REQUEST_FILE_DIR_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 "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "net/base/directory_lister.h" | 12 #include "net/base/directory_lister.h" |
13 #include "net/url_request/url_request_job.h" | 13 #include "net/url_request/url_request_job.h" |
14 | 14 |
15 class URLRequestFileDirJob | 15 class URLRequestFileDirJob |
16 : public URLRequestJob, | 16 : public URLRequestJob, |
17 public net::DirectoryLister::DirectoryListerDelegate { | 17 public net::DirectoryLister::DirectoryListerDelegate { |
18 public: | 18 public: |
19 URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path); | 19 URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path); |
20 virtual ~URLRequestFileDirJob(); | |
21 | 20 |
22 // URLRequestJob methods: | 21 // URLRequestJob methods: |
23 virtual void Start(); | 22 virtual void Start(); |
24 virtual void StartAsync(); | 23 virtual void StartAsync(); |
25 virtual void Kill(); | 24 virtual void Kill(); |
26 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); | 25 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
27 virtual bool GetMimeType(std::string* mime_type) const; | 26 virtual bool GetMimeType(std::string* mime_type) const; |
28 virtual bool GetCharset(std::string* charset); | 27 virtual bool GetCharset(std::string* charset); |
29 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); | 28 virtual bool IsRedirectResponse(GURL* location, int* http_status_code); |
30 | 29 |
31 // DirectoryLister::DirectoryListerDelegate methods: | 30 // DirectoryLister::DirectoryListerDelegate methods: |
32 virtual void OnListFile(const file_util::FileEnumerator::FindInfo& data); | 31 virtual void OnListFile(const file_util::FileEnumerator::FindInfo& data); |
33 virtual void OnListDone(int error); | 32 virtual void OnListDone(int error); |
34 | 33 |
35 bool list_complete() const { return list_complete_; } | 34 bool list_complete() const { return list_complete_; } |
36 | 35 |
37 private: | 36 private: |
| 37 virtual ~URLRequestFileDirJob(); |
| 38 |
38 void CloseLister(); | 39 void CloseLister(); |
39 // When we have data and a read has been pending, this function | 40 // When we have data and a read has been pending, this function |
40 // will fill the response buffer and notify the request | 41 // will fill the response buffer and notify the request |
41 // appropriately. | 42 // appropriately. |
42 void CompleteRead(); | 43 void CompleteRead(); |
43 | 44 |
44 // Fills a buffer with the output. | 45 // Fills a buffer with the output. |
45 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); | 46 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); |
46 | 47 |
47 scoped_refptr<net::DirectoryLister> lister_; | 48 scoped_refptr<net::DirectoryLister> lister_; |
(...skipping 11 matching lines...) Expand all Loading... |
59 // we wait for IO to complete. When done, we fill the buffer | 60 // we wait for IO to complete. When done, we fill the buffer |
60 // manually. | 61 // manually. |
61 bool read_pending_; | 62 bool read_pending_; |
62 scoped_refptr<net::IOBuffer> read_buffer_; | 63 scoped_refptr<net::IOBuffer> read_buffer_; |
63 int read_buffer_length_; | 64 int read_buffer_length_; |
64 | 65 |
65 DISALLOW_EVIL_CONSTRUCTORS(URLRequestFileDirJob); | 66 DISALLOW_EVIL_CONSTRUCTORS(URLRequestFileDirJob); |
66 }; | 67 }; |
67 | 68 |
68 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ | 69 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H__ |
OLD | NEW |