[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / page_sets / extension_profile_shared_state.py
blob2aa1dad3c1e3d730859e461aa2b537f2f166a229
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import shutil
7 from profile_creators import extension_profile_extender
8 from profile_creators import profile_generator
9 from telemetry.page import shared_page_state
12 class ExtensionProfileSharedState(shared_page_state.SharedPageState):
13 """Shared state tied with extension profile.
15 Generates extension profile on initialization.
16 """
18 def __init__(self, test, finder_options, story_set):
19 super(ExtensionProfileSharedState, self).__init__(
20 test, finder_options, story_set)
21 generator = profile_generator.ProfileGenerator(
22 extension_profile_extender.ExtensionProfileExtender,
23 'extension_profile')
24 self._out_dir = generator.Run(finder_options)
25 if self._out_dir:
26 finder_options.browser_options.profile_dir = self._out_dir
27 else:
28 finder_options.browser_options.dont_override_profile = True
30 def TearDownState(self):
31 """Clean up generated profile directory."""
32 super(ExtensionProfileSharedState, self).TearDownState()
33 if self._out_dir:
34 shutil.rmtree(self._out_dir)