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

Side by Side Diff: content/browser/devtools/devtools_http_handler_impl.cc

Issue 19637005: Allow HttpServer response to include custom headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, add back original Send method Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/devtools/devtools_http_handler_impl.h ('k') | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/devtools/devtools_http_handler_impl.h" 5 #include "content/browser/devtools/devtools_http_handler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 25 matching lines...) Expand all
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/notification_types.h" 37 #include "content/public/browser/notification_types.h"
38 #include "content/public/browser/render_view_host.h" 38 #include "content/public/browser/render_view_host.h"
39 #include "content/public/common/content_client.h" 39 #include "content/public/common/content_client.h"
40 #include "content/public/common/url_constants.h" 40 #include "content/public/common/url_constants.h"
41 #include "grit/devtools_resources_map.h" 41 #include "grit/devtools_resources_map.h"
42 #include "net/base/escape.h" 42 #include "net/base/escape.h"
43 #include "net/base/io_buffer.h" 43 #include "net/base/io_buffer.h"
44 #include "net/base/ip_endpoint.h" 44 #include "net/base/ip_endpoint.h"
45 #include "net/server/http_server_request_info.h" 45 #include "net/server/http_server_request_info.h"
46 #include "net/server/http_server_response_info.h"
46 #include "ui/base/layout.h" 47 #include "ui/base/layout.h"
47 #include "url/gurl.h" 48 #include "url/gurl.h"
48 #include "webkit/common/user_agent/user_agent.h" 49 #include "webkit/common/user_agent/user_agent.h"
49 #include "webkit/common/user_agent/user_agent_util.h" 50 #include "webkit/common/user_agent/user_agent_util.h"
50 51
51 namespace content { 52 namespace content {
52 53
53 const int kBufferSize = 16 * 1024; 54 const int kBufferSize = 16 * 1024;
54 55
55 namespace { 56 namespace {
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 std::string json_value; 748 std::string json_value;
748 if (value) { 749 if (value) {
749 base::JSONWriter::WriteWithOptions(value, 750 base::JSONWriter::WriteWithOptions(value,
750 base::JSONWriter::OPTIONS_PRETTY_PRINT, 751 base::JSONWriter::OPTIONS_PRETTY_PRINT,
751 &json_value); 752 &json_value);
752 } 753 }
753 std::string json_message; 754 std::string json_message;
754 scoped_ptr<base::Value> message_object(new base::StringValue(message)); 755 scoped_ptr<base::Value> message_object(new base::StringValue(message));
755 base::JSONWriter::Write(message_object.get(), &json_message); 756 base::JSONWriter::Write(message_object.get(), &json_message);
756 757
757 std::string response; 758 net::HttpServerResponseInfo response(status_code);
758 std::string mime_type = "application/json; charset=UTF-8"; 759 response.SetBody(json_value + message, "application/json; charset=UTF-8");
759
760 response = base::StringPrintf("%s%s", json_value.c_str(), message.c_str());
761 760
762 thread_->message_loop()->PostTask( 761 thread_->message_loop()->PostTask(
763 FROM_HERE, 762 FROM_HERE,
764 base::Bind(&net::HttpServer::Send, 763 base::Bind(&net::HttpServer::SendResponse,
765 server_.get(), 764 server_.get(),
766 connection_id, 765 connection_id,
767 status_code, 766 response));
768 response,
769 mime_type));
770 } 767 }
771 768
772 void DevToolsHttpHandlerImpl::Send200(int connection_id, 769 void DevToolsHttpHandlerImpl::Send200(int connection_id,
773 const std::string& data, 770 const std::string& data,
774 const std::string& mime_type) { 771 const std::string& mime_type) {
775 if (!thread_) 772 if (!thread_)
776 return; 773 return;
777 thread_->message_loop()->PostTask( 774 thread_->message_loop()->PostTask(
778 FROM_HERE, 775 FROM_HERE,
779 base::Bind(&net::HttpServer::Send200, 776 base::Bind(&net::HttpServer::Send200,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 host.c_str(), 883 host.c_str(),
887 kPageUrlPrefix, 884 kPageUrlPrefix,
888 id.c_str())); 885 id.c_str()));
889 std::string devtools_frontend_url = GetFrontendURLInternal( 886 std::string devtools_frontend_url = GetFrontendURLInternal(
890 id.c_str(), 887 id.c_str(),
891 host); 888 host);
892 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); 889 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url);
893 } 890 }
894 891
895 } // namespace content 892 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_http_handler_impl.h ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698