Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: native_client_sdk/src/examples/api/file_io/example.js

Issue 15969018: Add directory_entry.cc to libppapi_cpp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Called by the common.js module. 5 // Called by the common.js module.
6 function domContentLoaded(name, tc, config, width, height) { 6 function domContentLoaded(name, tc, config, width, height) {
7 window.webkitStorageInfo.requestQuota(window.PERSISTENT, 1024*1024, 7 window.webkitStorageInfo.requestQuota(window.PERSISTENT, 1024*1024,
8 function(bytes) { 8 function(bytes) {
9 common.updateStatus( 9 common.updateStatus(
10 'Allocated '+bytes+' bytes of persistant storage.'); 10 'Allocated '+bytes+' bytes of persistant storage.');
11 common.createNaClModule(name, tc, config, width, height); 11 common.createNaClModule(name, tc, config, width, height);
12 common.attachDefaultListeners(); 12 common.attachDefaultListeners();
13 }, 13 },
14 function(e) { alert('Failed to allocate space') }); 14 function(e) { alert('Failed to allocate space') });
15 } 15 }
16 16
17 // Called by the common.js module. 17 // Called by the common.js module.
18 function attachListeners() { 18 function attachListeners() {
19 document.getElementById('saveButton').addEventListener('click', saveFile); 19 document.getElementById('saveButton').addEventListener('click', saveFile);
20 document.getElementById('loadButton').addEventListener('click', loadFile); 20 document.getElementById('loadButton').addEventListener('click', loadFile);
21 document.getElementById('deleteButton').addEventListener('click', deleteFile); 21 document.getElementById('deleteButton').addEventListener('click', deleteFile);
22 document.getElementById('listButton').addEventListener('click', listDir);
22 } 23 }
23 24
24 function loadFile() { 25 function loadFile() {
25 if (common.naclModule) { 26 if (common.naclModule) {
26 var fileName = document.getElementById('fileName').value; 27 var fileName = document.getElementById('fileName').value;
27 28
28 // Package a message using a simple protocol containing: 29 // Package a message using a simple protocol containing:
29 // instruction file_name_length file_name 30 // instruction file_name_length file_name
30 var msg = "ld " + fileName.length + " " + fileName; 31 var msg = "ld " + fileName.length + " " + fileName;
31 common.naclModule.postMessage(msg); 32 common.naclModule.postMessage(msg);
(...skipping 16 matching lines...) Expand all
48 if (common.naclModule) { 49 if (common.naclModule) {
49 var fileName = document.getElementById('fileName').value; 50 var fileName = document.getElementById('fileName').value;
50 51
51 // Package a message using a simple protocol containing: 52 // Package a message using a simple protocol containing:
52 // instruction file_name_length file_name 53 // instruction file_name_length file_name
53 var msg = "de " + fileName.length + " " + fileName; 54 var msg = "de " + fileName.length + " " + fileName;
54 common.naclModule.postMessage(msg); 55 common.naclModule.postMessage(msg);
55 } 56 }
56 } 57 }
57 58
59 function listDir() {
60 if (common.naclModule) {
61 var dirName = document.getElementById('dirName').value;
62
63 // Package a message using a simple protocol containing:
64 // instruction file_name_length file_name
65 var msg = "ls " + dirName.length + " " + dirName;
66 common.naclModule.postMessage(msg);
67 }
68 }
69
58 // Called by the common.js module. 70 // Called by the common.js module.
59 function handleMessage(message_event) { 71 function handleMessage(message_event) {
60 var messageParts = message_event.data.split("|", 3); 72 var messageParts = message_event.data.split("|", 3);
61 73
62 if (messageParts[0] == "ERR") { 74 if (messageParts[0] == "ERR") {
63 common.updateStatus(messageParts[1]); 75 common.updateStatus(messageParts[1]);
64 document.getElementById('statusField').style.color = "red"; 76 document.getElementById('statusField').style.color = "red";
65 } 77 }
66 else if(messageParts[0] == "STAT") { 78 else if(messageParts[0] == "STAT") {
67 common.updateStatus(messageParts[1]); 79 common.updateStatus(messageParts[1]);
68 } 80 }
69 else if (messageParts[0] == "DISP") { 81 else if (messageParts[0] == "DISP") {
70 // Display the message in the file edit box 82 // Display the message in the file edit box
71 document.getElementById('fileEditor').value = messageParts[1]; 83 document.getElementById('fileEditor').value = messageParts[1];
72 } 84 }
73 else if (messageParts[0] == "READY") { 85 else if (messageParts[0] == "READY") {
74 var statusField = document.getElementById('statusField'); 86 var statusField = document.getElementById('statusField');
75 common.updateStatus(statusField.innerHTML + ' Ready!'); 87 common.updateStatus(statusField.innerHTML + ' Ready!');
76 } 88 }
77 } 89 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/sdk_files.list ('k') | native_client_sdk/src/examples/api/file_io/file_io.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698