From 7be56a178d69abcc0d27c7d28d832128596a0f88 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Mon, 4 Jun 2012 22:01:41 -0700 Subject: Don't use a closure for the onPageVisited handler. I'm worried about keeping around a reference to history forever, unnecessarily. --- background_scripts/completion.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index f76b0fe9..040b1fdb 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -257,12 +257,14 @@ HistoryCache = # sorting in ascending order. We will push new items on to the end as the user navigates to new pages. history.sort((a, b) -> (a.lastVisitTime || 0) - (b.lastVisitTime || 0)) @history = history - chrome.history.onVisited.addListener (newSite) => - firstTimeVisit = (newSite.visitedCount == 1) - @history.push(newSite) if firstTimeVisit + chrome.history.onVisited.addListener(@onPageVisited.proxy(this)) callback(@history) for callback in @callbacks @callbacks = null + onPageVisited: (newPage) -> + firstTimeVisit = (newSite.visitedCount == 1) + @history.push(newSite) if firstTimeVisit + root = exports ? window root.Suggestion = Suggestion root.BookmarkCompleter = BookmarkCompleter -- cgit v1.2.3