| 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/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 #include "net/http/http_byte_range.h" | 15 #include "net/http/http_byte_range.h" |
| 16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
| 18 | 18 |
| 19 namespace base{ | 19 namespace base { |
| 20 class TaskRunner; | 20 class TaskRunner; |
| 21 } | 21 } |
| 22 namespace file_util { | 22 namespace file_util { |
| 23 struct FileInfo; | 23 struct FileInfo; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 | 27 |
| 28 class FileStream; | 28 class FileStream; |
| 29 | 29 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 virtual bool ReadRawData(IOBuffer* buf, | 41 virtual bool ReadRawData(IOBuffer* buf, |
| 42 int buf_size, | 42 int buf_size, |
| 43 int* bytes_read) OVERRIDE; | 43 int* bytes_read) OVERRIDE; |
| 44 virtual bool IsRedirectResponse(GURL* location, | 44 virtual bool IsRedirectResponse(GURL* location, |
| 45 int* http_status_code) OVERRIDE; | 45 int* http_status_code) OVERRIDE; |
| 46 virtual Filter* SetupFilter() const OVERRIDE; | 46 virtual Filter* SetupFilter() const OVERRIDE; |
| 47 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 47 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 48 virtual void SetExtraRequestHeaders( | 48 virtual void SetExtraRequestHeaders( |
| 49 const HttpRequestHeaders& headers) OVERRIDE; | 49 const HttpRequestHeaders& headers) OVERRIDE; |
| 50 | 50 |
| 51 // An interface for subclasses who wish to monitor read operations. |
| 52 virtual void OnSeekComplete(int64 result); |
| 53 virtual void OnReadComplete(net::IOBuffer* buf, int result); |
| 54 |
| 51 protected: | 55 protected: |
| 52 virtual ~URLRequestFileJob(); | 56 virtual ~URLRequestFileJob(); |
| 53 | 57 |
| 54 // The OS-specific full path name of the file | 58 // The OS-specific full path name of the file |
| 55 base::FilePath file_path_; | 59 base::FilePath file_path_; |
| 56 | 60 |
| 57 private: | 61 private: |
| 58 // Meta information about the file. It's used as a member in the | 62 // Meta information about the file. It's used as a member in the |
| 59 // URLRequestFileJob and also passed between threads because disk access is | 63 // URLRequestFileJob and also passed between threads because disk access is |
| 60 // necessary to obtain it. | 64 // necessary to obtain it. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 // Callback after fetching file info on a background thread. | 85 // Callback after fetching file info on a background thread. |
| 82 void DidFetchMetaInfo(const FileMetaInfo* meta_info); | 86 void DidFetchMetaInfo(const FileMetaInfo* meta_info); |
| 83 | 87 |
| 84 // Callback after opening file on a background thread. | 88 // Callback after opening file on a background thread. |
| 85 void DidOpen(int result); | 89 void DidOpen(int result); |
| 86 | 90 |
| 87 // Callback after seeking to the beginning of |byte_range_| in the file | 91 // Callback after seeking to the beginning of |byte_range_| in the file |
| 88 // on a background thread. | 92 // on a background thread. |
| 89 void DidSeek(int64 result); | 93 void DidSeek(int64 result); |
| 90 | 94 |
| 91 // Callback after data is asynchronously read from the file. | 95 // Callback after data is asynchronously read from the file into |buf|. |
| 92 void DidRead(int result); | 96 void DidRead(scoped_refptr<net::IOBuffer> buf, int result); |
| 93 | 97 |
| 94 scoped_ptr<FileStream> stream_; | 98 scoped_ptr<FileStream> stream_; |
| 95 FileMetaInfo meta_info_; | 99 FileMetaInfo meta_info_; |
| 96 const scoped_refptr<base::TaskRunner> file_task_runner_; | 100 const scoped_refptr<base::TaskRunner> file_task_runner_; |
| 97 | 101 |
| 98 HttpByteRange byte_range_; | 102 HttpByteRange byte_range_; |
| 99 int64 remaining_bytes_; | 103 int64 remaining_bytes_; |
| 100 | 104 |
| 101 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; | 105 base::WeakPtrFactory<URLRequestFileJob> weak_ptr_factory_; |
| 102 | 106 |
| 103 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); | 107 DISALLOW_COPY_AND_ASSIGN(URLRequestFileJob); |
| 104 }; | 108 }; |
| 105 | 109 |
| 106 } // namespace net | 110 } // namespace net |
| 107 | 111 |
| 108 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ | 112 #endif // NET_URL_REQUEST_URL_REQUEST_FILE_JOB_H_ |
| OLD | NEW |