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" |
11 #include "content/browser/loader/stream_writer.h" | 11 #include "content/browser/loader/stream_writer.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 class URLRequest; | 14 class URLRequest; |
15 } // namespace net | 15 } // namespace net |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 class StreamRegistry; | 19 class StreamRegistry; |
20 | 20 |
21 // Redirect this resource to a stream. | 21 // Redirect this resource to a stream. |
22 class StreamResourceHandler : public ResourceHandler { | 22 class StreamResourceHandler : public ResourceHandler { |
23 public: | 23 public: |
24 // |origin| will be used to construct the URL for the Stream. See | 24 // |origin| will be used to construct the URL for the Stream. See |
25 // WebCore::BlobURL and and WebCore::SecurityOrigin in Blink to understand | 25 // WebCore::BlobURL and and WebCore::SecurityOrigin in Blink to understand |
26 // how origin check is done on resource loading. | 26 // how origin check is done on resource loading. |
27 StreamResourceHandler(net::URLRequest* request, | 27 StreamResourceHandler(net::URLRequest* request, |
28 StreamRegistry* registry, | 28 StreamRegistry* registry, |
29 const GURL& origin); | 29 const GURL& origin); |
30 virtual ~StreamResourceHandler(); | 30 ~StreamResourceHandler() override; |
31 | 31 |
32 virtual void SetController(ResourceController* controller) override; | 32 void SetController(ResourceController* controller) override; |
33 | 33 |
34 virtual bool OnUploadProgress(uint64 position, uint64 size) override; | 34 bool OnUploadProgress(uint64 position, uint64 size) override; |
35 | 35 |
36 // Not needed, as this event handler ought to be the final resource. | 36 // Not needed, as this event handler ought to be the final resource. |
37 virtual bool OnRequestRedirected(const net::RedirectInfo& redirect_info, | 37 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, |
38 ResourceResponse* resp, | 38 ResourceResponse* resp, |
39 bool* defer) override; | 39 bool* defer) override; |
40 | 40 |
41 virtual bool OnResponseStarted(ResourceResponse* resp, | 41 bool OnResponseStarted(ResourceResponse* resp, bool* defer) override; |
42 bool* defer) override; | |
43 | 42 |
44 virtual bool OnWillStart(const GURL& url, bool* defer) override; | 43 bool OnWillStart(const GURL& url, bool* defer) override; |
45 | 44 |
46 virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; | 45 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override; |
47 | 46 |
48 // Create a new buffer to store received data. | 47 // Create a new buffer to store received data. |
49 virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, | 48 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, |
50 int* buf_size, | 49 int* buf_size, |
51 int min_size) override; | 50 int min_size) override; |
52 | 51 |
53 // A read was completed, forward the data to the Stream. | 52 // A read was completed, forward the data to the Stream. |
54 virtual bool OnReadCompleted(int bytes_read, bool* defer) override; | 53 bool OnReadCompleted(int bytes_read, bool* defer) override; |
55 | 54 |
56 virtual void OnResponseCompleted(const net::URLRequestStatus& status, | 55 void OnResponseCompleted(const net::URLRequestStatus& status, |
57 const std::string& sec_info, | 56 const std::string& sec_info, |
58 bool* defer) override; | 57 bool* defer) override; |
59 | 58 |
60 virtual void OnDataDownloaded(int bytes_downloaded) override; | 59 void OnDataDownloaded(int bytes_downloaded) override; |
61 | 60 |
62 Stream* stream() { return writer_.stream(); } | 61 Stream* stream() { return writer_.stream(); } |
63 | 62 |
64 private: | 63 private: |
65 StreamWriter writer_; | 64 StreamWriter writer_; |
66 | 65 |
67 DISALLOW_COPY_AND_ASSIGN(StreamResourceHandler); | 66 DISALLOW_COPY_AND_ASSIGN(StreamResourceHandler); |
68 }; | 67 }; |
69 | 68 |
70 } // namespace content | 69 } // namespace content |
71 | 70 |
72 #endif // CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ | 71 #endif // CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_ |
OLD | NEW |