| 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 from collections import defaultdict | 5 from collections import defaultdict |
| 6 | 6 |
| 7 from common.diff import ChangeType | 7 from common.diff import ChangeType |
| 8 from common.git_repository import GitRepository | 8 from common.git_repository import GitRepository |
| 9 from common.http_client_appengine import HttpClientAppengine | 9 from common.http_client_appengine import HttpClientAppengine |
| 10 from crash import crash_util | 10 from crash import crash_util |
| 11 from crash.callstack import CallStack | 11 from crash.callstack import CallStack |
| 12 from crash.stacktrace import Stacktrace | 12 from crash.stacktrace import Stacktrace |
| 13 from crash.results import MatchResults | 13 from crash.results import MatchResults |
| 14 from crash.scorers.aggregator import Aggregator | 14 from crash.scorers.aggregated_scorer import AggregatedScorer |
| 15 from crash.scorers.min_distance import MinDistance | 15 from crash.scorers.min_distance import MinDistance |
| 16 from crash.scorers.top_frame_index import TopFrameIndex | 16 from crash.scorers.top_frame_index import TopFrameIndex |
| 17 | 17 |
| 18 | 18 |
| 19 #TODO(katesonia): Move this to config page. | 19 #TODO(katesonia): Move this to config page. |
| 20 _TOP_N_FRAMES = 7 | 20 _TOP_N_FRAMES = 7 |
| 21 | 21 |
| 22 | 22 |
| 23 def GetDepsInCrashStack(crash_stack, crash_deps): | 23 def GetDepsInCrashStack(crash_stack, crash_deps): |
| 24 """Gets Dependencies in crash stack.""" | 24 """Gets Dependencies in crash stack.""" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 dep_to_file_to_stack_infos = GetStackInfosForFilesGroupedByDeps( | 226 dep_to_file_to_stack_infos = GetStackInfosForFilesGroupedByDeps( |
| 227 stack_trace, stack_deps) | 227 stack_trace, stack_deps) |
| 228 | 228 |
| 229 results = FindMatchResults(dep_to_file_to_changelogs, | 229 results = FindMatchResults(dep_to_file_to_changelogs, |
| 230 dep_to_file_to_stack_infos, | 230 dep_to_file_to_stack_infos, |
| 231 stack_deps, ignore_cls) | 231 stack_deps, ignore_cls) |
| 232 | 232 |
| 233 if not results: | 233 if not results: |
| 234 return [] | 234 return [] |
| 235 | 235 |
| 236 aggregator = Aggregator([TopFrameIndex(), MinDistance()]) | 236 aggregator = AggregatedScorer([TopFrameIndex(), MinDistance()]) |
| 237 | 237 |
| 238 map(aggregator.ScoreAndReason, results) | 238 map(aggregator.Score, results) |
| 239 | 239 |
| 240 # Filter all the 0 confidence results. | 240 # Filter all the 0 confidence results. |
| 241 results = filter(lambda r: r.confidence != 0, results) | 241 results = filter(lambda r: r.confidence != 0, results) |
| 242 if not results: | 242 if not results: |
| 243 return [] | 243 return [] |
| 244 | 244 |
| 245 sorted_results = sorted(results, key=lambda r: -r.confidence) | 245 sorted_results = sorted(results, key=lambda r: -r.confidence) |
| 246 | 246 |
| 247 if sorted_results[0].confidence > 0.999: | 247 if sorted_results[0].confidence > 0.999: |
| 248 return sorted_results[:1] | 248 return sorted_results[:1] |
| 249 | 249 |
| 250 return sorted_results[:3] | 250 return sorted_results[:3] |
| OLD | NEW |