From 8e06b63e5eab5558823f4923e20a832c8b36cbe2 Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Thu, 2 Feb 2012 23:55:33 -0800
Subject: Chrome FileSystem API Testing
Doing benchmark testing of the native HTML5 FileSystem API available in Chrome. Need to run testing of local XHR requests and also getting files from packaged app.
---
js/io/system/coreioapi.js | 189 +++++++++++++++++++--------
js/io/system/fileio.js | 15 ++-
js/io/ui/cloudpopup.reel/css/cloudpopup.css | 4 +-
js/io/ui/cloudpopup.reel/css/cloudpopup.scss | 4 +-
js/mediators/io-mediator.js | 6 +-
5 files changed, 152 insertions(+), 66 deletions(-)
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index f0ca568f..99f46fd7 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -7,6 +7,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
/* /////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
NOTES:
+
+ Core API reference in NINJA: this.application.ninja.coreIoApi
+
////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////// */
var Montage = require("montage/core/core").Montage,
@@ -21,6 +24,80 @@ exports.CoreIoApi = Montage.create(Component, {
deserializedFromTemplate: {
enumerable: false,
value: function () {
+
+
+
+ ////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////
+ //TODO: Remove, this is only for testing
+
+
+ window.webkitRequestFileSystem(window.PERSISTENT, 10*1024*1024 /*10MB*/, function (fs) {
+
+
+ console.log(fs);
+
+ var start = new Date().getTime();
+
+ for (var i=0; i<250; i++) {
+
+ fs.root.getFile('test'+i+'.txt', {create: true}, function(fileEntry) {
+
+ fileEntry.createWriter(function(fileWriter) {
+
+ var bb = new window.WebKitBlobBuilder;
+ bb.append('In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est a nulla placerat dignissim. Morbi a enim in magna semper bibendum. Etiam scelerisque, nunc ac egestas consequat, odio nibh euismod nulla, eget auctor orci nibh vel nisi. Aliquam erat volutpat. Mauris vel neque sit amet nunc gravida congue sed sit amet purus. Quisque lacus quam, egestas ac tincidunt a, lacinia vel velit. Aenean facilisis nulla vitae urna tincidunt congue sed ut dui. Morbi malesuada nulla nec purus convallis consequat. Vivamus id mollis quam. Morbi ac commodo nulla. In condimentum orci id nisl volutpat bibendum. Quisque commodo hendrerit lorem quis egestas. Maecenas quis tortor arcu. Vivamus rutrum nunc non neque consectetur quis placerat neque lobortis. Nam vestibulum, arcu sodales feugiat consectetur, nisl orci bibendum elit, eu euismod magna sapien ut nibh. Donec semper quam scelerisque tortor dictum gravida. In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien. Phasellus quis est sed turpis sollicitudin venenatis sed eu odio. Praesent eget neque eu eros interdum malesuada non vel leo. Sed fringilla porta ligula egestas tincidunt. Nullam risus magna, ornare vitae varius eget, scelerisque a libero. Morbi eu porttitor ipsum. Nullam lorem nisi, posuere quis volutpat eget, luctus nec massa. Pellentesque aliquam lacinia tellus sit amet bibendum. Ut posuere justo in enim pretium scelerisque. Etiam ornare vehicula euismod. Vestibulum at risus augue. Sed non semper dolor. Sed fringilla consequat velit a porta. Pellentesque sed lectus pharetra ipsum ultricies commodo non sit amet velit. Suspendisse volutpat lobortis ipsum, in scelerisque nisi iaculis a. Duis pulvinar lacinia commodo. Integer in lorem id nibh luctus aliquam. Sed elementum, est ac sagittis porttitor, neque metus ultricies ante, in accumsan massa nisl non metus. Vivamus sagittis quam a lacus dictum tempor. Nullam in semper ipsum. Cras a est id massa malesuada tincidunt. Etiam a urna tellus. Ut rutrum vehicula dui, eu cursus magna tincidunt pretium. Donec malesuada accumsan quam, et commodo orci viverra et. Integer tincidunt sagittis lectus. Mauris ac ligula quis orci auctor tincidunt. Suspendisse odio justo, varius id posuere sit amet, iaculis sit amet orci. Suspendisse potenti. Suspendisse potenti. Aliquam erat volutpat. Sed posuere dignissim odio, nec cursus odio mollis et. Praesent cursus, orci ut dictum adipiscing, tellus ante porttitor leo, vel gravida lacus lorem vitae est. Duis ultricies feugiat ante nec aliquam. Maecenas varius, nulla vel fermentum semper, metus nibh bibendum nunc, vitae suscipit mauris velit ac nunc. Mauris nunc eros, egestas at vehicula tincidunt, commodo ac mauris. Nulla facilisi. Nunc eros sem, lobortis non pulvinar id, blandit in eros. In bibendum suscipit');
+ fileWriter.write(bb.getBlob('text/plain'));
+
+ });
+
+ });
+
+ }
+
+ var end = new Date().getTime();
+ var time = end - start;
+ console.log('Create execution time: ' + time);
+
+ start = new Date().getTime();
+
+ for (var j=0; j<250; j++) {
+
+ fs.root.getFile('test'+j+'.txt', {create: true}, function(fileEntry) {
+
+ fileEntry.file(function(file) {
+
+ var reader = new FileReader();
+ reader.onloadend = function(e) {
+ console.log(this.result);
+ };
+
+ reader.readAsText(file);
+
+ });
+
+ });
+
+ }
+
+
+ end = new Date().getTime();
+ time = end - start;
+ console.log('Read execution time: ' + time);
+
+
+
+
+
+
+ }.bind(this));
+
+
+ ////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////
+
+
+
//Checking for local storage of URL for IO
if (window.localStorage['ioRootUrl']) {
//Getting URL from local storage
@@ -74,62 +151,6 @@ exports.CoreIoApi = Montage.create(Component, {
},
////////////////////////////////////////////////////////////////////
//
- showCloudDialog: {
- enumerable: false,
- value: function () {
- //
- this._cloudDialogOpen = true;
- //
- this._cloudDialogComponents.blackout = document.createElement('div');
- this._cloudDialogComponents.blackout.style.width = '100%';
- this._cloudDialogComponents.blackout.style.height = '100%';
- this._cloudDialogComponents.blackout.style.background = '-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)';
- this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout);
- //
- ////////////////////////////////////////////////////
- //Creating popup from m-js component
- var popup = document.createElement('div');
- //
- this._cloudDialogComponents.dialog = CloudPopup.create();
- //
- document.body.appendChild(popup);
- //
- this._cloudDialogComponents.dialog.element = popup;
- this._cloudDialogComponents.dialog.needsDraw = true;
- this._cloudDialogComponents.dialog.element.style.opacity = 0;
- //
- this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false);
- }
- },
- ////////////////////////////////////////////////////////////////////
- //
- handleFirstDraw: {
- value: function (e) {
- if (e._target._element.className === 'cloud_popup') {
- this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false);
- //
- this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '50%', y: '50%'});
- this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false);
- } else {
- //
- this._cloudDialogComponents.dialog.element.style.opacity = 1;
- this._cloudDialogComponents.popup.element.style.opacity = 1;
- this._cloudDialogComponents.popup.element.style.margin = '-100px 0px 0px -190px';
- }
- }
- },
- ////////////////////////////////////////////////////////////////////
- //
- hideCloudDialog: {
- enumerable: false,
- value: function () {
- //
- this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.blackout);
- this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.popup.element);
- }
- },
- ////////////////////////////////////////////////////////////////////
- //
_ioServiceDetected: {
enumerable: false,
value: false
@@ -234,6 +255,62 @@ exports.CoreIoApi = Montage.create(Component, {
}
},
////////////////////////////////////////////////////////////////////
+ //
+ showCloudDialog: {
+ enumerable: false,
+ value: function () {
+ //
+ this._cloudDialogOpen = true;
+ //
+ this._cloudDialogComponents.blackout = document.createElement('div');
+ this._cloudDialogComponents.blackout.style.width = '100%';
+ this._cloudDialogComponents.blackout.style.height = '100%';
+ this._cloudDialogComponents.blackout.style.background = '-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)';
+ this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout);
+ //
+ ////////////////////////////////////////////////////
+ //Creating popup from m-js component
+ var popup = document.createElement('div');
+ //
+ this._cloudDialogComponents.dialog = CloudPopup.create();
+ //
+ document.body.appendChild(popup);
+ //
+ this._cloudDialogComponents.dialog.element = popup;
+ this._cloudDialogComponents.dialog.needsDraw = true;
+ this._cloudDialogComponents.dialog.element.style.opacity = 0;
+ //
+ this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false);
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ handleFirstDraw: {
+ value: function (e) {
+ if (e._target._element.className === 'cloud_popup') {
+ this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false);
+ //
+ this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '50%', y: '50%'});
+ this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false);
+ } else {
+ //
+ this._cloudDialogComponents.dialog.element.style.opacity = 1;
+ this._cloudDialogComponents.popup.element.style.opacity = 1;
+ this._cloudDialogComponents.popup.element.style.margin = '-100px 0px 0px -190px';
+ }
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
+ //
+ hideCloudDialog: {
+ enumerable: false,
+ value: function () {
+ //
+ this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.blackout);
+ this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.popup.element);
+ }
+ },
+ ////////////////////////////////////////////////////////////////////
// Checks for the existence of a file
// Parameters:
// the file parameter must contain the following properties
diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js
index f40aa96b..4ab98606 100755
--- a/js/io/system/fileio.js
+++ b/js/io/system/fileio.js
@@ -3,6 +3,7 @@ This file contains proprietary software owned by Motorola Mobility, Inc.
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
*/
+
/* /////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
NOTES:
@@ -62,6 +63,8 @@ exports.FileIo = Montage.create(Object.prototype, {
return status;
}
},
+ ////////////////////////////////////////////////////////////////////
+ //
readFile: {
enumerable: true,
value: function() {
@@ -73,6 +76,8 @@ exports.FileIo = Montage.create(Object.prototype, {
//
}
},
+ ////////////////////////////////////////////////////////////////////
+ //
saveFile: {
enumerable: true,
value: function() {
@@ -84,6 +89,8 @@ exports.FileIo = Montage.create(Object.prototype, {
//
}
},
+ ////////////////////////////////////////////////////////////////////
+ //
copyFile: {
enumerable: true,
value: function() {
@@ -95,6 +102,8 @@ exports.FileIo = Montage.create(Object.prototype, {
//
}
},
+ ////////////////////////////////////////////////////////////////////
+ //
infoFile: {
enumerable: true,
value: function() {
@@ -106,7 +115,8 @@ exports.FileIo = Montage.create(Object.prototype, {
//
}
}
-
+ ////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////
@@ -339,8 +349,7 @@ open: {
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
+
});
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
\ No newline at end of file
diff --git a/js/io/ui/cloudpopup.reel/css/cloudpopup.css b/js/io/ui/cloudpopup.reel/css/cloudpopup.css
index 6d804e50..fcf85e75 100644
--- a/js/io/ui/cloudpopup.reel/css/cloudpopup.css
+++ b/js/io/ui/cloudpopup.reel/css/cloudpopup.css
@@ -43,7 +43,7 @@
.cloud_popup .content .btn_test {
float: right;
clear: right;
- margin: 0px 0px 0px 8px;
+ margin: 1px 2px 0px 8px;
width: 60px;
}
@@ -94,5 +94,5 @@
width: 80px;
text-align: center;
float: right;
- margin: 8px 0px 0px 8px;
+ margin: 8px 2px 2px 8px;
}
diff --git a/js/io/ui/cloudpopup.reel/css/cloudpopup.scss b/js/io/ui/cloudpopup.reel/css/cloudpopup.scss
index 5137beff..b8c9f880 100755
--- a/js/io/ui/cloudpopup.reel/css/cloudpopup.scss
+++ b/js/io/ui/cloudpopup.reel/css/cloudpopup.scss
@@ -47,7 +47,7 @@ $grey_light: #494949;
{
float: right;
clear: right;
- margin: 0px 0px 0px 8px;
+ margin: 1px 2px 0px 8px;
width: 60px;
}
@@ -98,5 +98,5 @@ $grey_light: #494949;
width: 80px;
text-align: center;
float: right;
- margin: 8px 0px 0px 8px;
+ margin: 8px 2px 2px 8px;
}
\ No newline at end of file
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index f778c849..8d0a671e 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -6,9 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
////////////////////////////////////////////////////////////////////////
//
-var Montage = require("montage/core/core").Montage,
- FileIo = require("js/io/system/fileio").FileIo,
- ProjectIo = require("js/io/system/projectio").ProjectIo;
+var Montage = require("montage/core/core").Montage,
+ FileIo = require("js/io/system/fileio").FileIo,
+ ProjectIo = require("js/io/system/projectio").ProjectIo;
////////////////////////////////////////////////////////////////////////
//
exports.IoMediator = Montage.create(Object.prototype, {
--
cgit v1.2.3