| 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 logging | 5 import logging |
| 6 | 6 |
| 7 from crash.occurrence import RankByOccurrence | 7 from crash.occurrence import RankByOccurrence |
| 8 from crash.project import Project | 8 from crash.project import Project |
| 9 from crash.type_enums import LanguageType | 9 from crash.type_enums import LanguageType |
| 10 from model.crash.crash_config import CrashConfig | 10 from model.crash.crash_config import CrashConfig |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 Args: | 41 Args: |
| 42 suspects (list of Suspect): culprit suspects. | 42 suspects (list of Suspect): culprit suspects. |
| 43 | 43 |
| 44 Returns: | 44 Returns: |
| 45 The name of the most-suspected project; or the empty string on failure. | 45 The name of the most-suspected project; or the empty string on failure. |
| 46 """ | 46 """ |
| 47 rank_function = None | 47 rank_function = None |
| 48 if crash_stack.language_type == LanguageType.JAVA: | 48 if crash_stack.language_type == LanguageType.JAVA: |
| 49 def RankFunctionForJava(occurrence): | 49 def RankFunctionForJava(occurrence): |
| 50 # TODO(wrengr): why are we weighting by the length, instead of | 50 if 'chromium' in occurrence.name: |
| 51 # the negative length as we do in the DefaultOccurrenceRanging? | |
| 52 weight = len(occurrence) | |
| 53 project_name = occurrence.name | |
| 54 if 'chromium' in project_name: | |
| 55 index = 0 | 51 index = 0 |
| 56 else: | 52 else: |
| 57 index = self.non_chromium_project_rank_priority[project_name] | 53 index = self.non_chromium_project_rank_priority[occurrence.name] |
| 58 return (weight, index) | 54 return -len(occurrence), index |
| 59 | 55 |
| 60 rank_function = RankFunctionForJava | 56 rank_function = RankFunctionForJava |
| 61 | 57 |
| 62 def GetProjectFromStackFrame(frame): | 58 def GetProjectFromStackFrame(frame): |
| 63 """Determine which project is responsible for this frame.""" | 59 """Determine which project is responsible for this frame.""" |
| 64 for project in self.projects: | 60 for project in self.projects: |
| 65 if project.MatchesStackFrame(frame): | 61 if project.MatchesStackFrame(frame): |
| 66 return project.GetName(frame.dep_path) | 62 return project.GetName(frame.dep_path) |
| 67 | 63 |
| 68 return None | 64 return None |
| (...skipping 26 matching lines...) Expand all Loading... |
| 95 | 91 |
| 96 Args: | 92 Args: |
| 97 suspects (list of Suspect): culprit suspects. | 93 suspects (list of Suspect): culprit suspects. |
| 98 | 94 |
| 99 Returns: | 95 Returns: |
| 100 The name of the most-suspected project; or the empty string on failure. | 96 The name of the most-suspected project; or the empty string on failure. |
| 101 """ | 97 """ |
| 102 projects = map(self.ClassifySuspect, suspects) | 98 projects = map(self.ClassifySuspect, suspects) |
| 103 return ProjectClassifier._GetTopProject(projects, | 99 return ProjectClassifier._GetTopProject(projects, |
| 104 rank_function=lambda x:-len(x)) | 100 rank_function=lambda x:-len(x)) |
| OLD | NEW |