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

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

Issue 63203002: Docserver: Make the hand-written Cron methods run first rather than last, since (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jeffrey Created 7 years, 1 month 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 | Annotate | Revision Log
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 json 5 import json
6 6
7 from data_source import DataSource 7 from data_source import DataSource
8 import features_utility 8 import features_utility
9 from future import Gettable, Future
9 from manifest_features import ConvertDottedKeysToNested 10 from manifest_features import ConvertDottedKeysToNested
10 from third_party.json_schema_compiler.json_parse import Parse 11 from third_party.json_schema_compiler.json_parse import Parse
11 12
12 def _ListifyAndSortDocs(features, app_name): 13 def _ListifyAndSortDocs(features, app_name):
13 '''Convert a |feautres| dictionary, and all 'children' dictionaries, into 14 '''Convert a |feautres| dictionary, and all 'children' dictionaries, into
14 lists recursively. Sort lists first by 'level' then by name. 15 lists recursively. Sort lists first by 'level' then by name.
15 ''' 16 '''
16 def sort_key(item): 17 def sort_key(item):
17 '''Key function to sort items primarily by level (according to index into 18 '''Key function to sort items primarily by level (according to index into
18 levels) then subsort by name. 19 levels) then subsort by name.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 class ManifestDataSource(DataSource): 100 class ManifestDataSource(DataSource):
100 '''Provides access to the properties in manifest features. 101 '''Provides access to the properties in manifest features.
101 ''' 102 '''
102 def __init__(self, server_instance, _): 103 def __init__(self, server_instance, _):
103 self._features_bundle = server_instance.features_bundle 104 self._features_bundle = server_instance.features_bundle
104 self._object_store = server_instance.object_store_creator.Create( 105 self._object_store = server_instance.object_store_creator.Create(
105 ManifestDataSource) 106 ManifestDataSource)
106 107
107 def _CreateManifestData(self): 108 def _CreateManifestData(self):
108 def for_templates(manifest_features, platform): 109 future_manifest_features = self._features_bundle.GetManifestFeatures()
109 return _AddLevelAnnotations( 110 def resolve():
110 _ListifyAndSortDocs( 111 manifest_features = future_manifest_features.Get()
111 ConvertDottedKeysToNested( 112 def for_templates(manifest_features, platform):
112 features_utility.Filtered(manifest_features, platform)), 113 return _AddLevelAnnotations(_ListifyAndSortDocs(
113 app_name=platform.capitalize())) 114 ConvertDottedKeysToNested(
114 manifest_features = self._features_bundle.GetManifestFeatures() 115 features_utility.Filtered(manifest_features, platform)),
115 return { 116 app_name=platform.capitalize()))
116 'apps': for_templates(manifest_features, 'apps'), 117 return {
117 'extensions': for_templates(manifest_features, 'extensions') 118 'apps': for_templates(manifest_features, 'apps'),
118 } 119 'extensions': for_templates(manifest_features, 'extensions')
120 }
121 return Future(delegate=Gettable(resolve))
119 122
120 def _GetCachedManifestData(self, force_update=False): 123 def _GetCachedManifestData(self):
121 data = self._object_store.Get('manifest_data').Get() 124 data = self._object_store.Get('manifest_data').Get()
122 if data is None or force_update: 125 if data is None:
123 data = self._CreateManifestData() 126 data = self._CreateManifestData().Get()
124 self._object_store.Set('manifest_data', data) 127 self._object_store.Set('manifest_data', data)
125 return data 128 return data
126 129
127 def Cron(self): 130 def Cron(self):
128 self._GetCachedManifestData(force_update=True) 131 return self._CreateManifestData()
129 132
130 def get(self, key): 133 def get(self, key):
131 return self._GetCachedManifestData().get(key) 134 return self._GetCachedManifestData().get(key)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698