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

Side by Side Diff: chrome/browser/debugger/devtools_http_protocol_handler.cc

Issue 5384002: net: Remove typedef net::URLRequest URLRequest; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/debugger/devtools_http_protocol_handler.h" 5 #include "chrome/browser/debugger/devtools_http_protocol_handler.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return; 101 return;
102 } 102 }
103 103
104 size_t pos = info.path.find("/devtools/"); 104 size_t pos = info.path.find("/devtools/");
105 if (pos != 0) { 105 if (pos != 0) {
106 socket->Send404(); 106 socket->Send404();
107 return; 107 return;
108 } 108 }
109 109
110 // Proxy static files from chrome://devtools/*. 110 // Proxy static files from chrome://devtools/*.
111 URLRequest* request = new URLRequest(GURL("chrome:/" + info.path), this); 111 net::URLRequest* request = new net::URLRequest(
112 GURL("chrome:/" + info.path), this);
112 Bind(request, socket); 113 Bind(request, socket);
113 request->set_context( 114 request->set_context(
114 Profile::GetDefaultRequestContext()->GetURLRequestContext()); 115 Profile::GetDefaultRequestContext()->GetURLRequestContext());
115 request->Start(); 116 request->Start();
116 } 117 }
117 118
118 void DevToolsHttpProtocolHandler::OnWebSocketRequest( 119 void DevToolsHttpProtocolHandler::OnWebSocketRequest(
119 HttpListenSocket* socket, 120 HttpListenSocket* socket,
120 const HttpServerRequestInfo& request) { 121 const HttpServerRequestInfo& request) {
121 BrowserThread::PostTask( 122 BrowserThread::PostTask(
(...skipping 15 matching lines...) Expand all
137 this, 138 this,
138 &DevToolsHttpProtocolHandler::OnWebSocketMessageUI, 139 &DevToolsHttpProtocolHandler::OnWebSocketMessageUI,
139 make_scoped_refptr(socket), 140 make_scoped_refptr(socket),
140 data)); 141 data));
141 } 142 }
142 143
143 void DevToolsHttpProtocolHandler::OnClose(HttpListenSocket* socket) { 144 void DevToolsHttpProtocolHandler::OnClose(HttpListenSocket* socket) {
144 SocketToRequestsMap::iterator it = socket_to_requests_io_.find(socket); 145 SocketToRequestsMap::iterator it = socket_to_requests_io_.find(socket);
145 if (it != socket_to_requests_io_.end()) { 146 if (it != socket_to_requests_io_.end()) {
146 // Dispose delegating socket. 147 // Dispose delegating socket.
147 for (std::set<URLRequest*>::iterator it2 = it->second.begin(); 148 for (std::set<net::URLRequest*>::iterator it2 = it->second.begin();
148 it2 != it->second.end(); ++it2) { 149 it2 != it->second.end(); ++it2) {
149 URLRequest* request = *it2; 150 net::URLRequest* request = *it2;
150 request->Cancel(); 151 request->Cancel();
151 request_to_socket_io_.erase(request); 152 request_to_socket_io_.erase(request);
152 request_to_buffer_io_.erase(request); 153 request_to_buffer_io_.erase(request);
153 delete request; 154 delete request;
154 } 155 }
155 socket_to_requests_io_.erase(socket); 156 socket_to_requests_io_.erase(socket);
156 } 157 }
157 158
158 // This can't use make_scoped_refptr because |socket| is already deleted 159 // This can't use make_scoped_refptr because |socket| is already deleted
159 // when this runs -- http://crbug.com/59930 160 // when this runs -- http://crbug.com/59930
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 SocketToClientHostMap::iterator it = socket_to_client_host_ui_.find(socket); 267 SocketToClientHostMap::iterator it = socket_to_client_host_ui_.find(socket);
267 if (it == socket_to_client_host_ui_.end()) 268 if (it == socket_to_client_host_ui_.end())
268 return; 269 return;
269 DevToolsClientHostImpl* client_host = 270 DevToolsClientHostImpl* client_host =
270 static_cast<DevToolsClientHostImpl*>(it->second); 271 static_cast<DevToolsClientHostImpl*>(it->second);
271 client_host->NotifyCloseListener(); 272 client_host->NotifyCloseListener();
272 delete client_host; 273 delete client_host;
273 socket_to_client_host_ui_.erase(socket); 274 socket_to_client_host_ui_.erase(socket);
274 } 275 }
275 276
276 void DevToolsHttpProtocolHandler::OnResponseStarted(URLRequest* request) { 277 void DevToolsHttpProtocolHandler::OnResponseStarted(net::URLRequest* request) {
277 RequestToSocketMap::iterator it = request_to_socket_io_.find(request); 278 RequestToSocketMap::iterator it = request_to_socket_io_.find(request);
278 if (it == request_to_socket_io_.end()) 279 if (it == request_to_socket_io_.end())
279 return; 280 return;
280 281
281 HttpListenSocket* socket = it->second; 282 HttpListenSocket* socket = it->second;
282 283
283 int expected_size = static_cast<int>(request->GetExpectedContentSize()); 284 int expected_size = static_cast<int>(request->GetExpectedContentSize());
284 285
285 std::string content_type; 286 std::string content_type;
286 request->GetMimeType(&content_type); 287 request->GetMimeType(&content_type);
(...skipping 13 matching lines...) Expand all
300 // Some servers may treat HEAD requests as GET requests. To free up the 301 // Some servers may treat HEAD requests as GET requests. To free up the
301 // network connection as soon as possible, signal that the request has 302 // network connection as soon as possible, signal that the request has
302 // completed immediately, without trying to read any data back (all we care 303 // completed immediately, without trying to read any data back (all we care
303 // about is the response code and headers, which we already have). 304 // about is the response code and headers, which we already have).
304 net::IOBuffer* buffer = request_to_buffer_io_[request].get(); 305 net::IOBuffer* buffer = request_to_buffer_io_[request].get();
305 if (request->status().is_success()) 306 if (request->status().is_success())
306 request->Read(buffer, kBufferSize, &bytes_read); 307 request->Read(buffer, kBufferSize, &bytes_read);
307 OnReadCompleted(request, bytes_read); 308 OnReadCompleted(request, bytes_read);
308 } 309 }
309 310
310 void DevToolsHttpProtocolHandler::OnReadCompleted(URLRequest* request, 311 void DevToolsHttpProtocolHandler::OnReadCompleted(net::URLRequest* request,
311 int bytes_read) { 312 int bytes_read) {
312 RequestToSocketMap::iterator it = request_to_socket_io_.find(request); 313 RequestToSocketMap::iterator it = request_to_socket_io_.find(request);
313 if (it == request_to_socket_io_.end()) 314 if (it == request_to_socket_io_.end())
314 return; 315 return;
315 316
316 HttpListenSocket* socket = it->second; 317 HttpListenSocket* socket = it->second;
317 318
318 net::IOBuffer* buffer = request_to_buffer_io_[request].get(); 319 net::IOBuffer* buffer = request_to_buffer_io_[request].get();
319 do { 320 do {
320 if (!request->status().is_success() || bytes_read <= 0) 321 if (!request->status().is_success() || bytes_read <= 0)
(...skipping 13 matching lines...) Expand all
334 335
335 void DevToolsHttpProtocolHandler::Init() { 336 void DevToolsHttpProtocolHandler::Init() {
336 server_ = HttpListenSocket::Listen("127.0.0.1", port_, this); 337 server_ = HttpListenSocket::Listen("127.0.0.1", port_, this);
337 } 338 }
338 339
339 // Run on I/O thread 340 // Run on I/O thread
340 void DevToolsHttpProtocolHandler::Teardown() { 341 void DevToolsHttpProtocolHandler::Teardown() {
341 server_ = NULL; 342 server_ = NULL;
342 } 343 }
343 344
344 void DevToolsHttpProtocolHandler::Bind(URLRequest* request, 345 void DevToolsHttpProtocolHandler::Bind(net::URLRequest* request,
345 HttpListenSocket* socket) { 346 HttpListenSocket* socket) {
346 request_to_socket_io_[request] = socket; 347 request_to_socket_io_[request] = socket;
347 SocketToRequestsMap::iterator it = socket_to_requests_io_.find(socket); 348 SocketToRequestsMap::iterator it = socket_to_requests_io_.find(socket);
348 if (it == socket_to_requests_io_.end()) { 349 if (it == socket_to_requests_io_.end()) {
349 std::pair<HttpListenSocket*, std::set<URLRequest*> > value( 350 std::pair<HttpListenSocket*, std::set<net::URLRequest*> > value(
350 socket, 351 socket,
351 std::set<URLRequest*>()); 352 std::set<net::URLRequest*>());
352 it = socket_to_requests_io_.insert(value).first; 353 it = socket_to_requests_io_.insert(value).first;
353 } 354 }
354 it->second.insert(request); 355 it->second.insert(request);
355 request_to_buffer_io_[request] = new net::IOBuffer(kBufferSize); 356 request_to_buffer_io_[request] = new net::IOBuffer(kBufferSize);
356 } 357 }
357 358
358 void DevToolsHttpProtocolHandler::RequestCompleted(URLRequest* request) { 359 void DevToolsHttpProtocolHandler::RequestCompleted(net::URLRequest* request) {
359 RequestToSocketMap::iterator it = request_to_socket_io_.find(request); 360 RequestToSocketMap::iterator it = request_to_socket_io_.find(request);
360 if (it == request_to_socket_io_.end()) 361 if (it == request_to_socket_io_.end())
361 return; 362 return;
362 363
363 HttpListenSocket* socket = it->second; 364 HttpListenSocket* socket = it->second;
364 request_to_socket_io_.erase(request); 365 request_to_socket_io_.erase(request);
365 SocketToRequestsMap::iterator it2 = socket_to_requests_io_.find(socket); 366 SocketToRequestsMap::iterator it2 = socket_to_requests_io_.find(socket);
366 it2->second.erase(request); 367 it2->second.erase(request);
367 request_to_buffer_io_.erase(request); 368 request_to_buffer_io_.erase(request);
368 delete request; 369 delete request;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 TabStripModel* model = (*it)->tabstrip_model(); 412 TabStripModel* model = (*it)->tabstrip_model();
412 for (int i = 0, size = model->count(); i < size; ++i) { 413 for (int i = 0, size = model->count(); i < size; ++i) {
413 NavigationController& controller = 414 NavigationController& controller =
414 model->GetTabContentsAt(i)->controller(); 415 model->GetTabContentsAt(i)->controller();
415 if (controller.session_id().id() == session_id) 416 if (controller.session_id().id() == session_id)
416 return controller.tab_contents(); 417 return controller.tab_contents();
417 } 418 }
418 } 419 }
419 return NULL; 420 return NULL;
420 } 421 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698