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 fnmatch import fnmatch | 5 from fnmatch import fnmatch |
6 import mimetypes | 6 import mimetypes |
7 import os | |
8 | 7 |
9 from api_data_source import APIDataSource | 8 from api_data_source import APIDataSource |
10 from api_list_data_source import APIListDataSource | 9 from api_list_data_source import APIListDataSource |
11 from appengine_blobstore import AppEngineBlobstore | 10 from appengine_blobstore import AppEngineBlobstore |
12 from appengine_url_fetcher import AppEngineUrlFetcher | 11 from appengine_url_fetcher import AppEngineUrlFetcher |
| 12 from availability_data_source import AvailabilityDataSource |
13 from branch_utility import BranchUtility | 13 from branch_utility import BranchUtility |
| 14 from chrome_version_utility import ChromeVersionUtility |
14 from compiled_file_system import CompiledFileSystem | 15 from compiled_file_system import CompiledFileSystem |
15 from example_zipper import ExampleZipper | 16 from example_zipper import ExampleZipper |
16 from file_system import FileNotFoundError | 17 from file_system import FileNotFoundError |
17 from github_file_system import GithubFileSystem | 18 from github_file_system import GithubFileSystem |
18 from in_memory_object_store import InMemoryObjectStore | 19 from in_memory_object_store import InMemoryObjectStore |
19 from intro_data_source import IntroDataSource | 20 from intro_data_source import IntroDataSource |
20 from local_file_system import LocalFileSystem | 21 from local_file_system import LocalFileSystem |
21 from caching_file_system import CachingFileSystem | 22 from caching_file_system import CachingFileSystem |
22 from object_store_creator import ObjectStoreCreator | 23 from object_store_creator import ObjectStoreCreator |
23 from path_canonicalizer import PathCanonicalizer | 24 from path_canonicalizer import PathCanonicalizer |
(...skipping 17 matching lines...) Expand all Loading... |
41 | 42 |
42 branch_utility = None | 43 branch_utility = None |
43 github_file_system = None | 44 github_file_system = None |
44 | 45 |
45 @staticmethod | 46 @staticmethod |
46 def GetOrCreate(channel): | 47 def GetOrCreate(channel): |
47 # Lazily create so that we don't do unnecessary work in tests. | 48 # Lazily create so that we don't do unnecessary work in tests. |
48 if ServerInstance.branch_utility is None: | 49 if ServerInstance.branch_utility is None: |
49 ServerInstance.branch_utility = BranchUtility( | 50 ServerInstance.branch_utility = BranchUtility( |
50 url_constants.OMAHA_PROXY_URL, AppEngineUrlFetcher()) | 51 url_constants.OMAHA_PROXY_URL, AppEngineUrlFetcher()) |
51 branch = ServerInstance.branch_utility.GetBranchNumberForChannelName( | 52 |
52 channel) | 53 branch = ServerInstance.branch_utility.GetChannelInfoForChannelName( |
| 54 channel)['branch'] |
53 | 55 |
54 # Use the branch as the key to |_instances| since the branch data is | 56 # Use the branch as the key to |_instances| since the branch data is |
55 # predictable while the channel data (channels can swich branches) isn't. | 57 # predictable while the channel data (channels can swich branches) isn't. |
56 instance = ServerInstance._instances.get(branch) | 58 instance = ServerInstance._instances.get(branch) |
57 if instance is None: | 59 if instance is None: |
58 instance = ServerInstance._CreateForProduction(channel, branch) | 60 instance = ServerInstance._CreateForProduction(channel, branch) |
59 ServerInstance._instances[branch] = instance | 61 ServerInstance._instances[branch] = instance |
60 return instance | 62 return instance |
61 | 63 |
62 @staticmethod | 64 @staticmethod |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 svn_file_system, | 108 svn_file_system, |
107 github_file_system): | 109 github_file_system): |
108 self.svn_file_system = svn_file_system | 110 self.svn_file_system = svn_file_system |
109 | 111 |
110 self.github_file_system = github_file_system | 112 self.github_file_system = github_file_system |
111 | 113 |
112 self.compiled_fs_factory = CompiledFileSystem.Factory( | 114 self.compiled_fs_factory = CompiledFileSystem.Factory( |
113 svn_file_system, | 115 svn_file_system, |
114 object_store_creator_factory) | 116 object_store_creator_factory) |
115 | 117 |
| 118 self.chrome_version_utility = ChromeVersionUtility( |
| 119 url_constants.OMAHA_DEV_HISTORY, |
| 120 AppEngineUrlFetcher(None)) |
| 121 |
| 122 self.availability_data_source_factory = AvailabilityDataSource.Factory( |
| 123 self.chrome_version_utility, |
| 124 svn_file_system) |
| 125 |
116 self.api_list_data_source_factory = APIListDataSource.Factory( | 126 self.api_list_data_source_factory = APIListDataSource.Factory( |
117 self.compiled_fs_factory, | 127 self.compiled_fs_factory, |
118 svn_constants.API_PATH, | 128 svn_constants.API_PATH, |
119 svn_constants.PUBLIC_TEMPLATE_PATH) | 129 svn_constants.PUBLIC_TEMPLATE_PATH) |
120 | 130 |
121 self.api_data_source_factory = APIDataSource.Factory( | 131 self.api_data_source_factory = APIDataSource.Factory( |
122 self.compiled_fs_factory, | 132 self.compiled_fs_factory, |
123 svn_constants.API_PATH) | 133 svn_constants.API_PATH, |
| 134 self.availability_data_source_factory) |
124 | 135 |
125 self.ref_resolver_factory = ReferenceResolver.Factory( | 136 self.ref_resolver_factory = ReferenceResolver.Factory( |
126 self.api_data_source_factory, | 137 self.api_data_source_factory, |
127 self.api_list_data_source_factory, | 138 self.api_list_data_source_factory, |
128 object_store_creator_factory) | 139 object_store_creator_factory) |
129 | 140 |
130 self.api_data_source_factory.SetReferenceResolverFactory( | 141 self.api_data_source_factory.SetReferenceResolverFactory( |
131 self.ref_resolver_factory) | 142 self.ref_resolver_factory) |
132 | 143 |
133 self.samples_data_source_factory = SamplesDataSource.Factory( | 144 self.samples_data_source_factory = SamplesDataSource.Factory( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 elif path.endswith('.html'): | 227 elif path.endswith('.html'): |
217 content = templates.Render(path) | 228 content = templates.Render(path) |
218 | 229 |
219 response.headers['x-frame-options'] = 'sameorigin' | 230 response.headers['x-frame-options'] = 'sameorigin' |
220 if content: | 231 if content: |
221 response.headers['cache-control'] = 'max-age=300' | 232 response.headers['cache-control'] = 'max-age=300' |
222 response.out.write(content) | 233 response.out.write(content) |
223 else: | 234 else: |
224 response.set_status(404); | 235 response.set_status(404); |
225 response.out.write(templates.Render('404')) | 236 response.out.write(templates.Render('404')) |
OLD | NEW |