| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 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. |
| 4 |
| 5 import hashlib |
| 6 |
| 7 from google.appengine.ext import ndb |
| 8 |
| 9 from model.crash.crash_analysis import CrashAnalysis |
| 10 |
| 11 |
| 12 class FracasCrashAnalysis(CrashAnalysis): |
| 13 """Represents an analysis of a Chrome crash.""" |
| 14 # Data of crash per million page loads for each Chrome version. |
| 15 versions_to_cpm = ndb.JsonProperty(indexed=False) |
| 16 |
| 17 def Reset(self): |
| 18 super(FracasCrashAnalysis, self).Reset() |
| 19 self.versions_to_cpm = None |
| 20 |
| 21 @ndb.ComputedProperty |
| 22 def channel(self): |
| 23 return self.key.pairs()[0][1].split('/')[0] |
| 24 |
| 25 @ndb.ComputedProperty |
| 26 def platform(self): |
| 27 return self.key.pairs()[0][1].split('/')[1] |
| 28 |
| 29 @staticmethod |
| 30 def _CreateKey(channel, platform, signature): |
| 31 # Use sha1 hex digest of signature to avoid char conflict with '/'. |
| 32 return ndb.Key('FracasCrashAnalysis', '%s/%s/%s' % ( |
| 33 channel, platform, hashlib.sha1(signature).hexdigest())) |
| 34 |
| 35 @classmethod |
| 36 def Get(cls, channel, platform, signature): |
| 37 return cls._CreateKey(channel, platform, signature).get() |
| 38 |
| 39 @classmethod |
| 40 def Create(cls, channel, platform, signature): |
| 41 analysis = cls(key=cls._CreateKey(channel, platform, signature)) |
| 42 analysis.signature = signature |
| 43 return analysis |
| OLD | NEW |