Add IDs to Telemetry Pages.

For outputting Telemtry results as JSON, we will want to be able to refer to a
Page by an ID that uniquely identifies it within a page set. This CL puts that
machinery in place.

R=nduca, dtu
BUG=375541

Review URL: https://codereview.chromium.org/384483002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282178 0039d316-1c4b-4281-b951-d872f2087c98
parent 8fa08490
......@@ -7,8 +7,10 @@ import os
import re
import urlparse
_next_page_id = 0
class Page(object):
def __init__(self, url, page_set=None, base_dir=None, name=''):
self._url = url
self._page_set = page_set
......@@ -19,6 +21,10 @@ class Page(object):
self._base_dir = base_dir
self._name = name
global _next_page_id
self._id = _next_page_id
_next_page_id += 1
# These attributes can be set dynamically by the page.
self.synthetic_delays = dict()
self.startup_url = page_set.startup_url if page_set else ''
......@@ -63,6 +69,10 @@ class Page(object):
def url(self):
return self._url
@property
def id(self):
return self._id
def GetSyntheticDelayCategories(self):
result = []
for delay, options in self.synthetic_delays.items():
......
......@@ -115,3 +115,8 @@ class TestPage(unittest.TestCase):
ps.AddPageWithDefaultRunNavigate('file://../../otherdir/foo')
self.assertEquals(ps[0].display_name, 'foo')
def testPagesHaveDifferentIds(self):
p = page.Page("http://example.com")
p2 = page.Page("http://example.com")
self.assertNotEqual(p.id, p2.id)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment