Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/common/extensions/docs/server2/api_models.py

Issue 521693003: Docserver: Add @Cache annotation to CompiledFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small clarification + rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/compiled_file_system.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import posixpath 5 import posixpath
6 6
7 from compiled_file_system import SingleFile, Unicode 7 from compiled_file_system import Cache, SingleFile, Unicode
8 from extensions_paths import API_PATHS 8 from extensions_paths import API_PATHS
9 from features_bundle import HasParent, GetParentName 9 from features_bundle import HasParent, GetParentName
10 from file_system import FileNotFoundError 10 from file_system import FileNotFoundError
11 from future import All, Future, Race 11 from future import All, Future, Race
12 from operator import itemgetter 12 from operator import itemgetter
13 from path_util import Join 13 from path_util import Join
14 from platform_util import PlatformToExtensionType 14 from platform_util import PlatformToExtensionType
15 from schema_util import ProcessSchema 15 from schema_util import ProcessSchema
16 from third_party.json_schema_compiler.json_schema import DeleteNodes 16 from third_party.json_schema_compiler.json_schema import DeleteNodes
17 from third_party.json_schema_compiler.model import Namespace, UnixName 17 from third_party.json_schema_compiler.model import Namespace, UnixName
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 compiled_fs_factory, 57 compiled_fs_factory,
58 file_system, 58 file_system,
59 object_store_creator, 59 object_store_creator,
60 platform): 60 platform):
61 self._features_bundle = features_bundle 61 self._features_bundle = features_bundle
62 self._platform = PlatformToExtensionType(platform) 62 self._platform = PlatformToExtensionType(platform)
63 self._model_cache = compiled_fs_factory.Create( 63 self._model_cache = compiled_fs_factory.Create(
64 file_system, self._CreateAPIModel, APIModels, category=self._platform) 64 file_system, self._CreateAPIModel, APIModels, category=self._platform)
65 self._object_store = object_store_creator.Create(APIModels) 65 self._object_store = object_store_creator.Create(APIModels)
66 66
67 @Cache
67 @SingleFile 68 @SingleFile
68 @Unicode 69 @Unicode
69 def _CreateAPIModel(self, path, data): 70 def _CreateAPIModel(self, path, data):
70 def does_not_include_platform(node): 71 def does_not_include_platform(node):
71 return ('extension_types' in node and 72 return ('extension_types' in node and
72 node['extension_types'] != 'all' and 73 node['extension_types'] != 'all' and
73 self._platform not in node['extension_types']) 74 self._platform not in node['extension_types'])
74 75
75 schema = ProcessSchema(path, data)[0] 76 schema = ProcessSchema(path, data)[0]
76 if not schema: 77 if not schema:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 174
174 def IterModels(self): 175 def IterModels(self):
175 future_models = [(name, self.GetModel(name)) for name in self.GetNames()] 176 future_models = [(name, self.GetModel(name)) for name in self.GetNames()]
176 for name, future_model in future_models: 177 for name, future_model in future_models:
177 try: 178 try:
178 model = future_model.Get() 179 model = future_model.Get()
179 except FileNotFoundError: 180 except FileNotFoundError:
180 continue 181 continue
181 if model: 182 if model:
182 yield name, model 183 yield name, model
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/compiled_file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698