OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ |
| 6 #define CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ |
| 7 |
| 8 #include "net/url_request/url_request_job.h" |
| 9 #include "content/browser/streams/chrome_stream.h" |
| 10 #include "content/common/content_export.h" |
| 11 |
| 12 namespace content { |
| 13 class ChromeStream; |
| 14 |
| 15 // A request job that handles reading stream URLs. |
| 16 class CONTENT_EXPORT StreamURLRequestJob |
| 17 : public net::URLRequestJob, |
| 18 public ChromeStreamObserver { |
| 19 public: |
| 20 StreamURLRequestJob(net::URLRequest* request, |
| 21 net::NetworkDelegate* network_delegate, |
| 22 scoped_refptr<ChromeStream> stream); |
| 23 |
| 24 // ChromeStreamObserver methods. |
| 25 virtual void OnDataAvailable(ChromeStream* stream) OVERRIDE; |
| 26 virtual void OnStreamComplete(ChromeStream* stream) OVERRIDE; |
| 27 virtual void OnBufferAvailable(ChromeStream* stream) OVERRIDE; |
| 28 |
| 29 // net::URLRequestJob methods. |
| 30 virtual void Start() OVERRIDE; |
| 31 virtual void Kill() OVERRIDE; |
| 32 virtual bool ReadRawData(net::IOBuffer* buf, |
| 33 int buf_size, |
| 34 int* bytes_read) OVERRIDE; |
| 35 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 36 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
| 37 virtual int GetResponseCode() const OVERRIDE; |
| 38 virtual void SetExtraRequestHeaders( |
| 39 const net::HttpRequestHeaders& headers) OVERRIDE; |
| 40 |
| 41 protected: |
| 42 virtual ~StreamURLRequestJob(); |
| 43 |
| 44 private: |
| 45 void DidStart(); |
| 46 void NotifyFailure(int); |
| 47 void HeadersCompleted(int status_code, const std::string& status_txt); |
| 48 |
| 49 base::WeakPtrFactory<StreamURLRequestJob> weak_factory_; |
| 50 scoped_refptr<content::ChromeStream> stream_; |
| 51 bool headers_set_; |
| 52 scoped_refptr<net::IOBuffer> pending_buffer_; |
| 53 int pending_buffer_size_; |
| 54 scoped_ptr<net::HttpResponseInfo> response_info_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(StreamURLRequestJob); |
| 57 }; |
| 58 |
| 59 } // namespace content |
| 60 |
| 61 #endif // CONTENT_BROWSER_STREAMS_STREAM_URL_REQUEST_JOB_H_ |
OLD | NEW |