| 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 "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 <sstream> | 8 #include <sstream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 35 #include "content/public/common/user_agent.h" | 35 #include "content/public/common/user_agent.h" |
| 36 #include "content/public/common/user_agent.h" | 36 #include "content/public/common/user_agent.h" |
| 37 #include "grit/devtools_resources_map.h" | 37 #include "grit/devtools_resources_map.h" |
| 38 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
| 39 #include "net/base/io_buffer.h" | 39 #include "net/base/io_buffer.h" |
| 40 #include "net/base/ip_endpoint.h" | 40 #include "net/base/ip_endpoint.h" |
| 41 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
| 42 #include "net/server/http_server_request_info.h" | 42 #include "net/server/http_server_request_info.h" |
| 43 #include "net/server/http_server_response_info.h" | 43 #include "net/server/http_server_response_info.h" |
| 44 #include "net/socket/server_socket.h" |
| 44 | 45 |
| 45 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
| 46 #include "base/android/build_info.h" | 47 #include "base/android/build_info.h" |
| 47 #endif | 48 #endif |
| 48 | 49 |
| 49 namespace content { | 50 namespace content { |
| 50 | 51 |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 const base::FilePath::CharType kDevToolsActivePortFileName[] = | 54 const base::FilePath::CharType kDevToolsActivePortFileName[] = |
| 54 FILE_PATH_LITERAL("DevToolsActivePort"); | 55 FILE_PATH_LITERAL("DevToolsActivePort"); |
| 55 | 56 |
| 56 const char kDevToolsHandlerThreadName[] = "Chrome_DevToolsHandlerThread"; | 57 const char kDevToolsHandlerThreadName[] = "Chrome_DevToolsHandlerThread"; |
| 57 | 58 |
| 58 const char kThumbUrlPrefix[] = "/thumb/"; | 59 const char kThumbUrlPrefix[] = "/thumb/"; |
| 59 const char kPageUrlPrefix[] = "/devtools/page/"; | 60 const char kPageUrlPrefix[] = "/devtools/page/"; |
| 60 | 61 |
| 61 const char kTargetIdField[] = "id"; | 62 const char kTargetIdField[] = "id"; |
| 62 const char kTargetParentIdField[] = "parentId"; | 63 const char kTargetParentIdField[] = "parentId"; |
| 63 const char kTargetTypeField[] = "type"; | 64 const char kTargetTypeField[] = "type"; |
| 64 const char kTargetTitleField[] = "title"; | 65 const char kTargetTitleField[] = "title"; |
| 65 const char kTargetDescriptionField[] = "description"; | 66 const char kTargetDescriptionField[] = "description"; |
| 66 const char kTargetUrlField[] = "url"; | 67 const char kTargetUrlField[] = "url"; |
| 67 const char kTargetThumbnailUrlField[] = "thumbnailUrl"; | 68 const char kTargetThumbnailUrlField[] = "thumbnailUrl"; |
| 68 const char kTargetFaviconUrlField[] = "faviconUrl"; | 69 const char kTargetFaviconUrlField[] = "faviconUrl"; |
| 69 const char kTargetWebSocketDebuggerUrlField[] = "webSocketDebuggerUrl"; | 70 const char kTargetWebSocketDebuggerUrlField[] = "webSocketDebuggerUrl"; |
| 70 const char kTargetDevtoolsFrontendUrlField[] = "devtoolsFrontendUrl"; | 71 const char kTargetDevtoolsFrontendUrlField[] = "devtoolsFrontendUrl"; |
| 71 | 72 |
| 73 // Maximum write buffer size of devtools http/websocket connectinos. |
| 74 const int32 kSendBufferSizeForDevTools = 100 * 1024 * 1024; // 100Mb |
| 75 |
| 72 // An internal implementation of DevToolsClientHost that delegates | 76 // An internal implementation of DevToolsClientHost that delegates |
| 73 // messages sent for DevToolsClient to a DebuggerShell instance. | 77 // messages sent for DevToolsClient to a DebuggerShell instance. |
| 74 class DevToolsClientHostImpl : public DevToolsClientHost { | 78 class DevToolsClientHostImpl : public DevToolsClientHost { |
| 75 public: | 79 public: |
| 76 DevToolsClientHostImpl(base::MessageLoop* message_loop, | 80 DevToolsClientHostImpl(base::MessageLoop* message_loop, |
| 77 net::HttpServer* server, | 81 net::HttpServer* server, |
| 78 int connection_id) | 82 int connection_id) |
| 79 : message_loop_(message_loop), | 83 : message_loop_(message_loop), |
| 80 server_(server), | 84 server_(server), |
| 81 connection_id_(connection_id), | 85 connection_id_(connection_id), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 | 96 |
| 93 base::DictionaryValue notification; | 97 base::DictionaryValue notification; |
| 94 notification.SetString( | 98 notification.SetString( |
| 95 devtools::Inspector::detached::kParamReason, detach_reason_); | 99 devtools::Inspector::detached::kParamReason, detach_reason_); |
| 96 std::string response = DevToolsProtocol::CreateNotification( | 100 std::string response = DevToolsProtocol::CreateNotification( |
| 97 devtools::Inspector::detached::kName, | 101 devtools::Inspector::detached::kName, |
| 98 notification.DeepCopy())->Serialize(); | 102 notification.DeepCopy())->Serialize(); |
| 99 message_loop_->PostTask( | 103 message_loop_->PostTask( |
| 100 FROM_HERE, | 104 FROM_HERE, |
| 101 base::Bind(&net::HttpServer::SendOverWebSocket, | 105 base::Bind(&net::HttpServer::SendOverWebSocket, |
| 102 server_, | 106 base::Unretained(server_), |
| 103 connection_id_, | 107 connection_id_, |
| 104 response)); | 108 response)); |
| 105 | 109 |
| 106 message_loop_->PostTask( | 110 message_loop_->PostTask( |
| 107 FROM_HERE, | 111 FROM_HERE, |
| 108 base::Bind(&net::HttpServer::Close, server_, connection_id_)); | 112 base::Bind(&net::HttpServer::Close, |
| 113 base::Unretained(server_), |
| 114 connection_id_)); |
| 109 } | 115 } |
| 110 | 116 |
| 111 virtual void DispatchOnInspectorFrontend(const std::string& data) OVERRIDE { | 117 virtual void DispatchOnInspectorFrontend(const std::string& data) OVERRIDE { |
| 112 message_loop_->PostTask( | 118 message_loop_->PostTask( |
| 113 FROM_HERE, | 119 FROM_HERE, |
| 114 base::Bind(&net::HttpServer::SendOverWebSocket, | 120 base::Bind(&net::HttpServer::SendOverWebSocket, |
| 115 server_, | 121 base::Unretained(server_), |
| 116 connection_id_, | 122 connection_id_, |
| 117 data)); | 123 data)); |
| 118 } | 124 } |
| 119 | 125 |
| 120 virtual void ReplacedWithAnotherClient() OVERRIDE { | 126 virtual void ReplacedWithAnotherClient() OVERRIDE { |
| 121 detach_reason_ = "replaced_with_devtools"; | 127 detach_reason_ = "replaced_with_devtools"; |
| 122 } | 128 } |
| 123 | 129 |
| 124 private: | 130 private: |
| 125 base::MessageLoop* message_loop_; | 131 base::MessageLoop* const message_loop_; |
| 126 net::HttpServer* server_; | 132 net::HttpServer* const server_; |
| 127 int connection_id_; | 133 const int connection_id_; |
| 128 bool is_closed_; | 134 bool is_closed_; |
| 129 std::string detach_reason_; | 135 std::string detach_reason_; |
| 130 }; | 136 }; |
| 131 | 137 |
| 132 static bool TimeComparator(const DevToolsTarget* target1, | 138 static bool TimeComparator(const DevToolsTarget* target1, |
| 133 const DevToolsTarget* target2) { | 139 const DevToolsTarget* target2) { |
| 134 return target1->GetLastActivityTime() > target2->GetLastActivityTime(); | 140 return target1->GetLastActivityTime() > target2->GetLastActivityTime(); |
| 135 } | 141 } |
| 136 | 142 |
| 137 } // namespace | 143 } // namespace |
| 138 | 144 |
| 139 // static | 145 // static |
| 140 bool DevToolsHttpHandler::IsSupportedProtocolVersion( | 146 bool DevToolsHttpHandler::IsSupportedProtocolVersion( |
| 141 const std::string& version) { | 147 const std::string& version) { |
| 142 return devtools::IsSupportedProtocolVersion(version); | 148 return devtools::IsSupportedProtocolVersion(version); |
| 143 } | 149 } |
| 144 | 150 |
| 145 // static | 151 // static |
| 146 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { | 152 int DevToolsHttpHandler::GetFrontendResourceId(const std::string& name) { |
| 147 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { | 153 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { |
| 148 if (name == kDevtoolsResources[i].name) | 154 if (name == kDevtoolsResources[i].name) |
| 149 return kDevtoolsResources[i].value; | 155 return kDevtoolsResources[i].value; |
| 150 } | 156 } |
| 151 return -1; | 157 return -1; |
| 152 } | 158 } |
| 153 | 159 |
| 154 // static | 160 // static |
| 155 DevToolsHttpHandler* DevToolsHttpHandler::Start( | 161 DevToolsHttpHandler* DevToolsHttpHandler::Start( |
| 156 const net::StreamListenSocketFactory* socket_factory, | 162 scoped_ptr<ServerSocketFactory> server_socket_factory, |
| 157 const std::string& frontend_url, | 163 const std::string& frontend_url, |
| 158 DevToolsHttpHandlerDelegate* delegate, | 164 DevToolsHttpHandlerDelegate* delegate, |
| 159 const base::FilePath& active_port_output_directory) { | 165 const base::FilePath& active_port_output_directory) { |
| 160 DevToolsHttpHandlerImpl* http_handler = | 166 DevToolsHttpHandlerImpl* http_handler = |
| 161 new DevToolsHttpHandlerImpl(socket_factory, | 167 new DevToolsHttpHandlerImpl(server_socket_factory.Pass(), |
| 162 frontend_url, | 168 frontend_url, |
| 163 delegate, | 169 delegate, |
| 164 active_port_output_directory); | 170 active_port_output_directory); |
| 165 http_handler->Start(); | 171 http_handler->Start(); |
| 166 return http_handler; | 172 return http_handler; |
| 167 } | 173 } |
| 168 | 174 |
| 175 DevToolsHttpHandler::ServerSocketFactory::ServerSocketFactory( |
| 176 const std::string& address, |
| 177 int port, |
| 178 int backlog) |
| 179 : address_(address), |
| 180 port_(port), |
| 181 backlog_(backlog) { |
| 182 } |
| 183 |
| 184 DevToolsHttpHandler::ServerSocketFactory::~ServerSocketFactory() { |
| 185 } |
| 186 |
| 187 scoped_ptr<net::ServerSocket> |
| 188 DevToolsHttpHandler::ServerSocketFactory::CreateAndListen() const { |
| 189 scoped_ptr<net::ServerSocket> socket = Create(); |
| 190 if (socket && |
| 191 socket->ListenWithAddressAndPort(address_, port_, backlog_) == net::OK) { |
| 192 return socket.Pass(); |
| 193 } |
| 194 return scoped_ptr<net::ServerSocket>(); |
| 195 } |
| 196 |
| 169 DevToolsHttpHandlerImpl::~DevToolsHttpHandlerImpl() { | 197 DevToolsHttpHandlerImpl::~DevToolsHttpHandlerImpl() { |
| 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 171 // Stop() must be called prior to destruction. | 199 // Stop() must be called prior to destruction. |
| 172 DCHECK(server_.get() == NULL); | 200 DCHECK(server_.get() == NULL); |
| 173 DCHECK(thread_.get() == NULL); | 201 DCHECK(thread_.get() == NULL); |
| 174 STLDeleteValues(&target_map_); | 202 STLDeleteValues(&target_map_); |
| 175 } | 203 } |
| 176 | 204 |
| 177 void DevToolsHttpHandlerImpl::Start() { | 205 void DevToolsHttpHandlerImpl::Start() { |
| 178 if (thread_) | 206 if (thread_) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 204 } | 232 } |
| 205 | 233 |
| 206 void DevToolsHttpHandlerImpl::ResetHandlerThreadAndRelease() { | 234 void DevToolsHttpHandlerImpl::ResetHandlerThreadAndRelease() { |
| 207 ResetHandlerThread(); | 235 ResetHandlerThread(); |
| 208 Release(); | 236 Release(); |
| 209 } | 237 } |
| 210 | 238 |
| 211 void DevToolsHttpHandlerImpl::Stop() { | 239 void DevToolsHttpHandlerImpl::Stop() { |
| 212 if (!thread_) | 240 if (!thread_) |
| 213 return; | 241 return; |
| 242 // Deletes DevToolsClientHostImpl which has http sever reference. |
| 243 while (!connection_to_client_host_ui_.empty()) { |
| 244 OnCloseUI(connection_to_client_host_ui_.begin()->first); |
| 245 } |
| 214 BrowserThread::PostTaskAndReply( | 246 BrowserThread::PostTaskAndReply( |
| 215 BrowserThread::FILE, FROM_HERE, | 247 BrowserThread::FILE, FROM_HERE, |
| 216 base::Bind(&DevToolsHttpHandlerImpl::StopHandlerThread, this), | 248 base::Bind(&DevToolsHttpHandlerImpl::StopHandlerThread, this), |
| 217 base::Bind(&DevToolsHttpHandlerImpl::ResetHandlerThreadAndRelease, this)); | 249 base::Bind(&DevToolsHttpHandlerImpl::ResetHandlerThreadAndRelease, this)); |
| 218 } | 250 } |
| 219 | 251 |
| 220 GURL DevToolsHttpHandlerImpl::GetFrontendURL() { | 252 GURL DevToolsHttpHandlerImpl::GetFrontendURL() { |
| 221 net::IPEndPoint ip_address; | 253 net::IPEndPoint ip_address; |
| 222 if (server_->GetLocalAddress(&ip_address)) | 254 if (server_->GetLocalAddress(&ip_address)) |
| 223 return GURL(); | 255 return GURL(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 248 LOG(ERROR) << "GetMimeType doesn't know mime type for: " | 280 LOG(ERROR) << "GetMimeType doesn't know mime type for: " |
| 249 << filename | 281 << filename |
| 250 << " text/plain will be returned"; | 282 << " text/plain will be returned"; |
| 251 NOTREACHED(); | 283 NOTREACHED(); |
| 252 return "text/plain"; | 284 return "text/plain"; |
| 253 } | 285 } |
| 254 | 286 |
| 255 void DevToolsHttpHandlerImpl::OnHttpRequest( | 287 void DevToolsHttpHandlerImpl::OnHttpRequest( |
| 256 int connection_id, | 288 int connection_id, |
| 257 const net::HttpServerRequestInfo& info) { | 289 const net::HttpServerRequestInfo& info) { |
| 290 server_->SetSendBufferSize(connection_id, kSendBufferSizeForDevTools); |
| 291 |
| 258 if (info.path.find("/json") == 0) { | 292 if (info.path.find("/json") == 0) { |
| 259 BrowserThread::PostTask( | 293 BrowserThread::PostTask( |
| 260 BrowserThread::UI, | 294 BrowserThread::UI, |
| 261 FROM_HERE, | 295 FROM_HERE, |
| 262 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, | 296 base::Bind(&DevToolsHttpHandlerImpl::OnJsonRequestUI, |
| 263 this, | 297 this, |
| 264 connection_id, | 298 connection_id, |
| 265 info)); | 299 info)); |
| 266 return; | 300 return; |
| 267 } | 301 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 true /* handle on UI thread */); | 373 true /* handle on UI thread */); |
| 340 browser_target_->RegisterDomainHandler( | 374 browser_target_->RegisterDomainHandler( |
| 341 TetheringHandler::kDomain, | 375 TetheringHandler::kDomain, |
| 342 new TetheringHandler(delegate_.get()), | 376 new TetheringHandler(delegate_.get()), |
| 343 false /* handle on this thread */); | 377 false /* handle on this thread */); |
| 344 browser_target_->RegisterDomainHandler( | 378 browser_target_->RegisterDomainHandler( |
| 345 devtools::SystemInfo::kName, | 379 devtools::SystemInfo::kName, |
| 346 new DevToolsSystemInfoHandler(), | 380 new DevToolsSystemInfoHandler(), |
| 347 true /* handle on UI thread */); | 381 true /* handle on UI thread */); |
| 348 | 382 |
| 383 server_->SetSendBufferSize(connection_id, kSendBufferSizeForDevTools); |
| 349 server_->AcceptWebSocket(connection_id, request); | 384 server_->AcceptWebSocket(connection_id, request); |
| 350 return; | 385 return; |
| 351 } | 386 } |
| 352 | 387 |
| 353 BrowserThread::PostTask( | 388 BrowserThread::PostTask( |
| 354 BrowserThread::UI, | 389 BrowserThread::UI, |
| 355 FROM_HERE, | 390 FROM_HERE, |
| 356 base::Bind( | 391 base::Bind( |
| 357 &DevToolsHttpHandlerImpl::OnWebSocketRequestUI, | 392 &DevToolsHttpHandlerImpl::OnWebSocketRequestUI, |
| 358 this, | 393 this, |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 if (it != connection_to_client_host_ui_.end()) { | 675 if (it != connection_to_client_host_ui_.end()) { |
| 641 DevToolsClientHostImpl* client_host = | 676 DevToolsClientHostImpl* client_host = |
| 642 static_cast<DevToolsClientHostImpl*>(it->second); | 677 static_cast<DevToolsClientHostImpl*>(it->second); |
| 643 DevToolsManager::GetInstance()->ClientHostClosing(client_host); | 678 DevToolsManager::GetInstance()->ClientHostClosing(client_host); |
| 644 delete client_host; | 679 delete client_host; |
| 645 connection_to_client_host_ui_.erase(connection_id); | 680 connection_to_client_host_ui_.erase(connection_id); |
| 646 } | 681 } |
| 647 } | 682 } |
| 648 | 683 |
| 649 DevToolsHttpHandlerImpl::DevToolsHttpHandlerImpl( | 684 DevToolsHttpHandlerImpl::DevToolsHttpHandlerImpl( |
| 650 const net::StreamListenSocketFactory* socket_factory, | 685 scoped_ptr<ServerSocketFactory> server_socket_factory, |
| 651 const std::string& frontend_url, | 686 const std::string& frontend_url, |
| 652 DevToolsHttpHandlerDelegate* delegate, | 687 DevToolsHttpHandlerDelegate* delegate, |
| 653 const base::FilePath& active_port_output_directory) | 688 const base::FilePath& active_port_output_directory) |
| 654 : frontend_url_(frontend_url), | 689 : frontend_url_(frontend_url), |
| 655 socket_factory_(socket_factory), | 690 server_socket_factory_(server_socket_factory.Pass()), |
| 656 delegate_(delegate), | 691 delegate_(delegate), |
| 657 active_port_output_directory_(active_port_output_directory) { | 692 active_port_output_directory_(active_port_output_directory) { |
| 658 if (frontend_url_.empty()) | 693 if (frontend_url_.empty()) |
| 659 frontend_url_ = "/devtools/devtools.html"; | 694 frontend_url_ = "/devtools/devtools.html"; |
| 660 | 695 |
| 661 // Balanced in ResetHandlerThreadAndRelease(). | 696 // Balanced in ResetHandlerThreadAndRelease(). |
| 662 AddRef(); | 697 AddRef(); |
| 663 } | 698 } |
| 664 | 699 |
| 665 // Runs on the handler thread | 700 // Runs on the handler thread |
| 666 void DevToolsHttpHandlerImpl::Init() { | 701 void DevToolsHttpHandlerImpl::Init() { |
| 667 server_ = new net::HttpServer(*socket_factory_.get(), this); | 702 server_.reset(new net::HttpServer(server_socket_factory_->CreateAndListen(), |
| 703 this)); |
| 668 if (!active_port_output_directory_.empty()) | 704 if (!active_port_output_directory_.empty()) |
| 669 WriteActivePortToUserProfile(); | 705 WriteActivePortToUserProfile(); |
| 670 } | 706 } |
| 671 | 707 |
| 672 // Runs on the handler thread | 708 // Runs on the handler thread |
| 673 void DevToolsHttpHandlerImpl::Teardown() { | 709 void DevToolsHttpHandlerImpl::Teardown() { |
| 674 server_ = NULL; | 710 // Detaches DevToolsBrowserTarget which hold http server reference. |
| 711 if (browser_target_) { |
| 712 browser_target_->Detach(); |
| 713 browser_target_ = NULL; |
| 714 } |
| 715 server_.reset(NULL); |
| 675 } | 716 } |
| 676 | 717 |
| 677 // Runs on FILE thread to make sure that it is serialized against | 718 // Runs on FILE thread to make sure that it is serialized against |
| 678 // {Start|Stop}HandlerThread and to allow calling pthread_join. | 719 // {Start|Stop}HandlerThread and to allow calling pthread_join. |
| 679 void DevToolsHttpHandlerImpl::StopHandlerThread() { | 720 void DevToolsHttpHandlerImpl::StopHandlerThread() { |
| 680 if (!thread_->message_loop()) | 721 if (!thread_->message_loop()) |
| 681 return; | 722 return; |
| 682 thread_->message_loop()->PostTask( | 723 thread_->message_loop()->PostTask( |
| 683 FROM_HERE, | 724 FROM_HERE, |
| 684 base::Bind(&DevToolsHttpHandlerImpl::Teardown, this)); | 725 base::Bind(&DevToolsHttpHandlerImpl::Teardown, this)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 std::string json_message; | 765 std::string json_message; |
| 725 scoped_ptr<base::Value> message_object(new base::StringValue(message)); | 766 scoped_ptr<base::Value> message_object(new base::StringValue(message)); |
| 726 base::JSONWriter::Write(message_object.get(), &json_message); | 767 base::JSONWriter::Write(message_object.get(), &json_message); |
| 727 | 768 |
| 728 net::HttpServerResponseInfo response(status_code); | 769 net::HttpServerResponseInfo response(status_code); |
| 729 response.SetBody(json_value + message, "application/json; charset=UTF-8"); | 770 response.SetBody(json_value + message, "application/json; charset=UTF-8"); |
| 730 | 771 |
| 731 thread_->message_loop()->PostTask( | 772 thread_->message_loop()->PostTask( |
| 732 FROM_HERE, | 773 FROM_HERE, |
| 733 base::Bind(&net::HttpServer::SendResponse, | 774 base::Bind(&net::HttpServer::SendResponse, |
| 734 server_.get(), | 775 base::Unretained(server_.get()), |
| 735 connection_id, | 776 connection_id, |
| 736 response)); | 777 response)); |
| 737 } | 778 } |
| 738 | 779 |
| 739 void DevToolsHttpHandlerImpl::Send200(int connection_id, | 780 void DevToolsHttpHandlerImpl::Send200(int connection_id, |
| 740 const std::string& data, | 781 const std::string& data, |
| 741 const std::string& mime_type) { | 782 const std::string& mime_type) { |
| 742 if (!thread_) | 783 if (!thread_) |
| 743 return; | 784 return; |
| 744 thread_->message_loop()->PostTask( | 785 thread_->message_loop()->PostTask( |
| 745 FROM_HERE, | 786 FROM_HERE, |
| 746 base::Bind(&net::HttpServer::Send200, | 787 base::Bind(&net::HttpServer::Send200, |
| 747 server_.get(), | 788 base::Unretained(server_.get()), |
| 748 connection_id, | 789 connection_id, |
| 749 data, | 790 data, |
| 750 mime_type)); | 791 mime_type)); |
| 751 } | 792 } |
| 752 | 793 |
| 753 void DevToolsHttpHandlerImpl::Send404(int connection_id) { | 794 void DevToolsHttpHandlerImpl::Send404(int connection_id) { |
| 754 if (!thread_) | 795 if (!thread_) |
| 755 return; | 796 return; |
| 756 thread_->message_loop()->PostTask( | 797 thread_->message_loop()->PostTask( |
| 757 FROM_HERE, | 798 FROM_HERE, |
| 758 base::Bind(&net::HttpServer::Send404, server_.get(), connection_id)); | 799 base::Bind(&net::HttpServer::Send404, |
| 800 base::Unretained(server_.get()), |
| 801 connection_id)); |
| 759 } | 802 } |
| 760 | 803 |
| 761 void DevToolsHttpHandlerImpl::Send500(int connection_id, | 804 void DevToolsHttpHandlerImpl::Send500(int connection_id, |
| 762 const std::string& message) { | 805 const std::string& message) { |
| 763 if (!thread_) | 806 if (!thread_) |
| 764 return; | 807 return; |
| 765 thread_->message_loop()->PostTask( | 808 thread_->message_loop()->PostTask( |
| 766 FROM_HERE, | 809 FROM_HERE, |
| 767 base::Bind(&net::HttpServer::Send500, server_.get(), connection_id, | 810 base::Bind(&net::HttpServer::Send500, |
| 811 base::Unretained(server_.get()), |
| 812 connection_id, |
| 768 message)); | 813 message)); |
| 769 } | 814 } |
| 770 | 815 |
| 771 void DevToolsHttpHandlerImpl::AcceptWebSocket( | 816 void DevToolsHttpHandlerImpl::AcceptWebSocket( |
| 772 int connection_id, | 817 int connection_id, |
| 773 const net::HttpServerRequestInfo& request) { | 818 const net::HttpServerRequestInfo& request) { |
| 774 if (!thread_) | 819 if (!thread_) |
| 775 return; | 820 return; |
| 776 thread_->message_loop()->PostTask( | 821 thread_->message_loop()->PostTask( |
| 777 FROM_HERE, | 822 FROM_HERE, |
| 778 base::Bind(&net::HttpServer::AcceptWebSocket, server_.get(), | 823 base::Bind(&net::HttpServer::SetSendBufferSize, |
| 779 connection_id, request)); | 824 base::Unretained(server_.get()), |
| 825 connection_id, |
| 826 kSendBufferSizeForDevTools)); |
| 827 thread_->message_loop()->PostTask( |
| 828 FROM_HERE, |
| 829 base::Bind(&net::HttpServer::AcceptWebSocket, |
| 830 base::Unretained(server_.get()), |
| 831 connection_id, |
| 832 request)); |
| 780 } | 833 } |
| 781 | 834 |
| 782 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializeTarget( | 835 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializeTarget( |
| 783 const DevToolsTarget& target, | 836 const DevToolsTarget& target, |
| 784 const std::string& host) { | 837 const std::string& host) { |
| 785 base::DictionaryValue* dictionary = new base::DictionaryValue; | 838 base::DictionaryValue* dictionary = new base::DictionaryValue; |
| 786 | 839 |
| 787 std::string id = target.GetId(); | 840 std::string id = target.GetId(); |
| 788 dictionary->SetString(kTargetIdField, id); | 841 dictionary->SetString(kTargetIdField, id); |
| 789 std::string parent_id = target.GetParentId(); | 842 std::string parent_id = target.GetParentId(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 816 id.c_str(), | 869 id.c_str(), |
| 817 host); | 870 host); |
| 818 dictionary->SetString( | 871 dictionary->SetString( |
| 819 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 872 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 820 } | 873 } |
| 821 | 874 |
| 822 return dictionary; | 875 return dictionary; |
| 823 } | 876 } |
| 824 | 877 |
| 825 } // namespace content | 878 } // namespace content |
| OLD | NEW |