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

Unified Diff: native_client_sdk/src/examples/hello_nacl_io/example.js

Issue 13488007: [NaCl SDK] Make the SDK examples buildable as a packaged app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix license headers Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/examples/hello_nacl_io/example.js
diff --git a/native_client_sdk/src/examples/hello_nacl_io/example.js b/native_client_sdk/src/examples/hello_nacl_io/example.js
index c355b4d08a426a9351e8ce4ed3d7868ddad9d492..e764c21fc84df35923f867ecc4b730326ed8bc52 100644
--- a/native_client_sdk/src/examples/hello_nacl_io/example.js
+++ b/native_client_sdk/src/examples/hello_nacl_io/example.js
@@ -78,7 +78,7 @@ function fopen_result(filename, filehandle) {
filehandle_map[filehandle] = filename;
addFilenameToSelectElements(filehandle, filename)
- logMessage('File ' + filename + ' opened successfully.');
+ common.logMessage('File ' + filename + ' opened successfully.\n');
}
function fclose(e) {
@@ -89,7 +89,7 @@ function fclose(e) {
function fclose_result(filehandle) {
var filename = filehandle_map[filehandle];
removeFilenameFromSelectElements(filehandle, filename);
- logMessage('File ' + filename + ' closed successfully.');
+ common.logMessage('File ' + filename + ' closed successfully.\n');
}
function fread(e) {
@@ -100,7 +100,7 @@ function fread(e) {
function fread_result(filehandle, data) {
var filename = filehandle_map[filehandle];
- logMessage('Read "' + data + '" from file ' + filename + '.');
+ common.logMessage('Read "' + data + '" from file ' + filename + '.\n');
}
function fwrite(e) {
@@ -111,7 +111,8 @@ function fwrite(e) {
function fwrite_result(filehandle, bytes_written) {
var filename = filehandle_map[filehandle];
- logMessage('Wrote ' + bytes_written + ' bytes to file ' + filename + '.');
+ common.logMessage('Wrote ' + bytes_written + ' bytes to file ' + filename +
+ '.\n');
}
function fseek(e) {
@@ -123,7 +124,8 @@ function fseek(e) {
function fseek_result(filehandle, filepos) {
var filename = filehandle_map[filehandle];
- logMessage('Seeked to location ' + filepos + ' in file ' + filename + '.');
+ common.logMessage('Seeked to location ' + filepos + ' in file ' + filename +
+ '.\n');
}
/**
@@ -138,19 +140,6 @@ function startsWith(s, prefix) {
return s.lastIndexOf(prefix, 0) === 0;
}
-function logMessage(msg) {
- var logEl = document.getElementById('log');
-
- // Perform some basic escaping.
- msg = msg.replace(/&/g, '&')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;')
- .replace(/"/g, '&quot;')
- .replace(/'/g, '&apos;');
-
- logEl.innerHTML += msg + '<br>';
-}
-
function makeCall(func) {
var message = func;
for (var i = 1; i < arguments.length; ++i) {
@@ -164,7 +153,7 @@ function makeCall(func) {
function handleMessage(message_event) {
var msg = message_event.data;
if (startsWith(msg, 'Error:')) {
- logMessage(msg);
+ common.logMessage(msg + '\n');
} else {
// Result from a function call.
var params = msg.split('\1');
@@ -173,7 +162,7 @@ function handleMessage(message_event) {
var result_func = window[func_result_name];
if (!result_func) {
- logMessage('Error: Bad message received from NaCl module.');
+ common.logMessage('Error: Bad message received from NaCl module.\n');
return;
}
« no previous file with comments | « native_client_sdk/src/examples/hello_nacl_io/example.dsc ('k') | native_client_sdk/src/examples/hello_nacl_io/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698