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

Side by Side Diff: chrome/browser/net/load_timing_observer.cc

Issue 11450023: Partial changes to enable net-internals in iOS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/net/load_timing_observer.h" 5 #include "chrome/browser/net/load_timing_observer.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "chrome/browser/net/chrome_net_log.h" 8 #include "chrome/browser/net/chrome_net_log.h"
9 #include "content/public/common/resource_response.h" 9 #include "content/public/common/resource_response.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (chrome_net_log == NULL) 110 if (chrome_net_log == NULL)
111 return; 111 return;
112 112
113 uint32 source_id = request->net_log().source().id; 113 uint32 source_id = request->net_log().source().id;
114 LoadTimingObserver* observer = chrome_net_log->load_timing_observer(); 114 LoadTimingObserver* observer = chrome_net_log->load_timing_observer();
115 LoadTimingObserver::URLRequestRecord* record = 115 LoadTimingObserver::URLRequestRecord* record =
116 observer->GetURLRequestRecord(source_id); 116 observer->GetURLRequestRecord(source_id);
117 if (record) { 117 if (record) {
118 response->head.connection_id = record->socket_log_id; 118 response->head.connection_id = record->socket_log_id;
119 response->head.connection_reused = record->socket_reused; 119 response->head.connection_reused = record->socket_reused;
120 #if !defined(OS_IOS)
120 response->head.load_timing = record->timing; 121 response->head.load_timing = record->timing;
122 #endif
121 } 123 }
122 } 124 }
123 125
124 void LoadTimingObserver::OnAddURLRequestEntry(const net::NetLog::Entry& entry) { 126 void LoadTimingObserver::OnAddURLRequestEntry(const net::NetLog::Entry& entry) {
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
126 128
127 bool is_begin = entry.phase() == net::NetLog::PHASE_BEGIN; 129 bool is_begin = entry.phase() == net::NetLog::PHASE_BEGIN;
128 bool is_end = entry.phase() == net::NetLog::PHASE_END; 130 bool is_end = entry.phase() == net::NetLog::PHASE_END;
129 131
130 if (entry.type() == net::NetLog::TYPE_URL_REQUEST_START_JOB) { 132 if (entry.type() == net::NetLog::TYPE_URL_REQUEST_START_JOB) {
(...skipping 14 matching lines...) Expand all
145 // something went wrong. Should not happen. 147 // something went wrong. Should not happen.
146 if (url_request_to_record_.size() > kMaxNumEntries) { 148 if (url_request_to_record_.size() > kMaxNumEntries) {
147 LOG(WARNING) << "The load timing observer url request count has grown " 149 LOG(WARNING) << "The load timing observer url request count has grown "
148 "larger than expected, resetting"; 150 "larger than expected, resetting";
149 url_request_to_record_.clear(); 151 url_request_to_record_.clear();
150 } 152 }
151 153
152 URLRequestRecord& record = url_request_to_record_[entry.source().id]; 154 URLRequestRecord& record = url_request_to_record_[entry.source().id];
153 base::TimeTicks now = GetCurrentTime(); 155 base::TimeTicks now = GetCurrentTime();
154 record.base_ticks = now; 156 record.base_ticks = now;
157 #if !defined(OS_IOS)
155 record.timing = ResourceLoadTimingInfo(); 158 record.timing = ResourceLoadTimingInfo();
156 record.timing.base_ticks = now; 159 record.timing.base_ticks = now;
157 record.timing.base_time = TimeTicksToTime(now); 160 record.timing.base_time = TimeTicksToTime(now);
161 #endif
158 } 162 }
159 return; 163 return;
160 } else if (entry.type() == net::NetLog::TYPE_REQUEST_ALIVE) { 164 } else if (entry.type() == net::NetLog::TYPE_REQUEST_ALIVE) {
161 // Cleanup records based on the TYPE_REQUEST_ALIVE entry. 165 // Cleanup records based on the TYPE_REQUEST_ALIVE entry.
162 if (is_end) 166 if (is_end)
163 url_request_to_record_.erase(entry.source().id); 167 url_request_to_record_.erase(entry.source().id);
164 return; 168 return;
165 } 169 }
166 170
167 URLRequestRecord* record = GetURLRequestRecord(entry.source().id); 171 URLRequestRecord* record = GetURLRequestRecord(entry.source().id);
168 if (!record) 172 if (!record)
169 return; 173 return;
170 174
175 #if !defined(OS_IOS)
171 ResourceLoadTimingInfo& timing = record->timing; 176 ResourceLoadTimingInfo& timing = record->timing;
172 177
173 switch (entry.type()) { 178 switch (entry.type()) {
174 case net::NetLog::TYPE_PROXY_SERVICE: 179 case net::NetLog::TYPE_PROXY_SERVICE:
175 if (is_begin) 180 if (is_begin)
176 timing.proxy_start = TimeTicksToOffset(GetCurrentTime(), record); 181 timing.proxy_start = TimeTicksToOffset(GetCurrentTime(), record);
177 else if (is_end) 182 else if (is_end)
178 timing.proxy_end = TimeTicksToOffset(GetCurrentTime(), record); 183 timing.proxy_end = TimeTicksToOffset(GetCurrentTime(), record);
179 break; 184 break;
180 case net::NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB: { 185 case net::NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB: {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 timing.receive_headers_start = 227 timing.receive_headers_start =
223 TimeTicksToOffset(GetCurrentTime(), record); 228 TimeTicksToOffset(GetCurrentTime(), record);
224 } else if (is_end) { 229 } else if (is_end) {
225 timing.receive_headers_end = 230 timing.receive_headers_end =
226 TimeTicksToOffset(GetCurrentTime(), record); 231 TimeTicksToOffset(GetCurrentTime(), record);
227 } 232 }
228 break; 233 break;
229 default: 234 default:
230 break; 235 break;
231 } 236 }
237 #endif // !defined(OS_IOS)
232 } 238 }
233 239
234 void LoadTimingObserver::OnAddHTTPStreamJobEntry( 240 void LoadTimingObserver::OnAddHTTPStreamJobEntry(
235 const net::NetLog::Entry& entry) { 241 const net::NetLog::Entry& entry) {
236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 242 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
237 243
238 bool is_begin = entry.phase() == net::NetLog::PHASE_BEGIN; 244 bool is_begin = entry.phase() == net::NetLog::PHASE_BEGIN;
239 bool is_end = entry.phase() == net::NetLog::PHASE_END; 245 bool is_end = entry.phase() == net::NetLog::PHASE_END;
240 246
241 if (entry.type() == net::NetLog::TYPE_HTTP_STREAM_JOB) { 247 if (entry.type() == net::NetLog::TYPE_HTTP_STREAM_JOB) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (is_begin) 392 if (is_begin)
387 it->second.ssl_start = GetCurrentTime(); 393 it->second.ssl_start = GetCurrentTime();
388 else if (is_end) 394 else if (is_end)
389 it->second.ssl_end = GetCurrentTime(); 395 it->second.ssl_end = GetCurrentTime();
390 } 396 }
391 } 397 }
392 398
393 base::TimeTicks LoadTimingObserver::GetCurrentTime() const { 399 base::TimeTicks LoadTimingObserver::GetCurrentTime() const {
394 return base::TimeTicks::Now(); 400 return base::TimeTicks::Now();
395 } 401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698