OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 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 """Contains a set of Chrome-specific size queries.""" |
| 6 |
| 7 import logging |
| 8 import models |
| 9 |
| 10 |
| 11 class _Grouper(object): |
| 12 def __init__(self): |
| 13 self.groups = [] |
| 14 |
| 15 def Add(self, name, group): |
| 16 logging.debug('Computed %s', name) |
| 17 group.name = name |
| 18 self.groups.append(group) |
| 19 return group.Inverted() |
| 20 |
| 21 def Finalize(self, remaining): |
| 22 self.groups.sort(key=lambda s:-s.pss) |
| 23 if remaining: |
| 24 stars = remaining.Filter(lambda s: s.name.startswith('*')) |
| 25 if stars: |
| 26 remaining = stars.Inverted() |
| 27 stars.name = '** Merged Symbols' |
| 28 self.groups.append(stars) |
| 29 remaining.name = 'Other' |
| 30 self.groups.append(remaining) |
| 31 |
| 32 logging.debug('Finalized') |
| 33 return models.SymbolGroup(self.groups, is_sorted=True) |
| 34 |
| 35 |
| 36 def CategorizeByChromeComponent(symbols): |
| 37 g = _Grouper() |
| 38 |
| 39 # Put things that filter out a lot of symbols at the beginning where possible |
| 40 # to optimize speed. |
| 41 symbols = g.Add('WebRTC', symbols.WhereMatches(r'(?i)webrtc')) |
| 42 symbols = g.Add('Skia', symbols.Filter(lambda s: 'skia/' in s.source_path)) |
| 43 symbols = g.Add('V8', symbols.Filter( |
| 44 lambda s: s.source_path.startswith('v8/'))) |
| 45 symbols = g.Add('Blink (bindings)', symbols.Filter( |
| 46 lambda s: 'blink/bindings' in s.source_path)) |
| 47 symbols = g.Add('Blink (other)', symbols.WhereSourcePathMatches( |
| 48 r'\b(blink|WebKit)\b')) |
| 49 |
| 50 # Next, put non-regex queries, since they're a bit faster. |
| 51 symbols = g.Add('ICU', symbols.Filter(lambda s: '/icu/' in s.source_path)) |
| 52 symbols = g.Add('Prefetch', symbols.Filter( |
| 53 lambda s: 'resource_prefetch' in s.source_path)) |
| 54 symbols = g.Add('Password Manager', symbols.Filter( |
| 55 lambda s: 'password_manager' in s.source_path)) |
| 56 symbols = g.Add('Internals Pages', symbols.Filter( |
| 57 lambda s: '_internals' in s.source_path)) |
| 58 symbols = g.Add('Codecs', symbols.WhereSourcePathMatches( |
| 59 r'^third_party/(libweb[mp]|libpng|libjpeg_turbo|opus|ffmpeg|libvpx|)')) |
| 60 symbols = g.Add('Autofill', symbols.WhereSourcePathMatches(r'(?i)autofill')) |
| 61 symbols = g.Add('WebGL', symbols.WhereMatches(r'(?i)webgl')) |
| 62 symbols = g.Add('WebBluetooth', symbols.WhereMatches(r'(?i)bluetooth')) |
| 63 symbols = g.Add('WebUSB', symbols.WhereMatches(r'(?i)webusb|(\b|_)usb(\b|_)')) |
| 64 symbols = g.Add('WebVR', symbols.WhereMatches( |
| 65 r'{{_gvr_}}|{{_cwebvr_}}|{{_vr_}}')) |
| 66 symbols = g.Add('FileSystem', symbols.WhereSourcePathMatches( |
| 67 r'content/.*/fileapi|WebKit/.*/filesystem')) |
| 68 symbols = g.Add('WebCrypto', symbols.WhereMatches(r'(?i)webcrypto')) |
| 69 symbols = g.Add('Printing', symbols.WhereMatches(r'printing')) |
| 70 symbols = g.Add('Cast', symbols.WhereSourcePathMatches( |
| 71 r'(?i)(\b|_)cast(\b|_)')) |
| 72 symbols = g.Add('Media Source', symbols.WhereMatches( |
| 73 r'(?i)mediasource|blink::.*TrackDefault|blink::.*SourceBuffer')) |
| 74 |
| 75 # XSLT must come before libxml. |
| 76 symbols = g.Add('XSLT', symbols.WhereMatches(r'(?i)xslt')) |
| 77 symbols = g.Add('libxml', symbols.Filter( |
| 78 lambda s: 'libxml' in s.source_path)) |
| 79 |
| 80 return g.Finalize(symbols) |
| 81 |
| 82 |
| 83 def CategorizeGenerated(symbols): |
| 84 g = _Grouper() |
| 85 proto_filter = lambda s: ( |
| 86 '/protobuf/' in s.object_path or s.object_path.endswith('.pb.o')) |
| 87 mojo_filter = lambda s: ( |
| 88 s.source_path.endswith('.mojom.cc') or |
| 89 s.source_path.startswith('mojo/') or |
| 90 s.name.startswith('mojo::')) |
| 91 symbols = g.Add('Protocol Buffers', symbols.Filter(proto_filter)) |
| 92 symbols = g.Add('Mojo', symbols.Filter(mojo_filter)) |
| 93 symbols = g.Add('Other Generated', symbols.WhereSourceIsGenerated()) |
| 94 |
| 95 return g.Finalize(symbols) |
| 96 |
| 97 |
| 98 def TemplateStats(symbols): |
| 99 # TODO(agrieve): Stats about stl as well as general templates. |
| 100 raise Exception('Not yet implemented.') |
OLD | NEW |