OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of service; | 5 part of service; |
6 | 6 |
7 /// Abstract [ServiceObjectCache]. | 7 /// Abstract [ServiceObjectCache]. |
8 abstract class ServiceObjectCache<T extends ServiceObject> { | 8 abstract class ServiceObjectCache<T extends ServiceObject> { |
9 final Isolate isolate; | 9 final Isolate isolate; |
10 final _cache = new ObservableMap<String, T>(); | 10 final _cache = new ObservableMap<String, T>(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return codeList; | 110 return codeList; |
111 } | 111 } |
112 | 112 |
113 void _resetProfileData() { | 113 void _resetProfileData() { |
114 _cache.forEach((k, Code code) { | 114 _cache.forEach((k, Code code) { |
115 code.resetProfileData(); | 115 code.resetProfileData(); |
116 }); | 116 }); |
117 } | 117 } |
118 | 118 |
119 void _updateProfileData(ServiceMap profile, List<Code> codeTable) { | 119 void _updateProfileData(ServiceMap profile, List<Code> codeTable) { |
120 var codes = profile['codes']; | 120 var codeRegions = profile['codes']; |
121 var sampleCount = profile['samples']; | 121 var sampleCount = profile['samples']; |
122 for (var profileCode in codes) { | 122 for (var codeRegion in codeRegions) { |
123 Code code = profileCode['code']; | 123 Code code = codeRegion['code']; |
124 code.updateProfileData(profileCode, codeTable, sampleCount); | 124 code.updateProfileData(codeRegion, codeTable, sampleCount); |
125 } | 125 } |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 class ClassCache extends ServiceObjectCache<ServiceMap> { | 129 class ClassCache extends ServiceObjectCache<ServiceMap> { |
130 ClassCache(Isolate isolate) : super(isolate); | 130 ClassCache(Isolate isolate) : super(isolate); |
131 | 131 |
132 bool cachesId(String id) => _matcher.hasMatch(id); | 132 bool cachesId(String id) => _matcher.hasMatch(id); |
133 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Class'; | 133 bool cachesType(String type) => ServiceObject.stripRef(type) == 'Class'; |
134 ServiceMap _upgrade(ObservableMap obj) => | 134 ServiceMap _upgrade(ObservableMap obj) => |
135 new ServiceMap.fromMap(isolate, obj); | 135 new ServiceMap.fromMap(isolate, obj); |
136 | 136 |
137 static final RegExp _matcher = new RegExp(r'classes/\d+$'); | 137 static final RegExp _matcher = new RegExp(r'classes/\d+$'); |
138 } | 138 } |
OLD | NEW |