aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-02 23:55:33 -0800
committerJose Antonio Marquez2012-02-02 23:55:33 -0800
commit8e06b63e5eab5558823f4923e20a832c8b36cbe2 (patch)
treeb386ccc6226c6bd35790a2b702bd369627c2fc22
parent9b5ad78b393e87d84e79abe0abd0c96a685e5962 (diff)
downloadninja-8e06b63e5eab5558823f4923e20a832c8b36cbe2.tar.gz
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.
-rwxr-xr-xjs/io/system/coreioapi.js189
-rwxr-xr-xjs/io/system/fileio.js15
-rw-r--r--js/io/ui/cloudpopup.reel/css/cloudpopup.css4
-rwxr-xr-xjs/io/ui/cloudpopup.reel/css/cloudpopup.scss4
-rw-r--r--js/mediators/io-mediator.js6
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
7/* ///////////////////////////////////////////////////////////////////// 7/* /////////////////////////////////////////////////////////////////////
8//////////////////////////////////////////////////////////////////////// 8////////////////////////////////////////////////////////////////////////
9NOTES: 9NOTES:
10
11 Core API reference in NINJA: this.application.ninja.coreIoApi
12
10//////////////////////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////////////////////
11///////////////////////////////////////////////////////////////////// */ 14///////////////////////////////////////////////////////////////////// */
12var Montage = require("montage/core/core").Montage, 15var Montage = require("montage/core/core").Montage,
@@ -21,6 +24,80 @@ exports.CoreIoApi = Montage.create(Component, {
21 deserializedFromTemplate: { 24 deserializedFromTemplate: {
22 enumerable: false, 25 enumerable: false,
23 value: function () { 26 value: function () {
27
28
29
30 ////////////////////////////////////////////////////////////
31 ////////////////////////////////////////////////////////////
32 //TODO: Remove, this is only for testing
33
34
35 window.webkitRequestFileSystem(window.PERSISTENT, 10*1024*1024 /*10MB*/, function (fs) {
36
37
38 console.log(fs);
39
40 var start = new Date().getTime();
41
42 for (var i=0; i<250; i++) {
43
44 fs.root.getFile('test'+i+'.txt', {create: true}, function(fileEntry) {
45
46 fileEntry.createWriter(function(fileWriter) {
47
48 var bb = new window.WebKitBlobBuilder;
49 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');
50 fileWriter.write(bb.getBlob('text/plain'));
51
52 });
53
54 });
55
56 }
57
58 var end = new Date().getTime();
59 var time = end - start;
60 console.log('Create execution time: ' + time);
61
62 start = new Date().getTime();
63
64 for (var j=0; j<250; j++) {
65
66 fs.root.getFile('test'+j+'.txt', {create: true}, function(fileEntry) {
67
68 fileEntry.file(function(file) {
69
70 var reader = new FileReader();
71 reader.onloadend = function(e) {
72 console.log(this.result);
73 };
74
75 reader.readAsText(file);
76
77 });
78
79 });
80
81 }
82
83
84 end = new Date().getTime();
85 time = end - start;
86 console.log('Read execution time: ' + time);
87
88
89
90
91
92
93 }.bind(this));
94
95
96 ////////////////////////////////////////////////////////////
97 ////////////////////////////////////////////////////////////
98
99
100
24 //Checking for local storage of URL for IO 101 //Checking for local storage of URL for IO
25 if (window.localStorage['ioRootUrl']) { 102 if (window.localStorage['ioRootUrl']) {
26 //Getting URL from local storage 103 //Getting URL from local storage
@@ -74,62 +151,6 @@ exports.CoreIoApi = Montage.create(Component, {
74 }, 151 },
75 //////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////
76 // 153 //
77 showCloudDialog: {
78 enumerable: false,
79 value: function () {
80 //
81 this._cloudDialogOpen = true;
82 //
83 this._cloudDialogComponents.blackout = document.createElement('div');
84 this._cloudDialogComponents.blackout.style.width = '100%';
85 this._cloudDialogComponents.blackout.style.height = '100%';
86 this._cloudDialogComponents.blackout.style.background = '-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)';
87 this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout);
88 //
89 ////////////////////////////////////////////////////
90 //Creating popup from m-js component
91 var popup = document.createElement('div');
92 //
93 this._cloudDialogComponents.dialog = CloudPopup.create();
94 //
95 document.body.appendChild(popup);
96 //
97 this._cloudDialogComponents.dialog.element = popup;
98 this._cloudDialogComponents.dialog.needsDraw = true;
99 this._cloudDialogComponents.dialog.element.style.opacity = 0;
100 //
101 this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false);
102 }
103 },
104 ////////////////////////////////////////////////////////////////////
105 //
106 handleFirstDraw: {
107 value: function (e) {
108 if (e._target._element.className === 'cloud_popup') {
109 this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false);
110 //
111 this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '50%', y: '50%'});
112 this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false);
113 } else {
114 //
115 this._cloudDialogComponents.dialog.element.style.opacity = 1;
116 this._cloudDialogComponents.popup.element.style.opacity = 1;
117 this._cloudDialogComponents.popup.element.style.margin = '-100px 0px 0px -190px';
118 }
119 }
120 },
121 ////////////////////////////////////////////////////////////////////
122 //
123 hideCloudDialog: {
124 enumerable: false,
125 value: function () {
126 //
127 this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.blackout);
128 this.application.ninja.popupManager.removePopup(this._cloudDialogComponents.popup.element);
129 }
130 },
131 ////////////////////////////////////////////////////////////////////
132 //
133 _ioServiceDetected: { 154 _ioServiceDetected: {
134 enumerable: false, 155 enumerable: false,
135 value: false 156 value: false
@@ -234,6 +255,62 @@ exports.CoreIoApi = Montage.create(Component, {
234 } 255 }
235 }, 256 },
236 //////////////////////////////////////////////////////////////////// 257 ////////////////////////////////////////////////////////////////////
258 //
259 showCloudDialog: {
260 enumerable: false,
261 value: function () {
262 //
263 this._cloudDialogOpen = true;
264 //
265 this._cloudDialogComponents.blackout = document.createElement('div');
266 this._cloudDialogComponents.blackout.style.width = '100%';
267 this._cloudDialogComponents.blackout.style.height = '100%';
268 this._cloudDialogComponents.blackout.style.background = '-webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,.65) 0%, rgba(0,0,0,0.8) 80%)';
269 this.application.ninja.popupManager.addPopup(this._cloudDialogComponents.blackout);
270 //
271 ////////////////////////////////////////////////////
272 //Creating popup from m-js component
273 var popup = document.createElement('div');
274 //
275 this._cloudDialogComponents.dialog = CloudPopup.create();
276 //
277 document.body.appendChild(popup);
278 //
279 this._cloudDialogComponents.dialog.element = popup;
280 this._cloudDialogComponents.dialog.needsDraw = true;
281 this._cloudDialogComponents.dialog.element.style.opacity = 0;
282 //
283 this._cloudDialogComponents.dialog.addEventListener('firstDraw', this, false);
284 }
285 },
286 ////////////////////////////////////////////////////////////////////
287 //
288 handleFirstDraw: {
289 value: function (e) {
290 if (e._target._element.className === 'cloud_popup') {
291 this._cloudDialogComponents.dialog.removeEventListener('firstDraw', this, false);
292 //
293 this._cloudDialogComponents.popup = this.application.ninja.popupManager.createPopup(this._cloudDialogComponents.dialog.element, {x: '50%', y: '50%'});
294 this._cloudDialogComponents.popup.addEventListener('firstDraw', this, false);
295 } else {
296 //
297 this._cloudDialogComponents.dialog.element.style.opacity = 1;
298 this._cloudDialogComponents.popup.element.style.opacity = 1;
299 this._cloudDialogComponents.