Commit 752a5ebc authored by kalman@chromium.org's avatar kalman@chromium.org

Docs: Memoize the FeaturesBundles that are created by AvailabilityFinder to

maintain their caches. r259958 altered the way the feature data was populated
and caused a big regression. This fixes it.

R=rockot@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/216703003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260232 0039d316-1c4b-4281-b951-d872f2087c98
parent 55fb2d5c
application: chrome-apps-doc application: chrome-apps-doc
version: 3-15-1 version: 3-15-2
runtime: python27 runtime: python27
api_version: 1 api_version: 1
threadsafe: false threadsafe: false
......
...@@ -11,6 +11,7 @@ from extensions_paths import API_PATHS, JSON_TEMPLATES ...@@ -11,6 +11,7 @@ from extensions_paths import API_PATHS, JSON_TEMPLATES
from features_bundle import FeaturesBundle from features_bundle import FeaturesBundle
import features_utility import features_utility
from file_system import FileNotFoundError from file_system import FileNotFoundError
from third_party.json_schema_compiler.memoize import memoize
from third_party.json_schema_compiler.model import UnixName from third_party.json_schema_compiler.model import UnixName
...@@ -177,6 +178,7 @@ class AvailabilityFinder(object): ...@@ -177,6 +178,7 @@ class AvailabilityFinder(object):
channel_info.channel)) channel_info.channel))
return available_channel is not None and newest == channel_info.channel return available_channel is not None and newest == channel_info.channel
@memoize
def _CreateFeaturesBundle(self, file_system): def _CreateFeaturesBundle(self, file_system):
return FeaturesBundle(file_system, return FeaturesBundle(file_system,
self._compiled_fs_factory, self._compiled_fs_factory,
......
...@@ -2,4 +2,4 @@ cron: ...@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data. - description: Repopulates all cached data.
url: /_cron url: /_cron
schedule: every 5 minutes schedule: every 5 minutes
target: 3-15-1 target: 3-15-2
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import posixpath import posixpath
from compiled_file_system import Unicode from compiled_file_system import SingleFile, Unicode
from extensions_paths import ( from extensions_paths import (
API_FEATURES, JSON_TEMPLATES, MANIFEST_FEATURES, PERMISSION_FEATURES) API_FEATURES, JSON_TEMPLATES, MANIFEST_FEATURES, PERMISSION_FEATURES)
import features_utility import features_utility
...@@ -40,8 +40,11 @@ def _AddPlatformsFromDependencies(feature, ...@@ -40,8 +40,11 @@ def _AddPlatformsFromDependencies(feature,
class _FeaturesCache(object): class _FeaturesCache(object):
def __init__(self, file_system, compiled_fs_factory, *json_paths): def __init__(self, file_system, compiled_fs_factory, *json_paths):
self._cache = compiled_fs_factory.Create( populate = self._CreateCache
file_system, self._CreateCache, type(self)) if len(json_paths) == 1:
populate = SingleFile(populate)
self._cache = compiled_fs_factory.Create(file_system, populate, type(self))
self._text_cache = compiled_fs_factory.ForUnicode(file_system) self._text_cache = compiled_fs_factory.ForUnicode(file_system)
self._json_path = json_paths[0] self._json_path = json_paths[0]
self._extra_paths = json_paths[1:] self._extra_paths = json_paths[1:]
......
...@@ -171,6 +171,13 @@ class FileSystem(object): ...@@ -171,6 +171,13 @@ class FileSystem(object):
for walkinfo in walk(root): for walkinfo in walk(root):
yield walkinfo yield walkinfo
def __eq__(self, other):
return (isinstance(other, FileSystem) and
self.GetIdentity() == other.GetIdentity())
def __ne__(self, other):
return not (self == other)
def __repr__(self): def __repr__(self):
return '<%s>' % type(self).__name__ return '<%s>' % type(self).__name__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment