| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.source.io; | 8 library engine.source.io; |
| 9 | 9 |
| 10 import 'engine.dart'; | 10 import 'engine.dart'; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 /** | 122 /** |
| 123 * Initialize a newly created source object. | 123 * Initialize a newly created source object. |
| 124 * | 124 * |
| 125 * @param file the file represented by this source | 125 * @param file the file represented by this source |
| 126 * @param uri the URI from which this source was originally derived | 126 * @param uri the URI from which this source was originally derived |
| 127 */ | 127 */ |
| 128 FileBasedSource.con2(this.uri, this.file); | 128 FileBasedSource.con2(this.uri, this.file); |
| 129 | 129 |
| 130 @override | 130 @override |
| 131 TimestampedData<String> get contents { | 131 TimestampedData<String> get contents { |
| 132 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start(); | 132 PerformanceTag prevTag = PerformanceStatistics.io.makeCurrent(); |
| 133 try { | 133 try { |
| 134 return contentsFromFile; | 134 return contentsFromFile; |
| 135 } finally { | 135 } finally { |
| 136 _reportIfSlowIO(handle.stop()); | 136 prevTag.makeCurrent(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Get the contents and timestamp of the underlying file. | 141 * Get the contents and timestamp of the underlying file. |
| 142 * | 142 * |
| 143 * Clients should consider using the the method [AnalysisContext.getContents] | 143 * Clients should consider using the the method [AnalysisContext.getContents] |
| 144 * because contexts can have local overrides of the content of a source that t
he source is not | 144 * because contexts can have local overrides of the content of a source that t
he source is not |
| 145 * aware of. | 145 * aware of. |
| 146 * | 146 * |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 @override | 231 @override |
| 232 String toString() { | 232 String toString() { |
| 233 if (file == null) { | 233 if (file == null) { |
| 234 return "<unknown source>"; | 234 return "<unknown source>"; |
| 235 } | 235 } |
| 236 return file.getAbsolutePath(); | 236 return file.getAbsolutePath(); |
| 237 } | 237 } |
| 238 | |
| 239 /** | |
| 240 * Record the time the IO took if it was slow | |
| 241 */ | |
| 242 void _reportIfSlowIO(int nanos) { | |
| 243 // TODO(brianwilkerson) Decide whether we still want to capture this data. | |
| 244 // //If slower than 10ms | |
| 245 // if (nanos > 10 * TimeCounter.NANOS_PER_MILLI) { | |
| 246 // InstrumentationBuilder builder = Instrumentation.builder2("SlowIO"); | |
| 247 // try { | |
| 248 // builder.data3("fileName", fullName); | |
| 249 // builder.metric2("IO-Time-Nanos", nanos); | |
| 250 // } finally { | |
| 251 // builder.log(); | |
| 252 // } | |
| 253 // } | |
| 254 } | |
| 255 } | 238 } |
| 256 | 239 |
| 257 /** | 240 /** |
| 258 * Instances of the class `FileUriResolver` resolve `file` URI's. | 241 * Instances of the class `FileUriResolver` resolve `file` URI's. |
| 259 */ | 242 */ |
| 260 class FileUriResolver extends UriResolver { | 243 class FileUriResolver extends UriResolver { |
| 261 /** | 244 /** |
| 262 * The name of the `file` scheme. | 245 * The name of the `file` scheme. |
| 263 */ | 246 */ |
| 264 static String FILE_SCHEME = "file"; | 247 static String FILE_SCHEME = "file"; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 521 } |
| 539 | 522 |
| 540 /** | 523 /** |
| 541 * Return `true` if the given URI is a `file` URI. | 524 * Return `true` if the given URI is a `file` URI. |
| 542 * | 525 * |
| 543 * @param uri the URI being tested | 526 * @param uri the URI being tested |
| 544 * @return `true` if the given URI is a `file` URI | 527 * @return `true` if the given URI is a `file` URI |
| 545 */ | 528 */ |
| 546 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 529 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 547 } | 530 } |
| OLD | NEW |