xpcom/base/nsConsoleService.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     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/. */
     6 /*
     7  * nsConsoleService class declaration.
     8  */
    10 #ifndef __nsconsoleservice_h__
    11 #define __nsconsoleservice_h__
    13 #include "mozilla/Attributes.h"
    14 #include "mozilla/Mutex.h"
    16 #include "nsInterfaceHashtable.h"
    17 #include "nsHashKeys.h"
    19 #include "nsIConsoleService.h"
    21 class nsConsoleService MOZ_FINAL : public nsIConsoleService
    22 {
    23 public:
    24     nsConsoleService();
    25     nsresult Init();
    27     NS_DECL_THREADSAFE_ISUPPORTS
    28     NS_DECL_NSICONSOLESERVICE
    30     void SetIsDelivering() {
    31         MOZ_ASSERT(NS_IsMainThread());
    32         MOZ_ASSERT(!mDeliveringMessage);
    33         mDeliveringMessage = true;
    34     }
    36     void SetDoneDelivering() {
    37         MOZ_ASSERT(NS_IsMainThread());
    38         MOZ_ASSERT(mDeliveringMessage);
    39         mDeliveringMessage = false;
    40     }
    42     // This is a variant of LogMessage which allows the caller to determine
    43     // if the message should be output to an OS-specific log. This is used on
    44     // B2G to control whether the message is logged to the android log or not.
    46     enum OutputMode {
    47         SuppressLog,
    48         OutputToLog
    49     };
    50     virtual nsresult LogMessageWithMode(nsIConsoleMessage *message, OutputMode outputMode);
    52     typedef nsInterfaceHashtable<nsISupportsHashKey, nsIConsoleListener> ListenerHash;
    53     void EnumerateListeners(ListenerHash::EnumReadFunction aFunction, void* aClosure);
    55 private:
    56     ~nsConsoleService();
    58     // Circular buffer of saved messages
    59     nsIConsoleMessage **mMessages;
    61     // How big?
    62     uint32_t mBufferSize;
    64     // Index of slot in mMessages that'll be filled by *next* log message
    65     uint32_t mCurrent;
    67     // Is the buffer full? (Has mCurrent wrapped around at least once?)
    68     bool mFull;
    70     // Are we currently delivering a console message on the main thread? If
    71     // so, we suppress incoming messages on the main thread only, to avoid
    72     // infinite repitition.
    73     bool mDeliveringMessage;
    75     // Listeners to notify whenever a new message is logged.
    76     ListenerHash mListeners;
    78     // To serialize interesting methods.
    79     mozilla::Mutex mLock;
    80 };
    82 #endif /* __nsconsoleservice_h__ */

mercurial