OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/task.h" | 13 #include "base/task.h" |
14 #include "net/base/directory_lister.h" | 14 #include "net/base/directory_lister.h" |
15 #include "net/url_request/url_request_job.h" | 15 #include "net/url_request/url_request_job.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class URLRequestFileDirJob | 19 class URLRequestFileDirJob |
20 : public URLRequestJob, | 20 : public URLRequestJob, |
21 public DirectoryLister::DirectoryListerDelegate { | 21 public DirectoryLister::DirectoryListerDelegate { |
22 public: | 22 public: |
23 URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path); | 23 URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path); |
24 | 24 |
| 25 bool list_complete() const { return list_complete_; } |
| 26 |
| 27 virtual void StartAsync(); |
| 28 |
25 // Overridden from URLRequestJob: | 29 // Overridden from URLRequestJob: |
26 virtual void Start(); | 30 virtual void Start(); |
27 virtual void StartAsync(); | |
28 virtual void Kill(); | 31 virtual void Kill(); |
29 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); | 32 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); |
30 virtual bool GetMimeType(std::string* mime_type) const; | 33 virtual bool GetMimeType(std::string* mime_type) const; |
31 virtual bool GetCharset(std::string* charset); | 34 virtual bool GetCharset(std::string* charset); |
32 | 35 |
33 // Overridden from DirectoryLister::DirectoryListerDelegate: | 36 // Overridden from DirectoryLister::DirectoryListerDelegate: |
34 virtual void OnListFile( | 37 virtual void OnListFile( |
35 const DirectoryLister::DirectoryListerData& data); | 38 const DirectoryLister::DirectoryListerData& data); |
36 virtual void OnListDone(int error); | 39 virtual void OnListDone(int error); |
37 | 40 |
38 bool list_complete() const { return list_complete_; } | |
39 | |
40 private: | 41 private: |
41 virtual ~URLRequestFileDirJob(); | 42 virtual ~URLRequestFileDirJob(); |
42 | 43 |
43 void CloseLister(); | 44 void CloseLister(); |
| 45 |
44 // When we have data and a read has been pending, this function | 46 // When we have data and a read has been pending, this function |
45 // will fill the response buffer and notify the request | 47 // will fill the response buffer and notify the request |
46 // appropriately. | 48 // appropriately. |
47 void CompleteRead(); | 49 void CompleteRead(); |
48 | 50 |
49 // Fills a buffer with the output. | 51 // Fills a buffer with the output. |
50 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); | 52 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); |
51 | 53 |
52 scoped_refptr<DirectoryLister> lister_; | 54 scoped_refptr<DirectoryLister> lister_; |
53 FilePath dir_path_; | 55 FilePath dir_path_; |
(...skipping 13 matching lines...) Expand all Loading... |
67 scoped_refptr<IOBuffer> read_buffer_; | 69 scoped_refptr<IOBuffer> read_buffer_; |
68 int read_buffer_length_; | 70 int read_buffer_length_; |
69 ScopedRunnableMethodFactory<URLRequestFileDirJob> method_factory_; | 71 ScopedRunnableMethodFactory<URLRequestFileDirJob> method_factory_; |
70 | 72 |
71 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); | 73 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); |
72 }; | 74 }; |
73 | 75 |
74 } // namespace net | 76 } // namespace net |
75 | 77 |
76 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ | 78 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ |
OLD | NEW |