summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 23:14:38 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 23:14:38 +0000
commitb675425c3f89b8b0a839d641cbedef06564ec9ff (patch)
treeb63890799e9b4ecc25ed89c469a4a3c6660b04bd /net
parentc598dbec7db3bbdccc87a66a32c8a683afa976be (diff)
downloadchromium_src-b675425c3f89b8b0a839d641cbedef06564ec9ff.zip
chromium_src-b675425c3f89b8b0a839d641cbedef06564ec9ff.tar.gz
chromium_src-b675425c3f89b8b0a839d641cbedef06564ec9ff.tar.bz2
NetLogEventParameter to Callback refactoring 5.
Get rid of all uses of NetLogEventParameters in net/http. R=eroman@chromium.org BUG=126243 Review URL: https://chromiumcodereview.appspot.com/10534129 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_auth_handler.cc6
-rw-r--r--net/http/http_cache_transaction.cc26
-rw-r--r--net/http/http_network_transaction.cc77
-rw-r--r--net/http/http_pipelined_connection_impl.cc78
-rw-r--r--net/http/http_proxy_client_socket.cc4
-rw-r--r--net/http/http_stream_factory_impl_job.cc86
-rw-r--r--net/http/http_stream_factory_impl_request.cc11
-rw-r--r--net/http/http_stream_parser.cc2
8 files changed, 103 insertions, 187 deletions
diff --git a/net/http/http_auth_handler.cc b/net/http/http_auth_handler.cc
index 0aad829..ab809fae 100644
--- a/net/http/http_auth_handler.cc
+++ b/net/http/http_auth_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -69,7 +69,7 @@ int HttpAuthHandler::GenerateAuthToken(
DCHECK(auth_token != NULL);
DCHECK(callback_.is_null());
callback_ = callback;
- net_log_.BeginEvent(EventTypeFromAuthTarget(target_), NULL);
+ net_log_.BeginEvent(EventTypeFromAuthTarget(target_));
int rv = GenerateAuthTokenImpl(
credentials, request,
base::Bind(&HttpAuthHandler::OnGenerateAuthTokenComplete,
@@ -101,7 +101,7 @@ void HttpAuthHandler::OnGenerateAuthTokenComplete(int rv) {
void HttpAuthHandler::FinishGenerateAuthToken() {
// TOOD(cbentzel): Should this be done in OK case only?
- net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL);
+ net_log_.EndEvent(EventTypeFromAuthTarget(target_));
callback_.Reset();
}
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 527118a..006759e 100644
--- a/net/http/http_cache_transaction.cc
+++ b/net/http/http_cache_transaction.cc
@@ -652,7 +652,7 @@ int HttpCache::Transaction::DoLoop(int result) {
int HttpCache::Transaction::DoGetBackend() {
cache_pending_ = true;
next_state_ = STATE_GET_BACKEND_COMPLETE;
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND);
return cache_->GetBackendForTransaction(this);
}
@@ -845,7 +845,7 @@ int HttpCache::Transaction::DoOpenEntry() {
DCHECK(!new_entry_);
next_state_ = STATE_OPEN_ENTRY_COMPLETE;
cache_pending_ = true;
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY);
return cache_->OpenEntry(cache_key_, &new_entry_, this);
}
@@ -895,7 +895,7 @@ int HttpCache::Transaction::DoCreateEntry() {
DCHECK(!new_entry_);
next_state_ = STATE_CREATE_ENTRY_COMPLETE;
cache_pending_ = true;
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY);
return cache_->CreateEntry(cache_key_, &new_entry_, this);
}
@@ -930,7 +930,7 @@ int HttpCache::Transaction::DoCreateEntryComplete(int result) {
int HttpCache::Transaction::DoDoomEntry() {
next_state_ = STATE_DOOM_ENTRY_COMPLETE;
cache_pending_ = true;
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY);
return cache_->DoomEntry(cache_key_, this);
}
@@ -948,7 +948,7 @@ int HttpCache::Transaction::DoAddToEntry() {
DCHECK(new_entry_);
cache_pending_ = true;
next_state_ = STATE_ADD_TO_ENTRY_COMPLETE;
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY);
DCHECK(entry_lock_waiting_since_.is_null());
entry_lock_waiting_since_ = base::TimeTicks::Now();
return cache_->AddTransactionToEntry(new_entry_, this);
@@ -1135,7 +1135,7 @@ int HttpCache::Transaction::DoTruncateCachedData() {
if (!entry_)
return OK;
if (net_log_.IsLoggingAllEvents())
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA);
// Truncate the stream.
return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_);
@@ -1157,7 +1157,7 @@ int HttpCache::Transaction::DoTruncateCachedMetadata() {
return OK;
if (net_log_.IsLoggingAllEvents())
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_);
}
@@ -1205,7 +1205,7 @@ int HttpCache::Transaction::DoCacheReadResponse() {
io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex);
read_buf_ = new IOBuffer(io_buf_len_);
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO);
return entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_,
io_buf_len_, io_callback_);
}
@@ -1256,13 +1256,13 @@ int HttpCache::Transaction::DoCacheReadResponseComplete(int result) {
int HttpCache::Transaction::DoCacheWriteResponse() {
if (net_log_.IsLoggingAllEvents() && entry_)
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
return WriteResponseInfoToEntry(false);
}
int HttpCache::Transaction::DoCacheWriteTruncatedResponse() {
if (net_log_.IsLoggingAllEvents() && entry_)
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);
return WriteResponseInfoToEntry(true);
}
@@ -1292,7 +1292,7 @@ int HttpCache::Transaction::DoCacheReadMetadata() {
response_.metadata =
new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex));
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO);
return entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata,
response_.metadata->size(),
io_callback_);
@@ -1326,7 +1326,7 @@ int HttpCache::Transaction::DoCacheReadData() {
next_state_ = STATE_CACHE_READ_DATA_COMPLETE;
if (net_log_.IsLoggingAllEvents())
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA);
if (partial_.get()) {
return partial_->CacheRead(entry_->disk_entry, read_buf_, io_buf_len_,
io_callback_);
@@ -1363,7 +1363,7 @@ int HttpCache::Transaction::DoCacheWriteData(int num_bytes) {
next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE;
write_len_ = num_bytes;
if (net_log_.IsLoggingAllEvents() && entry_)
- net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA);
return AppendResponseDataToEntry(read_buf_, num_bytes, io_callback_);
}
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 03de2a4..48060e9 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -93,36 +93,18 @@ bool IsClientCertificateError(int error) {
}
}
-class SSLVersionFallbackParams : public NetLog::EventParameters {
- public:
- SSLVersionFallbackParams(const std::string& host_and_port,
- int net_error,
- uint16 version_before,
- uint16 version_after)
- : host_and_port_(host_and_port),
- net_error_(net_error),
- version_before_(version_before),
- version_after_(version_after) {
- }
-
- virtual Value* ToValue() const {
- DictionaryValue* dict = new DictionaryValue();
- dict->SetString("host_and_port", host_and_port_);
- dict->SetInteger("net_error", net_error_);
- dict->SetInteger("version_before", version_before_);
- dict->SetInteger("version_after", version_after_);
- return dict;
- }
-
- protected:
- virtual ~SSLVersionFallbackParams() {}
-
- private:
- const std::string host_and_port_;
- const int net_error_; // Network error code that caused the fallback.
- const uint16 version_before_; // SSL version before the fallback.
- const uint16 version_after_; // SSL version after the fallback.
-};
+Value* NetLogSSLVersionFallbackCallback(const GURL* url,
+ int net_error,
+ uint16 version_before,
+ uint16 version_after,
+ NetLog::LogLevel /* log_level */) {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString("host_and_port", GetHostAndPort(*url));
+ dict->SetInteger("net_error", net_error);
+ dict->SetInteger("version_before", version_before);
+ dict->SetInteger("version_after", version_after);
+ return dict;
+}
} // namespace
@@ -554,7 +536,7 @@ int HttpNetworkTransaction::DoLoop(int result) {
break;
case STATE_BUILD_REQUEST:
DCHECK_EQ(OK, rv);
- net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST);
rv = DoBuildRequest();
break;
case STATE_BUILD_REQUEST_COMPLETE:
@@ -571,7 +553,7 @@ int HttpNetworkTransaction::DoLoop(int result) {
break;
case STATE_READ_HEADERS:
DCHECK_EQ(OK, rv);
- net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS);
rv = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE:
@@ -581,7 +563,7 @@ int HttpNetworkTransaction::DoLoop(int result) {
break;
case STATE_READ_BODY:
DCHECK_EQ(OK, rv);
- net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY);
rv = DoReadBody();
break;
case STATE_READ_BODY_COMPLETE:
@@ -592,7 +574,7 @@ int HttpNetworkTransaction::DoLoop(int result) {
case STATE_DRAIN_BODY_FOR_AUTH_RESTART:
DCHECK_EQ(OK, rv);
net_log_.BeginEvent(
- NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART, NULL);
+ NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART);
rv = DoDrainBodyForAuthRestart();
break;
case STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE:
@@ -1207,9 +1189,9 @@ int HttpNetworkTransaction::HandleSSLHandshakeError(int error) {
server_ssl_config_.version_max--;
net_log_.AddEvent(
NetLog::TYPE_SSL_VERSION_FALLBACK,
- make_scoped_refptr(new SSLVersionFallbackParams(
- GetHostAndPort(request_->url), error,
- version_before, server_ssl_config_.version_max)));
+ base::Bind(&NetLogSSLVersionFallbackCallback,
+ &request_->url, error, version_before,
+ server_ssl_config_.version_max));
server_ssl_config_.version_fallback = true;
ResetConnectionAndRequestForResend();
error = OK;
@@ -1226,9 +1208,9 @@ int HttpNetworkTransaction::HandleSSLHandshakeError(int error) {
server_ssl_config_.version_max = SSL_PROTOCOL_VERSION_SSL3;
net_log_.AddEvent(
NetLog::TYPE_SSL_VERSION_FALLBACK,
- make_scoped_refptr(new SSLVersionFallbackParams(
- GetHostAndPort(request_->url), error,
- version_before, server_ssl_config_.version_max)));
+ base::Bind(&NetLogSSLVersionFallbackCallback,
+ &request_->url, error, version_before,
+ server_ssl_config_.version_max));
server_ssl_config_.version_fallback = true;
ResetConnectionAndRequestForResend();
error = OK;
@@ -1268,27 +1250,24 @@ int HttpNetworkTransaction::HandleIOError(int error) {
// See http://crbug.com/105824 for more details.
case ERR_SOCKET_NOT_CONNECTED:
if (ShouldResendRequest(error)) {
- net_log_.AddEvent(
- NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR,
- make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
+ net_log_.AddEventWithNetErrorCode(
+ NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
ResetConnectionAndRequestForResend();
error = OK;
}
break;
case ERR_PIPELINE_EVICTION:
if (!session_->force_http_pipelining()) {
- net_log_.AddEvent(
- NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR,
- make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
+ net_log_.AddEventWithNetErrorCode(
+ NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
ResetConnectionAndRequestForResend();
error = OK;
}
break;
case ERR_SPDY_PING_FAILED:
case ERR_SPDY_SERVER_REFUSED_STREAM:
- net_log_.AddEvent(
- NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR,
- make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
+ net_log_.AddEventWithNetErrorCode(
+ NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR, error);
ResetConnectionAndRequestForResend();
error = OK;
break;
diff --git a/net/http/http_pipelined_connection_impl.cc b/net/http/http_pipelined_connection_impl.cc
index fe55598..531d959 100644
--- a/net/http/http_pipelined_connection_impl.cc
+++ b/net/http/http_pipelined_connection_impl.cc
@@ -25,46 +25,30 @@ namespace net {
namespace {
-class ReceivedHeadersParameters : public NetLog::EventParameters {
- public:
- ReceivedHeadersParameters(const NetLog::Source& source,
- const std::string& feedback)
- : source_(source), feedback_(feedback) {}
-
- virtual Value* ToValue() const OVERRIDE {
- DictionaryValue* dict = new DictionaryValue;
- dict->Set("source_dependency", source_.ToValue());
- dict->SetString("feedback", feedback_);
- return dict;
- }
-
- protected:
- virtual ~ReceivedHeadersParameters() {}
-
- private:
- const NetLog::Source source_;
- const std::string feedback_;
-};
-
-class StreamClosedParameters : public NetLog::EventParameters {
- public:
- StreamClosedParameters(const NetLog::Source& source, bool not_reusable)
- : source_(source), not_reusable_(not_reusable) {}
-
- virtual Value* ToValue() const OVERRIDE {
- DictionaryValue* dict = new DictionaryValue;
- dict->Set("source_dependency", source_.ToValue());
- dict->SetBoolean("not_reusable", not_reusable_);
- return dict;
- }
+Value* NetLogReceivedHeadersCallback(const NetLog::Source& source,
+ const std::string* feedback,
+ NetLog::LogLevel /* log_level */) {
+ DictionaryValue* dict = new DictionaryValue;
+ source.AddToEventParameters(dict);
+ dict->SetString("feedback", *feedback);
+ return dict;
+}
- protected:
- virtual ~StreamClosedParameters() {}
+Value* NetLogStreamClosedCallback(const NetLog::Source& source,
+ bool not_reusable,
+ NetLog::LogLevel /* log_level */) {
+ DictionaryValue* dict = new DictionaryValue;
+ source.AddToEventParameters(dict);
+ dict->SetBoolean("not_reusable", not_reusable);
+ return dict;
+}
- private:
- const NetLog::Source source_;
- const bool not_reusable_;
-};
+Value* NetLogHostPortPairCallback(const HostPortPair* host_port_pair,
+ NetLog::LogLevel /* log_level */) {
+ DictionaryValue* dict = new DictionaryValue;
+ dict->SetString("host_and_port", host_port_pair->ToString());
+ return dict;
+}
} // anonymous namespace
@@ -99,8 +83,7 @@ HttpPipelinedConnectionImpl::HttpPipelinedConnectionImpl(
CHECK(connection_.get());
net_log_.BeginEvent(
NetLog::TYPE_HTTP_PIPELINED_CONNECTION,
- make_scoped_refptr(new NetLogStringParameter(
- "host_and_port", origin.ToString())));
+ base::Bind(&NetLogHostPortPairCallback, &origin));
}
HttpPipelinedConnectionImpl::~HttpPipelinedConnectionImpl() {
@@ -116,7 +99,7 @@ HttpPipelinedConnectionImpl::~HttpPipelinedConnectionImpl() {
connection_->socket()->Disconnect();
}
connection_->Reset();
- net_log_.EndEvent(NetLog::TYPE_HTTP_PIPELINED_CONNECTION, NULL);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_PIPELINED_CONNECTION);
}
HttpPipelinedStream* HttpPipelinedConnectionImpl::CreateNewStream() {
@@ -293,9 +276,8 @@ int HttpPipelinedConnectionImpl::DoSendComplete(int result) {
stream_info_map_[active_send_request_->pipeline_id].state = STREAM_SENT;
net_log_.AddEvent(
NetLog::TYPE_HTTP_PIPELINED_CONNECTION_SENT_REQUEST,
- make_scoped_refptr(new NetLogSourceParameter(
- "source_dependency",
- stream_info_map_[active_send_request_->pipeline_id].source)));
+ stream_info_map_[active_send_request_->pipeline_id].source.
+ ToEventParametersCallback());
if (result == ERR_SOCKET_NOT_CONNECTED && completed_one_request_) {
result = ERR_PIPELINE_EVICTION;
@@ -549,8 +531,8 @@ void HttpPipelinedConnectionImpl::Close(int pipeline_id,
CHECK(ContainsKey(stream_info_map_, pipeline_id));
net_log_.AddEvent(
NetLog::TYPE_HTTP_PIPELINED_CONNECTION_STREAM_CLOSED,
- make_scoped_refptr(new StreamClosedParameters(
- stream_info_map_[pipeline_id].source, not_reusable)));
+ base::Bind(&NetLogStreamClosedCallback,
+ stream_info_map_[pipeline_id].source, not_reusable));
switch (stream_info_map_[pipeline_id].state) {
case STREAM_CREATED:
stream_info_map_[pipeline_id].state = STREAM_UNUSED;
@@ -762,8 +744,8 @@ void HttpPipelinedConnectionImpl::ReportPipelineFeedback(int pipeline_id,
}
net_log_.AddEvent(
NetLog::TYPE_HTTP_PIPELINED_CONNECTION_RECEIVED_HEADERS,
- make_scoped_refptr(new ReceivedHeadersParameters(
- stream_info_map_[pipeline_id].source, feedback_str)));
+ base::Bind(&NetLogReceivedHeadersCallback,
+ stream_info_map_[pipeline_id].source, &feedback_str));
delegate_->OnPipelineFeedback(this, feedback);
}
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index f09241a..c606544 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -336,7 +336,7 @@ int HttpProxyClientSocket::DoLoop(int last_io_result) {
case STATE_SEND_REQUEST:
DCHECK_EQ(OK, rv);
net_log_.BeginEvent(
- NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_SEND_REQUEST, NULL);
+ NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_SEND_REQUEST);
rv = DoSendRequest();
break;
case STATE_SEND_REQUEST_COMPLETE:
@@ -347,7 +347,7 @@ int HttpProxyClientSocket::DoLoop(int last_io_result) {
case STATE_READ_HEADERS:
DCHECK_EQ(OK, rv);
net_log_.BeginEvent(
- NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_READ_HEADERS, NULL);
+ NetLog::TYPE_HTTP_TRANSACTION_TUNNEL_READ_HEADERS);
rv = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE:
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index 4b04a24..c1b08e0 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -40,75 +40,30 @@
namespace net {
-// Parameters associated with the start of a HTTP stream job.
-class HttpStreamJobParameters : public NetLog::EventParameters {
- public:
- static scoped_refptr<HttpStreamJobParameters> Create(
- const GURL& original_url,
- const GURL& url) {
- return make_scoped_refptr(new HttpStreamJobParameters(original_url, url));
- }
-
- virtual Value* ToValue() const;
-
- protected:
- virtual ~HttpStreamJobParameters() {}
-
- private:
- HttpStreamJobParameters(const GURL& original_url, const GURL& url)
- : original_url_(original_url.GetOrigin().spec()),
- url_(url.GetOrigin().spec()) {
- }
-
- const std::string original_url_;
- const std::string url_;
-};
-
-Value* HttpStreamJobParameters::ToValue() const {
+// Returns parameters associated with the start of a HTTP stream job.
+Value* NetLogHttpStreamJobCallback(const GURL* original_url,
+ const GURL* url,
+ NetLog::LogLevel /* log_level */) {
DictionaryValue* dict = new DictionaryValue();
- dict->SetString("original_url", original_url_);
- dict->SetString("url", url_);
+ dict->SetString("original_url", original_url->GetOrigin().spec());
+ dict->SetString("url", url->GetOrigin().spec());
return dict;
}
-// Parameters associated with the Proto (with NPN negotiation) of a HTTP stream.
-class HttpStreamProtoParameters : public NetLog::EventParameters {
- public:
- static scoped_refptr<HttpStreamProtoParameters> Create(
- const SSLClientSocket::NextProtoStatus status,
- const std::string& proto,
- const std::string& server_protos) {
- return make_scoped_refptr(new HttpStreamProtoParameters(
- status, proto, server_protos));
- }
-
- virtual Value* ToValue() const;
-
- protected:
- virtual ~HttpStreamProtoParameters() {}
-
- private:
- HttpStreamProtoParameters(const SSLClientSocket::NextProtoStatus status,
- const std::string& proto,
- const std::string& server_protos)
- : status_(status),
- proto_(proto),
- server_protos_(server_protos) {
- }
-
- const SSLClientSocket::NextProtoStatus status_;
- const std::string proto_;
- const std::string server_protos_;
-};
-
-Value* HttpStreamProtoParameters::ToValue() const {
+// Returns parameters associated with the Proto (with NPN negotiation) of a HTTP
+// stream.
+Value* NetLogHttpStreamProtoCallback(
+ const SSLClientSocket::NextProtoStatus status,
+ const std::string* proto,
+ const std::string* server_protos,
+ NetLog::LogLevel /* log_level */) {
DictionaryValue* dict = new DictionaryValue();
dict->SetString("next_proto_status",
- SSLClientSocket::NextProtoStatusToString(status_));
- dict->SetString("proto", proto_);
+ SSLClientSocket::NextProtoStatusToString(status));
+ dict->SetString("proto", *proto);
dict->SetString("server_protos",
- SSLClientSocket::ServerProtosToString(server_protos_));
+ SSLClientSocket::ServerProtosToString(*server_protos));
return dict;
}
@@ -149,7 +104,7 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory,
}
HttpStreamFactoryImpl::Job::~Job() {
- net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB, NULL);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB);
// When we're in a partially constructed state, waiting for the user to
// provide certificate handling information or authentication, we can't reuse
@@ -597,8 +552,8 @@ int HttpStreamFactoryImpl::Job::DoStart() {
http_pipelining_key_.reset(new HttpPipelinedHost::Key(origin_));
net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB,
- HttpStreamJobParameters::Create(request_info_.url,
- origin_url_));
+ base::Bind(&NetLogHttpStreamJobCallback,
+ &request_info_.url, &origin_url_));
// Don't connect to restricted ports.
if (!IsPortAllowedByDefault(port) && !IsPortAllowedByOverride(port)) {
@@ -840,7 +795,8 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) {
protocol_negotiated_ = protocol_negotiated;
net_log_.AddEvent(
NetLog::TYPE_HTTP_STREAM_REQUEST_PROTO,
- HttpStreamProtoParameters::Create(status, proto, server_protos));
+ base::Bind(&NetLogHttpStreamProtoCallback,
+ status, &proto, &server_protos));
if (ssl_socket->was_spdy_negotiated())
SwitchToSpdyMode();
}
diff --git a/net/http/http_stream_factory_impl_request.cc b/net/http/http_stream_factory_impl_request.cc
index 2ac3354..7f536c8 100644
--- a/net/http/http_stream_factory_impl_request.cc
+++ b/net/http/http_stream_factory_impl_request.cc
@@ -4,6 +4,7 @@
#include "net/http/http_stream_factory_impl_request.h"
+#include "base/callback.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "net/http/http_stream_factory_impl_job.h"
@@ -27,7 +28,7 @@ HttpStreamFactoryImpl::Request::Request(const GURL& url,
DCHECK(factory_);
DCHECK(delegate_);
- net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST);
}
HttpStreamFactoryImpl::Request::~Request() {
@@ -36,7 +37,7 @@ HttpStreamFactoryImpl::Request::~Request() {
else
DCHECK(!jobs_.empty());
- net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL);
+ net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST);
for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
factory_->request_map_.erase(*it);
@@ -87,12 +88,10 @@ void HttpStreamFactoryImpl::Request::Complete(
using_spdy_ = using_spdy;
net_log_.AddEvent(
NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB,
- make_scoped_refptr(new NetLogSourceParameter(
- "source_dependency", job_net_log.source())));
+ job_net_log.source().ToEventParametersCallback());
job_net_log.AddEvent(
NetLog::TYPE_HTTP_STREAM_JOB_BOUND_TO_REQUEST,
- make_scoped_refptr(new NetLogSourceParameter(
- "source_dependency", net_log_.source())));
+ net_log_.source().ToEventParametersCallback());
}
void HttpStreamFactoryImpl::Request::OnStreamReady(
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 7fda009..92f62d3 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -379,7 +379,7 @@ int HttpStreamParser::DoLoop(int result) {
can_do_more = false;
break;
case STATE_READ_HEADERS:
- net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_PARSER_READ_HEADERS, NULL);
+ net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_PARSER_READ_HEADERS);
result = DoReadHeaders();
break;
case STATE_READ_HEADERS_COMPLETE: