зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1357318 - remember previous priority boost request in imgRequest. r=tnikkel
MozReview-Commit-ID: IieWWUw8EIB --HG-- extra : rebase_source : 2a4fcc625f6f44833533b524bb388bedfeceecaa
This commit is contained in:
Родитель
114ebfd44a
Коммит
fe043ed110
|
@ -208,5 +208,23 @@ interface imgIRequest : nsIRequest
|
|||
* underlying call.
|
||||
*/
|
||||
void decrementAnimationConsumers();
|
||||
|
||||
/**
|
||||
* Request loading priority boost to requested category, each category
|
||||
* of request increases priority only one time..
|
||||
*
|
||||
* CATEGORY_FRAME_INIT: increase priority when the imgRequest is associated
|
||||
* with an nsImageFrame.
|
||||
*
|
||||
* CATEGORY_SIZE_QUERY: increase priority when size decoding is necessary to
|
||||
* determine the layout size of the associated nsImageFrame.
|
||||
*
|
||||
* CATEGORY_DISPLAY: increase priority when the image is about to be displayed
|
||||
* in the viewport.
|
||||
*/
|
||||
const uint32_t CATEGORY_FRAME_INIT = 1 << 0;
|
||||
const uint32_t CATEGORY_SIZE_QUERY = 1 << 1;
|
||||
const uint32_t CATEGORY_DISPLAY = 1 << 2;
|
||||
void boostPriority(in uint32_t aCategory);
|
||||
};
|
||||
|
||||
|
|
|
@ -541,12 +541,50 @@ imgRequest::AdjustPriority(imgRequestProxy* proxy, int32_t delta)
|
|||
return;
|
||||
}
|
||||
|
||||
AdjustPriorityInternal(delta);
|
||||
}
|
||||
|
||||
void
|
||||
imgRequest::AdjustPriorityInternal(int32_t aDelta)
|
||||
{
|
||||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(mChannel);
|
||||
if (p) {
|
||||
p->AdjustPriority(delta);
|
||||
p->AdjustPriority(aDelta);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
imgRequest::BoostPriority(uint32_t aCategory)
|
||||
{
|
||||
uint32_t newRequestedCategory =
|
||||
(mBoostCategoriesRequested & aCategory) ^ aCategory;
|
||||
if (!newRequestedCategory) {
|
||||
// priority boost for each category can only apply once.
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_LOG(gImgLog, LogLevel::Debug,
|
||||
("[this=%p] imgRequest::BoostPriority for category %x",
|
||||
this, newRequestedCategory));
|
||||
|
||||
int32_t delta = 0;
|
||||
|
||||
if (newRequestedCategory & imgIRequest::CATEGORY_FRAME_INIT) {
|
||||
--delta;
|
||||
}
|
||||
|
||||
if (newRequestedCategory & imgIRequest::CATEGORY_SIZE_QUERY) {
|
||||
--delta;
|
||||
}
|
||||
|
||||
if (newRequestedCategory & imgIRequest::CATEGORY_DISPLAY) {
|
||||
delta += nsISupportsPriority::PRIORITY_HIGH;
|
||||
}
|
||||
|
||||
AdjustPriorityInternal(delta);
|
||||
mBoostCategoriesRequested |= newRequestedCategory;
|
||||
}
|
||||
|
||||
bool
|
||||
imgRequest::HasTransferredData() const
|
||||
{
|
||||
|
|
|
@ -171,6 +171,8 @@ public:
|
|||
/// of @aProxy.
|
||||
void AdjustPriority(imgRequestProxy* aProxy, int32_t aDelta);
|
||||
|
||||
void BoostPriority(uint32_t aCategory);
|
||||
|
||||
/// Returns a weak pointer to the underlying request.
|
||||
nsIRequest* GetRequest() const { return mRequest; }
|
||||
|
||||
|
@ -223,6 +225,8 @@ private:
|
|||
/// Returns true if StartDecoding() was called.
|
||||
bool IsDecodeRequested() const;
|
||||
|
||||
void AdjustPriorityInternal(int32_t aDelta);
|
||||
|
||||
// Weak reference to parent loader; this request cannot outlive its owner.
|
||||
imgLoader* mLoader;
|
||||
nsCOMPtr<nsIRequest> mRequest;
|
||||
|
@ -275,6 +279,9 @@ private:
|
|||
|
||||
nsresult mImageErrorCode;
|
||||
|
||||
// The categories of prioritization strategy that have been requested.
|
||||
uint32_t mBoostCategoriesRequested = 0;
|
||||
|
||||
mutable mozilla::Mutex mMutex;
|
||||
|
||||
// Member variables protected by mMutex. Note that *all* flags in our bitfield
|
||||
|
|
|
@ -718,6 +718,14 @@ imgRequestProxy::GetCORSMode(int32_t* aCorsMode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::BoostPriority(uint32_t aCategory)
|
||||
{
|
||||
NS_ENSURE_STATE(GetOwner() && !mCanceled);
|
||||
GetOwner()->BoostPriority(aCategory);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** nsISupportsPriority methods **/
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
Загрузка…
Ссылка в новой задаче