Index: content/browser/loader/stream_resource_handler.cc |
diff --git a/content/browser/loader/stream_resource_handler.cc b/content/browser/loader/stream_resource_handler.cc |
index 564165929add133bc42ebc86fde5c88993b4d602..cb4d0e77141c165419e36cc7891805e209ab691c 100644 |
--- a/content/browser/loader/stream_resource_handler.cc |
+++ b/content/browser/loader/stream_resource_handler.cc |
@@ -15,11 +15,14 @@ |
namespace content { |
-StreamResourceHandler::StreamResourceHandler(net::URLRequest* request, |
- StreamRegistry* registry, |
- const GURL& origin) |
+StreamResourceHandler::StreamResourceHandler( |
+ net::URLRequest* request, |
+ StreamRegistry* registry, |
+ const GURL& origin, |
+ const std::string& payload) |
: ResourceHandler(request), |
- read_buffer_(NULL) { |
+ read_buffer_(NULL), |
+ payload_(payload) { |
// TODO(tyoshino): Find a way to share this with the blob URL creation in |
// WebKit. |
GURL url(std::string(kBlobScheme) + ":" + origin.spec() + |
@@ -47,6 +50,29 @@ bool StreamResourceHandler::OnRequestRedirected(int request_id, |
bool StreamResourceHandler::OnResponseStarted(int request_id, |
ResourceResponse* resp, |
bool* defer) { |
+ if (next_handler_) { |
+ bool defer_ignored = false; |
+ next_handler_->OnResponseStarted(request_id, resp, &defer_ignored); |
+ DCHECK(!defer_ignored); |
+ std::string response = payload_; |
+ |
+ scoped_refptr<net::IOBuffer> buf; |
+ int size = 0; |
+ |
+ next_handler_->OnWillRead(request_id, &buf, &size, response.length()); |
+ CHECK(size >= (int)response.length()); |
+ |
+ memcpy(buf->data(), response.c_str(), response.length()); |
+ |
+ next_handler_->OnReadCompleted(request_id, response.length(), |
+ &defer_ignored); |
mmenke
2014/05/12 17:12:13
Why do we just send whatever portion of the payloa
|
+ DCHECK(!defer_ignored); |
+ |
+ net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
+ next_handler_->OnResponseCompleted(request_id, status, std::string(), |
+ &defer_ignored); |
+ DCHECK(!defer_ignored); |
+ } |
return true; |
} |