summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/net/load_timing_observer.cc49
-rw-r--r--chrome/browser/net/load_timing_observer.h13
2 files changed, 62 insertions, 0 deletions
diff --git a/chrome/browser/net/load_timing_observer.cc b/chrome/browser/net/load_timing_observer.cc
index cd80b7d..d0e0485 100644
--- a/chrome/browser/net/load_timing_observer.cc
+++ b/chrome/browser/net/load_timing_observer.cc
@@ -71,6 +71,8 @@ void LoadTimingObserver::OnAddEntry(net::NetLog::EventType type,
OnAddURLRequestEntry(type, time, source, phase, params);
else if (source.type == net::NetLog::SOURCE_CONNECT_JOB)
OnAddConnectJobEntry(type, time, source, phase, params);
+ else if (source.type == net::NetLog::SOURCE_SOCKET)
+ OnAddSocketEntry(type, time, source, phase, params);
}
void LoadTimingObserver::OnAddURLRequestEntry(
@@ -148,6 +150,14 @@ void LoadTimingObserver::OnAddURLRequestEntry(
case net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET:
record->socket_log_id = static_cast<net::NetLogSourceParameter*>(
params)->value().id;
+ if (!record->socket_reused) {
+ SocketToRecordMap::iterator it =
+ socket_to_record_.find(record->socket_log_id);
+ if (it != socket_to_record_.end() && !it->second.ssl_start.is_null()) {
+ timing.ssl_start = TimeTicksToOffset(it->second.ssl_start, record);
+ timing.ssl_end = TimeTicksToOffset(it->second.ssl_end, record);
+ }
+ }
break;
case net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST:
case net::NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST:
@@ -204,3 +214,42 @@ void LoadTimingObserver::OnAddConnectJobEntry(
}
}
}
+
+void LoadTimingObserver::OnAddSocketEntry(
+ net::NetLog::EventType type,
+ const base::TimeTicks& time,
+ const net::NetLog::Source& source,
+ net::NetLog::EventPhase phase,
+ net::NetLog::EventParameters* params) {
+ bool is_begin = phase == net::NetLog::PHASE_BEGIN;
+ bool is_end = phase == net::NetLog::PHASE_END;
+
+ // Manage record lifetime based on the SOCKET_ALIVE entry.
+ if (type == net::NetLog::TYPE_SOCKET_ALIVE) {
+ if (is_begin) {
+ // Prevents us from passively growing the memory memory unbounded in case
+ // something went wrong. Should not happen.
+ if (socket_to_record_.size() > kMaxNumEntries) {
+ LOG(WARNING) << "The load timing observer socket count has grown "
+ "larger than expected, resetting";
+ socket_to_record_.clear();
+ }
+
+ socket_to_record_.insert(
+ std::make_pair(source.id, SocketRecord()));
+ } else if (is_end) {
+ socket_to_record_.erase(source.id);
+ }
+ return;
+ }
+ SocketToRecordMap::iterator it = socket_to_record_.find(source.id);
+ if (it == socket_to_record_.end())
+ return;
+
+ if (type == net::NetLog::TYPE_SSL_CONNECT) {
+ if (is_begin)
+ it->second.ssl_start = time;
+ else if (is_end)
+ it->second.ssl_end = time;
+ }
+}
diff --git a/chrome/browser/net/load_timing_observer.h b/chrome/browser/net/load_timing_observer.h
index b49de5d..9e25b2d 100644
--- a/chrome/browser/net/load_timing_observer.h
+++ b/chrome/browser/net/load_timing_observer.h
@@ -30,6 +30,11 @@ class LoadTimingObserver : public ChromeNetLog::Observer {
base::TimeTicks dns_end;
};
+ struct SocketRecord {
+ base::TimeTicks ssl_start;
+ base::TimeTicks ssl_end;
+ };
+
LoadTimingObserver();
~LoadTimingObserver();
@@ -54,13 +59,21 @@ class LoadTimingObserver : public ChromeNetLog::Observer {
net::NetLog::EventPhase phase,
net::NetLog::EventParameters* params);
+ void OnAddSocketEntry(net::NetLog::EventType type,
+ const base::TimeTicks& time,
+ const net::NetLog::Source& source,
+ net::NetLog::EventPhase phase,
+ net::NetLog::EventParameters* params);
+
URLRequestRecord* CreateURLRequestRecord(uint32 source_id);
void DeleteURLRequestRecord(uint32 source_id);
typedef base::hash_map<uint32, URLRequestRecord> URLRequestToRecordMap;
typedef base::hash_map<uint32, ConnectJobRecord> ConnectJobToRecordMap;
+ typedef base::hash_map<uint32, SocketRecord> SocketToRecordMap;
URLRequestToRecordMap url_request_to_record_;
ConnectJobToRecordMap connect_job_to_record_;
+ SocketToRecordMap socket_to_record_;
DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver);
};