OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.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 namespace net { | 15 namespace net { |
16 | 16 |
17 class URLRequestFileDirJob | 17 class URLRequestFileDirJob : public URLRequestJob, |
18 : public URLRequestJob, | 18 public DirectoryLister::DirectoryListerDelegate { |
19 public DirectoryLister::DirectoryListerDelegate { | |
20 public: | 19 public: |
21 URLRequestFileDirJob(URLRequest* request, | 20 URLRequestFileDirJob(URLRequest* request, |
22 NetworkDelegate* network_delegate, | 21 NetworkDelegate* network_delegate, |
23 const base::FilePath& dir_path); | 22 const base::FilePath& dir_path); |
24 | 23 |
25 bool list_complete() const { return list_complete_; } | 24 bool list_complete() const { return list_complete_; } |
26 | 25 |
27 virtual void StartAsync(); | 26 virtual void StartAsync(); |
28 | 27 |
29 // Overridden from URLRequestJob: | 28 // Overridden from URLRequestJob: |
(...skipping 14 matching lines...) Expand all Loading... |
44 virtual ~URLRequestFileDirJob(); | 43 virtual ~URLRequestFileDirJob(); |
45 | 44 |
46 void CloseLister(); | 45 void CloseLister(); |
47 | 46 |
48 // When we have data and a read has been pending, this function | 47 // When we have data and a read has been pending, this function |
49 // will fill the response buffer and notify the request | 48 // will fill the response buffer and notify the request |
50 // appropriately. | 49 // appropriately. |
51 void CompleteRead(); | 50 void CompleteRead(); |
52 | 51 |
53 // Fills a buffer with the output. | 52 // Fills a buffer with the output. |
54 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); | 53 bool FillReadBuffer(char* buf, int buf_size, int* bytes_read); |
55 | 54 |
56 DirectoryLister lister_; | 55 DirectoryLister lister_; |
57 base::FilePath dir_path_; | 56 base::FilePath dir_path_; |
58 std::string data_; | 57 std::string data_; |
59 bool canceled_; | 58 bool canceled_; |
60 | 59 |
61 // Indicates whether we have the complete list of the dir | 60 // Indicates whether we have the complete list of the dir |
62 bool list_complete_; | 61 bool list_complete_; |
63 | 62 |
64 // Indicates whether we have written the HTML header | 63 // Indicates whether we have written the HTML header |
65 bool wrote_header_; | 64 bool wrote_header_; |
66 | 65 |
67 // To simulate Async IO, we hold onto the Reader's buffer while | 66 // To simulate Async IO, we hold onto the Reader's buffer while |
68 // we wait for IO to complete. When done, we fill the buffer | 67 // we wait for IO to complete. When done, we fill the buffer |
69 // manually. | 68 // manually. |
70 bool read_pending_; | 69 bool read_pending_; |
71 scoped_refptr<IOBuffer> read_buffer_; | 70 scoped_refptr<IOBuffer> read_buffer_; |
72 int read_buffer_length_; | 71 int read_buffer_length_; |
73 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_; | 72 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_; |
74 | 73 |
75 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); | 74 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); |
76 }; | 75 }; |
77 | 76 |
78 } // namespace net | 77 } // namespace net |
79 | 78 |
80 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ | 79 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ |
OLD | NEW |