Source:
<code>public void responseHeadersReceived(InspectorResponse response) { NetworkPeerManager peerManager = getPeerManagerIfEnabled(); if (peerManager != null) { Network.Response responseJSON = new Network.Response(); responseJSON.url = response.url(); responseJSON.status = response.statusCode(); responseJSON.statusText = response.reasonPhrase(); responseJSON.headers = formatHeadersAsJSON(response); String contentType = getContentType(response); responseJSON.mimeType = contentType != null ? getResourceTypeHelper().stripContentExtras(contentType) : "application/octet-stream"; responseJSON.connectionReused = response.connectionReused(); responseJSON.connectionId = response.connectionId(); responseJSON.fromDiskCache = response.fromDiskCache(); Network.ResponseReceivedParams receivedParams = new Network.ResponseReceivedParams(); receivedParams.requestId = response.requestId(); receivedParams.frameId = "1"; receivedParams.loaderId = "1"; receivedParams.timestamp = stethoNow() / 1000.0; receivedParams.type = contentType != null ? getResourceTypeHelper().determineResourceType(contentType) : Page.ResourceType.OTHER; receivedParams.response = responseJSON; AsyncPrettyPrinterRegistry registry= peerManager.getAsyncPrettyPrinterRegistry(); AsyncPrettyPrinterFactory factory = null; <START> for (int i = 0; i < response.headerCount(); i++) { <END> factory = registry.lookup(response.headerName(i)); if (factory != null) { AsyncPrettyPrinter asyncPrettyPrinter = factory.getInstance( response.headerName(i), response.headerValue(i)); peerManager.getResponseBodyFileManager().addAsyncPrettyPrinter( response.requestId(), asyncPrettyPrinter); break; } } peerManager.sendNotificationToPeers("Network.responseReceived", receivedParams); } }</code><technical_language>recommend a for-loop pattern this reduce per-iteration overhead: for (int i = 0, count = response.headerCount(); i < count; i++) { (yeah, this matter android!)</technical_language>

Target:
public void responseHeadersReceived(InspectorResponse response) { NetworkPeerManager peerManager = getPeerManagerIfEnabled(); if (peerManager != null) { Network.Response responseJSON = new Network.Response(); responseJSON.url = response.url(); responseJSON.status = response.statusCode(); responseJSON.statusText = response.reasonPhrase(); responseJSON.headers = formatHeadersAsJSON(response); String contentType = getContentType(response); responseJSON.mimeType = contentType != null ? getResourceTypeHelper().stripContentExtras(contentType) : "application/octet-stream"; responseJSON.connectionReused = response.connectionReused(); responseJSON.connectionId = response.connectionId(); responseJSON.fromDiskCache = response.fromDiskCache(); Network.ResponseReceivedParams receivedParams = new Network.ResponseReceivedParams(); receivedParams.requestId = response.requestId(); receivedParams.frameId = "1"; receivedParams.loaderId = "1"; receivedParams.timestamp = stethoNow() / 1000.0; receivedParams.response = responseJSON; AsyncPrettyPrinter asyncPrettyPrinter = initAsyncPrettyPrinterForResponse(response, peerManager); receivedParams.type = determineResourceType(asyncPrettyPrinter, contentType, getResourceTypeHelper()); peerManager.sendNotificationToPeers("Network.responseReceived", receivedParams); } }