Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: tools/android/loading/loading_trace_database.py

Issue 1969373002: tools/android/loading Move LoadingTraceDatabase under cloud/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@report
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/android/loading/loading_trace_database.py
diff --git a/tools/android/loading/loading_trace_database.py b/tools/android/loading/loading_trace_database.py
deleted file mode 100644
index f6e946a2df197bf6ddc5faa520ee346ede80aa5e..0000000000000000000000000000000000000000
--- a/tools/android/loading/loading_trace_database.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2016 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.
-
-"""Represents a database of on-disk traces."""
-
-import json
-
-
-class LoadingTraceDatabase(object):
- def __init__(self, traces_dict):
- """traces_dict is a dictionary mapping filenames of traces to metadata
- about those traces."""
- self._traces_dict = traces_dict
-
- def SetTrace(self, filename, trace_dict):
- """Sets a mapping from |filename| to |trace_dict| into the database.
- If there is an existing mapping for filename, it is replaced.
- """
- self._traces_dict[filename] = trace_dict
-
- def GetTraceFilesForURL(self, url):
- """Given a URL, returns the set of filenames of traces that were generated
- for this URL."""
- trace_files = [f for f in self._traces_dict.keys()
- if self._traces_dict[f]["url"] == url]
- return trace_files
-
- def ToJsonDict(self):
- """Returns a dict representing this instance."""
- return self._traces_dict
-
- def ToJsonString(self):
- """Returns a string representing this instance."""
- return json.dumps(self._traces_dict, indent=2)
-
- def ToJsonFile(self, json_path):
- """Saves a json file representing this instance."""
- json_dict = self.ToJsonDict()
- with open(json_path, 'w') as output_file:
- json.dump(json_dict, output_file, indent=2)
-
- @classmethod
- def FromJsonDict(cls, json_dict):
- """Returns an instance from a dict returned by ToJsonDict()."""
- return LoadingTraceDatabase(json_dict)
-
- @classmethod
- def FromJsonString(cls, json_string):
- """Returns an instance from a string returned by ToJsonString()."""
- return LoadingTraceDatabase(json.loads(json_string))
-
- @classmethod
- def FromJsonFile(cls, json_path):
- """Returns an instance from a json file saved by ToJsonFile()."""
- with open(json_path) as input_file:
- return cls.FromJsonDict(json.load(input_file))

Powered by Google App Engine
This is Rietveld 408576698