| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 from operator import itemgetter | 5 from operator import itemgetter |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 from third_party.json_schema_compiler.json_parse import Parse | 8 from third_party.json_schema_compiler.json_parse import Parse |
| 9 import third_party.json_schema_compiler.model as model | 9 import third_party.json_schema_compiler.model as model |
| 10 import docs_server_utils as utils | 10 import docs_server_utils as utils |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 def __init__(self, | 38 def __init__(self, |
| 39 compiled_fs_factory, | 39 compiled_fs_factory, |
| 40 file_system, | 40 file_system, |
| 41 public_template_path, | 41 public_template_path, |
| 42 features_bundle, | 42 features_bundle, |
| 43 object_store_creator): | 43 object_store_creator): |
| 44 self._file_system = file_system | 44 self._file_system = file_system |
| 45 def NormalizePath(string): | 45 def NormalizePath(string): |
| 46 return string if string.endswith('/') else (string + '/') | 46 return string if string.endswith('/') else (string + '/') |
| 47 self._public_template_path = NormalizePath(public_template_path) | 47 self._public_template_path = NormalizePath(public_template_path) |
| 48 self._cache = compiled_fs_factory.Create(self._CollectDocumentedAPIs, | 48 self._cache = compiled_fs_factory.Create(file_system, |
| 49 self._CollectDocumentedAPIs, |
| 49 APIListDataSource) | 50 APIListDataSource) |
| 50 self._features_bundle = features_bundle | 51 self._features_bundle = features_bundle |
| 51 self._object_store_creator = object_store_creator | 52 self._object_store_creator = object_store_creator |
| 52 | 53 |
| 53 def _CollectDocumentedAPIs(self, base_dir, files): | 54 def _CollectDocumentedAPIs(self, base_dir, files): |
| 54 def GetDocumentedAPIsForPlatform(names, platform): | 55 def GetDocumentedAPIsForPlatform(names, platform): |
| 55 public_templates = [] | 56 public_templates = [] |
| 56 for root, _, files in self._file_system.Walk( | 57 for root, _, files in self._file_system.Walk( |
| 57 self._public_template_path + platform): | 58 self._public_template_path + platform): |
| 58 public_templates.extend( | 59 public_templates.extend( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 107 |
| 107 def _GetCachedAPIData(self): | 108 def _GetCachedAPIData(self): |
| 108 data = self._object_store.Get('api_data').Get() | 109 data = self._object_store.Get('api_data').Get() |
| 109 if data is None: | 110 if data is None: |
| 110 data = self._factory._GenerateAPIDict() | 111 data = self._factory._GenerateAPIDict() |
| 111 self._object_store.Set('api_data', data) | 112 self._object_store.Set('api_data', data) |
| 112 return data | 113 return data |
| 113 | 114 |
| 114 def get(self, key): | 115 def get(self, key): |
| 115 return self._GetCachedAPIData().get(key) | 116 return self._GetCachedAPIData().get(key) |
| OLD | NEW |