| 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 #ifndef NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 14 #include "net/http/http_byte_range.h" | 15 #include "net/http/http_byte_range.h" |
| 15 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 16 #include "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
| 17 | 18 |
| 18 namespace base{ | 19 namespace base{ |
| 19 struct PlatformFileInfo; | 20 struct PlatformFileInfo; |
| 21 class TaskRunner; |
| 20 } | 22 } |
| 21 namespace file_util { | 23 namespace file_util { |
| 22 struct FileInfo; | 24 struct FileInfo; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace net { | 27 namespace net { |
| 26 | 28 |
| 27 class FileStream; | 29 class FileStream; |
| 28 | 30 |
| 29 // A request job that handles reading file URLs | 31 // A request job that handles reading file URLs |
| 30 class NET_EXPORT URLRequestFileJob : public URLRequestJob { | 32 class NET_EXPORT URLRequestFileJob : public URLRequestJob { |
| 31 public: | 33 public: |
| 32 URLRequestFileJob(URLRequest* request, | 34 URLRequestFileJob(URLRequest* request, |
| 33 NetworkDelegate* network_delegate, | 35 NetworkDelegate* network_delegate, |
| 34 const base::FilePath& file_path); | 36 const base::FilePath& file_path, |
| 37 const scoped_refptr<base::TaskRunner>& file_task_runner); |
| 35 | 38 |
| 36 // URLRequestJob: | 39 // URLRequestJob: |
| 37 virtual void Start() OVERRIDE; | 40 virtual void Start() OVERRIDE; |
| 38 virtual void Kill() OVERRIDE; | 41 virtual void Kill() OVERRIDE; |
| 39 virtual bool ReadRawData(IOBuffer* buf, | 42 virtual bool ReadRawData(IOBuffer* buf, |
| 40 int buf_size, | 43 int buf_size, |
| 41 int* bytes_read) OVERRIDE; | 44 int* bytes_read) OVERRIDE; |
| 42 virtual bool IsRedirectResponse(GURL* location, | 45 virtual bool IsRedirectResponse(GURL* location, |
| 43 int* http_status_code) OVERRIDE; | 46 int* http_status_code) OVERRIDE; |
| 44 virtual Filter* SetupFilter() const OVERRIDE; | 47 virtual Filter* SetupFilter() const OVERRIDE; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 87 |
| 85 // Callback after seeking to the beginning of |byte_range_| in the file | 88 // Callback after seeking to the beginning of |byte_range_| in the file |
| 86 // on a background thread. | 89 // on a background thread. |
| 87 void DidSeek(int64 result); | 90 void DidSeek(int64 result); |
| 88 | 91 |
| 89 // Callback after data is asynchronously read from the file. | 92 // Callback after data is asynchronously read from the file. |
| 90 void DidRead(int result); | 93 void DidRead(int result); |
| 91 | 94 |
| 92 scoped_ptr<FileStream> stream_; | 95 scoped_ptr<FileStream> stream_; |
| 93 FileMetaInfo meta_info_; | 96 FileMetaInfo meta_info_; |
| 97 const scoped_refptr<base::TaskRunner> file_task_runner_; |
| 94 | 98 |
| 95 HttpByteRange byte_range_; | 99 HttpByteRange byte_range_; |
| 96 int64 remaining_bytes_; | 100 int64 remaining_bytes_; |
| 97 | 101 |
| 98 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; | 102 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; |
| 99 | 103 |
| 100 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 104 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 } // namespace net | 107 } // namespace net |
| 104 | 108 |
| 105 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 109 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
| OLD | NEW |