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

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

Issue 2682523002: Use TaskScheduler in directory_lister.cc. (Closed)
Patch Set: remove ScopedTaskScheduler from TokenBindingURLRequestTest Created 3 years, 10 months 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
« no previous file with comments | « net/base/directory_lister_unittest.cc ('k') | net/url_request/url_request_file_dir_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/worker_pool.h"
15 #include "net/base/directory_lister.h" 14 #include "net/base/directory_lister.h"
16 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
17 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
18 #include "net/url_request/url_request_job.h" 17 #include "net/url_request/url_request_job.h"
19 18
20 namespace net { 19 namespace net {
21 20
22 class NET_EXPORT_PRIVATE URLRequestFileDirJob 21 class NET_EXPORT_PRIVATE URLRequestFileDirJob
23 : public URLRequestJob, 22 : public URLRequestJob,
24 public NON_EXPORTED_BASE(DirectoryLister::DirectoryListerDelegate) { 23 public NON_EXPORTED_BASE(DirectoryLister::DirectoryListerDelegate) {
25 public: 24 public:
26 URLRequestFileDirJob(URLRequest* request, 25 URLRequestFileDirJob(URLRequest* request,
27 NetworkDelegate* network_delegate, 26 NetworkDelegate* network_delegate,
28 const base::FilePath& dir_path); 27 const base::FilePath& dir_path);
29 28
30 URLRequestFileDirJob(URLRequest* request,
31 NetworkDelegate* network_delegate,
32 const base::FilePath& dir_path,
33 const scoped_refptr<base::TaskRunner>& dir_task_runner);
34
35 void StartAsync(); 29 void StartAsync();
36 // Overridden from URLRequestJob: 30 // Overridden from URLRequestJob:
37 void Start() override; 31 void Start() override;
38 void Kill() override; 32 void Kill() override;
39 int ReadRawData(IOBuffer* buf, int buf_size) override; 33 int ReadRawData(IOBuffer* buf, int buf_size) override;
40 bool GetMimeType(std::string* mime_type) const override; 34 bool GetMimeType(std::string* mime_type) const override;
41 bool GetCharset(std::string* charset) override; 35 bool GetCharset(std::string* charset) override;
42 36
43 // Overridden from DirectoryLister::DirectoryListerDelegate: 37 // Overridden from DirectoryLister::DirectoryListerDelegate:
44 void OnListFile(const DirectoryLister::DirectoryListerData& data) override; 38 void OnListFile(const DirectoryLister::DirectoryListerData& data) override;
45 void OnListDone(int error) override; 39 void OnListDone(int error) override;
46 40
47 protected: 41 protected:
48 ~URLRequestFileDirJob() override; 42 ~URLRequestFileDirJob() override;
49 43
50 private: 44 private:
51 void CloseLister(); 45 void CloseLister();
52 46
53 // 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
54 // will fill the response buffer and notify the request 48 // will fill the response buffer and notify the request
55 // appropriately. 49 // appropriately.
56 void CompleteRead(Error error); 50 void CompleteRead(Error error);
57 51
58 int ReadBuffer(char* buf, int buf_size); 52 int ReadBuffer(char* buf, int buf_size);
59 53
60 DirectoryLister lister_; 54 DirectoryLister lister_;
61 base::FilePath dir_path_; 55 base::FilePath dir_path_;
62 56
63 const scoped_refptr<base::TaskRunner> dir_task_runner_;
64
65 std::string data_; 57 std::string data_;
66 bool canceled_; 58 bool canceled_;
67 59
68 // Indicates whether we have the complete list of the dir 60 // Indicates whether we have the complete list of the dir
69 bool list_complete_; 61 bool list_complete_;
70 62
71 // Indicates the status of the list 63 // Indicates the status of the list
72 Error list_complete_result_; 64 Error list_complete_result_;
73 65
74 // Indicates whether we have written the HTML header 66 // Indicates whether we have written the HTML header
75 bool wrote_header_; 67 bool wrote_header_;
76 68
77 // To simulate Async IO, we hold onto the Reader's buffer while 69 // To simulate Async IO, we hold onto the Reader's buffer while
78 // we wait for IO to complete. When done, we fill the buffer 70 // we wait for IO to complete. When done, we fill the buffer
79 // manually. 71 // manually.
80 bool read_pending_; 72 bool read_pending_;
81 scoped_refptr<IOBuffer> read_buffer_; 73 scoped_refptr<IOBuffer> read_buffer_;
82 int read_buffer_length_; 74 int read_buffer_length_;
83 75
84 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_; 76 base::WeakPtrFactory<URLRequestFileDirJob> weak_factory_;
85 77
86 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob); 78 DISALLOW_COPY_AND_ASSIGN(URLRequestFileDirJob);
87 }; 79 };
88 80
89 } // namespace net 81 } // namespace net
90 82
91 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_ 83 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_DIR_JOB_H_
OLDNEW
« no previous file with comments | « net/base/directory_lister_unittest.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