tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CookieLogging.h (2069B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef mozilla_net_CookieLogging_h
      7 #define mozilla_net_CookieLogging_h
      8 
      9 #include "mozilla/Logging.h"
     10 #include "nsString.h"
     11 
     12 class nsIConsoleReportCollector;
     13 class nsIURI;
     14 
     15 namespace mozilla {
     16 namespace net {
     17 
     18 // define logging macros for convenience
     19 #define SET_COOKIE true
     20 #define GET_COOKIE false
     21 
     22 extern LazyLogModule gCookieLog;
     23 
     24 #define COOKIE_LOGFAILURE(a, b, c, d) CookieLogging::LogFailure(a, b, c, d)
     25 #define COOKIE_LOGSUCCESS(a, b, c, d, e) \
     26  CookieLogging::LogSuccess(a, b, c, d, e)
     27 
     28 #define COOKIE_LOGEVICTED(a, details)            \
     29  PR_BEGIN_MACRO                                 \
     30  if (MOZ_LOG_TEST(gCookieLog, LogLevel::Debug)) \
     31    CookieLogging::LogEvicted(a, details);       \
     32  PR_END_MACRO
     33 
     34 #define COOKIE_LOGSTRING(lvl, fmt)  \
     35  PR_BEGIN_MACRO                    \
     36  MOZ_LOG(gCookieLog, lvl, fmt);    \
     37  MOZ_LOG(gCookieLog, lvl, ("\n")); \
     38  PR_END_MACRO
     39 
     40 class Cookie;
     41 
     42 class CookieLogging final {
     43 public:
     44  static void LogSuccess(bool aSetCookie, nsIURI* aHostURI,
     45                         const nsACString& aCookieString, Cookie* aCookie,
     46                         bool aReplacing);
     47 
     48  static void LogFailure(bool aSetCookie, nsIURI* aHostURI,
     49                         const nsACString& aCookieString, const char* aReason);
     50 
     51  static void LogCookie(Cookie* aCookie);
     52 
     53  static void LogEvicted(Cookie* aCookie, const char* aDetails);
     54 
     55  static void LogMessageToConsole(nsIConsoleReportCollector* aCRC, nsIURI* aURI,
     56                                  uint32_t aErrorFlags,
     57                                  const nsACString& aCategory,
     58                                  const nsACString& aMsg,
     59                                  const nsTArray<nsString>& aParams);
     60 };
     61 
     62 }  // namespace net
     63 }  // namespace mozilla
     64 
     65 #endif  // mozilla_net_CookieLogging_h