| 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_categorizer import APICategorizer | 5 from api_categorizer import APICategorizer |
| 6 from api_data_source import APIDataSource | 6 from api_data_source import APIDataSource |
| 7 from api_list_data_source import APIListDataSource | 7 from api_list_data_source import APIListDataSource |
| 8 from api_models import APIModels | 8 from api_models import APIModels |
| 9 from availability_finder import AvailabilityFinder | 9 from availability_finder import AvailabilityFinder |
| 10 from compiled_file_system import CompiledFileSystem | 10 from compiled_file_system import CompiledFileSystem |
| 11 from content_providers import ContentProviders | 11 from content_providers import ContentProviders |
| 12 from document_renderer import DocumentRenderer | 12 from document_renderer import DocumentRenderer |
| 13 from empty_dir_file_system import EmptyDirFileSystem | 13 from empty_dir_file_system import EmptyDirFileSystem |
| 14 from environment import IsDevServer | 14 from environment import IsDevServer |
| 15 from features_bundle import FeaturesBundle | 15 from features_bundle import FeaturesBundle |
| 16 from gcs_file_system_provider import CloudStorageFileSystemProvider |
| 16 from github_file_system_provider import GithubFileSystemProvider | 17 from github_file_system_provider import GithubFileSystemProvider |
| 18 from host_file_system_iterator import HostFileSystemIterator |
| 17 from host_file_system_provider import HostFileSystemProvider | 19 from host_file_system_provider import HostFileSystemProvider |
| 18 from host_file_system_iterator import HostFileSystemIterator | |
| 19 from object_store_creator import ObjectStoreCreator | 20 from object_store_creator import ObjectStoreCreator |
| 20 from reference_resolver import ReferenceResolver | 21 from reference_resolver import ReferenceResolver |
| 21 from samples_data_source import SamplesDataSource | 22 from samples_data_source import SamplesDataSource |
| 22 from table_of_contents_renderer import TableOfContentsRenderer | 23 from table_of_contents_renderer import TableOfContentsRenderer |
| 23 from template_renderer import TemplateRenderer | 24 from template_renderer import TemplateRenderer |
| 24 from test_branch_utility import TestBranchUtility | 25 from test_branch_utility import TestBranchUtility |
| 25 from test_object_store import TestObjectStore | 26 from test_object_store import TestObjectStore |
| 26 | 27 |
| 27 | 28 |
| 28 class ServerInstance(object): | 29 class ServerInstance(object): |
| 29 | 30 |
| 30 def __init__(self, | 31 def __init__(self, |
| 31 object_store_creator, | 32 object_store_creator, |
| 32 compiled_fs_factory, | 33 compiled_fs_factory, |
| 33 branch_utility, | 34 branch_utility, |
| 34 host_file_system_provider, | 35 host_file_system_provider, |
| 35 github_file_system_provider, | 36 github_file_system_provider, |
| 37 gcs_file_system_provider, |
| 36 base_path='/'): | 38 base_path='/'): |
| 37 ''' | 39 ''' |
| 38 |object_store_creator| | 40 |object_store_creator| |
| 39 The ObjectStoreCreator used to create almost all caches. | 41 The ObjectStoreCreator used to create almost all caches. |
| 40 |compiled_fs_factory| | 42 |compiled_fs_factory| |
| 41 Factory used to create CompiledFileSystems, a higher-level cache type | 43 Factory used to create CompiledFileSystems, a higher-level cache type |
| 42 than ObjectStores. This can usually be derived from just | 44 than ObjectStores. This can usually be derived from just |
| 43 |object_store_creator| but under special circumstances a different | 45 |object_store_creator| but under special circumstances a different |
| 44 implementation needs to be passed in. | 46 implementation needs to be passed in. |
| 45 |branch_utility| | 47 |branch_utility| |
| 46 Has knowledge of Chrome branches, channels, and versions. | 48 Has knowledge of Chrome branches, channels, and versions. |
| 47 |host_file_system_provider| | 49 |host_file_system_provider| |
| 48 Creates FileSystem instances which host the server at alternative | 50 Creates FileSystem instances which host the server at alternative |
| 49 revisions. | 51 revisions. |
| 50 |github_file_system_provider| | 52 |github_file_system_provider| |
| 51 Creates FileSystem instances backed by GitHub. | 53 Creates FileSystem instances backed by GitHub. |
| 52 |base_path| | 54 |base_path| |
| 53 The path which all HTML is generated relative to. Usually this is / | 55 The path which all HTML is generated relative to. Usually this is / |
| 54 but some servlets need to override this. | 56 but some servlets need to override this. |
| 55 ''' | 57 ''' |
| 56 self.object_store_creator = object_store_creator | 58 self.object_store_creator = object_store_creator |
| 57 | 59 |
| 58 self.compiled_fs_factory = compiled_fs_factory | 60 self.compiled_fs_factory = compiled_fs_factory |
| 59 | 61 |
| 60 self.host_file_system_provider = host_file_system_provider | 62 self.host_file_system_provider = host_file_system_provider |
| 61 host_fs_at_trunk = host_file_system_provider.GetTrunk() | 63 host_fs_at_trunk = host_file_system_provider.GetTrunk() |
| 62 | 64 |
| 63 self.github_file_system_provider = github_file_system_provider | 65 self.github_file_system_provider = github_file_system_provider |
| 66 self.gcs_file_system_provider = gcs_file_system_provider |
| 64 | 67 |
| 65 assert base_path.startswith('/') and base_path.endswith('/') | 68 assert base_path.startswith('/') and base_path.endswith('/') |
| 66 self.base_path = base_path | 69 self.base_path = base_path |
| 67 | 70 |
| 68 self.host_file_system_iterator = HostFileSystemIterator( | 71 self.host_file_system_iterator = HostFileSystemIterator( |
| 69 host_file_system_provider, | 72 host_file_system_provider, |
| 70 branch_utility) | 73 branch_utility) |
| 71 | 74 |
| 72 self.features_bundle = FeaturesBundle( | 75 self.features_bundle = FeaturesBundle( |
| 73 host_fs_at_trunk, | 76 host_fs_at_trunk, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 CompiledFileSystem.Factory(object_store_creator), | 132 CompiledFileSystem.Factory(object_store_creator), |
| 130 self.ref_resolver_factory, | 133 self.ref_resolver_factory, |
| 131 base_path) | 134 base_path) |
| 132 | 135 |
| 133 self.api_data_source_factory.SetSamplesDataSourceFactory( | 136 self.api_data_source_factory.SetSamplesDataSourceFactory( |
| 134 self.samples_data_source_factory) | 137 self.samples_data_source_factory) |
| 135 | 138 |
| 136 self.content_providers = ContentProviders( | 139 self.content_providers = ContentProviders( |
| 137 self.compiled_fs_factory, | 140 self.compiled_fs_factory, |
| 138 host_fs_at_trunk, | 141 host_fs_at_trunk, |
| 139 self.github_file_system_provider) | 142 self.github_file_system_provider, |
| 143 self.gcs_file_system_provider) |
| 140 | 144 |
| 141 # TODO(kalman): Move all the remaining DataSources into DataSourceRegistry, | 145 # TODO(kalman): Move all the remaining DataSources into DataSourceRegistry, |
| 142 # then factor out the DataSource creation into a factory method, so that | 146 # then factor out the DataSource creation into a factory method, so that |
| 143 # the entire ServerInstance doesn't need to be passed in here. | 147 # the entire ServerInstance doesn't need to be passed in here. |
| 144 self.template_renderer = TemplateRenderer(self) | 148 self.template_renderer = TemplateRenderer(self) |
| 145 | 149 |
| 146 # TODO(kalman): It may be better for |document_renderer| to construct a | 150 # TODO(kalman): It may be better for |document_renderer| to construct a |
| 147 # TemplateDataSource itself rather than depending on template_renderer, but | 151 # TemplateDataSource itself rather than depending on template_renderer, but |
| 148 # for that the above todo should be addressed. | 152 # for that the above todo should be addressed. |
| 149 self.document_renderer = DocumentRenderer( | 153 self.document_renderer = DocumentRenderer( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 163 'can be specified') | 167 'can be specified') |
| 164 if file_system_provider is None: | 168 if file_system_provider is None: |
| 165 file_system_provider = HostFileSystemProvider.ForTest( | 169 file_system_provider = HostFileSystemProvider.ForTest( |
| 166 file_system, | 170 file_system, |
| 167 object_store_creator) | 171 object_store_creator) |
| 168 return ServerInstance(object_store_creator, | 172 return ServerInstance(object_store_creator, |
| 169 CompiledFileSystem.Factory(object_store_creator), | 173 CompiledFileSystem.Factory(object_store_creator), |
| 170 TestBranchUtility.CreateWithCannedData(), | 174 TestBranchUtility.CreateWithCannedData(), |
| 171 file_system_provider, | 175 file_system_provider, |
| 172 GithubFileSystemProvider.ForEmpty(), | 176 GithubFileSystemProvider.ForEmpty(), |
| 177 CloudStorageFileSystemProvider(object_store_creator), |
| 173 base_path=base_path) | 178 base_path=base_path) |
| 174 | 179 |
| 175 @staticmethod | 180 @staticmethod |
| 176 def ForLocal(): | 181 def ForLocal(): |
| 177 object_store_creator = ObjectStoreCreator(start_empty=False, | 182 object_store_creator = ObjectStoreCreator(start_empty=False, |
| 178 store_type=TestObjectStore) | 183 store_type=TestObjectStore) |
| 179 host_file_system_provider = HostFileSystemProvider.ForLocal( | 184 host_file_system_provider = HostFileSystemProvider.ForLocal( |
| 180 object_store_creator) | 185 object_store_creator) |
| 181 return ServerInstance( | 186 return ServerInstance( |
| 182 object_store_creator, | 187 object_store_creator, |
| 183 CompiledFileSystem.Factory(object_store_creator), | 188 CompiledFileSystem.Factory(object_store_creator), |
| 184 TestBranchUtility.CreateWithCannedData(), | 189 TestBranchUtility.CreateWithCannedData(), |
| 185 host_file_system_provider, | 190 host_file_system_provider, |
| 186 GithubFileSystemProvider.ForEmpty()) | 191 GithubFileSystemProvider.ForEmpty(), |
| 192 CloudStorageFileSystemProvider(object_store_creator)) |
| OLD | NEW |