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