/* vim: ts=2 sw=2 expandtab
 * BEGIN FLOCK GPL
 *
 * Copyright Flock Inc. 2005-2009
 * http://flock.com
 *
 * This file may be used under the terms of the
 * GNU General Public License Version 2 or later (the "GPL"),
 * http://www.gnu.org/licenses/gpl.html
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * END FLOCK GPL
 */
 
#ifndef flockSystemInfo___h___
#define flockSystemInfo___h___

#include "flockISystemInfo.h"
#include "nsCOMPtr.h"
#include "nsStringAPI.h"
#include "nsIPrefService.h"
#include "nsServiceManagerUtils.h"
#include "nsIXULAppInfo.h"
#include "nsIXULRuntime.h"
#include "prenv.h"

#include <stdlib.h>       // For the atoi function

#if defined(XP_WIN32)
#include <windows.h>
#if _MSC_VER > 1200
#include <psapi.h>
#else
typedef struct _PROCESS_MEMORY_COUNTERS {
  DWORD cb;
  DWORD PageFaultCount;
  SIZE_T PeakWorkingSetSize;
  SIZE_T WorkingSetSize;
  SIZE_T QuotaPeakPagedPoolUsage;
  SIZE_T QuotaPagedPoolUsage;
  SIZE_T QuotaPeakNonPagedPoolUsage;
  SIZE_T QuotaNonPagedPoolUsage;
  SIZE_T PagefileUsage;
  SIZE_T PeakPagefileUsage;
} PROCESS_MEMORY_COUNTERS;
typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS;
#endif
typedef BOOL (WINAPI * GETPROCESSMEMORYINFO_FUNC)(HANDLE process, PPROCESS_MEMORY_COUNTERS counters, DWORD cb);
#endif

#if defined(__linux)
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <asm/param.h>
#endif

#if defined(XP_MACOSX)
#include <mach/mach.h>
#include <mach/task.h>
#endif

#define PREF_FIRSTRUN_COMPLETED "flock.firstrun.components.browser_startup.completed"

class flockSystemInfo : public flockISystemInfo
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_FLOCKISYSTEMINFO

  flockSystemInfo();
	
private:
  ~flockSystemInfo();
  PRBool mFirstRun;
  
#if defined(__linux)
  unsigned long long mHertz;
#endif

#if defined(XP_WIN32)
  HMODULE sPSModule;
  HANDLE sProcess;
  GETPROCESSMEMORYINFO_FUNC sGetMemInfo;
  PRInt64 mLastUserTimeProcess;
  PRInt64 mLastKernelTimeProcess;
  PRInt64 mLastTime;
#endif

};

#endif
