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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 public: | 156 public: |
157 BrowserTarget(base::MessageLoop* message_loop, | 157 BrowserTarget(base::MessageLoop* message_loop, |
158 net::HttpServer* server, | 158 net::HttpServer* server, |
159 int connection_id) | 159 int connection_id) |
160 : message_loop_(message_loop), | 160 : message_loop_(message_loop), |
161 server_(server), | 161 server_(server), |
162 connection_id_(connection_id), | 162 connection_id_(connection_id), |
163 tracing_handler_(new devtools::tracing::TracingHandler( | 163 tracing_handler_(new devtools::tracing::TracingHandler( |
164 devtools::tracing::TracingHandler::Browser)), | 164 devtools::tracing::TracingHandler::Browser)), |
165 protocol_handler_(new DevToolsProtocolHandlerImpl()) { | 165 protocol_handler_(new DevToolsProtocolHandlerImpl()) { |
| 166 VLOG(2) << "BrowserTarget::BrowserTarget()"; |
166 protocol_handler_->SetNotifier( | 167 protocol_handler_->SetNotifier( |
167 base::Bind(&BrowserTarget::Respond, base::Unretained(this))); | 168 base::Bind(&BrowserTarget::Respond, base::Unretained(this))); |
168 protocol_handler_->SetTracingHandler(tracing_handler_.get()); | 169 protocol_handler_->SetTracingHandler(tracing_handler_.get()); |
169 } | 170 } |
170 | 171 |
171 ~BrowserTarget() { | 172 ~BrowserTarget() { |
| 173 VLOG(2) << "BrowserTarget::~BrowserTarget()"; |
172 STLDeleteElements(&handlers_); | 174 STLDeleteElements(&handlers_); |
173 } | 175 } |
174 | 176 |
175 // Takes ownership. | 177 // Takes ownership. |
176 void RegisterHandler(DevToolsProtocol::Handler* handler) { | 178 void RegisterHandler(DevToolsProtocol::Handler* handler) { |
177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
178 handler->SetNotifier( | 180 handler->SetNotifier( |
179 base::Bind(&BrowserTarget::Respond, base::Unretained(this))); | 181 base::Bind(&BrowserTarget::Respond, base::Unretained(this))); |
180 handlers_.push_back(handler); | 182 handlers_.push_back(handler); |
181 } | 183 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 | 695 |
694 void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( | 696 void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( |
695 int connection_id, | 697 int connection_id, |
696 const net::HttpServerRequestInfo& request) { | 698 const net::HttpServerRequestInfo& request) { |
697 if (!thread_) | 699 if (!thread_) |
698 return; | 700 return; |
699 | 701 |
700 std::string browser_prefix = "/devtools/browser"; | 702 std::string browser_prefix = "/devtools/browser"; |
701 size_t browser_pos = request.path.find(browser_prefix); | 703 size_t browser_pos = request.path.find(browser_prefix); |
702 if (browser_pos == 0) { | 704 if (browser_pos == 0) { |
| 705 VLOG(2) << "OnWebSocketRequestUI: new BrowserTarget"; |
703 BrowserTarget* browser_target = new BrowserTarget( | 706 BrowserTarget* browser_target = new BrowserTarget( |
704 thread_->message_loop(), server_.get(), connection_id); | 707 thread_->message_loop(), server_.get(), connection_id); |
705 browser_target->RegisterHandler( | 708 browser_target->RegisterHandler( |
706 new TetheringHandler(delegate_.get(), thread_->message_loop_proxy())); | 709 new TetheringHandler(delegate_.get(), thread_->message_loop_proxy())); |
707 browser_target->RegisterHandler( | 710 browser_target->RegisterHandler( |
708 new DevToolsSystemInfoHandler()); | 711 new DevToolsSystemInfoHandler()); |
709 browser_targets_[connection_id] = browser_target; | 712 browser_targets_[connection_id] = browser_target; |
710 AcceptWebSocket(connection_id, request); | 713 AcceptWebSocket(connection_id, request); |
711 return; | 714 return; |
712 } | 715 } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 id.c_str(), | 983 id.c_str(), |
981 host); | 984 host); |
982 dictionary->SetString( | 985 dictionary->SetString( |
983 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 986 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
984 } | 987 } |
985 | 988 |
986 return dictionary; | 989 return dictionary; |
987 } | 990 } |
988 | 991 |
989 } // namespace content | 992 } // namespace content |
OLD | NEW |