agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
  If custom metrics were requested, gather them
-----------------------------------------------------------------------------*/
If custom metrics were requested, gather them
If custom metrics were requested gather them
void CPagetestReporting::SaveCustomMetrics(CString file) {
  CStringA out;
  if (!customMetrics.IsEmpty()) {
    out = "{";
    DWORD count = 0;
    POSITION pos = customMetrics.GetHeadPosition();
    while(pos) {
      CCustomMetric metric = customMetrics.GetNext(pos);
      CString result = GetCustomMetric(metric.code);
      if (count)
        out += ",";
      out += "\"";
      out += JSONEscape((LPCSTR)CT2A(metric.name, CP_UTF8));
      out += "\":\"";
      out += JSONEscape((LPCSTR)CT2A(result, CP_UTF8));
      out += "\"";
      count++;
    }
    out += "}";
  }
  if (!out.IsEmpty()) {
    HANDLE hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
    if (hFile != INVALID_HANDLE_VALUE) {
      DWORD bytes = 0;
      WriteFile(hFile, (LPCSTR)out, out.GetLength(), &bytes, 0);
      CloseHandle(hFile);
    }
  }
}
void CPagetestReporting :: SaveCustomMetrics ( CString file ) { CStringA out ; if ( ! customMetrics . IsEmpty ( ) ) { out = " " ; DWORD count = 0 ; POSITION pos = customMetrics . GetHeadPosition ( ) ; while ( pos ) { CCustomMetric metric = customMetrics . GetNext ( pos ) ; CString result = GetCustomMetric ( metric . code ) ; if ( count ) out += " " ; out += " \" " ; out += JSONEscape ( ( LPCSTR ) CT2A ( metric . name , CP_UTF8 ) ) ; out += " \" \" " ; out += JSONEscape ( ( LPCSTR ) CT2A ( result , CP_UTF8 ) ) ; out += " \" " ; count ++ ; } out += " " ; } if ( ! out . IsEmpty ( ) ) { HANDLE hFile = CreateFile ( file , GENERIC_WRITE , 0 , 0 , CREATE_ALWAYS , 0 , 0 ) ; if ( hFile != INVALID_HANDLE_VALUE ) { DWORD bytes = 0 ; WriteFile ( hFile , ( LPCSTR ) out , out . GetLength ( ) , & bytes , 0 ) ; CloseHandle ( hFile ) ; } } }
If custom metrics were requested, gather them
If custom metrics were requested gather them