| OLD | NEW |
| 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 "webkit/fileapi/file_system_dir_url_request_job.h" | 5 #include "webkit/fileapi/file_system_dir_url_request_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 22 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
| 23 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
| 24 #include "webkit/fileapi/file_system_context.h" | 24 #include "webkit/fileapi/file_system_context.h" |
| 25 #include "webkit/fileapi/file_system_operation_interface.h" | 25 #include "webkit/fileapi/file_system_operation.h" |
| 26 #include "webkit/fileapi/file_system_url.h" | 26 #include "webkit/fileapi/file_system_url.h" |
| 27 | 27 |
| 28 using net::URLRequest; | 28 using net::URLRequest; |
| 29 using net::URLRequestJob; | 29 using net::URLRequestJob; |
| 30 using net::URLRequestStatus; | 30 using net::URLRequestStatus; |
| 31 | 31 |
| 32 namespace fileapi { | 32 namespace fileapi { |
| 33 | 33 |
| 34 FileSystemDirURLRequestJob::FileSystemDirURLRequestJob( | 34 FileSystemDirURLRequestJob::FileSystemDirURLRequestJob( |
| 35 URLRequest* request, FileSystemContext* file_system_context) | 35 URLRequest* request, FileSystemContext* file_system_context) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) { | 72 bool FileSystemDirURLRequestJob::GetCharset(std::string* charset) { |
| 73 *charset = "utf-8"; | 73 *charset = "utf-8"; |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void FileSystemDirURLRequestJob::StartAsync() { | 77 void FileSystemDirURLRequestJob::StartAsync() { |
| 78 if (!request_) | 78 if (!request_) |
| 79 return; | 79 return; |
| 80 url_ = FileSystemURL(request_->url()); | 80 url_ = FileSystemURL(request_->url()); |
| 81 FileSystemOperationInterface* operation = GetNewOperation(); | 81 FileSystemOperation* operation = GetNewOperation(); |
| 82 if (!operation) { | 82 if (!operation) { |
| 83 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 83 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
| 84 net::ERR_INVALID_URL)); | 84 net::ERR_INVALID_URL)); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 operation->ReadDirectory( | 87 operation->ReadDirectory( |
| 88 url_, | 88 url_, |
| 89 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 89 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (has_more) { | 124 if (has_more) { |
| 125 GetNewOperation()->ReadDirectory( | 125 GetNewOperation()->ReadDirectory( |
| 126 url_, | 126 url_, |
| 127 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); | 127 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); |
| 128 } else { | 128 } else { |
| 129 set_expected_content_size(data_.size()); | 129 set_expected_content_size(data_.size()); |
| 130 NotifyHeadersComplete(); | 130 NotifyHeadersComplete(); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 FileSystemOperationInterface* | 134 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation() { |
| 135 FileSystemDirURLRequestJob::GetNewOperation() { | |
| 136 return file_system_context_->CreateFileSystemOperation(url_); | 135 return file_system_context_->CreateFileSystemOperation(url_); |
| 137 } | 136 } |
| 138 | 137 |
| 139 } // namespace fileapi | 138 } // namespace fileapi |
| OLD | NEW |