/* Predictor Messages */ bool NeckoParent::RecvPredPredict(const ipc::OptionalURIParams& aTargetURI, const ipc::OptionalURIParams& aSourceURI, const uint32_t& aReason, const SerializedLoadContext& aLoadContext, const bool& hasVerifier) { nsCOMPtr<nsIURI> targetURI = DeserializeURI(aTargetURI); nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI); // We only actually care about the loadContext.mPrivateBrowsing, so we'll just // pass dummy params for nestFrameId, inBrowser and appId uint64_t nestedFrameId = 0; nsCOMPtr<nsILoadContext> loadContext; if (aLoadContext.IsNotNull()) { loadContext = new LoadContext(aLoadContext, nestedFrameId, NECKO_UNKNOWN_APP_ID, false); } // Get the current predictor nsresult rv = NS_OK; nsCOMPtr<nsINetworkPredictor> predictor = do_GetService("@mozilla.org/network/predictor;1", &rv); NS_ENSURE_SUCCESS(rv, false); nsCOMPtr<nsINetworkPredictorVerifier> verifier; if (hasVerifier) { verifier = do_QueryInterface(predictor); } predictor->Predict(targetURI, sourceURI, aReason, loadContext, verifier); return true; }
bool NeckoParent::RecvPredLearn(const ipc::URIParams& aTargetURI, const ipc::OptionalURIParams& aSourceURI, const uint32_t& aReason, const SerializedLoadContext& aLoadContext) { nsCOMPtr<nsIURI> targetURI = DeserializeURI(aTargetURI); nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI); // We only actually care about the loadContext.mPrivateBrowsing, so we'll just // pass dummy params for nestFrameId, and originAttributes; uint64_t nestedFrameId = 0; DocShellOriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false); nsCOMPtr<nsILoadContext> loadContext; if (aLoadContext.IsNotNull()) { loadContext = new LoadContext(aLoadContext, nestedFrameId, attrs); } // Get the current predictor nsresult rv = NS_OK; nsCOMPtr<nsINetworkPredictor> predictor = do_GetService("@mozilla.org/network/predictor;1", &rv); NS_ENSURE_SUCCESS(rv, false); predictor->Learn(targetURI, sourceURI, aReason, loadContext); return true; }
/* Predictor Messages */ mozilla::ipc::IPCResult NeckoParent::RecvPredPredict(const ipc::OptionalURIParams& aTargetURI, const ipc::OptionalURIParams& aSourceURI, const uint32_t& aReason, const SerializedLoadContext& aLoadContext, const bool& hasVerifier) { nsCOMPtr<nsIURI> targetURI = DeserializeURI(aTargetURI); nsCOMPtr<nsIURI> sourceURI = DeserializeURI(aSourceURI); // We only actually care about the loadContext.mPrivateBrowsing, so we'll just // pass dummy params for nestFrameId, and originAttributes. uint64_t nestedFrameId = 0; DocShellOriginAttributes attrs(NECKO_UNKNOWN_APP_ID, false); nsCOMPtr<nsILoadContext> loadContext; if (aLoadContext.IsNotNull()) { attrs.SyncAttributesWithPrivateBrowsing(aLoadContext.mOriginAttributes.mPrivateBrowsingId > 0); loadContext = new LoadContext(aLoadContext, nestedFrameId, attrs); } // Get the current predictor nsresult rv = NS_OK; nsCOMPtr<nsINetworkPredictor> predictor = do_GetService("@mozilla.org/network/predictor;1", &rv); NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this)); nsCOMPtr<nsINetworkPredictorVerifier> verifier; if (hasVerifier) { verifier = do_QueryInterface(predictor); } predictor->Predict(targetURI, sourceURI, aReason, loadContext, verifier); return IPC_OK(); }
static PBOverrideStatus PBOverrideStatusFromLoadContext(const SerializedLoadContext& aSerialized) { if (!aSerialized.IsNotNull() && aSerialized.IsPrivateBitValid()) { return aSerialized.mUsePrivateBrowsing ? kPBOverride_Private : kPBOverride_NotPrivate; } return kPBOverride_Unset; }