| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2013 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/base/base64.html"> | 8 <link rel="import" href="/tracing/base/base64.html"> |
| 9 <link rel="import" | 9 <link rel="import" |
| 10 href="/tracing/ui/extras/about_tracing/tracing_controller_client.html"> | 10 href="/tracing/ui/extras/about_tracing/tracing_controller_client.html"> |
| 11 | 11 |
| 12 <script> | 12 <script> |
| 13 'use strict'; | 13 'use strict'; |
| 14 | 14 |
| 15 tr.exportTo('tr.ui.e.about_tracing', function() { | 15 tr.exportTo('tr.ui.e.about_tracing', function() { |
| 16 var Base64 = tr.b.Base64; | 16 var Base64 = tr.b.Base64; |
| 17 | 17 |
| 18 function beginXhr(method, path, data) { | 18 function beginXhr(method, path, data) { |
| 19 if (data === undefined) | 19 if (data === undefined) |
| 20 data = null; | 20 data = null; |
| 21 return new Promise(function(resolve, reject) { | 21 return new Promise(function(resolve, reject) { |
| 22 var req = new XMLHttpRequest(); | 22 var req = new XMLHttpRequest(); |
| 23 if (method != 'POST' && data !== null) | 23 if (method !== 'POST' && data !== null) |
| 24 throw new Error('Non-POST should have data==null'); | 24 throw new Error('Non-POST should have data==null'); |
| 25 req.open(method, path, true); | 25 req.open(method, path, true); |
| 26 req.onreadystatechange = function(e) { | 26 req.onreadystatechange = function(e) { |
| 27 if (req.readyState == 4) { | 27 if (req.readyState === 4) { |
| 28 window.setTimeout(function() { | 28 window.setTimeout(function() { |
| 29 if (req.status == 200 && req.responseText != '##ERROR##') { | 29 if (req.status === 200 && req.responseText !== '##ERROR##') { |
| 30 resolve(req.responseText); | 30 resolve(req.responseText); |
| 31 } else { | 31 } else { |
| 32 reject(new Error('Error occured at ' + path)); | 32 reject(new Error('Error occured at ' + path)); |
| 33 } | 33 } |
| 34 }, 0); | 34 }, 0); |
| 35 } | 35 } |
| 36 }; | 36 }; |
| 37 req.send(data); | 37 req.send(data); |
| 38 }); | 38 }); |
| 39 } | 39 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 defaultTraceName: function() { | 104 defaultTraceName: function() { |
| 105 return 'trace.json.gz'; | 105 return 'trace.json.gz'; |
| 106 } | 106 } |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 return { | 109 return { |
| 110 XhrBasedTracingControllerClient: XhrBasedTracingControllerClient | 110 XhrBasedTracingControllerClient: XhrBasedTracingControllerClient |
| 111 }; | 111 }; |
| 112 }); | 112 }); |
| 113 </script> | 113 </script> |
| OLD | NEW |