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