| 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 |
| 18 : public URLRequestJob, | 18 : public URLRequestJob, |
| 19 public DirectoryLister::DirectoryListerDelegate { | 19 public DirectoryLister::DirectoryListerDelegate { |
| 20 public: | 20 public: |
| 21 URLRequestFileDirJob(URLRequest* request, | 21 URLRequestFileDirJob(URLRequest* request, |
| 22 NetworkDelegate* network_delegate, | 22 NetworkDelegate* network_delegate, |
| 23 const base::FilePath& dir_path); | 23 const base::FilePath& dir_path); |
| 24 | 24 |
| 25 bool list_complete() const { return list_complete_; } | 25 bool list_complete() const { return list_complete_; } |
| 26 | 26 |
| 27 virtual void StartAsync(); | 27 virtual void StartAsync(); |
| 28 | 28 |
| 29 // Overridden from URLRequestJob: | 29 // Overridden from URLRequestJob: |
| 30 virtual void Start() override; | 30 void Start() override; |
| 31 virtual void Kill() override; | 31 void Kill() override; |
| 32 virtual bool ReadRawData(IOBuffer* buf, | 32 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override; |
| 33 int buf_size, | 33 bool GetMimeType(std::string* mime_type) const override; |
| 34 int* bytes_read) override; | 34 bool GetCharset(std::string* charset) override; |
| 35 virtual bool GetMimeType(std::string* mime_type) const override; | |
| 36 virtual bool GetCharset(std::string* charset) override; | |
| 37 | 35 |
| 38 // Overridden from DirectoryLister::DirectoryListerDelegate: | 36 // Overridden from DirectoryLister::DirectoryListerDelegate: |
| 39 virtual void OnListFile( | 37 void OnListFile(const DirectoryLister::DirectoryListerData& data) override; |
| 40 const DirectoryLister::DirectoryListerData& data) override; | 38 void OnListDone(int error) override; |
| 41 virtual void OnListDone(int error) override; | |
| 42 | 39 |
| 43 private: | 40 private: |
| 44 virtual ~URLRequestFileDirJob(); | 41 ~URLRequestFileDirJob() override; |
| 45 | 42 |
| 46 void CloseLister(); | 43 void CloseLister(); |
| 47 | 44 |
| 48 // When we have data and a read has been pending, this function | 45 // When we have data and a read has been pending, this function |
| 49 // will fill the response buffer and notify the request | 46 // will fill the response buffer and notify the request |
| 50 // appropriately. | 47 // appropriately. |
| 51 void CompleteRead(); | 48 void CompleteRead(); |
| 52 | 49 |
| 53 // Fills a buffer with the output. | 50 // Fills a buffer with the output. |
| 54 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); | 51 bool FillReadBuffer(char *buf, int buf_size, int *bytes_read); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 scoped_refptr<IOBuffer> read_buffer_; | 68 scoped_refptr<IOBuffer> read_buffer_; |
| 72 int read_buffer_length_; | 69 int read_buffer_length_; |
| 73 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_; | 70 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_; |
| 74 | 71 |
| 75 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); | 72 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); |
| 76 }; | 73 }; |
| 77 | 74 |
| 78 } // namespace net | 75 } // namespace net |
| 79 | 76 |
| 80 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ | 77 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ |
| OLD | NEW |