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

Side by Side Diff: webkit/fileapi/file_system_url_request_job.cc

Issue 10082002: Add FileSystemMountPointProvider::CreateFileReader() which returns appropriate Reader instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 8 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 | Annotate | Revision Log
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 "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"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util_proxy.h" 12 #include "base/file_util_proxy.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/platform_file.h" 14 #include "base/platform_file.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "base/time.h" 16 #include "base/time.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/file_stream.h" 19 #include "net/base/file_stream.h"
20 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
21 #include "net/base/mime_util.h" 21 #include "net/base/mime_util.h"
22 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
23 #include "net/base/net_util.h" 23 #include "net/base/net_util.h"
24 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
25 #include "net/http/http_response_info.h" 25 #include "net/http/http_response_info.h"
26 #include "net/http/http_util.h" 26 #include "net/http/http_util.h"
27 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
28 #include "webkit/blob/file_reader.h"
28 #include "webkit/fileapi/file_system_context.h" 29 #include "webkit/fileapi/file_system_context.h"
29 #include "webkit/fileapi/file_system_file_reader.h"
30 #include "webkit/fileapi/file_system_operation.h" 30 #include "webkit/fileapi/file_system_operation.h"
31 #include "webkit/fileapi/file_system_util.h" 31 #include "webkit/fileapi/file_system_util.h"
32 32
33 using net::URLRequest; 33 using net::URLRequest;
34 using net::URLRequestJob; 34 using net::URLRequestJob;
35 using net::URLRequestStatus; 35 using net::URLRequestStatus;
36 using webkit_blob::LocalFileReader;
37 36
38 namespace fileapi { 37 namespace fileapi {
39 38
40 static net::HttpResponseHeaders* CreateHttpResponseHeaders() { 39 static net::HttpResponseHeaders* CreateHttpResponseHeaders() {
41 // HttpResponseHeaders expects its input string to be terminated by two NULs. 40 // HttpResponseHeaders expects its input string to be terminated by two NULs.
42 static const char kStatus[] = "HTTP/1.1 200 OK\0"; 41 static const char kStatus[] = "HTTP/1.1 200 OK\0";
43 static const size_t kStatusLen = arraysize(kStatus); 42 static const size_t kStatusLen = arraysize(kStatus);
44 43
45 net::HttpResponseHeaders* headers = 44 net::HttpResponseHeaders* headers =
46 new net::HttpResponseHeaders(std::string(kStatus, kStatusLen)); 45 new net::HttpResponseHeaders(std::string(kStatus, kStatusLen));
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (is_directory_) { 196 if (is_directory_) {
198 NotifyHeadersComplete(); 197 NotifyHeadersComplete();
199 return; 198 return;
200 } 199 }
201 200
202 remaining_bytes_ = byte_range_.last_byte_position() - 201 remaining_bytes_ = byte_range_.last_byte_position() -
203 byte_range_.first_byte_position() + 1; 202 byte_range_.first_byte_position() + 1;
204 DCHECK_GE(remaining_bytes_, 0); 203 DCHECK_GE(remaining_bytes_, 0);
205 204
206 DCHECK(!reader_.get()); 205 DCHECK(!reader_.get());
207 reader_.reset(new FileSystemFileReader( 206 reader_.reset(
208 file_thread_proxy_, 207 file_system_context_->CreateFileReader(
209 file_system_context_,
210 request_->url(), 208 request_->url(),
211 byte_range_.first_byte_position())); 209 byte_range_.first_byte_position(),
210 file_thread_proxy_));
212 211
213 set_expected_content_size(remaining_bytes_); 212 set_expected_content_size(remaining_bytes_);
214 response_info_.reset(new net::HttpResponseInfo()); 213 response_info_.reset(new net::HttpResponseInfo());
215 response_info_->headers = CreateHttpResponseHeaders(); 214 response_info_->headers = CreateHttpResponseHeaders();
216 NotifyHeadersComplete(); 215 NotifyHeadersComplete();
217 } 216 }
218 217
219 void FileSystemURLRequestJob::DidRead(int result) { 218 void FileSystemURLRequestJob::DidRead(int result) {
220 if (result > 0) 219 if (result > 0)
221 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status 220 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status
(...skipping 23 matching lines...) Expand all
245 } 244 }
246 245
247 return false; 246 return false;
248 } 247 }
249 248
250 void FileSystemURLRequestJob::NotifyFailed(int rv) { 249 void FileSystemURLRequestJob::NotifyFailed(int rv) {
251 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 250 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
252 } 251 }
253 252
254 } // namespace fileapi 253 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_url_request_job.h ('k') | webkit/fileapi/isolated_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698