Ejemplo n.º 1
0
 def BuildOriginalWpr():
     common_util.EnsureParentDirectoryExists(BuildOriginalWpr.path)
     runner = self.CreateSandwichRunner()
     runner.wpr_archive_path = BuildOriginalWpr.path
     runner.wpr_record = True
     runner.output_dir = BuildOriginalWpr.run_path
     runner.Run()
Ejemplo n.º 2
0
    def SetupBenchmark():
      whitelisted_urls = _ExtractDiscoverableUrls(
          original_headers_path=self._original_headers_path,
          loading_trace_path=self._trace_from_grabbing_reference_cache,
          subresource_discoverer=subresource_discoverer)

      common_util.EnsureParentDirectoryExists(SetupBenchmark.path)
      with open(SetupBenchmark.path, 'w') as output:
        json.dump({
            'cache_whitelist': [url for url in whitelisted_urls],
            'subresource_discoverer': subresource_discoverer,
          }, output)
    def BuildPatchedWpr():
      common_util.EnsureParentDirectoryExists(BuildPatchedWpr.path)
      shutil.copyfile(
          self._common_builder.original_wpr_task.path, BuildPatchedWpr.path)
      wpr_archive = wpr_backend.WprArchiveBackend(BuildPatchedWpr.path)

      # Save up original response headers.
      original_response_headers = {e.url: e.GetResponseHeadersDict() \
          for e in wpr_archive.ListUrlEntries()}
      with open(self._original_headers_path, 'w') as file_output:
        json.dump(original_response_headers, file_output)

      # Patch WPR.
      _PatchWpr(wpr_archive)
      wpr_archive.Persist()
Ejemplo n.º 4
0
    def SetupBenchmark():
      trace_path = os.path.join(self._subresources_for_urls_run_task.path, '0',
                                sandwich_runner.TRACE_FILENAME)
      whitelisted_urls = sandwich_misc.ExtractDiscoverableUrls(
          trace_path, subresource_discoverer)

      urls_resources = json.load(open(self._subresources_for_urls_task.path))
      # TODO(gabadie): Implement support for multiple URLs in this Task.
      assert len(urls_resources) == 1
      url = urls_resources.keys()[0]
      url_resources = urls_resources[url]
      common_util.EnsureParentDirectoryExists(SetupBenchmark.path)
      with open(SetupBenchmark.path, 'w') as output:
        json.dump({
            'cache_whitelist': [url for url in whitelisted_urls],
            'subresource_discoverer': subresource_discoverer,
            'url_resources': url_resources,
          }, output)
Ejemplo n.º 5
0
 def BuildPatchedWpr():
   common_util.EnsureParentDirectoryExists(BuildPatchedWpr.path)
   shutil.copyfile(self._original_wpr_task.path, BuildPatchedWpr.path)
   sandwich_misc.PatchWpr(BuildPatchedWpr.path)