Exemple #1
0
 def create_availability_finder(host_fs_creator):
     test_object_store = ObjectStoreCreator.ForTest()
     return AvailabilityFinder(
         self._branch_utility,
         CompiledFileSystem.Factory(test_object_store),
         HostFileSystemIterator(host_fs_creator, self._branch_utility),
         host_fs_creator.GetTrunk(), test_object_store)
 def _create_availability_finder(self, host_fs_creator, host_fs_iterator,
                                 platform):
     test_object_store = ObjectStoreCreator.ForTest()
     return AvailabilityFinder(
         self._branch_utility,
         CompiledFileSystem.Factory(test_object_store), host_fs_iterator,
         host_fs_creator.GetTrunk(), test_object_store, platform)
Exemple #3
0
 def create_availability_finder(file_system_data):
     fake_host_fs_creator = FakeHostFileSystemProvider(file_system_data)
     test_object_store = ObjectStoreCreator.ForTest()
     return AvailabilityFinder(
         self._branch_utility,
         CompiledFileSystem.Factory(test_object_store),
         HostFileSystemIterator(fake_host_fs_creator,
                                self._branch_utility),
         fake_host_fs_creator.GetTrunk(), test_object_store)
 def GetAvailabilityFinder(self, platform):
   if self._platform_data[platform].availability_finder is None:
     self._platform_data[platform].availability_finder = AvailabilityFinder(
         self._branch_utility,
         self._compiled_fs_factory,
         self._host_file_system_iterator,
         self._host_fs_at_trunk,
         self._object_store_creator,
         platform)
   return self._platform_data[platform].availability_finder
 def setUp(self):
     self._avail_ds_factory = AvailabilityFinder.Factory(
         ObjectStoreCreator.ForTest(),
         CompiledFileSystem.Factory(
             TestFileSystem(CANNED_API_FILE_SYSTEM_DATA['trunk']),
             ObjectStoreCreator.ForTest()),
         BranchUtility(
             os.path.join('branch_utility', 'first.json'),
             os.path.join('branch_utility', 'second.json'),
             FakeUrlFetcher(os.path.join(sys.path[0], 'test_data')),
             ObjectStoreCreator.ForTest()), _CreateCannedFileSystem)
     self._avail_ds = self._avail_ds_factory.Create()
Exemple #6
0
 def GetAvailabilityFinder(self, platform):
     if self._platform_data[platform].availability_finder is None:
         self._platform_data[
             platform].availability_finder = AvailabilityFinder(
                 self._branch_utility, self._compiled_fs_factory,
                 self._host_file_system_iterator, self._host_fs_at_master,
                 self._object_store_creator, platform,
                 SchemaProcessorFactory(
                     Future(callback=lambda: self.GetReferenceResolver(
                         platform)),
                     Future(callback=lambda: self.GetAPIModels(platform)),
                     Future(
                         callback=lambda: self.GetFeaturesBundle(platform)),
                     self._compiled_fs_factory, self._host_fs_at_master))
     return self._platform_data[platform].availability_finder
  def setUp(self):
    tabs_unmodified_versions = (16, 20, 23, 24)
    self._branch_utility = BranchUtility(
        os.path.join('branch_utility', 'first.json'),
        os.path.join('branch_utility', 'second.json'),
        FakeUrlFetcher(Server2Path('test_data')),
        ObjectStoreCreator.ForTest())
    self._node_fs_creator = FakeHostFileSystemProvider(TABS_SCHEMA_BRANCHES)
    self._node_fs_iterator = HostFileSystemIterator(self._node_fs_creator,
                                                    self._branch_utility)
    test_object_store = ObjectStoreCreator.ForTest()
    self._avail_finder = AvailabilityFinder(
        self._branch_utility,
        CompiledFileSystem.Factory(test_object_store),
        self._node_fs_iterator,
        self._node_fs_creator.GetMaster(),
        test_object_store,
        'extensions',
        SchemaProcessorFactoryForTest())

    server_instance = ServerInstance.ForTest(
        file_system_provider=FakeHostFileSystemProvider(
            TABS_SCHEMA_BRANCHES))
    self._api_models = server_instance.platform_bundle.GetAPIModels(
        'extensions')
    self._json_cache = server_instance.compiled_fs_factory.ForJson(
        server_instance.host_file_system_provider.GetMaster())

    # Imitate the actual SVN file system by incrementing the stats for paths
    # where an API schema has changed.
    last_stat = type('last_stat', (object,), {'val': 0})

    def stat_paths(file_system, channel_info):
      if channel_info.version not in tabs_unmodified_versions:
        last_stat.val += 1
      # HACK: |file_system| is a MockFileSystem backed by a TestFileSystem.
      # Increment the TestFileSystem stat count.
      file_system._file_system.IncrementStat(by=last_stat.val)
      # Continue looping. The iterator will stop after 'master' automatically.
      return True

    # Use the HostFileSystemIterator created above to change global stat values
    # for the TestFileSystems that it creates.
    self._node_fs_iterator.Ascending(
        # The earliest version represented with the tabs' test data is 13.
        self._branch_utility.GetStableChannelInfo(13),
        stat_paths)
    def __init__(self, object_store_creator, host_file_system,
                 app_samples_file_system, base_path, compiled_fs_factory,
                 branch_utility, host_file_system_creator):
        self.object_store_creator = object_store_creator

        self.host_file_system = host_file_system

        self.app_samples_file_system = app_samples_file_system

        self.compiled_host_fs_factory = compiled_fs_factory

        self.host_file_system_creator = host_file_system_creator

        self.availability_finder_factory = AvailabilityFinder.Factory(
            object_store_creator, self.compiled_host_fs_factory,
            branch_utility, host_file_system_creator)

        self.api_list_data_source_factory = APIListDataSource.Factory(
            self.compiled_host_fs_factory, self.host_file_system,
            svn_constants.API_PATH, svn_constants.PUBLIC_TEMPLATE_PATH)

        self.api_data_source_factory = APIDataSource.Factory(
            self.compiled_host_fs_factory, svn_constants.API_PATH,
            self.availability_finder_factory)

        self.ref_resolver_factory = ReferenceResolver.Factory(
            self.api_data_source_factory, self.api_list_data_source_factory,
            object_store_creator)

        self.api_data_source_factory.SetReferenceResolverFactory(
            self.ref_resolver_factory)

        # Note: samples are super slow in the dev server because it doesn't support
        # async fetch, so disable them.
        if IsDevServer():
            extension_samples_fs = EmptyDirFileSystem()
        else:
            extension_samples_fs = self.host_file_system
        self.samples_data_source_factory = SamplesDataSource.Factory(
            extension_samples_fs,
            CompiledFileSystem.Factory(extension_samples_fs,
                                       object_store_creator),
            self.app_samples_file_system,
            CompiledFileSystem.Factory(self.app_samples_file_system,
                                       object_store_creator),
            self.ref_resolver_factory, svn_constants.EXAMPLES_PATH, base_path)

        self.api_data_source_factory.SetSamplesDataSourceFactory(
            self.samples_data_source_factory)

        self.intro_data_source_factory = IntroDataSource.Factory(
            self.compiled_host_fs_factory, self.ref_resolver_factory,
            [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH])

        self.sidenav_data_source_factory = SidenavDataSource.Factory(
            self.compiled_host_fs_factory, svn_constants.JSON_PATH)

        self.manifest_data_source = ManifestDataSource(
            self.compiled_host_fs_factory, host_file_system, '/'.join(
                (svn_constants.JSON_PATH, 'manifest.json')), '/'.join(
                    (svn_constants.API_PATH, '_manifest_features.json')))

        self.template_data_source_factory = TemplateDataSource.Factory(
            self.api_data_source_factory, self.api_list_data_source_factory,
            self.intro_data_source_factory, self.samples_data_source_factory,
            self.sidenav_data_source_factory, self.compiled_host_fs_factory,
            self.ref_resolver_factory, self.manifest_data_source,
            svn_constants.PUBLIC_TEMPLATE_PATH,
            svn_constants.PRIVATE_TEMPLATE_PATH, base_path)

        self.api_data_source_factory.SetTemplateDataSource(
            self.template_data_source_factory)

        self.example_zipper = ExampleZipper(self.compiled_host_fs_factory,
                                            self.host_file_system,
                                            svn_constants.DOCS_PATH)

        self.path_canonicalizer = PathCanonicalizer(
            self.compiled_host_fs_factory)

        self.redirector = Redirector(self.compiled_host_fs_factory,
                                     self.host_file_system,
                                     svn_constants.PUBLIC_TEMPLATE_PATH)
  def __init__(self,
               object_store_creator,
               compiled_fs_factory,
               branch_utility,
               host_file_system_provider,
               github_file_system_provider,
               gcs_file_system_provider,
               base_path='/'):
    '''
    |object_store_creator|
        The ObjectStoreCreator used to create almost all caches.
    |compiled_fs_factory|
        Factory used to create CompiledFileSystems, a higher-level cache type
        than ObjectStores. This can usually be derived from just
        |object_store_creator| but under special circumstances a different
        implementation needs to be passed in.
    |branch_utility|
        Has knowledge of Chrome branches, channels, and versions.
    |host_file_system_provider|
        Creates FileSystem instances which host the server at alternative
        revisions.
    |github_file_system_provider|
        Creates FileSystem instances backed by GitHub.
    |base_path|
        The path which all HTML is generated relative to. Usually this is /
        but some servlets need to override this.
    '''
    self.object_store_creator = object_store_creator

    self.compiled_fs_factory = compiled_fs_factory

    self.host_file_system_provider = host_file_system_provider
    host_fs_at_trunk = host_file_system_provider.GetTrunk()

    self.github_file_system_provider = github_file_system_provider
    self.gcs_file_system_provider = gcs_file_system_provider

    assert base_path.startswith('/') and base_path.endswith('/')
    self.base_path = base_path

    self.host_file_system_iterator = HostFileSystemIterator(
        host_file_system_provider,
        branch_utility)

    self.features_bundle = FeaturesBundle(
        host_fs_at_trunk,
        self.compiled_fs_factory,
        self.object_store_creator)

    self.api_models = APIModels(
        self.features_bundle,
        self.compiled_fs_factory,
        host_fs_at_trunk)

    self.availability_finder = AvailabilityFinder(
        branch_utility,
        compiled_fs_factory,
        self.host_file_system_iterator,
        host_fs_at_trunk,
        object_store_creator)

    self.api_categorizer = APICategorizer(
        host_fs_at_trunk,
        compiled_fs_factory)

    self.api_data_source_factory = APIDataSource.Factory(
        self.compiled_fs_factory,
        host_fs_at_trunk,
        self.availability_finder,
        self.api_models,
        self.features_bundle,
        self.object_store_creator)

    self.ref_resolver_factory = ReferenceResolver.Factory(
        self.api_data_source_factory,
        self.api_models,
        object_store_creator)

    self.api_data_source_factory.SetReferenceResolverFactory(
        self.ref_resolver_factory)

    # Note: samples are super slow in the dev server because it doesn't support
    # async fetch, so disable them.
    if IsDevServer():
      extension_samples_fs = EmptyDirFileSystem()
      app_samples_fs = EmptyDirFileSystem()
    else:
      extension_samples_fs = host_fs_at_trunk
      # TODO(kalman): Re-enable the apps samples, see http://crbug.com/344097.
      app_samples_fs = EmptyDirFileSystem()
      #app_samples_fs = github_file_system_provider.Create(
      #    'GoogleChrome', 'chrome-app-samples')
    self.samples_data_source_factory = SamplesDataSource.Factory(
        extension_samples_fs,
        app_samples_fs,
        CompiledFileSystem.Factory(object_store_creator),
        self.ref_resolver_factory,
        base_path)

    self.api_data_source_factory.SetSamplesDataSourceFactory(
        self.samples_data_source_factory)

    self.content_providers = ContentProviders(
        object_store_creator,
        self.compiled_fs_factory,
        host_fs_at_trunk,
        self.github_file_system_provider,
        self.gcs_file_system_provider)

    # TODO(kalman): Move all the remaining DataSources into DataSourceRegistry,
    # then factor out the DataSource creation into a factory method, so that
    # the entire ServerInstance doesn't need to be passed in here.
    self.template_renderer = TemplateRenderer(self)

    # TODO(kalman): It may be better for |document_renderer| to construct a
    # TemplateDataSource itself rather than depending on template_renderer, but
    # for that the above todo should be addressed.
    self.document_renderer = DocumentRenderer(
        TableOfContentsRenderer(host_fs_at_trunk,
                                compiled_fs_factory,
                                self.template_renderer),
        self.ref_resolver_factory.Create())
Exemple #10
0
    def __init__(self,
                 object_store_creator,
                 compiled_fs_factory,
                 branch_utility,
                 host_file_system_provider,
                 github_file_system_provider,
                 base_path='/'):
        '''
    |object_store_creator|
        The ObjectStoreCreator used to create almost all caches.
    |compiled_fs_factory|
        Factory used to create CompiledFileSystems, a higher-level cache type
        than ObjectStores. This can usually be derived from just
        |object_store_creator| but under special circumstances a different
        implementation needs to be passed in.
    |branch_utility|
        Has knowledge of Chrome branches, channels, and versions.
    |host_file_system_provider|
        Creates FileSystem instances which host the server at alternative
        revisions.
    |github_file_system_provider|
        Creates FileSystem instances backed by GitHub.
    |base_path|
        The path which all HTML is generated relative to. Usually this is /
        but some servlets need to override this.
    '''
        self.object_store_creator = object_store_creator

        self.compiled_fs_factory = compiled_fs_factory

        self.host_file_system_provider = host_file_system_provider
        host_fs_at_trunk = host_file_system_provider.GetTrunk()

        self.github_file_system_provider = github_file_system_provider

        assert base_path.startswith('/') and base_path.endswith('/')
        self.base_path = base_path

        self.host_file_system_iterator = HostFileSystemIterator(
            host_file_system_provider, branch_utility)

        self.features_bundle = FeaturesBundle(host_fs_at_trunk,
                                              self.compiled_fs_factory,
                                              self.object_store_creator)

        self.api_models = APIModels(self.features_bundle,
                                    self.compiled_fs_factory, host_fs_at_trunk)

        self.availability_finder = AvailabilityFinder(
            branch_utility, compiled_fs_factory,
            self.host_file_system_iterator, host_fs_at_trunk,
            object_store_creator)

        self.api_list_data_source_factory = APIListDataSource.Factory(
            self.compiled_fs_factory, host_fs_at_trunk, self.features_bundle,
            self.object_store_creator)

        self.api_data_source_factory = APIDataSource.Factory(
            self.compiled_fs_factory, host_fs_at_trunk, svn_constants.API_PATH,
            self.availability_finder, branch_utility)

        self.ref_resolver_factory = ReferenceResolver.Factory(
            self.api_data_source_factory, self.api_models,
            object_store_creator)

        self.api_data_source_factory.SetReferenceResolverFactory(
            self.ref_resolver_factory)

        # Note: samples are super slow in the dev server because it doesn't support
        # async fetch, so disable them.
        if IsDevServer():
            extension_samples_fs = EmptyDirFileSystem()
            app_samples_fs = EmptyDirFileSystem()
        else:
            extension_samples_fs = host_fs_at_trunk
            app_samples_fs = github_file_system_provider.Create(
                'GoogleChrome', 'chrome-app-samples')
        self.samples_data_source_factory = SamplesDataSource.Factory(
            extension_samples_fs, app_samples_fs,
            CompiledFileSystem.Factory(object_store_creator),
            self.ref_resolver_factory, svn_constants.EXAMPLES_PATH, base_path)

        self.api_data_source_factory.SetSamplesDataSourceFactory(
            self.samples_data_source_factory)

        self.intro_data_source_factory = IntroDataSource.Factory(
            self.compiled_fs_factory, host_fs_at_trunk,
            self.ref_resolver_factory,
            [svn_constants.INTRO_PATH, svn_constants.ARTICLE_PATH])

        self.path_canonicalizer = PathCanonicalizer(self.compiled_fs_factory,
                                                    host_fs_at_trunk)

        self.content_providers = ContentProviders(
            self.compiled_fs_factory, host_fs_at_trunk,
            self.github_file_system_provider)

        # TODO(kalman): Move all the remaining DataSources into DataSourceRegistry,
        # then factor out the DataSource creation into a factory method, so that
        # the entire ServerInstance doesn't need to be passed in here.
        self.template_renderer = TemplateRenderer(self)

        self.strings_json_path = svn_constants.STRINGS_JSON_PATH
        self.manifest_json_path = svn_constants.MANIFEST_JSON_PATH
        self.manifest_features_path = svn_constants.MANIFEST_FEATURES_PATH