OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_ |
6 #define CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_ | 6 #define CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_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 "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "net/base/net_errors.h" | |
16 #include "net/http/http_byte_range.h" | 15 #include "net/http/http_byte_range.h" |
17 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
18 #include "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
19 | 18 |
20 namespace base { | 19 namespace base { |
21 class TaskRunner; | 20 class TaskRunner; |
22 } | 21 } |
23 | 22 |
24 namespace file_util { | 23 namespace file_util { |
25 struct FileInfo; | 24 struct FileInfo; |
(...skipping 10 matching lines...) Expand all Loading... |
36 public: | 35 public: |
37 URLRequestContentJob( | 36 URLRequestContentJob( |
38 net::URLRequest* request, | 37 net::URLRequest* request, |
39 net::NetworkDelegate* network_delegate, | 38 net::NetworkDelegate* network_delegate, |
40 const base::FilePath& content_path, | 39 const base::FilePath& content_path, |
41 const scoped_refptr<base::TaskRunner>& content_task_runner); | 40 const scoped_refptr<base::TaskRunner>& content_task_runner); |
42 | 41 |
43 // net::URLRequestJob: | 42 // net::URLRequestJob: |
44 void Start() override; | 43 void Start() override; |
45 void Kill() override; | 44 void Kill() override; |
46 int ReadRawData(net::IOBuffer* buf, int buf_size) override; | 45 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; |
47 bool IsRedirectResponse(GURL* location, int* http_status_code) override; | 46 bool IsRedirectResponse(GURL* location, int* http_status_code) override; |
48 bool GetMimeType(std::string* mime_type) const override; | 47 bool GetMimeType(std::string* mime_type) const override; |
49 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; | 48 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; |
50 | 49 |
51 protected: | 50 protected: |
52 ~URLRequestContentJob() override; | 51 ~URLRequestContentJob() override; |
53 | 52 |
54 private: | 53 private: |
55 // Meta information about the content URI. It's used as a member in the | 54 // Meta information about the content URI. It's used as a member in the |
56 // URLRequestContentJob and also passed between threads because disk access is | 55 // URLRequestContentJob and also passed between threads because disk access is |
(...skipping 16 matching lines...) Expand all Loading... |
73 void DidFetchMetaInfo(const ContentMetaInfo* meta_info); | 72 void DidFetchMetaInfo(const ContentMetaInfo* meta_info); |
74 | 73 |
75 // Callback after opening content URI on a background thread. | 74 // Callback after opening content URI on a background thread. |
76 void DidOpen(int result); | 75 void DidOpen(int result); |
77 | 76 |
78 // Callback after seeking to the beginning of |byte_range_| in the content URI | 77 // Callback after seeking to the beginning of |byte_range_| in the content URI |
79 // on a background thread. | 78 // on a background thread. |
80 void DidSeek(int64 result); | 79 void DidSeek(int64 result); |
81 | 80 |
82 // Callback after data is asynchronously read from the content URI into |buf|. | 81 // Callback after data is asynchronously read from the content URI into |buf|. |
83 void DidRead(int result); | 82 void DidRead(scoped_refptr<net::IOBuffer> buf, int result); |
84 | 83 |
85 // The full path of the content URI. | 84 // The full path of the content URI. |
86 base::FilePath content_path_; | 85 base::FilePath content_path_; |
87 | 86 |
88 scoped_ptr<net::FileStream> stream_; | 87 scoped_ptr<net::FileStream> stream_; |
89 ContentMetaInfo meta_info_; | 88 ContentMetaInfo meta_info_; |
90 const scoped_refptr<base::TaskRunner> content_task_runner_; | 89 const scoped_refptr<base::TaskRunner> content_task_runner_; |
91 | 90 |
92 net::HttpByteRange byte_range_; | 91 net::HttpByteRange byte_range_; |
93 net::Error range_parse_result_; | |
94 int64 remaining_bytes_; | 92 int64 remaining_bytes_; |
95 | 93 |
96 bool io_pending_; | 94 bool io_pending_; |
97 | 95 |
98 base::WeakPtrFactory<URLRequestContentJob> weak_ptr_factory_; | 96 base::WeakPtrFactory<URLRequestContentJob> weak_ptr_factory_; |
99 | 97 |
100 DISALLOW_COPY_AND_ASSIGN(URLRequestContentJob); | 98 DISALLOW_COPY_AND_ASSIGN(URLRequestContentJob); |
101 }; | 99 }; |
102 | 100 |
103 } // namespace content | 101 } // namespace content |
104 | 102 |
105 #endif // CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_ | 103 #endif // CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_ |
OLD | NEW |