| 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_LOADER_STREAM_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/browser/loader/resource_handler.h" | 10 #include "content/browser/loader/resource_handler.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 // Redirect this resource to a stream. | 22 // Redirect this resource to a stream. |
| 23 class StreamResourceHandler : public StreamWriteObserver, | 23 class StreamResourceHandler : public StreamWriteObserver, |
| 24 public ResourceHandler { | 24 public ResourceHandler { |
| 25 public: | 25 public: |
| 26 // |origin| will be used to construct the URL for the Stream. See | 26 // |origin| will be used to construct the URL for the Stream. See |
| 27 // WebCore::BlobURL and and WebCore::SecurityOrigin in Blink to understand | 27 // WebCore::BlobURL and and WebCore::SecurityOrigin in Blink to understand |
| 28 // how origin check is done on resource loading. | 28 // how origin check is done on resource loading. |
| 29 StreamResourceHandler(net::URLRequest* request, | 29 StreamResourceHandler(net::URLRequest* request, |
| 30 StreamRegistry* registry, | 30 StreamRegistry* registry, |
| 31 const GURL& origin); | 31 const GURL& origin, |
| 32 const std::string& payload); |
| 32 virtual ~StreamResourceHandler(); | 33 virtual ~StreamResourceHandler(); |
| 33 | 34 |
| 34 virtual bool OnUploadProgress(int request_id, | 35 virtual bool OnUploadProgress(int request_id, |
| 35 uint64 position, | 36 uint64 position, |
| 36 uint64 size) OVERRIDE; | 37 uint64 size) OVERRIDE; |
| 37 | 38 |
| 38 // Not needed, as this event handler ought to be the final resource. | 39 // Not needed, as this event handler ought to be the final resource. |
| 39 virtual bool OnRequestRedirected(int request_id, | 40 virtual bool OnRequestRedirected(int request_id, |
| 40 const GURL& url, | 41 const GURL& url, |
| 41 ResourceResponse* resp, | 42 ResourceResponse* resp, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 65 bool* defer) OVERRIDE; | 66 bool* defer) OVERRIDE; |
| 66 | 67 |
| 67 virtual void OnResponseCompleted(int request_id, | 68 virtual void OnResponseCompleted(int request_id, |
| 68 const net::URLRequestStatus& status, | 69 const net::URLRequestStatus& status, |
| 69 const std::string& sec_info, | 70 const std::string& sec_info, |
| 70 bool* defer) OVERRIDE; | 71 bool* defer) OVERRIDE; |
| 71 | 72 |
| 72 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; | 73 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; |
| 73 | 74 |
| 74 Stream* stream() { return stream_.get(); } | 75 Stream* stream() { return stream_.get(); } |
| 76 void SetNextHandler(scoped_ptr<ResourceHandler> next_handler) { |
| 77 next_handler_ = next_handler.Pass(); |
| 78 } |
| 79 bool HasPayload() { |
| 80 return !payload_.empty(); |
| 81 } |
| 75 | 82 |
| 76 private: | 83 private: |
| 77 virtual void OnSpaceAvailable(Stream* stream) OVERRIDE; | 84 virtual void OnSpaceAvailable(Stream* stream) OVERRIDE; |
| 78 virtual void OnClose(Stream* stream) OVERRIDE; | 85 virtual void OnClose(Stream* stream) OVERRIDE; |
| 79 | 86 |
| 80 scoped_refptr<Stream> stream_; | 87 scoped_refptr<Stream> stream_; |
| 81 scoped_refptr<net::IOBuffer> read_buffer_; | 88 scoped_refptr<net::IOBuffer> read_buffer_; |
| 89 scoped_ptr<ResourceHandler> next_handler_; |
| 90 std::string payload_; |
| 91 |
| 82 DISALLOW_COPY_AND_ASSIGN(StreamResourceHandler); | 92 DISALLOW_COPY_AND_ASSIGN(StreamResourceHandler); |
| 83 }; | 93 }; |
| 84 | 94 |
| 85 } // namespace content | 95 } // namespace content |
| 86 | 96 |
| 87 #endif // CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ | 97 #endif // CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ |
| OLD | NEW |