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

Side by Side Diff: chrome/browser/dom_ui/net_internals_ui.cc

Issue 6338002: net: Remove typedef net::URLRequestContext URLRequestContext; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for real Created 9 years, 11 months 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) 2011 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/dom_ui/net_internals_ui.h" 5 #include "chrome/browser/dom_ui/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 namespace { 55 namespace {
56 56
57 // Delay between when an event occurs and when it is passed to the Javascript 57 // Delay between when an event occurs and when it is passed to the Javascript
58 // page. All events that occur during this period are grouped together and 58 // page. All events that occur during this period are grouped together and
59 // sent to the page at once, which reduces context switching and CPU usage. 59 // sent to the page at once, which reduces context switching and CPU usage.
60 const int kNetLogEventDelayMilliseconds = 100; 60 const int kNetLogEventDelayMilliseconds = 100;
61 61
62 // Returns the HostCache for |context|'s primary HostResolver, or NULL if 62 // Returns the HostCache for |context|'s primary HostResolver, or NULL if
63 // there is none. 63 // there is none.
64 net::HostCache* GetHostResolverCache(URLRequestContext* context) { 64 net::HostCache* GetHostResolverCache(net::URLRequestContext* context) {
65 net::HostResolverImpl* host_resolver_impl = 65 net::HostResolverImpl* host_resolver_impl =
66 context->host_resolver()->GetAsHostResolverImpl(); 66 context->host_resolver()->GetAsHostResolverImpl();
67 67
68 if (!host_resolver_impl) 68 if (!host_resolver_impl)
69 return NULL; 69 return NULL;
70 70
71 return host_resolver_impl->cache(); 71 return host_resolver_impl->cache();
72 } 72 }
73 73
74 // Returns the disk cache backend for |context| if there is one, or NULL. 74 // Returns the disk cache backend for |context| if there is one, or NULL.
75 disk_cache::Backend* GetDiskCacheBackend(URLRequestContext* context) { 75 disk_cache::Backend* GetDiskCacheBackend(net::URLRequestContext* context) {
76 if (!context->http_transaction_factory()) 76 if (!context->http_transaction_factory())
77 return NULL; 77 return NULL;
78 78
79 net::HttpCache* http_cache = context->http_transaction_factory()->GetCache(); 79 net::HttpCache* http_cache = context->http_transaction_factory()->GetCache();
80 if (!http_cache) 80 if (!http_cache)
81 return NULL; 81 return NULL;
82 82
83 return http_cache->GetCurrentBackend(); 83 return http_cache->GetCurrentBackend();
84 } 84 }
85 85
86 // Returns the http network session for |context| if there is one. 86 // Returns the http network session for |context| if there is one.
87 // Otherwise, returns NULL. 87 // Otherwise, returns NULL.
88 net::HttpNetworkSession* GetHttpNetworkSession(URLRequestContext* context) { 88 net::HttpNetworkSession* GetHttpNetworkSession(
89 net::URLRequestContext* context) {
89 if (!context->http_transaction_factory()) 90 if (!context->http_transaction_factory())
90 return NULL; 91 return NULL;
91 92
92 return context->http_transaction_factory()->GetSession(); 93 return context->http_transaction_factory()->GetSession();
93 } 94 }
94 95
95 Value* ExperimentToValue(const ConnectionTester::Experiment& experiment) { 96 Value* ExperimentToValue(const ConnectionTester::Experiment& experiment) {
96 DictionaryValue* dict = new DictionaryValue(); 97 DictionaryValue* dict = new DictionaryValue();
97 98
98 if (experiment.url.is_valid()) 99 if (experiment.url.is_valid())
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 // Register with network stack to observe events. 685 // Register with network stack to observe events.
685 is_observing_log_ = true; 686 is_observing_log_ = true;
686 ChromeNetLog::EntryList entries; 687 ChromeNetLog::EntryList entries;
687 io_thread_->net_log()->AddObserverAndGetAllPassivelyCapturedEvents(this, 688 io_thread_->net_log()->AddObserverAndGetAllPassivelyCapturedEvents(this,
688 &entries); 689 &entries);
689 SendPassiveLogEntries(entries); 690 SendPassiveLogEntries(entries);
690 } 691 }
691 692
692 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( 693 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings(
693 const ListValue* list) { 694 const ListValue* list) {
694 URLRequestContext* context = context_getter_->GetURLRequestContext(); 695 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
695 net::ProxyService* proxy_service = context->proxy_service(); 696 net::ProxyService* proxy_service = context->proxy_service();
696 697
697 DictionaryValue* dict = new DictionaryValue(); 698 DictionaryValue* dict = new DictionaryValue();
698 if (proxy_service->fetched_config().is_valid()) 699 if (proxy_service->fetched_config().is_valid())
699 dict->Set("original", proxy_service->fetched_config().ToValue()); 700 dict->Set("original", proxy_service->fetched_config().ToValue());
700 if (proxy_service->config().is_valid()) 701 if (proxy_service->config().is_valid())
701 dict->Set("effective", proxy_service->config().ToValue()); 702 dict->Set("effective", proxy_service->config().ToValue());
702 703
703 CallJavascriptFunction(L"g_browser.receivedProxySettings", dict); 704 CallJavascriptFunction(L"g_browser.receivedProxySettings", dict);
704 } 705 }
705 706
706 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( 707 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings(
707 const ListValue* list) { 708 const ListValue* list) {
708 URLRequestContext* context = context_getter_->GetURLRequestContext(); 709 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
709 context->proxy_service()->ForceReloadProxyConfig(); 710 context->proxy_service()->ForceReloadProxyConfig();
710 711
711 // Cause the renderer to be notified of the new values. 712 // Cause the renderer to be notified of the new values.
712 OnGetProxySettings(NULL); 713 OnGetProxySettings(NULL);
713 } 714 }
714 715
715 void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( 716 void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies(
716 const ListValue* list) { 717 const ListValue* list) {
717 URLRequestContext* context = context_getter_->GetURLRequestContext(); 718 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
718 719
719 const net::ProxyRetryInfoMap& bad_proxies_map = 720 const net::ProxyRetryInfoMap& bad_proxies_map =
720 context->proxy_service()->proxy_retry_info(); 721 context->proxy_service()->proxy_retry_info();
721 722
722 ListValue* dict_list = new ListValue(); 723 ListValue* dict_list = new ListValue();
723 724
724 for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); 725 for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin();
725 it != bad_proxies_map.end(); ++it) { 726 it != bad_proxies_map.end(); ++it) {
726 const std::string& proxy_uri = it->first; 727 const std::string& proxy_uri = it->first;
727 const net::ProxyRetryInfo& retry_info = it->second; 728 const net::ProxyRetryInfo& retry_info = it->second;
728 729
729 DictionaryValue* dict = new DictionaryValue(); 730 DictionaryValue* dict = new DictionaryValue();
730 dict->SetString("proxy_uri", proxy_uri); 731 dict->SetString("proxy_uri", proxy_uri);
731 dict->SetString("bad_until", 732 dict->SetString("bad_until",
732 net::NetLog::TickCountToString(retry_info.bad_until)); 733 net::NetLog::TickCountToString(retry_info.bad_until));
733 734
734 dict_list->Append(dict); 735 dict_list->Append(dict);
735 } 736 }
736 737
737 CallJavascriptFunction(L"g_browser.receivedBadProxies", dict_list); 738 CallJavascriptFunction(L"g_browser.receivedBadProxies", dict_list);
738 } 739 }
739 740
740 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( 741 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies(
741 const ListValue* list) { 742 const ListValue* list) {
742 URLRequestContext* context = context_getter_->GetURLRequestContext(); 743 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
743 context->proxy_service()->ClearBadProxiesCache(); 744 context->proxy_service()->ClearBadProxiesCache();
744 745
745 // Cause the renderer to be notified of the new values. 746 // Cause the renderer to be notified of the new values.
746 OnGetBadProxies(NULL); 747 OnGetBadProxies(NULL);
747 } 748 }
748 749
749 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( 750 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo(
750 const ListValue* list) { 751 const ListValue* list) {
751 URLRequestContext* context = context_getter_->GetURLRequestContext(); 752 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
752 net::HostResolverImpl* host_resolver_impl = 753 net::HostResolverImpl* host_resolver_impl =
753 context->host_resolver()->GetAsHostResolverImpl(); 754 context->host_resolver()->GetAsHostResolverImpl();
754 net::HostCache* cache = GetHostResolverCache(context); 755 net::HostCache* cache = GetHostResolverCache(context);
755 756
756 if (!host_resolver_impl || !cache) { 757 if (!host_resolver_impl || !cache) {
757 CallJavascriptFunction(L"g_browser.receivedHostResolverInfo", NULL); 758 CallJavascriptFunction(L"g_browser.receivedHostResolverInfo", NULL);
758 return; 759 return;
759 } 760 }
760 761
761 DictionaryValue* dict = new DictionaryValue(); 762 DictionaryValue* dict = new DictionaryValue();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 824
824 if (cache) 825 if (cache)
825 cache->clear(); 826 cache->clear();
826 827
827 // Cause the renderer to be notified of the new values. 828 // Cause the renderer to be notified of the new values.
828 OnGetHostResolverInfo(NULL); 829 OnGetHostResolverInfo(NULL);
829 } 830 }
830 831
831 void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6( 832 void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6(
832 const ListValue* list) { 833 const ListValue* list) {
833 URLRequestContext* context = context_getter_->GetURLRequestContext(); 834 net::URLRequestContext* context = context_getter_->GetURLRequestContext();
834 net::HostResolverImpl* host_resolver_impl = 835 net::HostResolverImpl* host_resolver_impl =
835 context->host_resolver()->GetAsHostResolverImpl(); 836 context->host_resolver()->GetAsHostResolverImpl();
836 837
837 if (host_resolver_impl) { 838 if (host_resolver_impl) {
838 host_resolver_impl->SetDefaultAddressFamily( 839 host_resolver_impl->SetDefaultAddressFamily(
839 net::ADDRESS_FAMILY_UNSPECIFIED); 840 net::ADDRESS_FAMILY_UNSPECIFIED);
840 } 841 }
841 842
842 // Cause the renderer to be notified of the new value. 843 // Cause the renderer to be notified of the new value.
843 OnGetHostResolverInfo(NULL); 844 OnGetHostResolverInfo(NULL);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); 1078 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource();
1078 1079
1079 // Set up the chrome://net-internals/ source. 1080 // Set up the chrome://net-internals/ source.
1080 BrowserThread::PostTask( 1081 BrowserThread::PostTask(
1081 BrowserThread::IO, FROM_HERE, 1082 BrowserThread::IO, FROM_HERE,
1082 NewRunnableMethod( 1083 NewRunnableMethod(
1083 ChromeURLDataManager::GetInstance(), 1084 ChromeURLDataManager::GetInstance(),
1084 &ChromeURLDataManager::AddDataSource, 1085 &ChromeURLDataManager::AddDataSource,
1085 make_scoped_refptr(html_source))); 1086 make_scoped_refptr(html_source)));
1086 } 1087 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698