Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: net/url_request/url_request_file_dir_job.h

Issue 1459333002: Revert "Reland: URLRequestJob: change ReadRawData contract" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base/net_errors.h"
14 #include "net/url_request/url_request_job.h" 13 #include "net/url_request/url_request_job.h"
15 14
16 namespace net { 15 namespace net {
17 16
18 class URLRequestFileDirJob 17 class URLRequestFileDirJob
19 : public URLRequestJob, 18 : public URLRequestJob,
20 public DirectoryLister::DirectoryListerDelegate { 19 public DirectoryLister::DirectoryListerDelegate {
21 public: 20 public:
22 URLRequestFileDirJob(URLRequest* request, 21 URLRequestFileDirJob(URLRequest* request,
23 NetworkDelegate* network_delegate, 22 NetworkDelegate* network_delegate,
24 const base::FilePath& dir_path); 23 const base::FilePath& dir_path);
25 24
26 bool list_complete() const { return list_complete_; } 25 bool list_complete() const { return list_complete_; }
27 26
28 virtual void StartAsync(); 27 virtual void StartAsync();
29 28
30 // Overridden from URLRequestJob: 29 // Overridden from URLRequestJob:
31 void Start() override; 30 void Start() override;
32 void Kill() override; 31 void Kill() override;
33 int ReadRawData(IOBuffer* buf, int buf_size) override; 32 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override;
34 bool GetMimeType(std::string* mime_type) const override; 33 bool GetMimeType(std::string* mime_type) const override;
35 bool GetCharset(std::string* charset) override; 34 bool GetCharset(std::string* charset) override;
36 35
37 // Overridden from DirectoryLister::DirectoryListerDelegate: 36 // Overridden from DirectoryLister::DirectoryListerDelegate:
38 void OnListFile(const DirectoryLister::DirectoryListerData& data) override; 37 void OnListFile(const DirectoryLister::DirectoryListerData& data) override;
39 void OnListDone(int error) override; 38 void OnListDone(int error) override;
40 39
41 private: 40 private:
42 ~URLRequestFileDirJob() override; 41 ~URLRequestFileDirJob() override;
43 42
44 void CloseLister(); 43 void CloseLister();
45 44
46 // 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
47 // will fill the response buffer and notify the request 46 // will fill the response buffer and notify the request
48 // appropriately. 47 // appropriately.
49 void CompleteRead(Error error); 48 void CompleteRead();
50 49
51 // Fills a buffer with the output. 50 // Fills a buffer with the output.
52 bool FillReadBuffer(char* buf, int buf_size, int* bytes_read); 51 bool FillReadBuffer(char* buf, int buf_size, int* bytes_read);
53 52
54 DirectoryLister lister_; 53 DirectoryLister lister_;
55 base::FilePath dir_path_; 54 base::FilePath dir_path_;
56 std::string data_; 55 std::string data_;
57 bool canceled_; 56 bool canceled_;
58 57
59 // Indicates whether we have the complete list of the dir 58 // Indicates whether we have the complete list of the dir
60 bool list_complete_; 59 bool list_complete_;
61 60
62 // Indicates whether we have written the HTML header 61 // Indicates whether we have written the HTML header
63 bool wrote_header_; 62 bool wrote_header_;
64 63
65 // To simulate Async IO, we hold onto the Reader's buffer while 64 // To simulate Async IO, we hold onto the Reader's buffer while
66 // we wait for IO to complete. When done, we fill the buffer 65 // we wait for IO to complete. When done, we fill the buffer
67 // manually. 66 // manually.
68 bool read_pending_; 67 bool read_pending_;
69 scoped_refptr<IOBuffer> read_buffer_; 68 scoped_refptr<IOBuffer> read_buffer_;
70 int read_buffer_length_; 69 int read_buffer_length_;
71
72 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_; 70 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_;
73 71
74 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); 72 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob);
75 }; 73 };
76 74
77 } // namespace net 75 } // namespace net
78 76
79 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ 77 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_
OLDNEW
« no previous file with comments | « net/test/url_request/url_request_slow_download_job.cc ('k') | net/url_request/url_request_file_dir_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698