OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/importer/importer.html"> | 8 <link rel="import" href="/tracing/importer/importer.html"> |
9 | 9 |
10 <script> | 10 <script> |
11 | 11 |
12 'use strict'; | 12 'use strict'; |
13 | 13 |
14 /** | 14 /** |
15 * @fileoverview GcloudTraceImporter imports JSON data from Google Cloud Trace. | 15 * @fileoverview GcloudTraceImporter imports JSON data from Google Cloud Trace. |
16 */ | 16 */ |
17 tr.exportTo('tr.e.importer.gcloud_trace', function() { | 17 tr.exportTo('tr.e.importer.gcloud_trace', function() { |
18 function GcloudTraceImporter(model, eventData) { | 18 function GcloudTraceImporter(model, eventData) { |
19 this.importPriority = 2; | 19 this.importPriority = 2; |
20 this.eventData_ = eventData; | 20 this.eventData_ = eventData; |
21 } | 21 } |
22 | 22 |
23 /** | 23 /** |
24 * @return {boolean} Whether obj looks like the JSON output from Cloud Trace. | 24 * @return {boolean} Whether obj looks like the JSON output from Cloud Trace. |
25 */ | 25 */ |
26 GcloudTraceImporter.canImport = function(eventData) { | 26 GcloudTraceImporter.canImport = function(eventData) { |
27 if (typeof(eventData) !== 'string' && !(eventData instanceof String)) | 27 if (typeof(eventData) !== 'string' && !(eventData instanceof String)) { |
28 return false; | 28 return false; |
| 29 } |
29 | 30 |
30 // Slice the data so we don't potentially do a replace on a gigantic string. | 31 // Slice the data so we don't potentially do a replace on a gigantic string. |
31 var normalizedEventData = eventData.slice(0, 20).replace(/\s/g, ''); | 32 var normalizedEventData = eventData.slice(0, 20).replace(/\s/g, ''); |
32 if (normalizedEventData.length < 14) | 33 if (normalizedEventData.length < 14) return false; |
33 return false; | |
34 | 34 |
35 return normalizedEventData.slice(0, 14) === '{"projectId":"'; | 35 return normalizedEventData.slice(0, 14) === '{"projectId":"'; |
36 }; | 36 }; |
37 | 37 |
38 GcloudTraceImporter.prototype = { | 38 GcloudTraceImporter.prototype = { |
39 | 39 |
40 __proto__: tr.importer.Importer.prototype, | 40 __proto__: tr.importer.Importer.prototype, |
41 | 41 |
42 get importerName() { | 42 get importerName() { |
43 return 'GcloudTraceImporter'; | 43 return 'GcloudTraceImporter'; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 }; | 91 }; |
92 | 92 |
93 tr.importer.Importer.register(GcloudTraceImporter); | 93 tr.importer.Importer.register(GcloudTraceImporter); |
94 | 94 |
95 return { | 95 return { |
96 GcloudTraceImporter, | 96 GcloudTraceImporter, |
97 }; | 97 }; |
98 }); | 98 }); |
99 </script> | 99 </script> |
OLD | NEW |