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: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ |
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 | * A mechanism for interacting with operating system-provided |
michael@0 | 8 | * debugging/profiling tools such as Microsoft EWT/Windows Performance Toolkit. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | #ifndef mozilla_perfprobe_h |
michael@0 | 12 | #define mozilla_perfprobe_h |
michael@0 | 13 | |
michael@0 | 14 | #if !defined(XP_WIN) |
michael@0 | 15 | #error "For the moment, perfprobe.h is defined only for Windows platforms" |
michael@0 | 16 | #endif |
michael@0 | 17 | |
michael@0 | 18 | #include "nsError.h" |
michael@0 | 19 | #include "nsString.h" |
michael@0 | 20 | #include "prlog.h" |
michael@0 | 21 | #include "nsTArray.h" |
michael@0 | 22 | #include "nsAutoPtr.h" |
michael@0 | 23 | #include <windows.h> |
michael@0 | 24 | #undef GetStartupInfo //Prevent Windows from polluting global namespace |
michael@0 | 25 | #include <wmistr.h> |
michael@0 | 26 | #include <evntrace.h> |
michael@0 | 27 | |
michael@0 | 28 | namespace mozilla { |
michael@0 | 29 | namespace probes { |
michael@0 | 30 | |
michael@0 | 31 | class ProbeManager; |
michael@0 | 32 | |
michael@0 | 33 | /** |
michael@0 | 34 | * A data structure supporting a trigger operation that can be used to |
michael@0 | 35 | * send information to the operating system. |
michael@0 | 36 | */ |
michael@0 | 37 | |
michael@0 | 38 | class Probe |
michael@0 | 39 | { |
michael@0 | 40 | public: |
michael@0 | 41 | NS_INLINE_DECL_REFCOUNTING(Probe) |
michael@0 | 42 | |
michael@0 | 43 | /** |
michael@0 | 44 | * Trigger the event. |
michael@0 | 45 | * |
michael@0 | 46 | * Note: Can be called from any thread. |
michael@0 | 47 | */ |
michael@0 | 48 | nsresult Trigger(); |
michael@0 | 49 | ~Probe() {}; |
michael@0 | 50 | |
michael@0 | 51 | protected: |
michael@0 | 52 | Probe(const nsCID &aGUID, |
michael@0 | 53 | const nsACString &aName, |
michael@0 | 54 | ProbeManager *aManager); |
michael@0 | 55 | friend class ProbeManager; |
michael@0 | 56 | |
michael@0 | 57 | protected: |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * The system GUID associated to this probe. See the documentation |
michael@0 | 61 | * of |ProbeManager::Make| for more details. |
michael@0 | 62 | */ |
michael@0 | 63 | const GUID mGUID; |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * The name of this probe. See the documentation |
michael@0 | 67 | * of |ProbeManager::Make| for more details. |
michael@0 | 68 | */ |
michael@0 | 69 | const nsCString mName; |
michael@0 | 70 | |
michael@0 | 71 | /** |
michael@0 | 72 | * The ProbeManager managing this probe. |
michael@0 | 73 | * |
michael@0 | 74 | * Note: This is a weak reference to avoid a useless cycle. |
michael@0 | 75 | */ |
michael@0 | 76 | class ProbeManager *mManager; |
michael@0 | 77 | }; |
michael@0 | 78 | |
michael@0 | 79 | |
michael@0 | 80 | /** |
michael@0 | 81 | * A manager for a group of probes. |
michael@0 | 82 | * |
michael@0 | 83 | * You can have several managers in one application, provided that they all |
michael@0 | 84 | * have distinct IDs and names. However, having more than 2 is considered a bad |
michael@0 | 85 | * practice. |
michael@0 | 86 | */ |
michael@0 | 87 | class ProbeManager |
michael@0 | 88 | { |
michael@0 | 89 | public: |
michael@0 | 90 | NS_INLINE_DECL_REFCOUNTING(ProbeManager) |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Create a new probe manager. |
michael@0 | 94 | * |
michael@0 | 95 | * This constructor should be called from the main thread. |
michael@0 | 96 | * |
michael@0 | 97 | * @param uid The unique ID of the probe. Under Windows, this unique |
michael@0 | 98 | * ID must have been previously registered using an external tool. |
michael@0 | 99 | * See MyCategory on http://msdn.microsoft.com/en-us/library/aa364100.aspx |
michael@0 | 100 | * @param name A name for the probe. Currently used only for logging purposes. |
michael@0 | 101 | * In the future, may be attached to the data sent to the operating system. |
michael@0 | 102 | * |
michael@0 | 103 | * Note: If two ProbeManagers are constructed with the same uid and/or name, |
michael@0 | 104 | * behavior is unspecified. |
michael@0 | 105 | */ |
michael@0 | 106 | ProbeManager(const nsCID &applicationUID, |
michael@0 | 107 | const nsACString &applicationName); |
michael@0 | 108 | |
michael@0 | 109 | /** |
michael@0 | 110 | * Acquire a probe. |
michael@0 | 111 | * |
michael@0 | 112 | * Note: Only probes acquired before the call to SetReady are taken into |
michael@0 | 113 | * account |
michael@0 | 114 | * Note: Can be called only from the main thread. |
michael@0 | 115 | * |
michael@0 | 116 | * @param eventUID The unique ID of the probe. Under Windows, this unique |
michael@0 | 117 | * ID must have been previously registered using an external tool. |
michael@0 | 118 | * See MyCategory on http://msdn.microsoft.com/en-us/library/aa364100.aspx |
michael@0 | 119 | * @param eventMame A name for the probe. Currently used only for logging |
michael@0 | 120 | * purposes. In the |
michael@0 | 121 | * future, may be attached to the data sent to the operating system. |
michael@0 | 122 | * @return Either |null| in case of error or a valid |Probe*|. |
michael@0 | 123 | * |
michael@0 | 124 | * Note: If this method is called twice with the same uid and/or name, |
michael@0 | 125 | * behavior is undefined. |
michael@0 | 126 | */ |
michael@0 | 127 | already_AddRefed<Probe> GetProbe(const nsCID &eventUID, |
michael@0 | 128 | const nsACString &eventName); |
michael@0 | 129 | |
michael@0 | 130 | /** |
michael@0 | 131 | * Start/stop the measuring session. |
michael@0 | 132 | * |
michael@0 | 133 | * This method should be called from the main thread. |
michael@0 | 134 | * |
michael@0 | 135 | * Note that starting an already started probe manager has no effect, |
michael@0 | 136 | * nor does stopping an already stopped probe manager. |
michael@0 | 137 | */ |
michael@0 | 138 | nsresult StartSession(); |
michael@0 | 139 | nsresult StopSession(); |
michael@0 | 140 | |
michael@0 | 141 | /** |
michael@0 | 142 | * @return true If measures are currently on, i.e. if triggering probes is any |
michael@0 | 143 | * is useful. You do not have to check this before triggering a probe, unless |
michael@0 | 144 | * this can avoid complex computations. |
michael@0 | 145 | */ |
michael@0 | 146 | bool IsActive(); |
michael@0 | 147 | |
michael@0 | 148 | ~ProbeManager(); |
michael@0 | 149 | |
michael@0 | 150 | protected: |
michael@0 | 151 | nsresult StartSession(nsTArray<nsRefPtr<Probe> > &probes); |
michael@0 | 152 | nsresult Init(const nsCID &applicationUID, const nsACString &applicationName); |
michael@0 | 153 | |
michael@0 | 154 | protected: |
michael@0 | 155 | /** |
michael@0 | 156 | * `true` if a session is in activity, `false` otherwise. |
michael@0 | 157 | */ |
michael@0 | 158 | bool mIsActive; |
michael@0 | 159 | |
michael@0 | 160 | /** |
michael@0 | 161 | * The UID of this manager. |
michael@0 | 162 | * See documentation above for registration steps that you |
michael@0 | 163 | * may have to take. |
michael@0 | 164 | */ |
michael@0 | 165 | nsCID mApplicationUID; |
michael@0 | 166 | |
michael@0 | 167 | /** |
michael@0 | 168 | * The name of the application. |
michael@0 | 169 | */ |
michael@0 | 170 | nsCString mApplicationName; |
michael@0 | 171 | |
michael@0 | 172 | /** |
michael@0 | 173 | * All the probes that have been created for this manager. |
michael@0 | 174 | */ |
michael@0 | 175 | nsTArray<nsRefPtr<Probe> > mAllProbes; |
michael@0 | 176 | |
michael@0 | 177 | /** |
michael@0 | 178 | * Handle used for triggering events |
michael@0 | 179 | */ |
michael@0 | 180 | TRACEHANDLE mSessionHandle; |
michael@0 | 181 | |
michael@0 | 182 | /** |
michael@0 | 183 | * Handle used for registration/unregistration |
michael@0 | 184 | */ |
michael@0 | 185 | TRACEHANDLE mRegistrationHandle; |
michael@0 | 186 | |
michael@0 | 187 | /** |
michael@0 | 188 | * `true` if initialization has been performed, `false` until then. |
michael@0 | 189 | */ |
michael@0 | 190 | bool mInitialized; |
michael@0 | 191 | |
michael@0 | 192 | friend class Probe;//Needs to access |mSessionHandle| |
michael@0 | 193 | friend ULONG WINAPI ControlCallback( |
michael@0 | 194 | WMIDPREQUESTCODE RequestCode, |
michael@0 | 195 | PVOID Context, |
michael@0 | 196 | ULONG *Reserved, |
michael@0 | 197 | PVOID Buffer |
michael@0 | 198 | );//Sets |mSessionHandle| |
michael@0 | 199 | }; |
michael@0 | 200 | } |
michael@0 | 201 | } |
michael@0 | 202 | |
michael@0 | 203 | #endif //mozilla_perfprobe_h |