| 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 #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_; } | 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(); | 30 virtual void Start() OVERRIDE; |
| 31 virtual void Kill(); | 31 virtual void Kill() OVERRIDE; |
| 32 virtual bool ReadRawData(IOBuffer* buf, int buf_size, int *bytes_read); | 32 virtual bool ReadRawData(IOBuffer* buf, |
| 33 virtual bool GetMimeType(std::string* mime_type) const; | 33 int buf_size, |
| 34 virtual bool GetCharset(std::string* charset); | 34 int *bytes_read) OVERRIDE; |
| 35 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 36 virtual bool GetCharset(std::string* charset) OVERRIDE; |
| 35 | 37 |
| 36 // Overridden from DirectoryLister::DirectoryListerDelegate: | 38 // Overridden from DirectoryLister::DirectoryListerDelegate: |
| 37 virtual void OnListFile( | 39 virtual void OnListFile( |
| 38 const DirectoryLister::DirectoryListerData& data); | 40 const DirectoryLister::DirectoryListerData& data) OVERRIDE; |
| 39 virtual void OnListDone(int error); | 41 virtual void OnListDone(int error) OVERRIDE; |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 virtual ~URLRequestFileDirJob(); | 44 virtual ~URLRequestFileDirJob(); |
| 43 | 45 |
| 44 void CloseLister(); | 46 void CloseLister(); |
| 45 | 47 |
| 46 // When we have data and a read has been pending, this function | 48 // When we have data and a read has been pending, this function |
| 47 // will fill the response buffer and notify the request | 49 // will fill the response buffer and notify the request |
| 48 // appropriately. | 50 // appropriately. |
| 49 void CompleteRead(); | 51 void CompleteRead(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 scoped_refptr<IOBuffer> read_buffer_; | 71 scoped_refptr<IOBuffer> read_buffer_; |
| 70 int read_buffer_length_; | 72 int read_buffer_length_; |
| 71 ScopedRunnableMethodFactory<URLRequestFileDirJob> method_factory_; | 73 ScopedRunnableMethodFactory<URLRequestFileDirJob> method_factory_; |
| 72 | 74 |
| 73 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); | 75 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 } // namespace net | 78 } // namespace net |
| 77 | 79 |
| 78 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ | 80 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ |
| OLD | NEW |