| 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 api_data_source import APIDataSource | 5 from api_data_source import APIDataSource |
| 6 from api_list_data_source import APIListDataSource | 6 from api_list_data_source import APIListDataSource |
| 7 from appengine_wrappers import IsDevServer | 7 from appengine_wrappers import IsDevServer |
| 8 from availability_finder import AvailabilityFinder | 8 from availability_finder import AvailabilityFinder |
| 9 from compiled_file_system import CompiledFileSystem | 9 from compiled_file_system import CompiledFileSystem |
| 10 from empty_dir_file_system import EmptyDirFileSystem | 10 from empty_dir_file_system import EmptyDirFileSystem |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 branch_utility, | 32 branch_utility, |
| 33 host_file_system_provider, | 33 host_file_system_provider, |
| 34 base_path='/'): | 34 base_path='/'): |
| 35 ''' | 35 ''' |
| 36 |object_store_creator| | 36 |object_store_creator| |
| 37 The ObjectStoreCreator used to create almost all caches. | 37 The ObjectStoreCreator used to create almost all caches. |
| 38 |app_samples_file_system| | 38 |app_samples_file_system| |
| 39 The FileSystem instance which hosts the App samples. | 39 The FileSystem instance which hosts the App samples. |
| 40 |compiled_fs_factory| | 40 |compiled_fs_factory| |
| 41 Factory used to create CompiledFileSystems, a higher-level cache type | 41 Factory used to create CompiledFileSystems, a higher-level cache type |
| 42 than ObjectStores. This can usually be derived from | 42 than ObjectStores. This can usually be derived from just |
| 43 |object_store_creator| and |host_file_system_provider| but under special | 43 |object_store_creator| but under special circumstances a different |
| 44 circumstances a different implementation needs to be passed in. | 44 implementation needs to be passed in. |
| 45 |branch_utility| | 45 |branch_utility| |
| 46 Has knowledge of Chrome branches, channels, and versions. | 46 Has knowledge of Chrome branches, channels, and versions. |
| 47 |host_file_system_provider| | 47 |host_file_system_provider| |
| 48 Creates FileSystem instances which host the server at alternative | 48 Creates FileSystem instances which host the server at alternative |
| 49 revisions. | 49 revisions. |
| 50 |base_path| | 50 |base_path| |
| 51 The path which all HTML is generated relative to. Usually this is / | 51 The path which all HTML is generated relative to. Usually this is / |
| 52 but some servlets need to override this. | 52 but some servlets need to override this. |
| 53 ''' | 53 ''' |
| 54 self.object_store_creator = object_store_creator | 54 self.object_store_creator = object_store_creator |
| 55 | 55 |
| 56 self.app_samples_file_system = app_samples_file_system | 56 self.app_samples_file_system = app_samples_file_system |
| 57 | 57 |
| 58 self.compiled_host_fs_factory = compiled_fs_factory | 58 self.compiled_fs_factory = compiled_fs_factory |
| 59 | 59 |
| 60 self.host_file_system_provider = host_file_system_provider | 60 self.host_file_system_provider = host_file_system_provider |
| 61 host_fs_at_trunk = host_file_system_provider.GetTrunk() | 61 host_fs_at_trunk = host_file_system_provider.GetTrunk() |
| 62 | 62 |
| 63 assert base_path.startswith('/') and base_path.endswith('/') | 63 assert base_path.startswith('/') and base_path.endswith('/') |
| 64 self.base_path = base_path | 64 self.base_path = base_path |
| 65 | 65 |
| 66 self.host_file_system_iterator = HostFileSystemIterator( | 66 self.host_file_system_iterator = HostFileSystemIterator( |
| 67 host_file_system_provider, | 67 host_file_system_provider, |
| 68 branch_utility) | 68 branch_utility) |
| 69 | 69 |
| 70 self.features_bundle = FeaturesBundle( | 70 self.features_bundle = FeaturesBundle( |
| 71 host_fs_at_trunk, | 71 host_fs_at_trunk, |
| 72 self.compiled_host_fs_factory, | 72 self.compiled_fs_factory, |
| 73 self.object_store_creator) | 73 self.object_store_creator) |
| 74 | 74 |
| 75 self.availability_finder = AvailabilityFinder( | 75 self.availability_finder = AvailabilityFinder( |
| 76 self.host_file_system_iterator, | 76 self.host_file_system_iterator, |
| 77 object_store_creator, | 77 object_store_creator, |
| 78 branch_utility, | 78 branch_utility, |
| 79 host_fs_at_trunk) | 79 host_fs_at_trunk) |
| 80 | 80 |
| 81 self.api_list_data_source_factory = APIListDataSource.Factory( | 81 self.api_list_data_source_factory = APIListDataSource.Factory( |
| 82 self.compiled_host_fs_factory, | 82 self.compiled_fs_factory, |
| 83 host_fs_at_trunk, | 83 host_fs_at_trunk, |
| 84 svn_constants.PUBLIC_TEMPLATE_PATH, | 84 svn_constants.PUBLIC_TEMPLATE_PATH, |
| 85 self.features_bundle, | 85 self.features_bundle, |
| 86 self.object_store_creator) | 86 self.object_store_creator) |
| 87 | 87 |
| 88 self.api_data_source_factory = APIDataSource.Factory( | 88 self.api_data_source_factory = APIDataSource.Factory( |
| 89 self.compiled_host_fs_factory, | 89 self.compiled_fs_factory, |
| 90 host_fs_at_trunk, |
| 90 svn_constants.API_PATH, | 91 svn_constants.API_PATH, |
| 91 self.availability_finder, | 92 self.availability_finder, |
| 92 branch_utility) | 93 branch_utility) |
| 93 | 94 |
| 94 self.ref_resolver_factory = ReferenceResolver.Factory( | 95 self.ref_resolver_factory = ReferenceResolver.Factory( |
| 95 self.api_data_source_factory, | 96 self.api_data_source_factory, |
| 96 self.api_list_data_source_factory, | 97 self.api_list_data_source_factory, |
| 97 object_store_creator) | 98 object_store_creator) |
| 98 | 99 |
| 99 self.api_data_source_factory.SetReferenceResolverFactory( | 100 self.api_data_source_factory.SetReferenceResolverFactory( |
| 100 self.ref_resolver_factory) | 101 self.ref_resolver_factory) |
| 101 | 102 |
| 102 # Note: samples are super slow in the dev server because it doesn't support | 103 # Note: samples are super slow in the dev server because it doesn't support |
| 103 # async fetch, so disable them. | 104 # async fetch, so disable them. |
| 104 if IsDevServer(): | 105 if IsDevServer(): |
| 105 extension_samples_fs = EmptyDirFileSystem() | 106 extension_samples_fs = EmptyDirFileSystem() |
| 106 else: | 107 else: |
| 107 extension_samples_fs = host_fs_at_trunk | 108 extension_samples_fs = host_fs_at_trunk |
| 108 self.samples_data_source_factory = SamplesDataSource.Factory( | 109 self.samples_data_source_factory = SamplesDataSource.Factory( |
| 109 extension_samples_fs, | 110 extension_samples_fs, |
| 110 CompiledFileSystem.Factory(extension_samples_fs, object_store_creator), | |
| 111 self.app_samples_file_system, | 111 self.app_samples_file_system, |
| 112 CompiledFileSystem.Factory(self.app_samples_file_system, | 112 CompiledFileSystem.Factory(object_store_creator), |
| 113 object_store_creator), | |
| 114 self.ref_resolver_factory, | 113 self.ref_resolver_factory, |
| 115 svn_constants.EXAMPLES_PATH, | 114 svn_constants.EXAMPLES_PATH, |
| 116 base_path) | 115 base_path) |
| 117 | 116 |
| 118 self.api_data_source_factory.SetSamplesDataSourceFactory( | 117 self.api_data_source_factory.SetSamplesDataSourceFactory( |
| 119 self.samples_data_source_factory) | 118 self.samples_data_source_factory) |
| 120 | 119 |
| 121 self.intro_data_source_factory = IntroDataSource.Factory( | 120 self.intro_data_source_factory = IntroDataSource.Factory( |
| 122 self.compiled_host_fs_factory, | 121 self.compiled_fs_factory, |
| 122 host_fs_at_trunk, |
| 123 self.ref_resolver_factory, | 123 self.ref_resolver_factory, |
| 124 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) | 124 [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH]) |
| 125 | 125 |
| 126 self.example_zipper = ExampleZipper( | 126 self.example_zipper = ExampleZipper( |
| 127 self.compiled_host_fs_factory, | 127 self.compiled_fs_factory, |
| 128 host_fs_at_trunk, | 128 host_fs_at_trunk, |
| 129 svn_constants.DOCS_PATH) | 129 svn_constants.DOCS_PATH) |
| 130 | 130 |
| 131 self.path_canonicalizer = PathCanonicalizer(self.compiled_host_fs_factory) | 131 self.path_canonicalizer = PathCanonicalizer( |
| 132 self.compiled_fs_factory, |
| 133 host_fs_at_trunk) |
| 132 | 134 |
| 133 self.redirector = Redirector( | 135 self.redirector = Redirector( |
| 134 self.compiled_host_fs_factory, | 136 self.compiled_fs_factory, |
| 135 host_fs_at_trunk, | 137 host_fs_at_trunk, |
| 136 svn_constants.PUBLIC_TEMPLATE_PATH) | 138 svn_constants.PUBLIC_TEMPLATE_PATH) |
| 137 | 139 |
| 138 self.strings_json_path = svn_constants.STRINGS_JSON_PATH | 140 self.strings_json_path = svn_constants.STRINGS_JSON_PATH |
| 139 self.manifest_json_path = svn_constants.MANIFEST_JSON_PATH | 141 self.manifest_json_path = svn_constants.MANIFEST_JSON_PATH |
| 140 self.manifest_features_path = svn_constants.MANIFEST_FEATURES_PATH | 142 self.manifest_features_path = svn_constants.MANIFEST_FEATURES_PATH |
| 141 | 143 |
| 142 self.template_data_source_factory = TemplateDataSource.Factory( | 144 self.template_data_source_factory = TemplateDataSource.Factory( |
| 143 self.api_data_source_factory, | 145 self.api_data_source_factory, |
| 144 self.api_list_data_source_factory, | 146 self.api_list_data_source_factory, |
| 145 self.intro_data_source_factory, | 147 self.intro_data_source_factory, |
| 146 self.samples_data_source_factory, | 148 self.samples_data_source_factory, |
| 147 self.compiled_host_fs_factory, | 149 self.compiled_fs_factory, |
| 150 host_fs_at_trunk, |
| 148 self.ref_resolver_factory, | 151 self.ref_resolver_factory, |
| 149 svn_constants.PUBLIC_TEMPLATE_PATH, | 152 svn_constants.PUBLIC_TEMPLATE_PATH, |
| 150 svn_constants.PRIVATE_TEMPLATE_PATH, | 153 svn_constants.PRIVATE_TEMPLATE_PATH, |
| 151 base_path) | 154 base_path) |
| 152 | 155 |
| 153 self.api_data_source_factory.SetTemplateDataSource( | 156 self.api_data_source_factory.SetTemplateDataSource( |
| 154 self.template_data_source_factory) | 157 self.template_data_source_factory) |
| 155 | 158 |
| 156 @staticmethod | 159 @staticmethod |
| 157 def ForTest(file_system, base_path='/'): | 160 def ForTest(file_system, base_path='/'): |
| 158 object_store_creator = ObjectStoreCreator.ForTest() | 161 object_store_creator = ObjectStoreCreator.ForTest() |
| 159 return ServerInstance(object_store_creator, | 162 return ServerInstance(object_store_creator, |
| 160 EmptyDirFileSystem(), | 163 EmptyDirFileSystem(), |
| 161 CompiledFileSystem.Factory(file_system, | 164 CompiledFileSystem.Factory(object_store_creator), |
| 162 object_store_creator), | |
| 163 TestBranchUtility.CreateWithCannedData(), | 165 TestBranchUtility.CreateWithCannedData(), |
| 164 HostFileSystemProvider.ForTest(file_system, | 166 HostFileSystemProvider.ForTest(file_system, |
| 165 object_store_creator), | 167 object_store_creator), |
| 166 base_path=base_path) | 168 base_path=base_path) |
| 167 | 169 |
| 168 @staticmethod | 170 @staticmethod |
| 169 def ForLocal(): | 171 def ForLocal(): |
| 170 object_store_creator = ObjectStoreCreator(start_empty=False, | 172 object_store_creator = ObjectStoreCreator(start_empty=False, |
| 171 store_type=TestObjectStore) | 173 store_type=TestObjectStore) |
| 172 host_file_system_provider = HostFileSystemProvider.ForLocal( | 174 host_file_system_provider = HostFileSystemProvider.ForLocal( |
| 173 object_store_creator) | 175 object_store_creator) |
| 174 return ServerInstance( | 176 return ServerInstance( |
| 175 object_store_creator, | 177 object_store_creator, |
| 176 EmptyDirFileSystem(), | 178 EmptyDirFileSystem(), |
| 177 CompiledFileSystem.Factory(host_file_system_provider.GetTrunk(), | 179 CompiledFileSystem.Factory(object_store_creator), |
| 178 object_store_creator), | |
| 179 TestBranchUtility.CreateWithCannedData(), | 180 TestBranchUtility.CreateWithCannedData(), |
| 180 host_file_system_provider) | 181 host_file_system_provider) |
| OLD | NEW |