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 data_source import DataSource | 5 from data_source import DataSource |
6 from docs_server_utils import StringIdentity | 6 from docs_server_utils import StringIdentity |
7 from environment import IsPreviewServer | 7 from environment import IsPreviewServer |
8 from file_system import FileNotFoundError | 8 from file_system import FileNotFoundError |
9 from future import Future, All | 9 from future import Future, All |
10 from jsc_view import JSCView, GetEventByNameFromEvents | 10 from jsc_view import JSCView, GetEventByNameFromEvents |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 def resolve(): | 64 def resolve(): |
65 jsc_view = jsc_view_future.Get() | 65 jsc_view = jsc_view_future.Get() |
66 if jsc_view is None: | 66 if jsc_view is None: |
67 jsc_view = JSCView( | 67 jsc_view = JSCView( |
68 content_script_apis_future.Get(), | 68 content_script_apis_future.Get(), |
69 model_future.Get(), | 69 model_future.Get(), |
70 self._platform_bundle.GetAvailabilityFinder(platform), | 70 self._platform_bundle.GetAvailabilityFinder(platform), |
71 self._json_cache, | 71 self._json_cache, |
72 self._template_cache, | 72 self._template_cache, |
73 self._platform_bundle.GetFeaturesBundle(platform), | 73 self._platform_bundle.GetFeaturesBundle(platform), |
74 self._LoadEventByName(platform)).ToDict() | 74 self._LoadEventByName(platform), |
| 75 platform).ToDict() |
75 self._view_cache.Set(object_store_key, jsc_view) | 76 self._view_cache.Set(object_store_key, jsc_view) |
76 return jsc_view | 77 return jsc_view |
77 return Future(callback=resolve) | 78 return Future(callback=resolve) |
78 | 79 |
79 def _GetImpl(self, platform, api_name): | 80 def _GetImpl(self, platform, api_name): |
80 jsc_view_future = self._GetSchemaView(platform, api_name) | 81 jsc_view_future = self._GetSchemaView(platform, api_name) |
81 def resolve(): | 82 def resolve(): |
82 jsc_view = jsc_view_future.Get() | 83 jsc_view = jsc_view_future.Get() |
83 # Parsing samples on the preview server takes seconds and doesn't add | 84 # Parsing samples on the preview server takes seconds and doesn't add |
84 # anything. Don't do it. | 85 # anything. Don't do it. |
(...skipping 11 matching lines...) Expand all Loading... |
96 getter = lambda: 0 | 97 getter = lambda: 0 |
97 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 98 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
98 return getter | 99 return getter |
99 | 100 |
100 def Cron(self): | 101 def Cron(self): |
101 futures = [] | 102 futures = [] |
102 for platform in GetPlatforms(): | 103 for platform in GetPlatforms(): |
103 futures += [self._GetImpl(platform, name) | 104 futures += [self._GetImpl(platform, name) |
104 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 105 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
105 return All(futures, except_pass=FileNotFoundError) | 106 return All(futures, except_pass=FileNotFoundError) |
OLD | NEW |