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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
17 | 17 |
18 #if defined(OS_POSIX) | 18 #if defined(OS_POSIX) |
19 #include <sys/stat.h> | 19 #include <sys/stat.h> |
20 #endif | 20 #endif |
21 | 21 |
22 using std::string; | 22 using std::string; |
23 | 23 |
24 URLRequestFileDirJob::URLRequestFileDirJob(net::URLRequest* request, | 24 URLRequestFileDirJob::URLRequestFileDirJob(net::URLRequest* request, |
25 const FilePath& dir_path) | 25 const FilePath& dir_path) |
26 : URLRequestJob(request), | 26 : net::URLRequestJob(request), |
27 dir_path_(dir_path), | 27 dir_path_(dir_path), |
28 canceled_(false), | 28 canceled_(false), |
29 list_complete_(false), | 29 list_complete_(false), |
30 wrote_header_(false), | 30 wrote_header_(false), |
31 read_pending_(false), | 31 read_pending_(false), |
32 read_buffer_length_(0), | 32 read_buffer_length_(0), |
33 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 33 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
34 } | 34 } |
35 | 35 |
36 URLRequestFileDirJob::~URLRequestFileDirJob() { | 36 URLRequestFileDirJob::~URLRequestFileDirJob() { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return; | 68 return; |
69 | 69 |
70 canceled_ = true; | 70 canceled_ = true; |
71 | 71 |
72 // Don't call CloseLister or dispatch an error to the net::URLRequest because | 72 // Don't call CloseLister or dispatch an error to the net::URLRequest because |
73 // we want OnListDone to be called to also write the error to the output | 73 // we want OnListDone to be called to also write the error to the output |
74 // stream. OnListDone will notify the net::URLRequest at this time. | 74 // stream. OnListDone will notify the net::URLRequest at this time. |
75 if (lister_) | 75 if (lister_) |
76 lister_->Cancel(); | 76 lister_->Cancel(); |
77 | 77 |
78 URLRequestJob::Kill(); | 78 net::URLRequestJob::Kill(); |
79 | 79 |
80 method_factory_.RevokeAll(); | 80 method_factory_.RevokeAll(); |
81 } | 81 } |
82 | 82 |
83 bool URLRequestFileDirJob::ReadRawData(net::IOBuffer* buf, int buf_size, | 83 bool URLRequestFileDirJob::ReadRawData(net::IOBuffer* buf, int buf_size, |
84 int *bytes_read) { | 84 int *bytes_read) { |
85 DCHECK(bytes_read); | 85 DCHECK(bytes_read); |
86 *bytes_read = 0; | 86 *bytes_read = 0; |
87 | 87 |
88 if (is_done()) | 88 if (is_done()) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 SetStatus(URLRequestStatus()); | 214 SetStatus(URLRequestStatus()); |
215 NotifyReadComplete(bytes_read); | 215 NotifyReadComplete(bytes_read); |
216 } else { | 216 } else { |
217 NOTREACHED(); | 217 NOTREACHED(); |
218 // TODO: Better error code. | 218 // TODO: Better error code. |
219 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 0)); | 219 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 0)); |
220 } | 220 } |
221 } | 221 } |
222 } | 222 } |
OLD | NEW |