OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
16 | 16 |
17 #if defined(OS_POSIX) | 17 #if defined(OS_POSIX) |
18 #include <sys/stat.h> | 18 #include <sys/stat.h> |
19 #endif | 19 #endif |
20 | 20 |
21 using std::string; | 21 using std::string; |
22 | 22 |
23 URLRequestFileDirJob::URLRequestFileDirJob(URLRequest* request, | 23 URLRequestFileDirJob::URLRequestFileDirJob(net::URLRequest* request, |
24 const FilePath& dir_path) | 24 const FilePath& dir_path) |
25 : URLRequestJob(request), | 25 : URLRequestJob(request), |
26 dir_path_(dir_path), | 26 dir_path_(dir_path), |
27 canceled_(false), | 27 canceled_(false), |
28 list_complete_(false), | 28 list_complete_(false), |
29 wrote_header_(false), | 29 wrote_header_(false), |
30 read_pending_(false), | 30 read_pending_(false), |
31 read_buffer_length_(0) { | 31 read_buffer_length_(0) { |
32 } | 32 } |
33 | 33 |
(...skipping 21 matching lines...) Expand all Loading... |
55 | 55 |
56 NotifyHeadersComplete(); | 56 NotifyHeadersComplete(); |
57 } | 57 } |
58 | 58 |
59 void URLRequestFileDirJob::Kill() { | 59 void URLRequestFileDirJob::Kill() { |
60 if (canceled_) | 60 if (canceled_) |
61 return; | 61 return; |
62 | 62 |
63 canceled_ = true; | 63 canceled_ = true; |
64 | 64 |
65 // Don't call CloseLister or dispatch an error to the URLRequest because we | 65 // Don't call CloseLister or dispatch an error to the net::URLRequest because |
66 // want OnListDone to be called to also write the error to the output stream. | 66 // we want OnListDone to be called to also write the error to the output |
67 // OnListDone will notify the URLRequest at this time. | 67 // stream. OnListDone will notify the net::URLRequest at this time. |
68 if (lister_) | 68 if (lister_) |
69 lister_->Cancel(); | 69 lister_->Cancel(); |
70 | 70 |
71 URLRequestJob::Kill(); | 71 URLRequestJob::Kill(); |
72 } | 72 } |
73 | 73 |
74 bool URLRequestFileDirJob::ReadRawData(net::IOBuffer* buf, int buf_size, | 74 bool URLRequestFileDirJob::ReadRawData(net::IOBuffer* buf, int buf_size, |
75 int *bytes_read) { | 75 int *bytes_read) { |
76 DCHECK(bytes_read); | 76 DCHECK(bytes_read); |
77 *bytes_read = 0; | 77 *bytes_read = 0; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 SetStatus(URLRequestStatus()); | 205 SetStatus(URLRequestStatus()); |
206 NotifyReadComplete(bytes_read); | 206 NotifyReadComplete(bytes_read); |
207 } else { | 207 } else { |
208 NOTREACHED(); | 208 NOTREACHED(); |
209 // TODO: Better error code. | 209 // TODO: Better error code. |
210 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 0)); | 210 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 0)); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
OLD | NEW |