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_url_request_job.h" | 5 #include "webkit/fileapi/file_system_url_request_job.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 if (rv == net::ERR_IO_PENDING) | 110 if (rv == net::ERR_IO_PENDING) |
111 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); | 111 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); |
112 else | 112 else |
113 NotifyFailed(rv); | 113 NotifyFailed(rv); |
114 return false; | 114 return false; |
115 } | 115 } |
116 | 116 |
117 bool FileSystemURLRequestJob::GetMimeType(std::string* mime_type) const { | 117 bool FileSystemURLRequestJob::GetMimeType(std::string* mime_type) const { |
118 DCHECK(request_); | 118 DCHECK(request_); |
119 DCHECK(url_.is_valid()); | 119 DCHECK(url_.is_valid()); |
120 FilePath::StringType extension = url_.path().Extension(); | 120 base::FilePath::StringType extension = url_.path().Extension(); |
121 if (!extension.empty()) | 121 if (!extension.empty()) |
122 extension = extension.substr(1); | 122 extension = extension.substr(1); |
123 return net::GetWellKnownMimeTypeFromExtension(extension, mime_type); | 123 return net::GetWellKnownMimeTypeFromExtension(extension, mime_type); |
124 } | 124 } |
125 | 125 |
126 void FileSystemURLRequestJob::SetExtraRequestHeaders( | 126 void FileSystemURLRequestJob::SetExtraRequestHeaders( |
127 const net::HttpRequestHeaders& headers) { | 127 const net::HttpRequestHeaders& headers) { |
128 std::string range_header; | 128 std::string range_header; |
129 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { | 129 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { |
130 std::vector<net::HttpByteRange> ranges; | 130 std::vector<net::HttpByteRange> ranges; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 operation->GetMetadata( | 168 operation->GetMetadata( |
169 url_, | 169 url_, |
170 base::Bind(&FileSystemURLRequestJob::DidGetMetadata, | 170 base::Bind(&FileSystemURLRequestJob::DidGetMetadata, |
171 weak_factory_.GetWeakPtr())); | 171 weak_factory_.GetWeakPtr())); |
172 } | 172 } |
173 | 173 |
174 void FileSystemURLRequestJob::DidGetMetadata( | 174 void FileSystemURLRequestJob::DidGetMetadata( |
175 base::PlatformFileError error_code, | 175 base::PlatformFileError error_code, |
176 const base::PlatformFileInfo& file_info, | 176 const base::PlatformFileInfo& file_info, |
177 const FilePath& platform_path) { | 177 const base::FilePath& platform_path) { |
178 if (error_code != base::PLATFORM_FILE_OK) { | 178 if (error_code != base::PLATFORM_FILE_OK) { |
179 NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ? | 179 NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ? |
180 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND); | 180 net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND); |
181 return; | 181 return; |
182 } | 182 } |
183 | 183 |
184 // We may have been orphaned... | 184 // We may have been orphaned... |
185 if (!request_) | 185 if (!request_) |
186 return; | 186 return; |
187 | 187 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 return false; | 245 return false; |
246 } | 246 } |
247 | 247 |
248 void FileSystemURLRequestJob::NotifyFailed(int rv) { | 248 void FileSystemURLRequestJob::NotifyFailed(int rv) { |
249 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 249 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
250 } | 250 } |
251 | 251 |
252 } // namespace fileapi | 252 } // namespace fileapi |
OLD | NEW |