Skip to content

Commit

Permalink
Bug 1322966 - Cleanup performance.cpp, r=qdot
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulf committed Dec 13, 2016
1 parent 19c6858 commit 3c9042f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 47 deletions.
20 changes: 2 additions & 18 deletions dom/base/nsGlobalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2823,8 +2823,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
newInnerWindow->mPerformance =
Performance::CreateForMainThread(newInnerWindow->AsInner(),
currentInner->mPerformance->GetDOMTiming(),
currentInner->mPerformance->GetChannel(),
currentInner->mPerformance->GetParentPerformance());
currentInner->mPerformance->GetChannel());
}
}

Expand Down Expand Up @@ -4033,22 +4032,7 @@ nsPIDOMWindowInner::CreatePerformanceObjectIfNeeded()
timedChannel = nullptr;
}
if (timing) {
// If we are dealing with an iframe, we will need the parent's performance
// object (so we can add the iframe as a resource of that page).
Performance* parentPerformance = nullptr;
nsCOMPtr<nsPIDOMWindowOuter> parentWindow = GetScriptableParentOrNull();
if (parentWindow) {
nsPIDOMWindowInner* parentInnerWindow = nullptr;
if (parentWindow) {
parentInnerWindow = parentWindow->GetCurrentInnerWindow();
}
if (parentInnerWindow) {
parentPerformance = parentInnerWindow->GetPerformance();
}
}
mPerformance =
Performance::CreateForMainThread(this, timing, timedChannel,
parentPerformance);
mPerformance = Performance::CreateForMainThread(this, timing, timedChannel);
}
}

Expand Down
6 changes: 2 additions & 4 deletions dom/performance/Performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,12 @@ NS_IMPL_RELEASE_INHERITED(Performance, DOMEventTargetHelper)
/* static */ already_AddRefed<Performance>
Performance::CreateForMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel,
Performance* aParentPerformance)
nsITimedChannel* aChannel)
{
MOZ_ASSERT(NS_IsMainThread());

RefPtr<Performance> performance =
new PerformanceMainThread(aWindow, aDOMTiming, aChannel,
aParentPerformance);
new PerformanceMainThread(aWindow, aDOMTiming, aChannel);
return performance.forget();
}

Expand Down
5 changes: 1 addition & 4 deletions dom/performance/Performance.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class Performance : public DOMEventTargetHelper
static already_AddRefed<Performance>
CreateForMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel,
Performance* aParentPerformance);
nsITimedChannel* aChannel);

static already_AddRefed<Performance>
CreateForWorker(workers::WorkerPrivate* aWorkerPrivate);
Expand Down Expand Up @@ -104,8 +103,6 @@ class Performance : public DOMEventTargetHelper

virtual nsITimedChannel* GetChannel() const = 0;

virtual Performance* GetParentPerformance() const = 0;

protected:
Performance();
explicit Performance(nsPIDOMWindowInner* aWindow);
Expand Down
10 changes: 3 additions & 7 deletions dom/performance/PerformanceMainThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
Performance)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming,
mNavigation,
mParentPerformance)
mNavigation)
tmp->mMozMemory = nullptr;
mozilla::DropJSObjects(this);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread,
Performance)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTiming,
mNavigation,
mParentPerformance)
mNavigation)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Expand All @@ -46,12 +44,10 @@ NS_INTERFACE_MAP_END_INHERITING(Performance)

PerformanceMainThread::PerformanceMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel,
Performance* aParentPerformance)
nsITimedChannel* aChannel)
: Performance(aWindow)
, mDOMTiming(aDOMTiming)
, mChannel(aChannel)
, mParentPerformance(aParentPerformance)
{
MOZ_ASSERT(aWindow, "Parent window object should be provided");
}
Expand Down
9 changes: 1 addition & 8 deletions dom/performance/PerformanceMainThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class PerformanceMainThread final : public Performance
public:
PerformanceMainThread(nsPIDOMWindowInner* aWindow,
nsDOMNavigationTiming* aDOMTiming,
nsITimedChannel* aChannel,
Performance* aParentPerformance);
nsITimedChannel* aChannel);

NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread,
Expand Down Expand Up @@ -51,11 +50,6 @@ class PerformanceMainThread final : public Performance
return mChannel;
}

virtual Performance* GetParentPerformance() const override
{
return mParentPerformance;
}

protected:
~PerformanceMainThread();

Expand All @@ -77,7 +71,6 @@ class PerformanceMainThread final : public Performance
nsCOMPtr<nsITimedChannel> mChannel;
RefPtr<PerformanceTiming> mTiming;
RefPtr<PerformanceNavigation> mNavigation;
RefPtr<Performance> mParentPerformance;
JS::Heap<JSObject*> mMozMemory;
};

Expand Down
6 changes: 0 additions & 6 deletions dom/performance/PerformanceWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ class PerformanceWorker final : public Performance
return nullptr;
}

virtual Performance* GetParentPerformance() const override
{
MOZ_CRASH("This should not be called on workers.");
return nullptr;
}

protected:
~PerformanceWorker();

Expand Down

0 comments on commit 3c9042f

Please sign in to comment.