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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /** |
michael@0 | 6 | * Native (xpcom) implementation of key OS.File functions |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | "use strict"; |
michael@0 | 10 | |
michael@0 | 11 | this.EXPORTED_SYMBOLS = ["read"]; |
michael@0 | 12 | |
michael@0 | 13 | let {results: Cr, utils: Cu, interfaces: Ci} = Components; |
michael@0 | 14 | |
michael@0 | 15 | let SharedAll = Cu.import("resource://gre/modules/osfile/osfile_shared_allthreads.jsm", {}); |
michael@0 | 16 | |
michael@0 | 17 | let SysAll = {}; |
michael@0 | 18 | if (SharedAll.Constants.Win) { |
michael@0 | 19 | Cu.import("resource://gre/modules/osfile/osfile_win_allthreads.jsm", SysAll); |
michael@0 | 20 | } else if (SharedAll.Constants.libc) { |
michael@0 | 21 | Cu.import("resource://gre/modules/osfile/osfile_unix_allthreads.jsm", SysAll); |
michael@0 | 22 | } else { |
michael@0 | 23 | throw new Error("I am neither under Windows nor under a Posix system"); |
michael@0 | 24 | } |
michael@0 | 25 | let {Promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); |
michael@0 | 26 | let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * The native service holding the implementation of the functions. |
michael@0 | 30 | */ |
michael@0 | 31 | XPCOMUtils.defineLazyServiceGetter(this, |
michael@0 | 32 | "Internals", |
michael@0 | 33 | "@mozilla.org/toolkit/osfile/native-internals;1", |
michael@0 | 34 | "nsINativeOSFileInternalsService"); |
michael@0 | 35 | |
michael@0 | 36 | /** |
michael@0 | 37 | * Native implementation of OS.File.read |
michael@0 | 38 | * |
michael@0 | 39 | * This implementation does not handle option |compression|. |
michael@0 | 40 | */ |
michael@0 | 41 | this.read = function(path, options = {}) { |
michael@0 | 42 | // Sanity check on types of options |
michael@0 | 43 | if ("encoding" in options && typeof options.encoding != "string") { |
michael@0 | 44 | return Promise.reject(new TypeError("Invalid type for option encoding")); |
michael@0 | 45 | } |
michael@0 | 46 | if ("compression" in options && typeof options.compression != "string") { |
michael@0 | 47 | return Promise.reject(new TypeError("Invalid type for option compression")); |
michael@0 | 48 | } |
michael@0 | 49 | if ("bytes" in options && typeof options.bytes != "number") { |
michael@0 | 50 | return Promise.reject(new TypeError("Invalid type for option bytes")); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | let deferred = Promise.defer(); |
michael@0 | 54 | Internals.read(path, |
michael@0 | 55 | options, |
michael@0 | 56 | function onSuccess(success) { |
michael@0 | 57 | success.QueryInterface(Ci.nsINativeOSFileResult); |
michael@0 | 58 | if ("outExecutionDuration" in options) { |
michael@0 | 59 | options.outExecutionDuration = |
michael@0 | 60 | success.executionDurationMS + |
michael@0 | 61 | (options.outExecutionDuration || 0); |
michael@0 | 62 | } |
michael@0 | 63 | deferred.resolve(success.result); |
michael@0 | 64 | }, |
michael@0 | 65 | function onError(operation, oserror) { |
michael@0 | 66 | deferred.reject(new SysAll.Error(operation, oserror, path)); |
michael@0 | 67 | } |
michael@0 | 68 | ); |
michael@0 | 69 | return deferred.promise; |
michael@0 | 70 | }; |