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:
Emilio Cobos Álvarez 2019-11-06 12:11:06 +00:00
parent df7e6010eb
commit 374f945297
4 changed files with 29 additions and 28 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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);

View File

@ -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));
}
}
}