Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Updated observatory_sources Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Some value smaller than the object ring, so requesting a large array 7 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 8 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 9 // object ring.
10 const int kDefaultFieldLimit = 100; 10 const int kDefaultFieldLimit = 100;
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 var reload = isolate.reload().catchError((e) { 920 var reload = isolate.reload().catchError((e) {
921 Logger.root.info('Bulk reloading of isolates failed: $e'); 921 Logger.root.info('Bulk reloading of isolates failed: $e');
922 }); 922 });
923 reloads.add(reload); 923 reloads.add(reload);
924 } 924 }
925 return Future.wait(reloads); 925 return Future.wait(reloads);
926 } 926 }
927 } 927 }
928 928
929 class FakeVM extends VM { 929 class FakeVM extends VM {
930 String get displayName => name;
931
930 final Map _responses = {}; 932 final Map _responses = {};
931 FakeVM(Map responses) { 933 FakeVM(Map responses) {
932 if (responses == null) { 934 if (responses == null) {
933 return; 935 return;
934 } 936 }
935 responses.forEach((uri, response) { 937 responses.forEach((uri, response) {
936 // Encode as string. 938 // Encode as string.
937 _responses[_canonicalizeUri(Uri.parse(uri))] = response; 939 _responses[_canonicalizeUri(Uri.parse(uri))] = response;
938 }); 940 });
939 } 941 }
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) => 1852 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) =>
1851 _map.notifyPropertyChange(field, oldValue, newValue); 1853 _map.notifyPropertyChange(field, oldValue, newValue);
1852 void observed() => _map.observed(); 1854 void observed() => _map.observed();
1853 void unobserved() => _map.unobserved(); 1855 void unobserved() => _map.unobserved();
1854 Stream<List<ChangeRecord>> get changes => _map.changes; 1856 Stream<List<ChangeRecord>> get changes => _map.changes;
1855 bool get hasObservers => _map.hasObservers; 1857 bool get hasObservers => _map.hasObservers;
1856 1858
1857 String toString() => "ServiceMap($_map)"; 1859 String toString() => "ServiceMap($_map)";
1858 } 1860 }
1859 1861
1862 M.ErrorKind stringToErrorKind(String value) {
1863 switch(value) {
1864 case 'UnhandledException': return M.ErrorKind.UnhandledException;
1865 case 'LanguageError': return M.ErrorKind.UnhandledException;
1866 case 'InternalError': return M.ErrorKind.InternalError;
1867 case 'TerminationError': return M.ErrorKind.TerminationError;
1868 }
1869 Logger.root.severe('Unrecognized error kind: $value');
1870 throw new FallThroughError();
1871 }
1872
1860 /// A [DartError] is peered to a Dart Error object. 1873 /// A [DartError] is peered to a Dart Error object.
1861 class DartError extends ServiceObject { 1874 class DartError extends ServiceObject implements M.Error {
1862 DartError._empty(ServiceObject owner) : super._empty(owner); 1875 DartError._empty(ServiceObject owner) : super._empty(owner);
1863 1876
1877 M.ErrorKind kind;
1864 @observable String message; 1878 @observable String message;
1865 @observable Instance exception; 1879 @observable Instance exception;
1866 @observable Instance stacktrace; 1880 @observable Instance stacktrace;
1867 1881
1868 void _update(ObservableMap map, bool mapIsRef) { 1882 void _update(ObservableMap map, bool mapIsRef) {
1869 message = map['message']; 1883 message = map['message'];
1884 kind = stringToErrorKind(map['kind']);
1870 exception = new ServiceObject._fromMap(owner, map['exception']); 1885 exception = new ServiceObject._fromMap(owner, map['exception']);
1871 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); 1886 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']);
1872 name = 'DartError($message)'; 1887 name = 'DartError($message)';
1873 vmName = name; 1888 vmName = name;
1874 } 1889 }
1875 1890
1876 String toString() => 'DartError($message)'; 1891 String toString() => 'DartError($message)';
1877 } 1892 }
1878 1893
1879 Level _findLogLevel(int value) { 1894 Level _findLogLevel(int value) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 static const kExtension = 'Extension'; 1930 static const kExtension = 'Extension';
1916 1931
1917 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); 1932 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner);
1918 1933
1919 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { 1934 ServiceEvent.connectionClosed(this.reason) : super._empty(null) {
1920 kind = kConnectionClosed; 1935 kind = kConnectionClosed;
1921 } 1936 }
1922 1937
1923 @observable String kind; 1938 @observable String kind;
1924 @observable DateTime timestamp; 1939 @observable DateTime timestamp;
1940 List pauseBreakpoints;
turnidge 2016/08/04 18:16:36 List<Breakpoint>
cbernaschina 2016/08/04 21:00:20 Done.
1925 @observable Breakpoint breakpoint; 1941 @observable Breakpoint breakpoint;
1926 @observable Frame topFrame; 1942 @observable Frame topFrame;
1943 @observable DartError error;
1927 @observable String extensionRPC; 1944 @observable String extensionRPC;
1928 @observable Instance exception; 1945 @observable Instance exception;
1929 @observable Instance reloadError; 1946 @observable Instance reloadError;
1930 @observable bool atAsyncSuspension; 1947 @observable bool atAsyncSuspension;
1931 @observable ServiceObject inspectee; 1948 @observable Instance inspectee;
1932 @observable ByteData data; 1949 @observable ByteData data;
1933 @observable int count; 1950 @observable int count;
1934 @observable String reason; 1951 @observable String reason;
1935 @observable String exceptions; 1952 @observable String exceptions;
1936 @observable String bytesAsString; 1953 @observable String bytesAsString;
1937 @observable Map logRecord; 1954 @observable Map logRecord;
1938 @observable String extensionKind; 1955 @observable String extensionKind;
1939 @observable Map extensionData; 1956 @observable Map extensionData;
1940 @observable List timelineEvents; 1957 @observable List timelineEvents;
1941 @observable String spawnToken; 1958 @observable String spawnToken;
(...skipping 17 matching lines...) Expand all
1959 assert(map['isolate'] == null || owner == map['isolate']); 1976 assert(map['isolate'] == null || owner == map['isolate']);
1960 timestamp = 1977 timestamp =
1961 new DateTime.fromMillisecondsSinceEpoch(map['timestamp']); 1978 new DateTime.fromMillisecondsSinceEpoch(map['timestamp']);
1962 kind = map['kind']; 1979 kind = map['kind'];
1963 notifyPropertyChange(#isPauseEvent, 0, 1); 1980 notifyPropertyChange(#isPauseEvent, 0, 1);
1964 name = 'ServiceEvent $kind'; 1981 name = 'ServiceEvent $kind';
1965 vmName = name; 1982 vmName = name;
1966 if (map['breakpoint'] != null) { 1983 if (map['breakpoint'] != null) {
1967 breakpoint = map['breakpoint']; 1984 breakpoint = map['breakpoint'];
1968 } 1985 }
1969 // TODO(turnidge): Expose the full list of breakpoints. For now
1970 // we just pretend like there is only one active breakpoint.
1971 if (map['pauseBreakpoints'] != null) { 1986 if (map['pauseBreakpoints'] != null) {
1972 var pauseBpts = map['pauseBreakpoints']; 1987 pauseBreakpoints = map['pauseBreakpoints'];
1973 if (pauseBpts.length > 0) { 1988 if (pauseBreakpoints.length > 0) {
1974 breakpoint = pauseBpts[0]; 1989 breakpoint = pauseBreakpoints[0];
1975 } 1990 }
1991 } else {
1992 pauseBreakpoints = const [];
1993 }
1994 if (map['error'] != null) {
1995 error = map['error'];
1976 } 1996 }
1977 if (map['extensionRPC'] != null) { 1997 if (map['extensionRPC'] != null) {
1978 extensionRPC = map['extensionRPC']; 1998 extensionRPC = map['extensionRPC'];
1979 } 1999 }
1980 topFrame = map['topFrame']; 2000 topFrame = map['topFrame'];
1981 if (map['exception'] != null) { 2001 if (map['exception'] != null) {
1982 exception = map['exception']; 2002 exception = map['exception'];
1983 } 2003 }
1984 atAsyncSuspension = map['atAsyncSuspension'] != null; 2004 atAsyncSuspension = map['atAsyncSuspension'] != null;
1985 if (map['inspectee'] != null) { 2005 if (map['inspectee'] != null) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 @observable Library library; 2264 @observable Library library;
2245 2265
2246 @observable bool isAbstract; 2266 @observable bool isAbstract;
2247 @observable bool isConst; 2267 @observable bool isConst;
2248 @observable bool isFinalized; 2268 @observable bool isFinalized;
2249 @observable bool isPatch; 2269 @observable bool isPatch;
2250 @observable bool isImplemented; 2270 @observable bool isImplemented;
2251 2271
2252 @observable SourceLocation location; 2272 @observable SourceLocation location;
2253 2273
2254 @observable ServiceMap error; 2274 @observable DartError error;
2255 @observable int vmCid; 2275 @observable int vmCid;
2256 2276
2257 final Allocations newSpace = new Allocations(); 2277 final Allocations newSpace = new Allocations();
2258 final Allocations oldSpace = new Allocations(); 2278 final Allocations oldSpace = new Allocations();
2259 final AllocationCount promotedByLastNewGC = new AllocationCount(); 2279 final AllocationCount promotedByLastNewGC = new AllocationCount();
2260 2280
2261 @observable bool get hasNoAllocations => newSpace.empty && oldSpace.empty; 2281 @observable bool get hasNoAllocations => newSpace.empty && oldSpace.empty;
2262 @observable bool traceAllocations = false; 2282 @observable bool traceAllocations = false;
2263 @reflectable final fields = new ObservableList<Field>(); 2283 @reflectable final fields = new ObservableList<Field>();
2264 @reflectable final functions = new ObservableList<ServiceFunction>(); 2284 @reflectable final functions = new ObservableList<ServiceFunction>();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 2392
2373 Future<ServiceObject> getAllocationSamples([String tags = 'None']) { 2393 Future<ServiceObject> getAllocationSamples([String tags = 'None']) {
2374 var params = { 'tags': tags, 2394 var params = { 'tags': tags,
2375 'classId': id }; 2395 'classId': id };
2376 return isolate.invokeRpc('_getAllocationSamples', params); 2396 return isolate.invokeRpc('_getAllocationSamples', params);
2377 } 2397 }
2378 2398
2379 String toString() => 'Class($vmName)'; 2399 String toString() => 'Class($vmName)';
2380 } 2400 }
2381 2401
2382 class Instance extends HeapObject { 2402 class Instance extends HeapObject implements M.InstanceRef {
2383 @observable String kind; 2403 @observable String kind;
2384 @observable String valueAsString; // If primitive. 2404 @observable String valueAsString; // If primitive.
2385 @observable bool valueAsStringIsTruncated; 2405 @observable bool valueAsStringIsTruncated;
2386 @observable ServiceFunction function; // If a closure. 2406 @observable ServiceFunction function; // If a closure.
2387 @observable Context context; // If a closure. 2407 @observable Context context; // If a closure.
2388 @observable int length; // If a List, Map or TypedData. 2408 @observable int length; // If a List, Map or TypedData.
2389 @observable Instance pattern; // If a RegExp. 2409 @observable Instance pattern; // If a RegExp.
2390 2410
2391 @observable String name; 2411 @observable String name;
2392 @observable Class typeClass; 2412 @observable Class typeClass;
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
4093 var v = list[i]; 4113 var v = list[i];
4094 if ((v is ObservableMap) && _isServiceMap(v)) { 4114 if ((v is ObservableMap) && _isServiceMap(v)) {
4095 list[i] = owner.getFromMap(v); 4115 list[i] = owner.getFromMap(v);
4096 } else if (v is ObservableList) { 4116 } else if (v is ObservableList) {
4097 _upgradeObservableList(v, owner); 4117 _upgradeObservableList(v, owner);
4098 } else if (v is ObservableMap) { 4118 } else if (v is ObservableMap) {
4099 _upgradeObservableMap(v, owner); 4119 _upgradeObservableMap(v, owner);
4100 } 4120 }
4101 } 4121 }
4102 } 4122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698