Bug 1016622: Renaming mozilla::network::Seer to mozilla::network Predictor. r=hurley

This commit is contained in:
Jeremy Poulin
2014-06-03 13:37:46 -07:00
parent d252a85303
commit ef9b7ddf74
22 changed files with 667 additions and 626 deletions

View File

@@ -88,9 +88,9 @@ pref("network.buffer.cache.count", 24);
pref("network.buffer.cache.size", 16384);
// predictive actions
pref("network.seer.enable", false); // disabled on b2g
pref("network.seer.max-db-size", 2097152); // bytes
pref("network.seer.preserve", 50); // percentage of seer data to keep when cleaning up
pref("network.predictor.enable", false); // disabled on b2g
pref("network.predictor.max-db-size", 2097152); // bytes
pref("network.predictor.preserve", 50); // percentage of predictor data to keep when cleaning up
/* session history */
pref("browser.sessionhistory.max_total_viewers", 1);

View File

@@ -221,9 +221,9 @@ Sanitizer.prototype = {
catch (e) { }
try {
var seer = Components.classes["@mozilla.org/network/seer;1"]
.getService(Components.interfaces.nsINetworkSeer);
seer.reset();
var predictor = Components.classes["@mozilla.org/network/predictor;1"]
.getService(Components.interfaces.nsINetworkPredictor);
predictor.reset();
} catch (e) { }
},

View File

@@ -49,7 +49,7 @@
#include "nsCrossSiteListenerProxy.h"
#include "nsSandboxFlags.h"
#include "nsContentTypeParser.h"
#include "nsINetworkSeer.h"
#include "nsINetworkPredictor.h"
#include "mozilla/dom/EncodingUtils.h"
#include "mozilla/CORSMode.h"
@@ -345,8 +345,8 @@ nsScriptLoader::StartLoad(nsScriptLoadRequest *aRequest, const nsAString &aType,
}
nsCOMPtr<nsILoadContext> loadContext(do_QueryInterface(docshell));
mozilla::net::SeerLearn(aRequest->mURI, mDocument->GetDocumentURI(),
nsINetworkSeer::LEARN_LOAD_SUBRESOURCE, loadContext);
mozilla::net::PredictorLearn(aRequest->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, loadContext);
// Set the initiator type
nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChannel));

View File

@@ -120,7 +120,7 @@
#include "nsIFaviconService.h"
#include "mozIAsyncFavicons.h"
#endif
#include "nsINetworkSeer.h"
#include "nsINetworkPredictor.h"
// Editor-related
#include "nsIEditingSession.h"
@@ -7211,7 +7211,7 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
}
} // if we have a host
else if (url && NS_SUCCEEDED(aStatus)) {
mozilla::net::SeerLearnRedirect(url, aChannel, this);
mozilla::net::PredictorLearnRedirect(url, aChannel, this);
}
return NS_OK;
@@ -9603,7 +9603,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
else
srcdoc = NullString();
mozilla::net::SeerPredict(aURI, nullptr, nsINetworkSeer::PREDICT_LOAD,
mozilla::net::PredictorPredict(aURI, nullptr,
nsINetworkPredictor::PREDICT_LOAD,
this, nullptr);
nsCOMPtr<nsIRequest> req;
@@ -12733,7 +12734,8 @@ nsDocShell::OnOverLink(nsIContent* aContent,
rv = textToSubURI->UnEscapeURIForUI(charset, spec, uStr);
NS_ENSURE_SUCCESS(rv, rv);
mozilla::net::SeerPredict(aURI, mCurrentURI, nsINetworkSeer::PREDICT_LINK,
mozilla::net::PredictorPredict(aURI, mCurrentURI,
nsINetworkPredictor::PREDICT_LINK,
this, nullptr);
if (browserChrome2) {

View File

@@ -29,7 +29,7 @@
#include "nsIFileURL.h"
#include "nsCRT.h"
#include "nsIDocument.h"
#include "nsINetworkSeer.h"
#include "nsINetworkPredictor.h"
#include "nsIApplicationCache.h"
#include "nsIApplicationCacheContainer.h"
@@ -1429,8 +1429,8 @@ bool imgLoader::ValidateRequestWithNewChannel(imgRequest *request,
// Add the proxy without notifying
hvc->AddProxy(proxy);
mozilla::net::SeerLearn(aURI, aInitialDocumentURI,
nsINetworkSeer::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
rv = newChannel->AsyncOpen(listener, nullptr);
if (NS_SUCCEEDED(rv))
@@ -1928,8 +1928,8 @@ nsresult imgLoader::LoadImage(nsIURI *aURI,
PR_LOG(GetImgLog(), PR_LOG_DEBUG,
("[this=%p] imgLoader::LoadImage -- Calling channel->AsyncOpen()\n", this));
mozilla::net::SeerLearn(aURI, aInitialDocumentURI,
nsINetworkSeer::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
nsresult openRes = newChannel->AsyncOpen(listener, nullptr);

View File

@@ -47,7 +47,7 @@
#include "nsGkAtoms.h"
#include "nsIThreadInternal.h"
#include "nsCrossSiteListenerProxy.h"
#include "nsINetworkSeer.h"
#include "nsINetworkPredictor.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/URL.h"
@@ -1423,8 +1423,8 @@ Loader::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState)
}
if (mDocument) {
mozilla::net::SeerLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkSeer::LEARN_LOAD_SUBRESOURCE,
mozilla::net::PredictorLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
mDocument);
}
@@ -1612,8 +1612,9 @@ Loader::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState)
}
if (mDocument) {
mozilla::net::SeerLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkSeer::LEARN_LOAD_SUBRESOURCE, mDocument);
mozilla::net::PredictorLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
mDocument);
}
rv = channel->AsyncOpen(channelListener, nullptr);

View File

@@ -30,7 +30,7 @@
#include "nsIDocShell.h"
#include "nsIWebNavigation.h"
#include "nsISupportsPriority.h"
#include "nsINetworkSeer.h"
#include "nsINetworkPredictor.h"
#include "nsIConsoleService.h"
@@ -383,8 +383,9 @@ nsUserFontSet::StartLoad(gfxMixedFontFamily* aFamily,
NS_ENSURE_SUCCESS(rv, rv);
nsIDocument *document = ps->GetDocument();
mozilla::net::SeerLearn(aFontFaceSrc->mURI, document->GetDocumentURI(),
nsINetworkSeer::LEARN_LOAD_SUBRESOURCE, loadGroup);
mozilla::net::PredictorLearn(aFontFaceSrc->mURI, document->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
loadGroup);
bool inherits = false;
rv = NS_URIChainHasFlags(aFontFaceSrc->mURI,

View File

@@ -103,9 +103,9 @@ pref("network.buffer.cache.count", 24);
pref("network.buffer.cache.size", 16384);
// predictive actions
pref("network.seer.enabled", false);
pref("network.seer.max-db-size", 2097152); // bytes
pref("network.seer.preserve", 50); // percentage of seer data to keep when cleaning up
pref("network.predictor.enabled", false);
pref("network.predictor.max-db-size", 2097152); // bytes
pref("network.predictor.preserve", 50); // percentage of predictor data to keep when cleaning up
/* history max results display */
pref("browser.display.history.maxresults", 100);

View File

@@ -146,8 +146,8 @@ Sanitizer.prototype = {
catch (e) { }
try {
var seer = Cc["@mozilla.org/network/seer;1"].getService(Ci.nsINetworkSeer);
seer.reset();
var predictor = Cc["@mozilla.org/network/predictor;1"].getService(Ci.nsINetworkPredictor);
predictor.reset();
} catch (e) { }
},

View File

@@ -1327,24 +1327,24 @@ pref("network.dir.format", 2);
pref("network.prefetch-next", true);
// enables the predictive service
pref("network.seer.enabled", false);
pref("network.seer.enable-hover-on-ssl", false);
pref("network.seer.page-degradation.day", 0);
pref("network.seer.page-degradation.week", 5);
pref("network.seer.page-degradation.month", 10);
pref("network.seer.page-degradation.year", 25);
pref("network.seer.page-degradation.max", 50);
pref("network.seer.subresource-degradation.day", 1);
pref("network.seer.subresource-degradation.week", 10);
pref("network.seer.subresource-degradation.month", 25);
pref("network.seer.subresource-degradation.year", 50);
pref("network.seer.subresource-degradation.max", 100);
pref("network.seer.preconnect-min-confidence", 90);
pref("network.seer.preresolve-min-confidence", 60);
pref("network.seer.redirect-likely-confidence", 75);
pref("network.seer.max-queue-size", 50);
pref("network.seer.max-db-size", 157286400); // bytes
pref("network.seer.preserve", 80); // percentage of seer data to keep when cleaning up
pref("network.predictor.enabled", false);
pref("network.predictor.enable-hover-on-ssl", false);
pref("network.predictor.page-degradation.day", 0);
pref("network.predictor.page-degradation.week", 5);
pref("network.predictor.page-degradation.month", 10);
pref("network.predictor.page-degradation.year", 25);
pref("network.predictor.page-degradation.max", 50);
pref("network.predictor.subresource-degradation.day", 1);
pref("network.predictor.subresource-degradation.week", 10);
pref("network.predictor.subresource-degradation.month", 25);
pref("network.predictor.subresource-degradation.year", 50);
pref("network.predictor.subresource-degradation.max", 100);
pref("network.predictor.preconnect-min-confidence", 90);
pref("network.predictor.preresolve-min-confidence", 60);
pref("network.predictor.redirect-likely-confidence", 75);
pref("network.predictor.max-queue-size", 50);
pref("network.predictor.max-db-size", 157286400); // bytes
pref("network.predictor.preserve", 80); // percentage of predictor data to keep when cleaning up
// The following prefs pertain to the negotiate-auth extension (see bug 17578),

View File

@@ -57,9 +57,9 @@ XPIDL_SOURCES += [
'nsINetAddr.idl',
'nsINetUtil.idl',
'nsINetworkLinkService.idl',
'nsINetworkPredictor.idl',
'nsINetworkPredictorVerifier.idl',
'nsINetworkProperties.idl',
'nsINetworkSeer.idl',
'nsINetworkSeerVerifier.idl',
'nsINSSErrorsService.idl',
'nsIParentChannel.idl',
'nsIParentRedirectingChannel.idl',

View File

@@ -7,18 +7,19 @@
interface nsIURI;
interface nsILoadContext;
interface nsINetworkSeerVerifier;
interface nsINetworkPredictorVerifier;
typedef unsigned long SeerPredictReason;
typedef unsigned long SeerLearnReason;
typedef unsigned long PredictorPredictReason;
typedef unsigned long PredictorLearnReason;
/**
* nsINetworkSeer - learn about pages users visit, and allow us to take
* nsINetworkPredictor - learn about pages users visit, and allow us to take
* predictive actions upon future visits.
* NOTE: nsINetworkSeer should only be used on the main thread
* NOTE: nsINetworkPredictor should only
* be used on the main thread.
*/
[scriptable, uuid(25e323b6-99e0-4274-b5b3-1a9eb56e28ac)]
interface nsINetworkSeer : nsISupports
[scriptable, uuid(980f70bc-0487-4b22-a4c1-bf1185c8ae1f)]
interface nsINetworkPredictor : nsISupports
{
/**
* Prediction reasons
@@ -32,14 +33,14 @@ interface nsINetworkSeer : nsISupports
* PREDICT_STARTUP - we are being asked to take predictive action
* because the browser is starting up.
*/
const SeerPredictReason PREDICT_LINK = 0;
const SeerPredictReason PREDICT_LOAD = 1;
const SeerPredictReason PREDICT_STARTUP = 2;
const PredictorPredictReason PREDICT_LINK = 0;
const PredictorPredictReason PREDICT_LOAD = 1;
const PredictorPredictReason PREDICT_STARTUP = 2;
/**
* Start taking predictive actions
*
* Calling this will cause the seer to (possibly) start
* Calling this will cause the predictor to (possibly) start
* taking actions such as DNS prefetch and/or TCP preconnect based on
* (1) the host name that we are given, and (2) the reason we are being
* asked to take actions.
@@ -59,15 +60,15 @@ interface nsINetworkSeer : nsISupports
* null.
* @param loadContext - The nsILoadContext of the page load we are predicting
* about.
* @param verifier - An nsINetworkSeerVerifier used in testing to ensure we're
* predicting the way we expect to. Not necessary (or desired) for normal
* operation.
* @param verifier - An nsINetworkPredictorVerifier used in testing to ensure
* we're predicting the way we expect to. Not necessary (or desired) for
* normal operation.
*/
void predict(in nsIURI targetURI,
in nsIURI sourceURI,
in SeerPredictReason reason,
in PredictorPredictReason reason,
in nsILoadContext loadContext,
in nsINetworkSeerVerifier verifier);
in nsINetworkPredictorVerifier verifier);
/*
@@ -82,10 +83,10 @@ interface nsINetworkSeer : nsISupports
*
* LEARN_STARTUP - we are learning about a page loaded during startup
*/
const SeerLearnReason LEARN_LOAD_TOPLEVEL = 0;
const SeerLearnReason LEARN_LOAD_SUBRESOURCE = 1;
const SeerLearnReason LEARN_LOAD_REDIRECT = 2;
const SeerLearnReason LEARN_STARTUP = 3;
const PredictorLearnReason LEARN_LOAD_TOPLEVEL = 0;
const PredictorLearnReason LEARN_LOAD_SUBRESOURCE = 1;
const PredictorLearnReason LEARN_LOAD_REDIRECT = 2;
const PredictorLearnReason LEARN_STARTUP = 3;
/**
* Add to our compendium of knowledge
@@ -111,7 +112,7 @@ interface nsINetworkSeer : nsISupports
*/
void learn(in nsIURI targetURI,
in nsIURI sourceURI,
in SeerLearnReason reason,
in PredictorLearnReason reason,
in nsILoadContext loadContext);
/**
@@ -130,38 +131,38 @@ interface nsINetworkSeer : nsISupports
};
%{C++
// Wrapper functions to make use of the seer easier and less invasive
// Wrapper functions to make use of the predictor easier and less invasive
class nsIChannel;
class nsIDocument;
class nsILoadContext;
class nsILoadGroup;
class nsINetworkSeerVerifier;
class nsINetworkPredictorVerifier;
namespace mozilla {
namespace net {
nsresult SeerPredict(nsIURI *targetURI,
nsresult PredictorPredict(nsIURI *targetURI,
nsIURI *sourceURI,
SeerPredictReason reason,
PredictorPredictReason reason,
nsILoadContext *loadContext,
nsINetworkSeerVerifier *verifier);
nsINetworkPredictorVerifier *verifier);
nsresult SeerLearn(nsIURI *targetURI,
nsresult PredictorLearn(nsIURI *targetURI,
nsIURI *sourceURI,
SeerLearnReason reason,
PredictorLearnReason reason,
nsILoadContext *loadContext);
nsresult SeerLearn(nsIURI *targetURI,
nsresult PredictorLearn(nsIURI *targetURI,
nsIURI *sourceURI,
SeerLearnReason reason,
PredictorLearnReason reason,
nsILoadGroup *loadGroup);
nsresult SeerLearn(nsIURI *targetURI,
nsresult PredictorLearn(nsIURI *targetURI,
nsIURI *sourceURI,
SeerLearnReason reason,
PredictorLearnReason reason,
nsIDocument *document);
nsresult SeerLearnRedirect(nsIURI *targetURI,
nsresult PredictorLearnRedirect(nsIURI *targetURI,
nsIChannel *channel,
nsILoadContext *loadContext);

View File

@@ -4,16 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* nsINetworkSeerVerifier - used for testing the network seer to ensure it
* does what we expect it to do.
* nsINetworkPredictorVerifier - used for testing the network predictor to
* ensure it does what we expect it to do.
*/
#include "nsISupports.idl"
interface nsIURI;
[scriptable, uuid(ea273653-43a8-4632-8b30-4032e0918e8b)]
interface nsINetworkSeerVerifier : nsISupports
[scriptable, uuid(00360c7d-a046-4f8d-a1fc-8bdc0f0fb444)]
interface nsINetworkPredictorVerifier : nsISupports
{
/**
* Callback for when we do a predictive preconnect

File diff suppressed because it is too large Load Diff

View File

@@ -3,10 +3,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_net_Seer_h
#define mozilla_net_Seer_h
#ifndef mozilla_net_Predictor_h
#define mozilla_net_Predictor_h
#include "nsINetworkSeer.h"
#include "nsINetworkPredictor.h"
#include "nsCOMPtr.h"
#include "nsIDNSListener.h"
@@ -14,13 +14,12 @@
#include "nsIObserver.h"
#include "nsISpeculativeConnect.h"
#include "nsProxyRelease.h"
#include "mozilla/Mutex.h"
#include "mozilla/storage/StatementCache.h"
#include "mozilla/TimeStamp.h"
class nsIDNSService;
class nsINetworkSeerVerifier;
class nsINetworkPredictorVerifier;
class nsIThread;
class nsITimer;
@@ -31,40 +30,40 @@ class mozIStorageStatement;
namespace mozilla {
namespace net {
typedef nsMainThreadPtrHandle<nsINetworkSeerVerifier> SeerVerifierHandle;
typedef nsMainThreadPtrHandle<nsINetworkPredictorVerifier> PredictorVerifierHandle;
class SeerPredictionRunner;
struct SeerTelemetryAccumulators;
class SeerDNSListener;
class PredictionRunner;
struct PredictorTelemetryAccumulators;
class PredictorDNSListener;
class Seer : public nsINetworkSeer
class Predictor : public nsINetworkPredictor
, public nsIObserver
, public nsISpeculativeConnectionOverrider
, public nsIInterfaceRequestor
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSINETWORKSEER
NS_DECL_NSINETWORKPREDICTOR
NS_DECL_NSIOBSERVER
NS_DECL_NSISPECULATIVECONNECTIONOVERRIDER
NS_DECL_NSIINTERFACEREQUESTOR
Seer();
virtual ~Seer();
Predictor();
virtual ~Predictor();
nsresult Init();
void Shutdown();
static nsresult Create(nsISupports *outer, const nsIID& iid, void **result);
private:
friend class SeerPredictionEvent;
friend class SeerLearnEvent;
friend class SeerResetEvent;
friend class SeerPredictionRunner;
friend class SeerDBShutdownRunner;
friend class SeerCommitTimerInitEvent;
friend class SeerNewTransactionEvent;
friend class SeerCleanupEvent;
friend class PredictionEvent;
friend class LearnEvent;
friend class PredictorResetEvent;
friend class PredictionRunner;
friend class PredictorDBShutdownRunner;
friend class PredictorCommitTimerInitEvent;
friend class PredictorNewTransactionEvent;
friend class PredictorCleanupEvent;
void CheckForAndDeleteOldDBFile();
nsresult EnsureInitStorage();
@@ -77,12 +76,12 @@ private:
void PredictForLink(nsIURI *targetURI,
nsIURI *sourceURI,
nsINetworkSeerVerifier *verifier);
nsINetworkPredictorVerifier *verifier);
void PredictForPageload(const UriInfo &dest,
SeerVerifierHandle &verifier,
PredictorVerifierHandle &verifier,
int stackCount,
TimeStamp &predictStartTime);
void PredictForStartup(SeerVerifierHandle &verifier,
void PredictForStartup(PredictorVerifierHandle &verifier,
TimeStamp &predictStartTime);
// Whether we're working on a page or an origin
@@ -116,7 +115,7 @@ private:
int globalDegradation);
void SetupPrediction(int confidence,
const nsACString &uri,
SeerPredictionRunner *runner);
PredictionRunner *runner);
bool LookupTopLevel(QueryType queryType,
const nsACString &key,
@@ -130,7 +129,7 @@ private:
bool TryPredict(QueryType queryType,
const TopLevelInfo &info,
PRTime now,
SeerVerifierHandle &verifier,
PredictorVerifierHandle &verifier,
TimeStamp &predictStartTime);
bool WouldRedirect(const TopLevelInfo &info,
PRTime now,
@@ -222,14 +221,14 @@ private:
int32_t mQueueSize;
mozilla::Mutex mQueueSizeLock;
nsAutoPtr<SeerTelemetryAccumulators> mAccumulators;
nsAutoPtr<PredictorTelemetryAccumulators> mAccumulators;
nsRefPtr<SeerDNSListener> mDNSListener;
nsRefPtr<PredictorDNSListener> mDNSListener;
nsCOMPtr<nsITimer> mCommitTimer;
#ifdef SEER_TESTS
friend class SeerPrepareForDnsTestEvent;
#ifdef PREDICTOR_TESTS
friend class PredictorPrepareForDnsTestEvent;
void PrepareForDnsTestInternal(int64_t timestamp, const nsACString &uri);
#endif
@@ -242,4 +241,4 @@ private:
} // ::mozilla::net
} // ::mozilla
#endif // mozilla_net_Seer_h
#endif // mozilla_net_Predictor_h

View File

@@ -70,9 +70,9 @@ UNIFIED_SOURCES += [
'nsURIChecker.cpp',
'nsURLHelper.cpp',
'nsURLParsers.cpp',
'Predictor.cpp',
'ProxyAutoConfig.cpp',
'RedirectChannelRegistrar.cpp',
'Seer.cpp',
'StreamingProtocolService.cpp',
'Tickler.cpp',
]
@@ -132,4 +132,4 @@ if CONFIG['MOZ_ENABLE_QTNETWORK']:
]
if CONFIG['ENABLE_TESTS']:
DEFINES['SEER_TESTS'] = True
DEFINES['PREDICTOR_TESTS'] = True

View File

@@ -446,15 +446,15 @@
{ 0x8d, 0x17, 0xa2, 0x7e, 0x44, 0xa8, 0x39, 0x3e } \
}
// service implementing nsINetworkSeer
#define NS_NETWORKSEER_CONTRACTID \
"@mozilla.org/network/seer;1"
#define NS_NETWORKSEER_CID \
{ /* {1C218009-A531-46AD-8351-1E7F45D5A3C4} */ \
0x1C218009, \
0xA531, \
0x46AD, \
{ 0x83, 0x51, 0x1E, 0x7F, 0x45, 0xD5, 0xA3, 0xC4 } \
// service implementing nsINetworkPredictor
#define NS_NETWORKPREDICTOR_CONTRACTID \
"@mozilla.org/network/predictor;1"
#define NS_NETWORKPREDICTOR_CID \
{ /* {969adfdf-7221-4419-aecf-05f8faf00c9b} */ \
0x969adfdf, \
0x7221, \
0x4419, \
{ 0xae, 0xcf, 0x05, 0xf8, 0xfa, 0xf0, 0x0c, 0x9b } \
}
/******************************************************************************

View File

@@ -37,7 +37,7 @@
#include "nsXULAppAPI.h"
#include "nsCategoryCache.h"
#include "nsIContentSniffer.h"
#include "Seer.h"
#include "Predictor.h"
#include "nsNetUtil.h"
#include "nsIThreadPool.h"
#include "mozilla/net/NeckoChild.h"
@@ -822,7 +822,7 @@ NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_SERIALIZATION_HELPER_CID);
NS_DEFINE_NAMED_CID(NS_REDIRECTCHANNELREGISTRAR_CID);
NS_DEFINE_NAMED_CID(NS_CACHE_STORAGE_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_NETWORKSEER_CID);
NS_DEFINE_NAMED_CID(NS_NETWORKPREDICTOR_CID);
static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
{ &kNS_IOSERVICE_CID, false, nullptr, nsIOServiceConstructor },
@@ -965,7 +965,7 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
{ &kNS_SERIALIZATION_HELPER_CID, false, nullptr, nsSerializationHelperConstructor },
{ &kNS_REDIRECTCHANNELREGISTRAR_CID, false, nullptr, RedirectChannelRegistrarConstructor },
{ &kNS_CACHE_STORAGE_SERVICE_CID, false, nullptr, CacheStorageServiceConstructor },
{ &kNS_NETWORKSEER_CID, false, nullptr, mozilla::net::Seer::Create },
{ &kNS_NETWORKPREDICTOR_CID, false, nullptr, mozilla::net::Predictor::Create },
{ nullptr }
};
@@ -1111,7 +1111,7 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
{ NS_SERIALIZATION_HELPER_CONTRACTID, &kNS_SERIALIZATION_HELPER_CID },
{ NS_REDIRECTCHANNELREGISTRAR_CONTRACTID, &kNS_REDIRECTCHANNELREGISTRAR_CID },
{ NS_CACHE_STORAGE_SERVICE_CONTRACTID, &kNS_CACHE_STORAGE_SERVICE_CID },
{ NS_NETWORKSEER_CONTRACTID, &kNS_NETWORKSEER_CID },
{ NS_NETWORKPREDICTOR_CONTRACTID, &kNS_NETWORKPREDICTOR_CID },
{ nullptr }
};

View File

@@ -6,7 +6,7 @@ var Cr = Components.results;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
var seer = null;
var predictor = null;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var profile = null;
@@ -29,7 +29,7 @@ LoadContext.prototype = {
},
QueryInterface: function loadContext_QueryInterface(iid) {
if (iid.equals(Ci.nsINetworkSeerVerifier) ||
if (iid.equals(Ci.nsINetworkPredictorVerifier) ||
iid.equals(Ci.nsILoadContext)) {
return this;
}
@@ -56,7 +56,7 @@ Verifier.prototype = {
},
QueryInterface: function verifier_QueryInterface(iid) {
if (iid.equals(Ci.nsINetworkSeerVerifier) ||
if (iid.equals(Ci.nsINetworkPredictorVerifier) ||
iid.equals(Ci.nsISupports)) {
return this;
}
@@ -95,8 +95,8 @@ Verifier.prototype = {
}
};
function reset_seer() {
seer.reset();
function reset_predictor() {
predictor.reset();
}
function newURI(s) {
@@ -104,17 +104,17 @@ function newURI(s) {
}
function test_link_hover() {
reset_seer();
reset_predictor();
var uri = newURI("http://localhost:4444/foo/bar");
var referrer = newURI("http://localhost:4444/foo");
var preconns = ["http://localhost:4444"];
var verifier = new Verifier("hover", preconns, []);
seer.predict(uri, referrer, seer.PREDICT_LINK, load_context, verifier);
predictor.predict(uri, referrer, predictor.PREDICT_LINK, load_context, verifier);
}
function test_pageload() {
reset_seer();
reset_predictor();
var toplevel = "http://localhost:4444/index.html";
var subresources = [
"http://localhost:4444/style.css",
@@ -123,20 +123,20 @@ function test_pageload() {
];
var tluri = newURI(toplevel);
seer.learn(tluri, null, seer.LEARN_LOAD_TOPLEVEL, load_context);
predictor.learn(tluri, null, predictor.LEARN_LOAD_TOPLEVEL, load_context);
var preconns = [];
for (var i = 0; i < subresources.length; i++) {
var sruri = newURI(subresources[i]);
seer.learn(sruri, tluri, seer.LEARN_LOAD_SUBRESOURCE, load_context);
predictor.learn(sruri, tluri, predictor.LEARN_LOAD_SUBRESOURCE, load_context);
preconns.push(extract_origin(sruri));
}
var verifier = new Verifier("pageload", preconns, []);
seer.predict(tluri, null, seer.PREDICT_LOAD, load_context, verifier);
predictor.predict(tluri, null, predictor.PREDICT_LOAD, load_context, verifier);
}
function test_redirect() {
reset_seer();
reset_predictor();
var initial = "http://localhost:4443/redirect";
var target = "http://localhost:4444/index.html";
var subresources = [
@@ -147,24 +147,24 @@ function test_redirect() {
var inituri = newURI(initial);
var targeturi = newURI(target);
seer.learn(inituri, null, seer.LEARN_LOAD_TOPLEVEL, load_context);
seer.learn(targeturi, inituri, seer.LEARN_LOAD_REDIRECT, load_context);
seer.learn(targeturi, null, seer.LEARN_LOAD_TOPLEVEL, load_context);
predictor.learn(inituri, null, predictor.LEARN_LOAD_TOPLEVEL, load_context);
predictor.learn(targeturi, inituri, predictor.LEARN_LOAD_REDIRECT, load_context);
predictor.learn(targeturi, null, predictor.LEARN_LOAD_TOPLEVEL, load_context);
var preconns = [];
preconns.push(extract_origin(targeturi));
for (var i = 0; i < subresources.length; i++) {
var sruri = newURI(subresources[i]);
seer.learn(sruri, targeturi, seer.LEARN_LOAD_SUBRESOURCE, load_context);
predictor.learn(sruri, targeturi, predictor.LEARN_LOAD_SUBRESOURCE, load_context);
preconns.push(extract_origin(sruri));
}
var verifier = new Verifier("redirect", preconns, []);
seer.predict(inituri, null, seer.PREDICT_LOAD, load_context, verifier);
predictor.predict(inituri, null, predictor.PREDICT_LOAD, load_context, verifier);
}
function test_startup() {
reset_seer();
reset_predictor();
var uris = [
"http://localhost:4444/startup",
"http://localhost:4443/startup"
@@ -172,16 +172,16 @@ function test_startup() {
var preconns = [];
for (var i = 0; i < uris.length; i++) {
var uri = newURI(uris[i]);
seer.learn(uri, null, seer.LEARN_STARTUP, load_context);
predictor.learn(uri, null, predictor.LEARN_STARTUP, load_context);
preconns.push(extract_origin(uri));
}
var verifier = new Verifier("startup", preconns, []);
seer.predict(null, null, seer.PREDICT_STARTUP, load_context, verifier);
predictor.predict(null, null, predictor.PREDICT_STARTUP, load_context, verifier);
}
// A class used to guarantee serialization of SQL queries so we can properly
// update last hit times on subresources to ensure the seer tries to do DNS
// update last hit times on subresources to ensure the predictor tries to do DNS
// preresolve on them instead of preconnecting
var DnsContinueVerifier = function _dnsContinueVerifier(subresource, tluri, preresolves) {
this.subresource = subresource;
@@ -200,7 +200,7 @@ DnsContinueVerifier.prototype = {
QueryInterface: function _dnsContinueVerifier_QueryInterface(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsINetworkSeerVerifier)) {
iid.equals(Ci.nsINetworkPredictorVerifier)) {
return this;
}
@@ -208,7 +208,7 @@ DnsContinueVerifier.prototype = {
},
onPredictPreconnect: function _dnsContinueVerifier_onPredictPreconnect() {
// This means that the seer has learned and done our "checkpoint" prediction
// This means that the predictor has learned and done our "checkpoint" prediction
// Now we can get on with the prediction we actually want to test
// tstamp is 10 days older than now - just over 1 week, which will ensure we
@@ -216,10 +216,10 @@ DnsContinueVerifier.prototype = {
// x1000 on the Date object value.
var tstamp = (new Date().valueOf() * 1000) - (10 * 86400 * 1000000);
seer.prepareForDnsTest(tstamp, this.subresource);
predictor.prepareForDnsTest(tstamp, this.subresource);
var verifier = new Verifier("dns", [], this.preresolves);
seer.predict(this.tluri, null, seer.PREDICT_LOAD, load_context, verifier);
predictor.predict(this.tluri, null, predictor.PREDICT_LOAD, load_context, verifier);
},
onPredictDNS: function _dnsContinueVerifier_onPredictDNS() {
@@ -228,24 +228,24 @@ DnsContinueVerifier.prototype = {
};
function test_dns() {
reset_seer();
reset_predictor();
var toplevel = "http://localhost:4444/index.html";
var subresource = "http://localhost:4443/jquery.js";
var tluri = newURI(toplevel);
seer.learn(tluri, null, seer.LEARN_LOAD_TOPLEVEL, load_context);
predictor.learn(tluri, null, predictor.LEARN_LOAD_TOPLEVEL, load_context);
var sruri = newURI(subresource);
seer.learn(sruri, tluri, seer.LEARN_LOAD_SUBRESOURCE, load_context);
predictor.learn(sruri, tluri, predictor.LEARN_LOAD_SUBRESOURCE, load_context);
var preresolves = [extract_origin(sruri)];
var continue_verifier = new DnsContinueVerifier(subresource, tluri, preresolves);
// Fire off a prediction that will do preconnects so we know when the seer
// Fire off a prediction that will do preconnects so we know when the predictor
// thread has gotten to the point where we can update the database manually
seer.predict(tluri, null, seer.PREDICT_LOAD, load_context, continue_verifier);
predictor.predict(tluri, null, predictor.PREDICT_LOAD, load_context, continue_verifier);
}
function test_origin() {
reset_seer();
reset_predictor();
var toplevel = "http://localhost:4444/index.html";
var subresources = [
"http://localhost:4444/style.css",
@@ -254,11 +254,11 @@ function test_origin() {
];
var tluri = newURI(toplevel);
seer.learn(tluri, null, seer.LEARN_LOAD_TOPLEVEL, load_context);
predictor.learn(tluri, null, predictor.LEARN_LOAD_TOPLEVEL, load_context);
var preconns = [];
for (var i = 0; i < subresources.length; i++) {
var sruri = newURI(subresources[i]);
seer.learn(sruri, tluri, seer.LEARN_LOAD_SUBRESOURCE, load_context);
predictor.learn(sruri, tluri, predictor.LEARN_LOAD_SUBRESOURCE, load_context);
var origin = extract_origin(sruri);
if (preconns.indexOf(origin) === -1) {
preconns.push(origin);
@@ -267,15 +267,15 @@ function test_origin() {
var loaduri = newURI("http://localhost:4444/anotherpage.html");
var verifier = new Verifier("origin", preconns, []);
seer.predict(loaduri, null, seer.PREDICT_LOAD, load_context, verifier);
predictor.predict(loaduri, null, predictor.PREDICT_LOAD, load_context, verifier);
}
var prefs;
var seer_pref;
var predictor_pref;
function cleanup() {
reset_seer();
prefs.setBoolPref("network.seer.enabled", seer_pref);
reset_predictor();
prefs.setBoolPref("network.predictor.enabled", predictor_pref);
}
var tests = [
@@ -291,9 +291,9 @@ function run_test() {
tests.forEach(add_test);
profile = do_get_profile();
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
seer_pref = prefs.getBoolPref("network.seer.enabled");
prefs.setBoolPref("network.seer.enabled", true);
seer = Cc["@mozilla.org/network/seer;1"].getService(Ci.nsINetworkSeer);
predictor_pref = prefs.getBoolPref("network.predictor.enabled");
prefs.setBoolPref("network.predictor.enabled", true);
predictor = Cc["@mozilla.org/network/predictor;1"].getService(Ci.nsINetworkPredictor);
do_register_cleanup(cleanup);
run_next_test();
}

View File

@@ -316,7 +316,7 @@ skip-if = os == "android"
[test_about_networking.js]
[test_ping_aboutnetworking.js]
[test_referrer.js]
[test_seer.js]
[test_predictor.js]
# Android version detection w/in gecko does not work right on infra, so we just
# disable this test on all android versions, even though it's enabled on 2.3+ in
# the wild.

View File

@@ -2090,39 +2090,39 @@
"extended_statistics_ok": true,
"description": "Time for an unsuccessful DNS OS resolution (msec)"
},
"SEER_PREDICT_ATTEMPTS": {
"PREDICTOR_PREDICT_ATTEMPTS": {
"expires_in_version": "never",
"kind": "exponential",
"high": "1000 * 1000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "Number of times nsINetworkSeer::Predict is called and attempts to predict"
"description": "Number of times nsINetworkPredictor::Predict is called and attempts to predict"
},
"SEER_LEARN_ATTEMPTS": {
"PREDICTOR_LEARN_ATTEMPTS": {
"expires_in_version": "never",
"kind": "exponential",
"high": "1000 * 1000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "Number of times nsINetworkSeer::Learn is called and attempts to learn"
"description": "Number of times nsINetworkPredictor::Learn is called and attempts to learn"
},
"SEER_PREDICT_FULL_QUEUE": {
"PREDICTOR_PREDICT_FULL_QUEUE": {
"expires_in_version": "never",
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "Number of times nsINetworkSeer::Predict doesn't continue because the queue is full"
"description": "Number of times nsINetworkPredictor::Predict doesn't continue because the queue is full"
},
"SEER_LEARN_FULL_QUEUE": {
"PREDICTOR_LEARN_FULL_QUEUE": {
"expires_in_version": "never",
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"extended_statistics_ok": true,
"description": "Number of times nsINetworkSeer::Learn doesn't continue because the queue is full"
"description": "Number of times nsINetworkPredictor::Learn doesn't continue because the queue is full"
},
"SEER_PREDICT_WAIT_TIME": {
"PREDICTOR_PREDICT_WAIT_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "3000",
@@ -2130,7 +2130,7 @@
"extended_statistics_ok": true,
"description": "Amount of time a predict event waits in the queue (ms)"
},
"SEER_PREDICT_WORK_TIME": {
"PREDICTOR_PREDICT_WORK_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "3000",
@@ -2138,7 +2138,7 @@
"extended_statistics_ok": true,
"description": "Amount of time spent doing the work for predict (ms)"
},
"SEER_LEARN_WAIT_TIME": {
"PREDICTOR_LEARN_WAIT_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "3000",
@@ -2146,7 +2146,7 @@
"extended_statistics_ok": true,
"description": "Amount of time a learn event waits in the queue (ms)"
},
"SEER_LEARN_WORK_TIME": {
"PREDICTOR_LEARN_WORK_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "3000",
@@ -2154,7 +2154,7 @@
"extended_statistics_ok": true,
"description": "Amount of time spent doing the work for learn (ms)"
},
"SEER_TOTAL_PREDICTIONS": {
"PREDICTOR_TOTAL_PREDICTIONS": {
"expires_in_version": "never",
"kind": "exponential",
"high": "1000 * 1000",
@@ -2162,7 +2162,7 @@
"extended_statistics_ok": true,
"description": "How many actual predictions (preresolves, preconnects, ...) happen"
},
"SEER_TOTAL_PRECONNECTS": {
"PREDICTOR_TOTAL_PRECONNECTS": {
"expires_in_version": "never",
"kind": "exponential",
"high": "1000 * 1000",
@@ -2170,7 +2170,7 @@
"extended_statistics_ok": true,
"description": "How many actual preconnects happen"
},
"SEER_TOTAL_PRERESOLVES": {
"PREDICTOR_TOTAL_PRERESOLVES": {
"expires_in_version": "never",
"kind": "exponential",
"high": "1000 * 1000",
@@ -2178,7 +2178,7 @@
"extended_statistics_ok": true,
"description": "How many actual preresolves happen"
},
"SEER_PREDICTIONS_CALCULATED": {
"PREDICTOR_PREDICTIONS_CALCULATED": {
"expires_in_version": "never",
"kind": "exponential",
"high": "1000 * 1000",
@@ -2186,94 +2186,94 @@
"extended_statistics_ok": true,
"description": "How many prediction calculations are performed"
},
"SEER_GLOBAL_DEGRADATION": {
"PREDICTOR_GLOBAL_DEGRADATION": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "The global degradation calculated"
},
"SEER_SUBRESOURCE_DEGRADATION": {
"PREDICTOR_SUBRESOURCE_DEGRADATION": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "The degradation calculated for a subresource"
},
"SEER_BASE_CONFIDENCE": {
"PREDICTOR_BASE_CONFIDENCE": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "The base confidence calculated for a subresource"
},
"SEER_CONFIDENCE": {
"PREDICTOR_CONFIDENCE": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "The final confidence calculated for a subresource"
},
"SEER_PREDICT_TIME_TO_ACTION": {
"PREDICTOR_PREDICT_TIME_TO_ACTION": {
"expires_in_version": "never",
"kind": "exponential",
"high": "3000",
"n_buckets": 10,
"description": "How long it takes from the time Predict() is called to the time we take action"
},
"SEER_PREDICT_TIME_TO_INACTION": {
"PREDICTOR_PREDICT_TIME_TO_INACTION": {
"expires_in_version": "never",
"kind": "exponential",
"high": "3000",
"n_buckets": 10,
"description": "How long it takes from the time Predict() is called to the time we figure out there's nothing to do"
},
"SEER_CLEANUP_DELTA": {
"PREDICTOR_CLEANUP_DELTA": {
"expires_in_version": "never",
"kind": "exponential",
"high": "60000",
"n_buckets": 50,
"description": "How long between seer db cleanups, in ms"
"description": "How long between predictor db cleanups, in ms"
},
"SEER_CLEANUP_SUCCEEDED": {
"PREDICTOR_CLEANUP_SUCCEEDED": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Whether or not the seer cleanup succeeded"
"description": "Whether or not the predictor cleanup succeeded"
},
"SEER_CLEANUP_TIME": {
"PREDICTOR_CLEANUP_TIME": {
"expires_in_version": "never",
"kind": "exponential",
"high": "5000",
"n_buckets": 10,
"description": "How long it takes to run the seer cleanup"
"description": "How long it takes to run the predictor cleanup"
},
"SEER_CLEANUP_SCHEDULED": {
"PREDICTOR_CLEANUP_SCHEDULED": {
"expires_in_version": "never",
"kind": "boolean",
"description": "Whether or not we actually try the cleanup method when we think about it"
},
"SEER_LOAD_COUNT_IS_ZERO": {
"PREDICTOR_LOAD_COUNT_IS_ZERO": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "Number of times load count is zero"
},
"SEER_LOAD_COUNT_OVERFLOWS": {
"PREDICTOR_LOAD_COUNT_OVERFLOWS": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "Number of times load count overflowed"
},
"SEER_STARTUP_COUNT_IS_ZERO": {
"PREDICTOR_STARTUP_COUNT_IS_ZERO": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",
"n_buckets": 50,
"description": "Number of times startup count is zero"
},
"SEER_STARTUP_COUNT_OVERFLOWS": {
"PREDICTOR_STARTUP_COUNT_OVERFLOWS": {
"expires_in_version": "never",
"kind": "linear",
"high": "100",

View File

@@ -222,8 +222,8 @@ this.ForgetAboutSite = {
// Predictive network data - like cache, no way to clear this per
// domain, so just trash it all
let ns = Cc["@mozilla.org/network/seer;1"].
getService(Ci.nsINetworkSeer);
ns.reset();
let np = Cc["@mozilla.org/network/predictor;1"].
getService(Ci.nsINetworkPredictor);
np.reset();
}
};