summaryrefslogtreecommitdiffstats
path: root/tools/perf/profile_creators/small_profile_extender.py
blob: ff9a793af3ba8c7b4226e79aeba81bc3a7e17484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import page_sets

from profile_creators import fast_navigation_profile_extender


class SmallProfileExtender(
    fast_navigation_profile_extender.FastNavigationProfileExtender):
  """Creates a small profile by performing 25 navigations."""

  def __init__(self, finder_options):
    # Use exactly 5 tabs to generate the profile. This is because consumers of
    # this profile will perform a session restore, and expect 5 restored tabs.
    maximum_batch_size = 5
    super(SmallProfileExtender, self).__init__(
        finder_options, maximum_batch_size)

    # Get the list of urls from the typical 25 page set.
    self._page_set = page_sets.Typical25PageSet()
    urls = []
    for user_story in self._page_set.user_stories:
      urls.append(user_story.url)
    self._navigation_urls = urls

  def GetUrlIterator(self):
    """Superclass override."""
    return iter(self._navigation_urls)

  def ShouldExitAfterBatchNavigation(self):
    """Superclass override."""
    return False

  def WebPageReplayArchivePath(self):
    """Superclass override."""
    return self._page_set.WprFilePathForUserStory(
        self._page_set.user_stories[0])

  def FetchWebPageReplayArchives(self):
    """Superclass override."""
    self._page_set.wpr_archive_info.DownloadArchivesIfNeeded()