OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_STREAMS_STREAM_URL_REQUEST_JOB_H_ | 5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ |
6 #define CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ | 6 #define CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include "net/http/http_status_code.h" | 8 #include "net/http/http_status_code.h" |
9 #include "net/url_request/url_request_job.h" | 9 #include "net/url_request/url_request_job.h" |
10 #include "content/browser/streams/stream_read_observer.h" | 10 #include "content/browser/streams/stream_read_observer.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class Stream; | 15 class Stream; |
16 | 16 |
17 // A request job that handles reading stream URLs. | 17 // A request job that handles reading stream URLs. |
18 class CONTENT_EXPORT StreamURLRequestJob | 18 class CONTENT_EXPORT StreamURLRequestJob |
19 : public net::URLRequestJob, | 19 : public net::URLRequestJob, |
20 public StreamReadObserver { | 20 public StreamReadObserver { |
21 public: | 21 public: |
22 StreamURLRequestJob(net::URLRequest* request, | 22 StreamURLRequestJob(net::URLRequest* request, |
23 net::NetworkDelegate* network_delegate, | 23 net::NetworkDelegate* network_delegate, |
24 scoped_refptr<Stream> stream); | 24 scoped_refptr<Stream> stream); |
25 | 25 |
26 // StreamObserver methods. | 26 // StreamObserver methods. |
27 virtual void OnDataAvailable(Stream* stream) override; | 27 void OnDataAvailable(Stream* stream) override; |
28 | 28 |
29 // net::URLRequestJob methods. | 29 // net::URLRequestJob methods. |
30 virtual void Start() override; | 30 void Start() override; |
31 virtual void Kill() override; | 31 void Kill() override; |
32 virtual bool ReadRawData(net::IOBuffer* buf, | 32 bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; |
33 int buf_size, | 33 bool GetMimeType(std::string* mime_type) const override; |
34 int* bytes_read) override; | 34 void GetResponseInfo(net::HttpResponseInfo* info) override; |
35 virtual bool GetMimeType(std::string* mime_type) const override; | 35 int GetResponseCode() const override; |
36 virtual void GetResponseInfo(net::HttpResponseInfo* info) override; | 36 void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; |
37 virtual int GetResponseCode() const override; | |
38 virtual void SetExtraRequestHeaders( | |
39 const net::HttpRequestHeaders& headers) override; | |
40 | 37 |
41 protected: | 38 protected: |
42 virtual ~StreamURLRequestJob(); | 39 ~StreamURLRequestJob() override; |
43 | 40 |
44 private: | 41 private: |
45 void DidStart(); | 42 void DidStart(); |
46 void NotifyFailure(int); | 43 void NotifyFailure(int); |
47 void HeadersCompleted(net::HttpStatusCode status_code); | 44 void HeadersCompleted(net::HttpStatusCode status_code); |
48 void ClearStream(); | 45 void ClearStream(); |
49 | 46 |
50 base::WeakPtrFactory<StreamURLRequestJob> weak_factory_; | 47 base::WeakPtrFactory<StreamURLRequestJob> weak_factory_; |
51 scoped_refptr<content::Stream> stream_; | 48 scoped_refptr<content::Stream> stream_; |
52 bool headers_set_; | 49 bool headers_set_; |
53 scoped_refptr<net::IOBuffer> pending_buffer_; | 50 scoped_refptr<net::IOBuffer> pending_buffer_; |
54 int pending_buffer_size_; | 51 int pending_buffer_size_; |
55 scoped_ptr<net::HttpResponseInfo> response_info_; | 52 scoped_ptr<net::HttpResponseInfo> response_info_; |
56 | 53 |
57 int total_bytes_read_; | 54 int total_bytes_read_; |
58 int max_range_; | 55 int max_range_; |
59 bool request_failed_; | 56 bool request_failed_; |
60 | 57 |
61 DISALLOW_COPY_AND_ASSIGN(StreamURLRequestJob); | 58 DISALLOW_COPY_AND_ASSIGN(StreamURLRequestJob); |
62 }; | 59 }; |
63 | 60 |
64 } // namespace content | 61 } // namespace content |
65 | 62 |
66 #endif // CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ | 63 #endif // CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ |
OLD | NEW |