diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 39f8a140b..729e86abf 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -385,7 +385,7 @@ class SearchEngineCompleter # immediately. return onComplete [] - SearchEngines.complete searchUrl, queryTerms, (searchSuggestions = []) => + CompletionEngines.complete searchUrl, queryTerms, (searchSuggestions = []) => for suggestion in searchSuggestions insertText = if custom then "#{keyword} #{suggestion}" else suggestion suggestions.push @mkSuggestion insertText, queryTerms, type, mkUrl(suggestion), suggestion, @computeRelevancy, score diff --git a/background_scripts/search_engines.coffee b/background_scripts/completion_engines.coffee similarity index 97% rename from background_scripts/search_engines.coffee rename to background_scripts/completion_engines.coffee index 63c61a474..0177806a1 100644 --- a/background_scripts/search_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -13,8 +13,8 @@ # 3. "parse" - This takes a successful XMLHttpRequest object (the request has completed successfully), and # returns a list of suggestions (a list of strings). # -# The main completion entry point is SearchEngines.complete(). This implements all lookup and caching -# logic. It is possible to add new completion engines without changing the SearchEngines infrastructure +# The main completion entry point is CompletionEngines.complete(). This implements all lookup and caching +# logic. It is possible to add new completion engines without changing the CompletionEngines infrastructure # itself. # A base class for common regexp-based matching engines. @@ -113,7 +113,7 @@ completionEngines = [ DummySearchEngine ] -SearchEngines = +CompletionEngines = debug: true get: (searchUrl, url, callback) -> @@ -216,4 +216,4 @@ SearchEngines = @mostRecentHandler = null root = exports ? window -root.SearchEngines = SearchEngines +root.CompletionEngines = CompletionEngines diff --git a/lib/utils.coffee b/lib/utils.coffee index 1b2a7a3fa..e97872f0d 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -207,14 +207,14 @@ globalRoot.extend = (hash1, hash2) -> hash1[key] = hash2[key] hash1 -# A simple cache. Entries used within an expiry period are retained (for one more expiry period), otherwise -# they are discarded. +# A simple cache. Entries used within two expiry periods are retained, otherwise they are discarded. +# At most 2 * @entries entries are retained. class SimpleCache # expiry: expiry time in milliseconds (default, one hour) # entries: maximum number of entries in @cache (there may be this many entries in @previous, too) constructor: (@expiry = 60 * 60 * 1000, @entries = 1000) -> @cache = {} - @rotate() # Force starts the rotation timer. + @rotate() # Force start the rotation timer. rotate: -> @previous = @cache diff --git a/manifest.json b/manifest.json index d3f6249f3..195d16c88 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "background_scripts/sync.js", "background_scripts/settings.js", "background_scripts/exclusions.js", - "background_scripts/search_engines.js", + "background_scripts/completion_engines.js", "background_scripts/completion.js", "background_scripts/marks.js", "background_scripts/main.js"