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

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

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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "net/url_request/url_request_file_dir_job.h" 5 #include "net/url_request/url_request_file_dir_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "net/base/directory_listing.h" 15 #include "net/base/directory_listing.h"
16 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
17 #include "net/url_request/url_request_status.h" 17 #include "net/url_request/url_request_status.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 #if defined(OS_POSIX) 20 #if defined(OS_POSIX)
21 #include <sys/stat.h> 21 #include <sys/stat.h>
22 #endif 22 #endif
23 23
24 namespace net { 24 namespace net {
25 25
26 URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request, 26 URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request,
27 NetworkDelegate* network_delegate, 27 NetworkDelegate* network_delegate,
28 const base::FilePath& dir_path) 28 const base::FilePath& dir_path)
29 : URLRequestFileDirJob(request,
30 network_delegate,
31 dir_path,
32 base::WorkerPool::GetTaskRunner(true)) {}
33
34 URLRequestFileDirJob::URLRequestFileDirJob(
35 URLRequest* request,
36 NetworkDelegate* network_delegate,
37 const base::FilePath& dir_path,
38 const scoped_refptr<base::TaskRunner>& dir_task_runner)
39 : URLRequestJob(request, network_delegate), 29 : URLRequestJob(request, network_delegate),
40 lister_(dir_path, this), 30 lister_(dir_path, this),
41 dir_path_(dir_path), 31 dir_path_(dir_path),
42 dir_task_runner_(dir_task_runner),
43 canceled_(false), 32 canceled_(false),
44 list_complete_(false), 33 list_complete_(false),
45 wrote_header_(false), 34 wrote_header_(false),
46 read_pending_(false), 35 read_pending_(false),
47 read_buffer_length_(0), 36 read_buffer_length_(0),
48 weak_factory_(this) {} 37 weak_factory_(this) {}
49 38
50 void URLRequestFileDirJob::StartAsync() { 39 void URLRequestFileDirJob::StartAsync() {
51 lister_.Start(dir_task_runner_.get()); 40 lister_.Start();
52
53 NotifyHeadersComplete(); 41 NotifyHeadersComplete();
54 } 42 }
55 43
56 void URLRequestFileDirJob::Start() { 44 void URLRequestFileDirJob::Start() {
57 // Start reading asynchronously so that all error reporting and data 45 // Start reading asynchronously so that all error reporting and data
58 // callbacks happen as they would for network requests. 46 // callbacks happen as they would for network requests.
59 base::ThreadTaskRunnerHandle::Get()->PostTask( 47 base::ThreadTaskRunnerHandle::Get()->PostTask(
60 FROM_HERE, base::Bind(&URLRequestFileDirJob::StartAsync, 48 FROM_HERE, base::Bind(&URLRequestFileDirJob::StartAsync,
61 weak_factory_.GetWeakPtr())); 49 weak_factory_.GetWeakPtr()));
62 } 50 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 data_.erase(0, count); 169 data_.erase(0, count);
182 return count; 170 return count;
183 } else if (list_complete_) { 171 } else if (list_complete_) {
184 // EOF 172 // EOF
185 return list_complete_result_; 173 return list_complete_result_;
186 } 174 }
187 return ERR_IO_PENDING; 175 return ERR_IO_PENDING;
188 } 176 }
189 177
190 } // namespace net 178 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_file_dir_job.h ('k') | net/url_request/url_request_file_dir_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698