Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import hashlib | 5 import hashlib |
| 6 | 6 |
| 7 from google.appengine.ext import ndb | 7 from google.appengine.ext import ndb |
| 8 | 8 |
| 9 from model.crash.crash_analysis import CrashAnalysis | 9 from model.crash.crash_analysis import CrashAnalysis |
| 10 | 10 |
| 11 | 11 |
| 12 class FracasCrashAnalysis(CrashAnalysis): | 12 class FracasCrashAnalysis(CrashAnalysis): |
| 13 """Represents an analysis of a Chrome crash.""" | 13 """Represents an analysis of a Chrome crash.""" |
| 14 # Data of crash per million page loads for each Chrome version. | 14 # Customized properties for Fracas crash. |
| 15 versions_to_cpm = ndb.JsonProperty(indexed=False) | 15 historic_metadata = ndb.JsonProperty(indexed=False) |
| 16 channel = ndb.StringProperty(indexed=False) | |
| 16 | 17 |
| 17 def Reset(self): | 18 def Reset(self): |
| 18 super(FracasCrashAnalysis, self).Reset() | 19 super(FracasCrashAnalysis, self).Reset() |
| 19 self.versions_to_cpm = None | 20 self.historic_metadata = None |
| 20 | 21 self.channel = None |
| 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 | 22 |
| 29 @staticmethod | 23 @staticmethod |
| 30 def _CreateKey(channel, platform, signature): | 24 def _CreateKey(crash_identifiers): |
| 31 # Use sha1 hex digest of signature to avoid char conflict with '/'. | 25 # Use sha1 hex digest of signature to avoid char conflict with '/'. |
| 32 return ndb.Key('FracasCrashAnalysis', '%s/%s/%s' % ( | 26 return ndb.Key('FracasCrashAnalysis', '%s/%s/%s/%s/%s' % ( |
| 33 channel, platform, hashlib.sha1(signature).hexdigest())) | 27 crash_identifiers['channel'], crash_identifiers['platform'], |
|
stgao
2016/05/04 00:12:10
This solution is allergy to change of crash identi
Sharu Jiang
2016/05/04 00:57:17
Done.
| |
| 28 hashlib.sha1(crash_identifiers['signature']).hexdigest(), | |
| 29 crash_identifiers['chrome_version'], | |
| 30 crash_identifiers[ | |
| 31 'process_type'] if crash_identifiers['process_type'] else '')) | |
| 34 | 32 |
| 35 @classmethod | 33 @classmethod |
| 36 def Get(cls, channel, platform, signature): | 34 def Get(cls, crash_identifiers): |
| 37 return cls._CreateKey(channel, platform, signature).get() | 35 return cls._CreateKey(crash_identifiers).get() |
| 38 | 36 |
| 39 @classmethod | 37 @classmethod |
| 40 def Create(cls, channel, platform, signature): | 38 def Create(cls, crash_identifiers): |
| 41 analysis = cls(key=cls._CreateKey(channel, platform, signature)) | 39 analysis = cls(key=cls._CreateKey(crash_identifiers)) |
| 42 analysis.signature = signature | |
| 43 return analysis | 40 return analysis |
| OLD | NEW |