michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * Cache Service Utility Functions michael@0: */ michael@0: michael@0: #ifndef _nsCache_h_ michael@0: #define _nsCache_h_ michael@0: michael@0: #if defined(MOZ_LOGGING) michael@0: #define FORCE_PR_LOG michael@0: #endif michael@0: michael@0: #if defined(PR_LOG) michael@0: #error "If nsCache.h #included it must come before any files that #include prlog.h" michael@0: #endif michael@0: michael@0: #include "prlog.h" michael@0: #include "nsISupports.h" michael@0: #include "nsIFile.h" michael@0: #include "nsAString.h" michael@0: #include "prtime.h" michael@0: #include "nsError.h" michael@0: michael@0: // PR_LOG args = "format string", arg, arg, ... michael@0: #if defined(PR_LOGGING) michael@0: extern PRLogModuleInfo * gCacheLog; michael@0: void CacheLogInit(); michael@0: void CacheLogPrintPath(PRLogModuleLevel level, michael@0: const char * format, michael@0: nsIFile * item); michael@0: #define CACHE_LOG_INIT() CacheLogInit() michael@0: #define CACHE_LOG_ALWAYS(args) PR_LOG(gCacheLog, PR_LOG_ALWAYS, args) michael@0: #define CACHE_LOG_ERROR(args) PR_LOG(gCacheLog, PR_LOG_ERROR, args) michael@0: #define CACHE_LOG_WARNING(args) PR_LOG(gCacheLog, PR_LOG_WARNING, args) michael@0: #define CACHE_LOG_DEBUG(args) PR_LOG(gCacheLog, PR_LOG_DEBUG, args) michael@0: #define CACHE_LOG_PATH(level, format, item) \ michael@0: CacheLogPrintPath(level, format, item) michael@0: #else michael@0: #define CACHE_LOG_INIT() {} michael@0: #define CACHE_LOG_ALWAYS(args) {} michael@0: #define CACHE_LOG_ERROR(args) {} michael@0: #define CACHE_LOG_WARNING(args) {} michael@0: #define CACHE_LOG_DEBUG(args) {} michael@0: #define CACHE_LOG_PATH(level, format, item) {} michael@0: #endif michael@0: michael@0: michael@0: extern uint32_t SecondsFromPRTime(PRTime prTime); michael@0: extern PRTime PRTimeFromSeconds(uint32_t seconds); michael@0: michael@0: michael@0: extern nsresult ClientIDFromCacheKey(const nsACString& key, char ** result); michael@0: extern nsresult ClientKeyFromCacheKey(const nsCString& key, nsACString &result); michael@0: michael@0: michael@0: #endif // _nsCache_h