Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / about_tracing / profiling_view.html
index f3ce094..0025f53 100644 (file)
@@ -10,10 +10,10 @@ found in the LICENSE file.
 <link rel="import" href="/about_tracing/xhr_based_tracing_controller_client.html">
 <link rel="import" href="/about_tracing/features.html">
 <link rel="import" href="/tracing/timeline_view.html">
-<link rel="import" href="/tvcm/key_event_manager.html">
-<link rel="import" href="/tvcm/ui.html">
-<link rel="import" href="/tvcm/ui/info_bar.html">
-<link rel="import" href="/tvcm/ui/overlay.html">
+<link rel="import" href="/base/key_event_manager.html">
+<link rel="import" href="/base/ui.html">
+<link rel="import" href="/base/ui/info_bar.html">
+<link rel="import" href="/base/ui/overlay.html">
 
 <style>
 x-profiling-view {
@@ -33,6 +33,10 @@ x-profiling-view .controls #upload-button {
 x-profiling-view > x-timeline-view {
   -webkit-flex: 1 1 auto;
 }
+
+.report-id-message {
+  -webkit-user-select: text;
+}
 </style>
 
 <template id="profiling-view-template">
@@ -59,7 +63,7 @@ x-profiling-view > x-timeline-view {
  * @fileoverview ProfilingView glues the View control to
  * TracingController.
  */
-tvcm.exportTo('about_tracing', function() {
+tv.exportTo('about_tracing', function() {
   function readFile(file) {
     return new Promise(function(resolve, reject) {
       var reader = new FileReader();
@@ -84,21 +88,22 @@ tvcm.exportTo('about_tracing', function() {
    * @constructor
    * @extends {HTMLUnknownElement}
    */
-  var ProfilingView = tvcm.ui.define('x-profiling-view');
+  var ProfilingView = tv.ui.define('x-profiling-view');
   var THIS_DOC = document.currentScript.ownerDocument;
+  var REPORT_UPLOAD_URL = 'http://crash-staging/';
 
   ProfilingView.prototype = {
     __proto__: HTMLUnknownElement.prototype,
 
     decorate: function(tracingControllerClient) {
-      this.appendChild(tvcm.instantiateTemplate('#profiling-view-template',
+      this.appendChild(tv.instantiateTemplate('#profiling-view-template',
           THIS_DOC));
 
       this.timelineView_ = this.querySelector('x-timeline-view');
       this.infoBarGroup_ = this.querySelector('x-info-bar-group');
 
-      tvcm.ui.decorate(this.infoBarGroup_, tvcm.ui.InfoBarGroup);
-      tvcm.ui.decorate(this.timelineView_, tracing.TimelineView);
+      tv.ui.decorate(this.infoBarGroup_, tv.ui.InfoBarGroup);
+      tv.ui.decorate(this.timelineView_, tracing.TimelineView);
 
       // Detach the buttons. We will reattach them to the timeline view.
       // TODO(nduca): Make <timeline-view> have a <content select="x-buttons">
@@ -108,7 +113,7 @@ tvcm.exportTo('about_tracing', function() {
       this.timelineView_.leftControls.appendChild(buttons);
       this.initButtons_(buttons);
 
-      tvcm.KeyEventManager.instance.addListener(
+      tv.KeyEventManager.instance.addListener(
           'keypress', this.onKeypress_, this);
 
       this.initDragAndDrop_();
@@ -132,17 +137,26 @@ tvcm.exportTo('about_tracing', function() {
       }.bind(this);
 
       window.onUploadError = function(error_message) {
-        this.onUploadStatusUpdate_('Trace upload failed: ' + error_message);
+        this.setUploadOverlayText_(['Trace upload failed: ' + error_message]);
       }.bind(this);
       window.onUploadProgress = function(percent, currentAsString,
                                          totalAsString) {
-        this.onUploadStatusUpdate_(
-            'Upload progress: ' + percent + '% (' + currentAsString + ' of ' +
-            currentAsString + ' bytes)');
+        this.setUploadOverlayText_(
+            ['Upload progress: ' + percent + '% (' + currentAsString + ' of ' +
+            currentAsString + ' bytes)']);
       }.bind(this);
-      window.onUploadComplete = function(report_id) {
-        this.onUploadStatusUpdate_(
-            'Trace uploaded successfully. Report id: ' + report_id);
+      window.onUploadComplete = function(reportId) {
+        var messageDiv = document.createElement('div');
+        var textNode =  document.createTextNode(
+            'Trace uploaded successfully. Report id: ');
+        messageDiv.appendChild(textNode);
+        var reportLink = document.createElement('a');
+        messageDiv.appendChild(reportLink);
+        reportLink.href = REPORT_UPLOAD_URL + reportId;
+        reportLink.text = reportId;
+        reportLink.className = 'report-id-message';
+        reportLink.target = '_blank';
+        this.setUploadOverlayContent_(messageDiv);
       }.bind(this);
 
       this.getMonitoringStatus();
@@ -207,7 +221,7 @@ tvcm.exportTo('about_tracing', function() {
             buttons.querySelector('#monitor-checkbox').disabled = false;
             if (err instanceof about_tracing.UserCancelledError)
               return;
-            tvcm.ui.Overlay.showError('Error while recording', err);
+            tv.ui.Overlay.showError('Error while recording', err);
           }.bind(this));
       return resultPromise;
     },
@@ -226,7 +240,7 @@ tvcm.exportTo('about_tracing', function() {
           function(err) {
             if (err instanceof about_tracing.UserCancelledError)
               return;
-            tvcm.ui.Overlay.showError('Error while monitoring', err);
+            tv.ui.Overlay.showError('Error while monitoring', err);
           }.bind(this));
       return resultPromise;
     },
@@ -245,7 +259,7 @@ tvcm.exportTo('about_tracing', function() {
           function(err) {
             if (err instanceof about_tracing.UserCancelledError)
               return;
-            tvcm.ui.Overlay.showError('Error while monitoring', err);
+            tv.ui.Overlay.showError('Error while monitoring', err);
           }.bind(this));
       return resultPromise;
     },
@@ -262,7 +276,7 @@ tvcm.exportTo('about_tracing', function() {
           function(err) {
             if (err instanceof about_tracing.UserCancelledError)
               return;
-            tvcm.ui.Overlay.showError('Error while monitoring', err);
+            tv.ui.Overlay.showError('Error while monitoring', err);
           }.bind(this));
       return resultPromise;
     },
@@ -277,7 +291,7 @@ tvcm.exportTo('about_tracing', function() {
           function(err) {
             if (err instanceof about_tracing.UserCancelledError)
               return;
-            tvcm.ui.Overlay.showError('Error while updating tracing states',
+            tv.ui.Overlay.showError('Error while updating tracing states',
                                       err);
           }.bind(this));
       return resultPromise;
@@ -335,7 +349,7 @@ tvcm.exportTo('about_tracing', function() {
             this.timelineView_.model = m;
           }.bind(this),
           function(err) {
-            tvcm.ui.Overlay.showError('While importing: ', err);
+            tv.ui.Overlay.showError('While importing: ', err);
           }.bind(this));
     },
 
@@ -382,6 +396,7 @@ tvcm.exportTo('about_tracing', function() {
         this.uploadButton_.style.display = 'inline-block';
       }
       this.uploadButton_.disabled = true;
+      this.uploadOverlay_ = null;
     },
 
     onSaveClicked_: function() {
@@ -405,7 +420,7 @@ tvcm.exportTo('about_tracing', function() {
     },
 
     initUploadStatusOverlay_: function() {
-      this.uploadOverlay_ = tvcm.ui.Overlay();
+      this.uploadOverlay_ = tv.ui.Overlay();
       this.uploadOverlay_.title = 'Uploading trace...';
       this.uploadOverlay_.userCanClose = false;
       this.uploadOverlay_.visible = true;
@@ -426,22 +441,23 @@ tvcm.exportTo('about_tracing', function() {
       this.uploadOverlay_.buttons.appendChild(cancelButton);
     },
 
-    onUploadStatusUpdate_: function(message) {
-      this.setUploadOverlayText_([message]);
-    },
-
-    setUploadOverlayText_: function(messages) {
+    setUploadOverlayContent_: function(content) {
       if (!this.uploadOverlay_)
         throw new Error('Not uploading');
 
       this.uploadOverlay_.textContent = '';
+      this.uploadOverlay_.appendChild(content);
+    },
+
+    setUploadOverlayText_: function(messages) {
+      var contentDiv = document.createElement('div');
 
       for (var i = 0; i < messages.length; ++i) {
-        this.uploadOverlay_.msgEl = document.createElement('div');
-        this.uploadOverlay_.appendChild(this.uploadOverlay_.msgEl);
-        this.uploadOverlay_.msgEl.style.margin = '20px';
-        this.uploadOverlay_.msgEl.textContent = messages[i];
+        var messageDiv = document.createElement('div');
+        messageDiv.textContent = messages[i];
+        contentDiv.appendChild(messageDiv);
       }
+      this.setUploadOverlayContent_(contentDiv);
     },
 
     doTraceUpload_: function() {
@@ -479,7 +495,7 @@ tvcm.exportTo('about_tracing', function() {
                   this.setActiveTrace(file.name, data);
                 }.bind(this),
                 function(err) {
-                  tvcm.ui.Overlay.showError('Error while loading file: ' + err);
+                  tv.ui.Overlay.showError('Error while loading file: ' + err);
                 });
           }.bind(this), false);
       inputElement.click();
@@ -521,7 +537,7 @@ tvcm.exportTo('about_tracing', function() {
 
       var files = e.dataTransfer.files;
       if (files.length !== 1) {
-        tvcm.ui.Overlay.showError('1 file supported at a time.');
+        tv.ui.Overlay.showError('1 file supported at a time.');
         return;
       }
 
@@ -530,7 +546,7 @@ tvcm.exportTo('about_tracing', function() {
             this.setActiveTrace(files[0].name, data);
           }.bind(this),
           function(err) {
-            tvcm.ui.Overlay.showError('Error while loading file: ' + err);
+            tv.ui.Overlay.showError('Error while loading file: ' + err);
           });
       return false;
     }