Index: native_client_sdk/src/examples/trace_events/example.js |
diff --git a/native_client_sdk/src/examples/trace_events/example.js b/native_client_sdk/src/examples/trace_events/example.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..60e232e13c721d4ef0e47e8aa394ba3f453a0ada |
--- /dev/null |
+++ b/native_client_sdk/src/examples/trace_events/example.js |
@@ -0,0 +1,37 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Called by the common.js module. |
+function moduleDidLoad() { |
+ // The module is not hidden by default so we can easily see if the plugin |
+ // failed to load. |
+ common.hideModule(); |
+} |
+ |
+// Called by the common.js module. |
+function attachListeners() { |
+ document.getElementById('runthreadedtask').addEventListener('click', |
+ runthreadedtask); |
+ document.getElementById('sendasynctrace').addEventListener('click', |
+ sendasynctrace); |
+} |
+ |
+function runthreadedtask() { |
+ common.naclModule.postMessage('runthreadedtask'); |
+} |
+ |
+function sendasynctrace() { |
+ var async_button = document.getElementById('sendasynctrace'); |
+ if (async_button.value == 'Send trace begin') { |
+ common.naclModule.postMessage('sendasyncbegin'); |
+ async_button.value = 'Send trace end'; |
+ } else { |
+ common.naclModule.postMessage('sendasyncend'); |
+ async_button.value = 'Send trace begin'; |
+ } |
+} |
+ |
+// Called by the common.js module. |
+function handleMessage(message_event) { |
+} |