summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 21:07:33 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 21:07:33 +0000
commit095c7cfacf4a59d5241a17207d7a8a8096469334 (patch)
tree7eb71d968ae4dc9705ba5e9c5ad1b1727f34b2fc /net
parent701142a4edf3872fc9b433b68bdaf2c0a3c22db8 (diff)
downloadchromium_src-095c7cfacf4a59d5241a17207d7a8a8096469334.zip
chromium_src-095c7cfacf4a59d5241a17207d7a8a8096469334.tar.gz
chromium_src-095c7cfacf4a59d5241a17207d7a8a8096469334.tar.bz2
Fix a regression whereby full-granularity network events were being captured by PassiveLogCollector.
BUG=53883 TEST=Load a webpage. Now open about:net-internals and verify that the log for that URL does NOT contain the HTTP request/response headers. Review URL: http://codereview.chromium.org/3274016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/capturing_net_log.h2
-rw-r--r--net/base/forwarding_net_log.cc4
-rw-r--r--net/base/forwarding_net_log.h2
-rw-r--r--net/base/net_log.cc10
-rw-r--r--net/base/net_log.h19
-rw-r--r--net/http/http_network_transaction.cc4
-rw-r--r--net/http/http_proxy_client_socket.cc4
-rw-r--r--net/proxy/proxy_service.cc2
-rw-r--r--net/socket/tcp_client_socket_pool.cc2
-rw-r--r--net/spdy/spdy_session.cc6
-rw-r--r--net/url_request/url_request.cc2
11 files changed, 37 insertions, 20 deletions
diff --git a/net/base/capturing_net_log.h b/net/base/capturing_net_log.h
index 9a5addd..9669445 100644
--- a/net/base/capturing_net_log.h
+++ b/net/base/capturing_net_log.h
@@ -53,7 +53,7 @@ class CapturingNetLog : public NetLog {
EventPhase phase,
EventParameters* extra_parameters);
virtual uint32 NextID();
- virtual bool HasListener() const { return true; }
+ virtual LogLevel GetLogLevel() const { return LOG_ALL; }
// Returns the list of all entries in the log.
const EntryList& entries() const { return entries_; }
diff --git a/net/base/forwarding_net_log.cc b/net/base/forwarding_net_log.cc
index dfc8700..efe6eff 100644
--- a/net/base/forwarding_net_log.cc
+++ b/net/base/forwarding_net_log.cc
@@ -86,10 +86,10 @@ uint32 ForwardingNetLog::NextID() {
return 0;
}
-bool ForwardingNetLog::HasListener() const {
+NetLog::LogLevel ForwardingNetLog::GetLogLevel() const {
// Can't forward a synchronous API.
CHECK(false) << "Not supported";
- return false;
+ return LOG_ALL;
}
} // namespace net
diff --git a/net/base/forwarding_net_log.h b/net/base/forwarding_net_log.h
index 36ff9d2..257b4c7 100644
--- a/net/base/forwarding_net_log.h
+++ b/net/base/forwarding_net_log.h
@@ -39,7 +39,7 @@ class ForwardingNetLog : public NetLog {
EventPhase phase,
EventParameters* params);
virtual uint32 NextID();
- virtual bool HasListener() const;
+ virtual LogLevel GetLogLevel() const;
private:
class Core;
diff --git a/net/base/net_log.cc b/net/base/net_log.cc
index 734cef1..2cc149f 100644
--- a/net/base/net_log.cc
+++ b/net/base/net_log.cc
@@ -122,10 +122,14 @@ void BoundNetLog::AddEntryWithTime(
}
}
-bool BoundNetLog::HasListener() const {
+NetLog::LogLevel BoundNetLog::GetLogLevel() const {
if (net_log_)
- return net_log_->HasListener();
- return false;
+ return net_log_->GetLogLevel();
+ return NetLog::LOG_BASIC;
+}
+
+bool BoundNetLog::IsLoggingAll() const {
+ return GetLogLevel() == NetLog::LOG_ALL;
}
void BoundNetLog::AddEvent(
diff --git a/net/base/net_log.h b/net/base/net_log.h
index d6eca7c..c97eb1a 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -95,6 +95,15 @@ class NetLog {
DISALLOW_COPY_AND_ASSIGN(EventParameters);
};
+ // Specifies the granularity of events that should be emitted to the log.
+ enum LogLevel {
+ // Log everything possible, even if it is slow and memory expensive.
+ LOG_ALL,
+
+ // Only log events which are cheap, and don't consume much memory.
+ LOG_BASIC,
+ };
+
NetLog() {}
virtual ~NetLog() {}
@@ -117,8 +126,9 @@ class NetLog {
// Returns a unique ID which can be used as a source ID.
virtual uint32 NextID() = 0;
- // Returns true if more complicated messages should be sent to the log.
- virtual bool HasListener() const = 0;
+ // Returns the logging level for this NetLog. This is used to avoid computing
+ // and saving expensive log entries.
+ virtual LogLevel GetLogLevel() const = 0;
// Returns a C-String symbolic name for |event_type|.
static const char* EventTypeToString(EventType event_type);
@@ -177,7 +187,10 @@ class BoundNetLog {
void EndEvent(NetLog::EventType event_type,
const scoped_refptr<NetLog::EventParameters>& params) const;
- bool HasListener() const;
+ NetLog::LogLevel GetLogLevel() const;
+
+ // Returns true if the log level is LOG_ALL.
+ bool IsLoggingAll() const;
// Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care
// of creating a unique source ID, and handles the case of NULL net_log.
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 1dad416..aec4977 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -688,7 +688,7 @@ int HttpNetworkTransaction::DoSendRequest() {
if (session_->network_delegate())
session_->network_delegate()->OnSendHttpRequest(&request_headers);
- if (net_log_.HasListener()) {
+ if (net_log_.IsLoggingAll()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
new NetLogHttpRequestParameter(request_line, request_headers));
@@ -784,7 +784,7 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) {
return rv;
}
- if (net_log_.HasListener()) {
+ if (net_log_.IsLoggingAll()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
new NetLogHttpResponseParameter(response_.headers));
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index 16f6e28..7ed80a5 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -337,7 +337,7 @@ int HttpProxyClientSocket::DoSendRequest() {
HttpRequestHeaders request_headers;
BuildTunnelRequest(&request_, authorization_headers, endpoint_,
&request_line, &request_headers);
- if (net_log_.HasListener()) {
+ if (net_log_.IsLoggingAll()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
new NetLogHttpRequestParameter(
@@ -373,7 +373,7 @@ int HttpProxyClientSocket::DoReadHeadersComplete(int result) {
if (response_.headers->GetParsedHttpVersion() < HttpVersion(1, 0))
return ERR_TUNNEL_CONNECTION_FAILED;
- if (net_log_.HasListener()) {
+ if (net_log_.IsLoggingAll()) {
net_log_.AddEvent(
NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
new NetLogHttpResponseParameter(response_.headers));
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index ae180a0..3d1539f 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -652,7 +652,7 @@ int ProxyService::DidFinishResolvingProxy(ProxyInfo* result,
// Log the result of the proxy resolution.
if (result_code == OK) {
// When full logging is enabled, dump the proxy list.
- if (net_log.HasListener()) {
+ if (net_log.IsLoggingAll()) {
net_log.AddEvent(
NetLog::TYPE_PROXY_SERVICE_RESOLVED_PROXY_LIST,
new NetLogStringParameter("pac_string", result->ToPacString()));
diff --git a/net/socket/tcp_client_socket_pool.cc b/net/socket/tcp_client_socket_pool.cc
index dce14dc..f3d94ac 100644
--- a/net/socket/tcp_client_socket_pool.cc
+++ b/net/socket/tcp_client_socket_pool.cc
@@ -217,7 +217,7 @@ int TCPClientSocketPool::RequestSocket(
const scoped_refptr<TCPSocketParams>* casted_params =
static_cast<const scoped_refptr<TCPSocketParams>*>(params);
- if (net_log.HasListener()) {
+ if (net_log.IsLoggingAll()) {
// TODO(eroman): Split out the host and port parameters.
net_log.AddEvent(
NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKET,
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 04037ac..957b90e 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -398,7 +398,7 @@ int SpdySession::WriteSynStream(
streams_initiated_count_++;
const BoundNetLog& log = stream->net_log();
- if (log.HasListener()) {
+ if (log.IsLoggingAll()) {
log.AddEvent(
NetLog::TYPE_SPDY_STREAM_SYN_STREAM,
new NetLogSpdySynParameter(headers, flags, stream_id));
@@ -1012,7 +1012,7 @@ void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame& frame,
stream = new SpdyStream(this, stream_id, true);
- if (net_log_.HasListener()) {
+ if (net_log_.IsLoggingAll()) {
net_log_.AddEvent(
NetLog::TYPE_SPDY_SESSION_PUSHED_SYN_STREAM,
new NetLogSpdySynParameter(
@@ -1069,7 +1069,7 @@ void SpdySession::OnSynReply(const spdy::SpdySynReplyControlFrame& frame,
stream->set_response_received();
const BoundNetLog& log = stream->net_log();
- if (log.HasListener()) {
+ if (log.IsLoggingAll()) {
log.AddEvent(
NetLog::TYPE_SPDY_STREAM_SYN_REPLY,
new NetLogSpdySynParameter(
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index c87d9a3..b4f9d51 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -490,7 +490,7 @@ void URLRequest::OrphanJob() {
}
int URLRequest::Redirect(const GURL& location, int http_status_code) {
- if (net_log_.HasListener()) {
+ if (net_log_.IsLoggingAll()) {
net_log_.AddEvent(
net::NetLog::TYPE_URL_REQUEST_REDIRECTED,
new net::NetLogStringParameter(