| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 void DevToolsHttpHandler::SendJson(int connection_id, | 806 void DevToolsHttpHandler::SendJson(int connection_id, |
| 807 net::HttpStatusCode status_code, | 807 net::HttpStatusCode status_code, |
| 808 base::Value* value, | 808 base::Value* value, |
| 809 const std::string& message) { | 809 const std::string& message) { |
| 810 if (!thread_) | 810 if (!thread_) |
| 811 return; | 811 return; |
| 812 | 812 |
| 813 // Serialize value and message. | 813 // Serialize value and message. |
| 814 std::string json_value; | 814 std::string json_value; |
| 815 if (value) { | 815 if (value) { |
| 816 base::JSONWriter::WriteWithOptions(value, | 816 base::JSONWriter::WriteWithOptions( |
| 817 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 817 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json_value); |
| 818 &json_value); | |
| 819 } | 818 } |
| 820 std::string json_message; | 819 std::string json_message; |
| 821 scoped_ptr<base::Value> message_object(new base::StringValue(message)); | 820 base::JSONWriter::Write(base::StringValue(message), &json_message); |
| 822 base::JSONWriter::Write(message_object.get(), &json_message); | |
| 823 | 821 |
| 824 net::HttpServerResponseInfo response(status_code); | 822 net::HttpServerResponseInfo response(status_code); |
| 825 response.SetBody(json_value + message, "application/json; charset=UTF-8"); | 823 response.SetBody(json_value + message, "application/json; charset=UTF-8"); |
| 826 | 824 |
| 827 thread_->message_loop()->PostTask( | 825 thread_->message_loop()->PostTask( |
| 828 FROM_HERE, | 826 FROM_HERE, |
| 829 base::Bind(&ServerWrapper::SendResponse, | 827 base::Bind(&ServerWrapper::SendResponse, |
| 830 base::Unretained(server_wrapper_), | 828 base::Unretained(server_wrapper_), |
| 831 connection_id, | 829 connection_id, |
| 832 response)); | 830 response)); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 id.c_str(), | 916 id.c_str(), |
| 919 host); | 917 host); |
| 920 dictionary->SetString( | 918 dictionary->SetString( |
| 921 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 919 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 922 } | 920 } |
| 923 | 921 |
| 924 return dictionary; | 922 return dictionary; |
| 925 } | 923 } |
| 926 | 924 |
| 927 } // namespace devtools_http_handler | 925 } // namespace devtools_http_handler |
| OLD | NEW |