Index: chrome/browser/ui/webui/net_internals/net_internals_ui.cc |
=================================================================== |
--- chrome/browser/ui/webui/net_internals/net_internals_ui.cc (revision 175049) |
+++ chrome/browser/ui/webui/net_internals/net_internals_ui.cc (working copy) |
@@ -36,6 +36,7 @@ |
#include "chrome/browser/net/chrome_net_log.h" |
#include "chrome/browser/net/chrome_network_delegate.h" |
#include "chrome/browser/net/connection_tester.h" |
+#include "chrome/browser/net/net_log_temp_file.h" |
#include "chrome/browser/net/url_fixer_upper.h" |
#include "chrome/browser/prerender/prerender_manager.h" |
#include "chrome/browser/prerender/prerender_manager_factory.h" |
@@ -191,6 +192,8 @@ |
source->add_resource_path("help.html", IDR_NET_INTERNALS_HELP_HTML); |
source->add_resource_path("help.js", IDR_NET_INTERNALS_HELP_JS); |
source->add_resource_path("index.js", IDR_NET_INTERNALS_INDEX_JS); |
+ source->add_resource_path("mobile.html", IDR_NET_INTERNALS_MOBILE_HTML); |
+ source->add_resource_path("mobile.js", IDR_NET_INTERNALS_MOBILE_JS); |
source->set_json_path("strings.js"); |
return source; |
} |
@@ -509,6 +512,10 @@ |
void OnGetHttpCacheInfo(const ListValue* list); |
void OnGetSocketPoolInfo(const ListValue* list); |
void OnGetSessionNetworkStats(const ListValue* list); |
+ void OnGetMobileNetLogInfo(const ListValue* list); |
+ void OnStartNetLog(const ListValue* list); |
+ void OnStopNetLog(const ListValue* list); |
+ void OnSendNetLog(const ListValue* list); |
void OnCloseIdleSockets(const ListValue* list); |
void OnFlushSocketPools(const ListValue* list); |
void OnGetSpdySessionInfo(const ListValue* list); |
@@ -561,6 +568,9 @@ |
// Adds entries with the states of ongoing URL requests. |
void PrePopulateEventList(); |
+ // Calls NetLogTempFile's ProcessCommand and updates the MobileNetLogInfo. |
+ void ProcessNetLogCommand(NetLogTempFile::Command command); |
+ |
net::URLRequestContext* GetMainContext() { |
return main_context_getter_->GetURLRequestContext(); |
} |
@@ -703,6 +713,22 @@ |
base::Bind(&IOThreadImpl::CallbackHelper, |
&IOThreadImpl::OnGetSessionNetworkStats, proxy_)); |
web_ui()->RegisterMessageCallback( |
+ "getMobileNetLogInfo", |
+ base::Bind(&IOThreadImpl::CallbackHelper, |
+ &IOThreadImpl::OnGetMobileNetLogInfo, proxy_)); |
+ web_ui()->RegisterMessageCallback( |
+ "startNetLog", |
+ base::Bind(&IOThreadImpl::CallbackHelper, |
+ &IOThreadImpl::OnStartNetLog, proxy_)); |
+ web_ui()->RegisterMessageCallback( |
+ "stopNetLog", |
+ base::Bind(&IOThreadImpl::CallbackHelper, |
+ &IOThreadImpl::OnStopNetLog, proxy_)); |
+ web_ui()->RegisterMessageCallback( |
+ "sendNetLog", |
+ base::Bind(&IOThreadImpl::CallbackHelper, |
+ &IOThreadImpl::OnSendNetLog, proxy_)); |
+ web_ui()->RegisterMessageCallback( |
"closeIdleSockets", |
base::Bind(&IOThreadImpl::CallbackHelper, |
&IOThreadImpl::OnCloseIdleSockets, proxy_)); |
@@ -966,6 +992,10 @@ |
void NetInternalsMessageHandler::IOThreadImpl::Detach() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ |
+ // Cancel any in-progress requests to collect net_log into temporary file. |
+ NetLogTempFile::GetInstance()->ProcessCommand(NetLogTempFile::DO_STOP); |
+ |
// Unregister with network stack to observe events. |
if (net_log()) |
net_log()->RemoveThreadSafeObserver(this); |
@@ -1350,6 +1380,31 @@ |
http_network_session->CloseAllConnections(); |
} |
+void NetInternalsMessageHandler::IOThreadImpl::OnGetMobileNetLogInfo( |
+ const ListValue* list) { |
+ DCHECK(!list); |
+ SendJavascriptCommand("receivedMobileNetLogInfo", |
+ NetLogTempFile::GetInstance()->NetLogTempFileToValue()); |
+} |
+ |
+void NetInternalsMessageHandler::IOThreadImpl::OnStartNetLog( |
+ const ListValue* list) { |
+ DCHECK(!list); |
+ ProcessNetLogCommand(NetLogTempFile::DO_START); |
+} |
+ |
+void NetInternalsMessageHandler::IOThreadImpl::OnStopNetLog( |
+ const ListValue* list) { |
+ DCHECK(!list); |
+ ProcessNetLogCommand(NetLogTempFile::DO_STOP); |
+} |
+ |
+void NetInternalsMessageHandler::IOThreadImpl::OnSendNetLog( |
+ const ListValue* list) { |
+ DCHECK(!list); |
+ ProcessNetLogCommand(NetLogTempFile::DO_SEND); |
+} |
+ |
void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( |
const ListValue* list) { |
DCHECK(!list); |
@@ -1757,6 +1812,13 @@ |
} |
} |
+void NetInternalsMessageHandler::IOThreadImpl::ProcessNetLogCommand( |
+ NetLogTempFile::Command command) { |
+ NetLogTempFile::GetInstance()->ProcessCommand(command); |
+ SendJavascriptCommand("receivedMobileNetLogInfo", |
+ NetLogTempFile::GetInstance()->NetLogTempFileToValue()); |
+} |
+ |
} // namespace |