| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 observatory; | 5 part of observatory; |
| 6 | 6 |
| 7 /// The LocationManager class observes and parses the hash ('#') portion of the | 7 /// The LocationManager class observes and parses the hash ('#') portion of the |
| 8 /// URL in window.location. The text after the '#' is used as the request | 8 /// URL in window.location. The text after the '#' is used as the request |
| 9 /// string for the VM service. | 9 /// string for the VM service. |
| 10 class LocationManager extends Observable { | 10 class LocationManager extends Observable { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // Request the current anchor. | 29 // Request the current anchor. |
| 30 requestCurrentHash(); | 30 requestCurrentHash(); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 if (!setDefaultHash()) { | 33 if (!setDefaultHash()) { |
| 34 // An anchor was already present, trigger a request. | 34 // An anchor was already present, trigger a request. |
| 35 requestCurrentHash(); | 35 requestCurrentHash(); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 |
| 39 /// Returns the current isolate prefix, i.e. '#/isolates/XX/' if one | 40 /// Returns the current isolate prefix, i.e. '#/isolates/XX/' if one |
| 40 /// is present and null otherwise. | 41 /// is present and null otherwise. |
| 41 String currentIsolateAnchorPrefix() { | 42 String currentIsolateAnchorPrefix() { |
| 42 Match m = currentIsolateMatcher.matchAsPrefix(currentHash); | 43 Match m = currentIsolateMatcher.matchAsPrefix(currentHash); |
| 43 if (m == null) { | 44 if (m == null) { |
| 44 return null; | 45 return null; |
| 45 } | 46 } |
| 46 return m.input.substring(m.start, m.end); | 47 return m.input.substring(m.start, m.end); |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 78 void requestCurrentHash() { | 79 void requestCurrentHash() { |
| 79 currentHash = window.location.hash; | 80 currentHash = window.location.hash; |
| 80 // Chomp off the # | 81 // Chomp off the # |
| 81 String requestUrl = currentHash.substring(1); | 82 String requestUrl = currentHash.substring(1); |
| 82 currentHashUri = Uri.parse(requestUrl); | 83 currentHashUri = Uri.parse(requestUrl); |
| 83 if (currentIsolateProfileMatcher.hasMatch(currentHash)) { | 84 if (currentIsolateProfileMatcher.hasMatch(currentHash)) { |
| 84 // We do not automatically fetch profile data. | 85 // We do not automatically fetch profile data. |
| 85 profile = true; | 86 profile = true; |
| 86 } else { | 87 } else { |
| 87 application.requestManager.get(requestUrl); | 88 application.requestManager.get(requestUrl); |
| 89 profile = false; |
| 88 } | 90 } |
| 89 } | 91 } |
| 90 | 92 |
| 91 /// Create a request for [l] on the current isolate. | 93 /// Create a request for [l] on the current isolate. |
| 92 @observable | 94 @observable |
| 93 String currentIsolateRelativeLink(String l) { | 95 String currentIsolateRelativeLink(String l) { |
| 94 var isolateId = currentIsolateId(); | 96 var isolateId = currentIsolateId(); |
| 95 if (isolateId == LocationManager.InvalidIsolateId) { | 97 if (isolateId == LocationManager.InvalidIsolateId) { |
| 96 return defaultHash; | 98 return defaultHash; |
| 97 } | 99 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 110 String relativeLink(String isolateId, String l) { | 112 String relativeLink(String isolateId, String l) { |
| 111 return '#/$isolateId/$l'; | 113 return '#/$isolateId/$l'; |
| 112 } | 114 } |
| 113 | 115 |
| 114 /// Create a request for [l] on [isolateId]. | 116 /// Create a request for [l] on [isolateId]. |
| 115 @observable | 117 @observable |
| 116 String absoluteLink(String l) { | 118 String absoluteLink(String l) { |
| 117 return '#/$l'; | 119 return '#/$l'; |
| 118 } | 120 } |
| 119 } | 121 } |
| OLD | NEW |