agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	? If the object is a JPEG, see if it is progressive (and count the scans)
-----------------------------------------------------------------------------*/
? If the object is a JPEG, see if it is progressive (and count the scans)
? If the object is a JPEG see if it is progressive ( and count the scans )
void CPagetestReporting::CheckProgressiveJpeg()
{
	progressiveJpegScore = -1;
  double progressive_bytes = 0;
  double total_bytes = 0;
	ATLTRACE(_T("[Pagetest] - CheckProgressiveJpeg\n"));
	POSITION pos = events.GetHeadPosition();
	while( pos ) {
		CTrackedEvent * e = events.GetNext(pos);
		if( e && e->type == CTrackedEvent::etWinInetRequest && !e->ignore ) {
			CWinInetRequest * w = (CWinInetRequest *)e;
			CString mime = w->response.contentType;
			mime.MakeLower();
			LPBYTE body = w->body;
			DWORD bodyLen = w->bodyLen;
			if( w->fromNet && 
				w->result == 200 && 
				mime.Find(_T("image/")) >= 0 && 
				body && bodyLen > 2 &&
				body[0] == 0xff && body[1] == 0xd8) {
        w->jpegScans = 0;
        DWORD pos = 0;
        BYTE * marker;
        DWORD marker_length;
        while (FindJPEGMarker(body, bodyLen, pos, marker, marker_length) &&
               marker) {
          if (marker[0] == 0xff && marker[1] == 0xda)
            w->jpegScans++;
          pos += marker_length;
        }
        if (bodyLen > 10240 && w->jpegScans > 0) {
          total_bytes += bodyLen;
          if (w->jpegScans > 1)
            progressive_bytes += bodyLen;
        }
			}
		}
	}
  if (total_bytes > 0)
    progressiveJpegScore = (int)((progressive_bytes * 100.0 / total_bytes) + 0.5);
}
void CPagetestReporting :: CheckProgressiveJpeg ( ) { progressiveJpegScore = -1 ; double progressive_bytes = 0 ; double total_bytes = 0 ; ATLTRACE ( _T ( " \n " ) ) ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos ) { CTrackedEvent * e = events . GetNext ( pos ) ; if ( e && e -> type == CTrackedEvent :: etWinInetRequest && ! e -> ignore ) { CWinInetRequest * w = ( CWinInetRequest * ) e ; CString mime = w -> response . contentType ; mime . MakeLower ( ) ; LPBYTE body = w -> body ; DWORD bodyLen = w -> bodyLen ; if ( w -> fromNet && w -> result == 200 && mime . Find ( _T ( " " ) ) >= 0 && body && bodyLen > 2 && body [ 0 ] == 0xff && body [ 1 ] == 0xd8 ) { w -> jpegScans = 0 ; DWORD pos = 0 ; BYTE * marker ; DWORD marker_length ; while ( FindJPEGMarker ( body , bodyLen , pos , marker , marker_length ) && marker ) { if ( marker [ 0 ] == 0xff && marker [ 1 ] == 0xda ) w -> jpegScans ++ ; pos += marker_length ; } if ( bodyLen > 10240 && w -> jpegScans > 0 ) { total_bytes += bodyLen ; if ( w -> jpegScans > 1 ) progressive_bytes += bodyLen ; } } } } if ( total_bytes > 0 ) progressiveJpegScore = ( int ) ( ( progressive_bytes * 100.0 / total_bytes ) + 0.5 ) ; }
?
?