summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/extensions/docs/server2/api_data_source.py34
-rw-r--r--chrome/common/extensions/docs/server2/api_list_data_source.py6
-rw-r--r--chrome/common/extensions/docs/server2/file_system_cache.py1
-rw-r--r--chrome/common/extensions/docs/server2/memcache_file_system.py2
4 files changed, 21 insertions, 22 deletions
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 64644d1..4f7139f 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -32,10 +32,10 @@ class APIDataSource(object):
def __init__(self, cache_builder, base_path, samples_factory):
self._permissions_cache = cache_builder.build(self._LoadPermissions,
fs_cache.PERMS)
- self._json_cache = cache_builder.build(self._LoadJsonAPI,
- fs_cache.JSON)
- self._idl_cache = cache_builder.build(self._LoadIdlAPI,
- fs_cache.IDL)
+ self._json_cache = cache_builder.build(self._LoadJsonAPI, fs_cache.JSON)
+ self._idl_cache = cache_builder.build(self._LoadIdlAPI, fs_cache.IDL)
+ self._idl_names_cache = cache_builder.build(self._GetIDLNames,
+ fs_cache.IDL_NAMES)
self._samples_factory = samples_factory
self._base_path = base_path
@@ -43,6 +43,7 @@ class APIDataSource(object):
return APIDataSource(self._permissions_cache,
self._json_cache,
self._idl_cache,
+ self._idl_names_cache,
self._base_path,
self._samples_factory.Create(request))
@@ -56,16 +57,22 @@ class APIDataSource(object):
idl = idl_parser.IDLParser().ParseData(api)
return HandlebarDictGenerator(idl_schema.IDLSchema(idl).process()[0])
+ def _GetIDLNames(self, apis):
+ return [model.UnixName(os.path.splitext(api.split('/')[-1])[0])
+ for api in apis if api.endswith('.idl')]
+
def __init__(self,
permissions_cache,
json_cache,
idl_cache,
+ idl_names_cache,
base_path,
samples):
self._base_path = base_path
self._permissions_cache = permissions_cache
self._json_cache = json_cache
self._idl_cache = idl_cache
+ self._idl_names_cache = idl_names_cache
self._samples = samples
def _GetFeature(self, path):
@@ -101,16 +108,9 @@ class APIDataSource(object):
def get(self, key):
path, ext = os.path.splitext(key)
unix_name = model.UnixName(path)
- json_path = unix_name + '.json'
- idl_path = unix_name + '.idl'
- try:
- return self._GenerateHandlebarContext(
- self._json_cache.GetFromFile(self._base_path + '/' + json_path),
- path)
- except FileNotFoundError:
- try:
- return self._GenerateHandlebarContext(
- self._idl_cache.GetFromFile(self._base_path + '/' + idl_path),
- path)
- except FileNotFoundError:
- raise
+ idl_names = self._idl_names_cache.GetFromFileListing(self._base_path)
+ cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else
+ (self._json_cache, '.json'))
+ return self._GenerateHandlebarContext(
+ cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)),
+ path)
diff --git a/chrome/common/extensions/docs/server2/api_list_data_source.py b/chrome/common/extensions/docs/server2/api_list_data_source.py
index e2aa5ed..6e94000 100644
--- a/chrome/common/extensions/docs/server2/api_list_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_list_data_source.py
@@ -16,6 +16,9 @@ IGNORED_FILES = [
]
class APIListDataSource(object):
+ """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs
+ that are used in the api_index.html and experimental.html pages.
+ """
class Factory(object):
def __init__(self, cache_builder, file_system, api_path, public_path):
self._cache = cache_builder.build(self._ListAPIs, fs_cache.LIST)
@@ -59,9 +62,6 @@ class APIListDataSource(object):
def Create(self):
return APIListDataSource(self._cache, self._api_path)
- """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs
- that are used in the api_index.html and experimental.html pages.
- """
def __init__(self, cache, api_path):
self._cache = cache
self._api_path = api_path
diff --git a/chrome/common/extensions/docs/server2/file_system_cache.py b/chrome/common/extensions/docs/server2/file_system_cache.py
index 943c74a..2526e50 100644
--- a/chrome/common/extensions/docs/server2/file_system_cache.py
+++ b/chrome/common/extensions/docs/server2/file_system_cache.py
@@ -11,6 +11,7 @@ CRON = 'Cron'
EXTENSIONS = 'Extensions'
HANDLEBAR = 'Handlebar'
IDL = 'IDL'
+IDL_NAMES = 'IDLNames'
INTRO = 'Intro'
JSON = 'JSON'
LIST = 'List'
diff --git a/chrome/common/extensions/docs/server2/memcache_file_system.py b/chrome/common/extensions/docs/server2/memcache_file_system.py
index 6bb2b4b..186e09d 100644
--- a/chrome/common/extensions/docs/server2/memcache_file_system.py
+++ b/chrome/common/extensions/docs/server2/memcache_file_system.py
@@ -51,8 +51,6 @@ class MemcacheFileSystem(FileSystem):
version = dir_stat.version
else:
version = dir_stat.child_versions.get(path.split('/')[-1], None)
- # TODO(cduvall): IDL APIs are restatting every load because this exception
- # is thrown so they never get cached.
if version is None:
raise FileNotFoundError(path)
mapping = { path: version }