Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: content/browser/loader/stream_resource_handler.cc

Issue 263513004: Forward MIME types to BrowserPlugin when a viewer is specified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fixes Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698