mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1593690 - Batch content -> parent visited queries. r=mak
Differential Revision: https://phabricator.services.mozilla.com/D51628 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
df7e6010eb
commit
374f945297
@ -3813,15 +3813,18 @@ mozilla::ipc::IPCResult ContentParent::RecvPSpeechSynthesisConstructor(
|
||||
#endif
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvStartVisitedQuery(
|
||||
const URIParams& aURI) {
|
||||
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
|
||||
if (!newURI) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
mozilla::ipc::IPCResult ContentParent::RecvStartVisitedQueries(
|
||||
const nsTArray<URIParams>& aUris) {
|
||||
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
||||
if (history) {
|
||||
history->RegisterVisitedCallback(newURI, nullptr);
|
||||
if (!history) {
|
||||
return IPC_OK();
|
||||
}
|
||||
for (const auto& params : aUris) {
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(params);
|
||||
if (NS_WARN_IF(!uri)) {
|
||||
continue;
|
||||
}
|
||||
history->RegisterVisitedCallback(uri, nullptr);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ class ContentParent final : public PContentParent,
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetShowPasswordSetting(bool* showPassword);
|
||||
|
||||
mozilla::ipc::IPCResult RecvStartVisitedQuery(const URIParams& uri);
|
||||
mozilla::ipc::IPCResult RecvStartVisitedQueries(const nsTArray<URIParams>&);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetURITitle(const URIParams& uri,
|
||||
const nsString& title);
|
||||
|
@ -915,7 +915,7 @@ parent:
|
||||
|
||||
// Services remoting
|
||||
|
||||
async StartVisitedQuery(URIParams uri);
|
||||
async StartVisitedQueries(URIParams[] uri);
|
||||
async SetURITitle(URIParams uri, nsString title);
|
||||
|
||||
async LoadURIExternal(URIParams uri, PBrowser windowContext);
|
||||
|
@ -371,19 +371,7 @@ class VisitedQuery final : public AsyncStatementCallback,
|
||||
static nsresult Start(nsIURI* aURI,
|
||||
mozIVisitedStatusCallback* aCallback = nullptr) {
|
||||
MOZ_ASSERT(aURI, "Null URI");
|
||||
|
||||
// If we are a content process, always remote the request to the
|
||||
// parent process.
|
||||
if (XRE_IsContentProcess()) {
|
||||
URIParams uri;
|
||||
SerializeURI(aURI, uri);
|
||||
|
||||
mozilla::dom::ContentChild* cpc =
|
||||
mozilla::dom::ContentChild::GetSingleton();
|
||||
NS_ASSERTION(cpc, "Content Protocol is NULL!");
|
||||
(void)cpc->SendStartVisitedQuery(uri);
|
||||
return NS_OK;
|
||||
}
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
nsMainThreadPtrHandle<mozIVisitedStatusCallback> callback(
|
||||
new nsMainThreadPtrHolder<mozIVisitedStatusCallback>(
|
||||
@ -2263,11 +2251,21 @@ History::IsURIVisited(nsIURI* aURI, mozIVisitedStatusCallback* aCallback) {
|
||||
|
||||
void History::StartPendingVisitedQueries(
|
||||
const PendingVisitedQueries& aQueries) {
|
||||
// TODO(emilio): Batch these if in the content process when sending them to
|
||||
// the parent?
|
||||
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
nsresult queryStatus = VisitedQuery::Start(iter.Get()->GetKey());
|
||||
Unused << NS_WARN_IF(NS_FAILED(queryStatus));
|
||||
if (XRE_IsContentProcess()) {
|
||||
nsTArray<URIParams> uris(aQueries.Count());
|
||||
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
SerializeURI(iter.Get()->GetKey(), *uris.AppendElement());
|
||||
}
|
||||
auto* cpc = mozilla::dom::ContentChild::GetSingleton();
|
||||
MOZ_ASSERT(cpc, "Content Protocol is NULL!");
|
||||
Unused << cpc->SendStartVisitedQueries(uris);
|
||||
} else {
|
||||
// TODO(bug 1594368): We could do a single query, as long as we can
|
||||
// then notify each URI individually.
|
||||
for (auto iter = aQueries.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
nsresult queryStatus = VisitedQuery::Start(iter.Get()->GetKey());
|
||||
Unused << NS_WARN_IF(NS_FAILED(queryStatus));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user