OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "net/url_request/url_request_view_net_internals_job.h" | 5 #include "net/url_request/url_request_view_net_internals_job.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "net/base/escape.h" | 12 #include "net/base/escape.h" |
13 #include "net/base/host_cache.h" | 13 #include "net/base/host_resolver_impl.h" |
14 #include "net/base/load_log_util.h" | 14 #include "net/base/load_log_util.h" |
15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
17 #include "net/base/sys_addrinfo.h" | 17 #include "net/base/sys_addrinfo.h" |
18 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_service.h" |
19 #include "net/socket_stream/socket_stream.h" | 19 #include "net/socket_stream/socket_stream.h" |
20 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
21 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
22 #include "net/url_request/view_cache_helper.h" | 22 #include "net/url_request/view_cache_helper.h" |
23 | 23 |
(...skipping 15 matching lines...) Expand all Loading... |
39 // string |command| back to the browser, and then refreshes the page. | 39 // string |command| back to the browser, and then refreshes the page. |
40 void DrawCommandButton(const std::string& title, | 40 void DrawCommandButton(const std::string& title, |
41 const std::string& command, | 41 const std::string& command, |
42 std::string* data) { | 42 std::string* data) { |
43 StringAppendF(data, "<input type=\"button\" value=\"%s\" " | 43 StringAppendF(data, "<input type=\"button\" value=\"%s\" " |
44 "onclick=\"DoCommand('%s')\" />", | 44 "onclick=\"DoCommand('%s')\" />", |
45 title.c_str(), | 45 title.c_str(), |
46 command.c_str()); | 46 command.c_str()); |
47 } | 47 } |
48 | 48 |
| 49 //------------------------------------------------------------------------------ |
| 50 // URLRequestContext helpers. |
| 51 //------------------------------------------------------------------------------ |
| 52 |
| 53 net::HostResolverImpl* GetHostResolverImpl(URLRequestContext* context) { |
| 54 if (context->host_resolver()->IsHostResolverImpl()) |
| 55 return static_cast<net::HostResolverImpl*> (context->host_resolver()); |
| 56 return NULL; |
| 57 } |
| 58 |
| 59 net::HostCache* GetHostCache(URLRequestContext* context) { |
| 60 if (GetHostResolverImpl(context)) |
| 61 return GetHostResolverImpl(context)->cache(); |
| 62 return NULL; |
| 63 } |
49 | 64 |
50 //------------------------------------------------------------------------------ | 65 //------------------------------------------------------------------------------ |
51 // Subsection definitions. | 66 // Subsection definitions. |
52 //------------------------------------------------------------------------------ | 67 //------------------------------------------------------------------------------ |
53 | 68 |
54 class SubSection { | 69 class SubSection { |
55 public: | 70 public: |
56 // |name| is the URL path component for this subsection. | 71 // |name| is the URL path component for this subsection. |
57 // |title| is the textual description. | 72 // |title| is the textual description. |
58 SubSection(SubSection* parent, const char* name, const char* title) | 73 SubSection(SubSection* parent, const char* name, const char* title) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 165 |
151 SubSection* parent_; | 166 SubSection* parent_; |
152 std::string name_; | 167 std::string name_; |
153 std::string title_; | 168 std::string title_; |
154 | 169 |
155 SubSectionList children_; | 170 SubSectionList children_; |
156 }; | 171 }; |
157 | 172 |
158 class ProxyServiceCurrentConfigSubSection : public SubSection { | 173 class ProxyServiceCurrentConfigSubSection : public SubSection { |
159 public: | 174 public: |
160 ProxyServiceCurrentConfigSubSection(SubSection* parent) | 175 explicit ProxyServiceCurrentConfigSubSection(SubSection* parent) |
161 : SubSection(parent, "config", "Current configuration") { | 176 : SubSection(parent, "config", "Current configuration") { |
162 } | 177 } |
163 | 178 |
164 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 179 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
165 DrawCommandButton("Force reload", "reload-proxy-config", out); | 180 DrawCommandButton("Force reload", "reload-proxy-config", out); |
166 | 181 |
167 net::ProxyService* proxy_service = context->proxy_service(); | 182 net::ProxyService* proxy_service = context->proxy_service(); |
168 if (proxy_service->config_has_been_initialized()) { | 183 if (proxy_service->config_has_been_initialized()) { |
169 // net::ProxyConfig defines an operator<<. | 184 // net::ProxyConfig defines an operator<<. |
170 std::ostringstream stream; | 185 std::ostringstream stream; |
171 stream << proxy_service->config(); | 186 stream << proxy_service->config(); |
172 OutputTextInPre(stream.str(), out); | 187 OutputTextInPre(stream.str(), out); |
173 } else { | 188 } else { |
174 out->append("<i>Not yet initialized</i>"); | 189 out->append("<i>Not yet initialized</i>"); |
175 } | 190 } |
176 } | 191 } |
177 }; | 192 }; |
178 | 193 |
179 class ProxyServiceLastInitLogSubSection : public SubSection { | 194 class ProxyServiceLastInitLogSubSection : public SubSection { |
180 public: | 195 public: |
181 ProxyServiceLastInitLogSubSection(SubSection* parent) | 196 explicit ProxyServiceLastInitLogSubSection(SubSection* parent) |
182 : SubSection(parent, "init_log", "Last initialized load log") { | 197 : SubSection(parent, "init_log", "Last initialized load log") { |
183 } | 198 } |
184 | 199 |
185 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 200 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
186 net::ProxyService* proxy_service = context->proxy_service(); | 201 net::ProxyService* proxy_service = context->proxy_service(); |
187 net::LoadLog* log = proxy_service->init_proxy_resolver_log(); | 202 net::LoadLog* log = proxy_service->init_proxy_resolver_log(); |
188 if (log) { | 203 if (log) { |
189 OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out); | 204 OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out); |
190 } else { | 205 } else { |
191 out->append("<i>None.</i>"); | 206 out->append("<i>None.</i>"); |
192 } | 207 } |
193 } | 208 } |
194 }; | 209 }; |
195 | 210 |
196 class ProxyServiceBadProxiesSubSection : public SubSection { | 211 class ProxyServiceBadProxiesSubSection : public SubSection { |
197 public: | 212 public: |
198 ProxyServiceBadProxiesSubSection(SubSection* parent) | 213 explicit ProxyServiceBadProxiesSubSection(SubSection* parent) |
199 : SubSection(parent, "bad_proxies", "Bad Proxies") { | 214 : SubSection(parent, "bad_proxies", "Bad Proxies") { |
200 } | 215 } |
201 | 216 |
202 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 217 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
203 net::ProxyService* proxy_service = context->proxy_service(); | 218 net::ProxyService* proxy_service = context->proxy_service(); |
204 const net::ProxyRetryInfoMap& bad_proxies_map = | 219 const net::ProxyRetryInfoMap& bad_proxies_map = |
205 proxy_service->proxy_retry_info(); | 220 proxy_service->proxy_retry_info(); |
206 | 221 |
207 DrawCommandButton("Clear", "clear-badproxies", out); | 222 DrawCommandButton("Clear", "clear-badproxies", out); |
208 | 223 |
(...skipping 22 matching lines...) Expand all Loading... |
231 ttl_ms); | 246 ttl_ms); |
232 | 247 |
233 out->append("</tr>"); | 248 out->append("</tr>"); |
234 } | 249 } |
235 out->append("</table>"); | 250 out->append("</table>"); |
236 } | 251 } |
237 }; | 252 }; |
238 | 253 |
239 class ProxyServiceSubSection : public SubSection { | 254 class ProxyServiceSubSection : public SubSection { |
240 public: | 255 public: |
241 ProxyServiceSubSection(SubSection* parent) | 256 explicit ProxyServiceSubSection(SubSection* parent) |
242 : SubSection(parent, "proxyservice", "ProxyService") { | 257 : SubSection(parent, "proxyservice", "ProxyService") { |
243 AddSubSection(new ProxyServiceCurrentConfigSubSection(this)); | 258 AddSubSection(new ProxyServiceCurrentConfigSubSection(this)); |
244 AddSubSection(new ProxyServiceLastInitLogSubSection(this)); | 259 AddSubSection(new ProxyServiceLastInitLogSubSection(this)); |
245 AddSubSection(new ProxyServiceBadProxiesSubSection(this)); | 260 AddSubSection(new ProxyServiceBadProxiesSubSection(this)); |
246 } | 261 } |
247 }; | 262 }; |
248 | 263 |
249 class HostResolverCacheSubSection : public SubSection { | 264 class HostResolverCacheSubSection : public SubSection { |
250 public: | 265 public: |
251 HostResolverCacheSubSection(SubSection* parent) | 266 explicit HostResolverCacheSubSection(SubSection* parent) |
252 : SubSection(parent, "hostcache", "HostCache") { | 267 : SubSection(parent, "hostcache", "HostCache") { |
253 } | 268 } |
254 | 269 |
255 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 270 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
256 const net::HostCache* host_cache = context->host_resolver()->GetHostCache(); | 271 const net::HostCache* host_cache = GetHostCache(context); |
257 | 272 |
258 if (!host_cache || host_cache->caching_is_disabled()) { | 273 if (!host_cache || host_cache->caching_is_disabled()) { |
259 out->append("<i>Caching is disabled.</i>"); | 274 out->append("<i>Caching is disabled.</i>"); |
260 return; | 275 return; |
261 } | 276 } |
262 | 277 |
263 DrawCommandButton("Clear", "clear-hostcache", out); | 278 DrawCommandButton("Clear", "clear-hostcache", out); |
264 | 279 |
265 StringAppendF( | 280 StringAppendF( |
266 out, | 281 out, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return "IPV6"; | 357 return "IPV6"; |
343 case net::ADDRESS_FAMILY_UNSPECIFIED: | 358 case net::ADDRESS_FAMILY_UNSPECIFIED: |
344 return "UNSPECIFIED"; | 359 return "UNSPECIFIED"; |
345 default: | 360 default: |
346 NOTREACHED(); | 361 NOTREACHED(); |
347 return "???"; | 362 return "???"; |
348 } | 363 } |
349 } | 364 } |
350 }; | 365 }; |
351 | 366 |
| 367 class HostResolverTraceSubSection : public SubSection { |
| 368 public: |
| 369 explicit HostResolverTraceSubSection(SubSection* parent) |
| 370 : SubSection(parent, "trace", "Trace of requests") { |
| 371 } |
| 372 |
| 373 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
| 374 net::HostResolverImpl* resolver = GetHostResolverImpl(context); |
| 375 if (!resolver) { |
| 376 out->append("<i>Tracing is not supported by this resolver.</i>"); |
| 377 return; |
| 378 } |
| 379 |
| 380 DrawCommandButton("Clear", "clear-hostresolver-trace", out); |
| 381 |
| 382 if (resolver->IsRequestsTracingEnabled()) { |
| 383 DrawCommandButton("Disable tracing", "hostresolver-trace-disable", out); |
| 384 } else { |
| 385 DrawCommandButton("Enable tracing", "hostresolver-trace-enable", out); |
| 386 } |
| 387 |
| 388 scoped_refptr<net::LoadLog> log = resolver->GetRequestsTrace(); |
| 389 |
| 390 if (log) { |
| 391 OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out); |
| 392 } else { |
| 393 out->append("<p><i>No trace information, must enable tracing.</i></p>"); |
| 394 } |
| 395 } |
| 396 }; |
| 397 |
352 class HostResolverSubSection : public SubSection { | 398 class HostResolverSubSection : public SubSection { |
353 public: | 399 public: |
354 HostResolverSubSection(SubSection* parent) | 400 explicit HostResolverSubSection(SubSection* parent) |
355 : SubSection(parent, "hostresolver", "HostResolver") { | 401 : SubSection(parent, "hostresolver", "HostResolver") { |
356 AddSubSection(new HostResolverCacheSubSection(this)); | 402 AddSubSection(new HostResolverCacheSubSection(this)); |
| 403 AddSubSection(new HostResolverTraceSubSection(this)); |
357 } | 404 } |
358 }; | 405 }; |
359 | 406 |
360 // Helper for the URLRequest "outstanding" and "live" sections. | 407 // Helper for the URLRequest "outstanding" and "live" sections. |
361 void OutputURLAndLoadLog(const GURL& url, | 408 void OutputURLAndLoadLog(const GURL& url, |
362 const net::LoadLog* log, | 409 const net::LoadLog* log, |
363 std::string* out) { | 410 std::string* out) { |
364 out->append("<li>"); | 411 out->append("<li>"); |
365 out->append("<nobr>"); | 412 out->append("<nobr>"); |
366 out->append(EscapeForHTML(url.possibly_invalid_spec())); | 413 out->append(EscapeForHTML(url.possibly_invalid_spec())); |
367 out->append("</nobr>"); | 414 out->append("</nobr>"); |
368 if (log) | 415 if (log) |
369 OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out); | 416 OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out); |
370 out->append("</li>"); | 417 out->append("</li>"); |
371 } | 418 } |
372 | 419 |
373 class URLRequestLiveSubSection : public SubSection { | 420 class URLRequestLiveSubSection : public SubSection { |
374 public: | 421 public: |
375 URLRequestLiveSubSection(SubSection* parent) | 422 explicit URLRequestLiveSubSection(SubSection* parent) |
376 : SubSection(parent, "outstanding", "Outstanding requests") { | 423 : SubSection(parent, "outstanding", "Outstanding requests") { |
377 } | 424 } |
378 | 425 |
379 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 426 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
380 std::vector<URLRequest*> requests = | 427 std::vector<URLRequest*> requests = |
381 context->url_request_tracker()->GetLiveRequests(); | 428 context->url_request_tracker()->GetLiveRequests(); |
382 | 429 |
383 out->append("<ol>"); | 430 out->append("<ol>"); |
384 for (size_t i = 0; i < requests.size(); ++i) { | 431 for (size_t i = 0; i < requests.size(); ++i) { |
385 // Reverse the list order, so we dispay from most recent to oldest. | 432 // Reverse the list order, so we dispay from most recent to oldest. |
386 size_t index = requests.size() - i - 1; | 433 size_t index = requests.size() - i - 1; |
387 OutputURLAndLoadLog(requests[index]->original_url(), | 434 OutputURLAndLoadLog(requests[index]->original_url(), |
388 requests[index]->load_log(), | 435 requests[index]->load_log(), |
389 out); | 436 out); |
390 } | 437 } |
391 out->append("</ol>"); | 438 out->append("</ol>"); |
392 } | 439 } |
393 }; | 440 }; |
394 | 441 |
395 class URLRequestRecentSubSection : public SubSection { | 442 class URLRequestRecentSubSection : public SubSection { |
396 public: | 443 public: |
397 URLRequestRecentSubSection(SubSection* parent) | 444 explicit URLRequestRecentSubSection(SubSection* parent) |
398 : SubSection(parent, "recent", "Recently completed requests") { | 445 : SubSection(parent, "recent", "Recently completed requests") { |
399 } | 446 } |
400 | 447 |
401 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 448 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
402 RequestTracker<URLRequest>::RecentRequestInfoList recent = | 449 RequestTracker<URLRequest>::RecentRequestInfoList recent = |
403 context->url_request_tracker()->GetRecentlyDeceased(); | 450 context->url_request_tracker()->GetRecentlyDeceased(); |
404 | 451 |
405 DrawCommandButton("Clear", "clear-urlrequest-graveyard", out); | 452 DrawCommandButton("Clear", "clear-urlrequest-graveyard", out); |
406 | 453 |
407 out->append("<ol>"); | 454 out->append("<ol>"); |
408 for (size_t i = 0; i < recent.size(); ++i) { | 455 for (size_t i = 0; i < recent.size(); ++i) { |
409 // Reverse the list order, so we dispay from most recent to oldest. | 456 // Reverse the list order, so we dispay from most recent to oldest. |
410 size_t index = recent.size() - i - 1; | 457 size_t index = recent.size() - i - 1; |
411 OutputURLAndLoadLog(recent[index].original_url, | 458 OutputURLAndLoadLog(recent[index].original_url, |
412 recent[index].load_log, out); | 459 recent[index].load_log, out); |
413 } | 460 } |
414 out->append("</ol>"); | 461 out->append("</ol>"); |
415 } | 462 } |
416 }; | 463 }; |
417 | 464 |
418 class URLRequestSubSection : public SubSection { | 465 class URLRequestSubSection : public SubSection { |
419 public: | 466 public: |
420 URLRequestSubSection(SubSection* parent) | 467 explicit URLRequestSubSection(SubSection* parent) |
421 : SubSection(parent, "urlrequest", "URLRequest") { | 468 : SubSection(parent, "urlrequest", "URLRequest") { |
422 AddSubSection(new URLRequestLiveSubSection(this)); | 469 AddSubSection(new URLRequestLiveSubSection(this)); |
423 AddSubSection(new URLRequestRecentSubSection(this)); | 470 AddSubSection(new URLRequestRecentSubSection(this)); |
424 } | 471 } |
425 }; | 472 }; |
426 | 473 |
427 class HttpCacheStatsSubSection : public SubSection { | 474 class HttpCacheStatsSubSection : public SubSection { |
428 public: | 475 public: |
429 HttpCacheStatsSubSection(SubSection* parent) | 476 explicit HttpCacheStatsSubSection(SubSection* parent) |
430 : SubSection(parent, "stats", "Statistics") { | 477 : SubSection(parent, "stats", "Statistics") { |
431 } | 478 } |
432 | 479 |
433 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 480 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
434 ViewCacheHelper::GetStatisticsHTML(context, out); | 481 ViewCacheHelper::GetStatisticsHTML(context, out); |
435 } | 482 } |
436 }; | 483 }; |
437 | 484 |
438 class HttpCacheSection : public SubSection { | 485 class HttpCacheSection : public SubSection { |
439 public: | 486 public: |
440 HttpCacheSection(SubSection* parent) | 487 explicit HttpCacheSection(SubSection* parent) |
441 : SubSection(parent, "httpcache", "HttpCache") { | 488 : SubSection(parent, "httpcache", "HttpCache") { |
442 AddSubSection(new HttpCacheStatsSubSection(this)); | 489 AddSubSection(new HttpCacheStatsSubSection(this)); |
443 } | 490 } |
444 | 491 |
445 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 492 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
446 // Advertise the view-cache URL (too much data to inline it). | 493 // Advertise the view-cache URL (too much data to inline it). |
447 out->append("<p><a href='/"); | 494 out->append("<p><a href='/"); |
448 out->append(kViewHttpCacheSubPath); | 495 out->append(kViewHttpCacheSubPath); |
449 out->append("'>View all cache entries</a></p>"); | 496 out->append("'>View all cache entries</a></p>"); |
450 } | 497 } |
451 }; | 498 }; |
452 | 499 |
453 class SocketStreamLiveSubSection : public SubSection { | 500 class SocketStreamLiveSubSection : public SubSection { |
454 public: | 501 public: |
455 SocketStreamLiveSubSection(SubSection* parent) | 502 explicit SocketStreamLiveSubSection(SubSection* parent) |
456 : SubSection(parent, "live", "Live SocketStreams") { | 503 : SubSection(parent, "live", "Live SocketStreams") { |
457 } | 504 } |
458 | 505 |
459 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 506 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
460 std::vector<net::SocketStream*> sockets = | 507 std::vector<net::SocketStream*> sockets = |
461 context->socket_stream_tracker()->GetLiveRequests(); | 508 context->socket_stream_tracker()->GetLiveRequests(); |
462 | 509 |
463 out->append("<ol>"); | 510 out->append("<ol>"); |
464 for (size_t i = 0; i < sockets.size(); ++i) { | 511 for (size_t i = 0; i < sockets.size(); ++i) { |
465 // Reverse the list order, so we dispay from most recent to oldest. | 512 // Reverse the list order, so we dispay from most recent to oldest. |
466 size_t index = sockets.size() - i - 1; | 513 size_t index = sockets.size() - i - 1; |
467 OutputURLAndLoadLog(sockets[index]->url(), | 514 OutputURLAndLoadLog(sockets[index]->url(), |
468 sockets[index]->load_log(), | 515 sockets[index]->load_log(), |
469 out); | 516 out); |
470 } | 517 } |
471 out->append("</ol>"); | 518 out->append("</ol>"); |
472 } | 519 } |
473 }; | 520 }; |
474 | 521 |
475 class SocketStreamRecentSubSection : public SubSection { | 522 class SocketStreamRecentSubSection : public SubSection { |
476 public: | 523 public: |
477 SocketStreamRecentSubSection(SubSection* parent) | 524 explicit SocketStreamRecentSubSection(SubSection* parent) |
478 : SubSection(parent, "recent", "Recently completed SocketStreams") { | 525 : SubSection(parent, "recent", "Recently completed SocketStreams") { |
479 } | 526 } |
480 | 527 |
481 virtual void OutputBody(URLRequestContext* context, std::string* out) { | 528 virtual void OutputBody(URLRequestContext* context, std::string* out) { |
482 RequestTracker<net::SocketStream>::RecentRequestInfoList recent = | 529 RequestTracker<net::SocketStream>::RecentRequestInfoList recent = |
483 context->socket_stream_tracker()->GetRecentlyDeceased(); | 530 context->socket_stream_tracker()->GetRecentlyDeceased(); |
484 | 531 |
485 DrawCommandButton("Clear", "clear-socketstream-graveyard", out); | 532 DrawCommandButton("Clear", "clear-socketstream-graveyard", out); |
486 | 533 |
487 out->append("<ol>"); | 534 out->append("<ol>"); |
488 for (size_t i = 0; i < recent.size(); ++i) { | 535 for (size_t i = 0; i < recent.size(); ++i) { |
489 // Reverse the list order, so we dispay from most recent to oldest. | 536 // Reverse the list order, so we dispay from most recent to oldest. |
490 size_t index = recent.size() - i - 1; | 537 size_t index = recent.size() - i - 1; |
491 OutputURLAndLoadLog(recent[index].original_url, | 538 OutputURLAndLoadLog(recent[index].original_url, |
492 recent[index].load_log, out); | 539 recent[index].load_log, out); |
493 } | 540 } |
494 out->append("</ol>"); | 541 out->append("</ol>"); |
495 } | 542 } |
496 }; | 543 }; |
497 | 544 |
498 class SocketStreamSubSection : public SubSection { | 545 class SocketStreamSubSection : public SubSection { |
499 public: | 546 public: |
500 SocketStreamSubSection(SubSection* parent) | 547 explicit SocketStreamSubSection(SubSection* parent) |
501 : SubSection(parent, "socketstream", "SocketStream") { | 548 : SubSection(parent, "socketstream", "SocketStream") { |
502 AddSubSection(new SocketStreamLiveSubSection(this)); | 549 AddSubSection(new SocketStreamLiveSubSection(this)); |
503 AddSubSection(new SocketStreamRecentSubSection(this)); | 550 AddSubSection(new SocketStreamRecentSubSection(this)); |
504 } | 551 } |
505 }; | 552 }; |
506 | 553 |
507 class AllSubSections : public SubSection { | 554 class AllSubSections : public SubSection { |
508 public: | 555 public: |
509 AllSubSections() : SubSection(NULL, "", "") { | 556 AllSubSections() : SubSection(NULL, "", "") { |
510 AddSubSection(new ProxyServiceSubSection(this)); | 557 AddSubSection(new ProxyServiceSubSection(this)); |
511 AddSubSection(new HostResolverSubSection(this)); | 558 AddSubSection(new HostResolverSubSection(this)); |
512 AddSubSection(new URLRequestSubSection(this)); | 559 AddSubSection(new URLRequestSubSection(this)); |
513 AddSubSection(new HttpCacheSection(this)); | 560 AddSubSection(new HttpCacheSection(this)); |
514 AddSubSection(new SocketStreamSubSection(this)); | 561 AddSubSection(new SocketStreamSubSection(this)); |
515 } | 562 } |
516 }; | 563 }; |
517 | 564 |
518 bool HandleCommand(const std::string& command, URLRequestContext* context) { | 565 bool HandleCommand(const std::string& command, URLRequestContext* context) { |
519 if (StartsWithASCII(command, "full-logging-", true)) { | 566 if (StartsWithASCII(command, "full-logging-", true)) { |
520 bool enable_full_logging = (command == "full-logging-enable"); | 567 bool enable_full_logging = (command == "full-logging-enable"); |
521 context->url_request_tracker()->SetUnbounded(enable_full_logging); | 568 context->url_request_tracker()->SetUnbounded(enable_full_logging); |
522 context->socket_stream_tracker()->SetUnbounded(enable_full_logging); | 569 context->socket_stream_tracker()->SetUnbounded(enable_full_logging); |
523 return true; | 570 return true; |
524 } | 571 } |
525 | 572 |
| 573 if (StartsWithASCII(command, "hostresolver-trace-", true)) { |
| 574 bool enable_tracing = (command == "hostresolver-trace-enable"); |
| 575 if (GetHostResolverImpl(context)) { |
| 576 GetHostResolverImpl(context)->EnableRequestsTracing(enable_tracing); |
| 577 } |
| 578 } |
| 579 |
526 if (command == "clear-urlrequest-graveyard") { | 580 if (command == "clear-urlrequest-graveyard") { |
527 context->url_request_tracker()->ClearRecentlyDeceased(); | 581 context->url_request_tracker()->ClearRecentlyDeceased(); |
528 return true; | 582 return true; |
529 } | 583 } |
530 | 584 |
531 if (command == "clear-socketstream-graveyard") { | 585 if (command == "clear-socketstream-graveyard") { |
532 context->socket_stream_tracker()->ClearRecentlyDeceased(); | 586 context->socket_stream_tracker()->ClearRecentlyDeceased(); |
533 return true; | 587 return true; |
534 } | 588 } |
535 | 589 |
536 if (command == "clear-hostcache") { | 590 if (command == "clear-hostcache") { |
537 net::HostCache* host_cache = context->host_resolver()->GetHostCache(); | 591 net::HostCache* host_cache = GetHostCache(context); |
538 if (host_cache) | 592 if (host_cache) |
539 host_cache->clear(); | 593 host_cache->clear(); |
540 return true; | 594 return true; |
541 } | 595 } |
542 | 596 |
543 if (command == "clear-badproxies") { | 597 if (command == "clear-badproxies") { |
544 context->proxy_service()->ClearBadProxiesCache(); | 598 context->proxy_service()->ClearBadProxiesCache(); |
545 return true; | 599 return true; |
546 } | 600 } |
547 | 601 |
| 602 if (command == "clear-hostresolver-trace") { |
| 603 if (GetHostResolverImpl(context)) |
| 604 GetHostResolverImpl(context)->ClearRequestsTrace(); |
| 605 } |
| 606 |
548 if (command == "reload-proxy-config") { | 607 if (command == "reload-proxy-config") { |
549 context->proxy_service()->ForceReloadProxyConfig(); | 608 context->proxy_service()->ForceReloadProxyConfig(); |
550 return true; | 609 return true; |
551 } | 610 } |
552 | 611 |
553 return false; | 612 return false; |
554 } | 613 } |
555 | 614 |
556 // Process any query strings in the request (for actions like toggling | 615 // Process any query strings in the request (for actions like toggling |
557 // full logging. | 616 // full logging. |
(...skipping 28 matching lines...) Expand all Loading... |
586 DrawCommandButton("Disable full logging", "full-logging-disable", data); | 645 DrawCommandButton("Disable full logging", "full-logging-disable", data); |
587 } else { | 646 } else { |
588 DrawCommandButton("Enable full logging", "full-logging-enable", data); | 647 DrawCommandButton("Enable full logging", "full-logging-enable", data); |
589 } | 648 } |
590 | 649 |
591 DrawCommandButton("Clear all data", | 650 DrawCommandButton("Clear all data", |
592 // Send a list of comma separated commands: | 651 // Send a list of comma separated commands: |
593 "clear-badproxies," | 652 "clear-badproxies," |
594 "clear-hostcache," | 653 "clear-hostcache," |
595 "clear-urlrequest-graveyard," | 654 "clear-urlrequest-graveyard," |
596 "clear-socketstream-graveyard", | 655 "clear-socketstream-graveyard," |
| 656 "clear-hostresolver-trace", |
597 data); | 657 data); |
598 | 658 |
599 data->append("</div>"); | 659 data->append("</div>"); |
600 } | 660 } |
601 | 661 |
602 } // namespace | 662 } // namespace |
603 | 663 |
604 bool URLRequestViewNetInternalsJob::GetData(std::string* mime_type, | 664 bool URLRequestViewNetInternalsJob::GetData(std::string* mime_type, |
605 std::string* charset, | 665 std::string* charset, |
606 std::string* data) const { | 666 std::string* data) const { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 761 |
702 if (path.size() > strlen(kViewHttpCacheSubPath) && | 762 if (path.size() > strlen(kViewHttpCacheSubPath) && |
703 path[strlen(kViewHttpCacheSubPath)] != '/') | 763 path[strlen(kViewHttpCacheSubPath)] != '/') |
704 return false; | 764 return false; |
705 | 765 |
706 if (key && path.size() > strlen(kViewHttpCacheSubPath) + 1) | 766 if (key && path.size() > strlen(kViewHttpCacheSubPath) + 1) |
707 *key = path.substr(strlen(kViewHttpCacheSubPath) + 1); | 767 *key = path.substr(strlen(kViewHttpCacheSubPath) + 1); |
708 | 768 |
709 return true; | 769 return true; |
710 } | 770 } |
OLD | NEW |