OLD | NEW |
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 /// @file file_io.cc | 5 /// @file file_io.cc |
6 /// This example demonstrates the use of persistent file I/O | 6 /// This example demonstrates the use of persistent file I/O |
7 | 7 |
8 #define __STDC_LIMIT_MACROS | 8 #define __STDC_LIMIT_MACROS |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 message.Set(i + 1, strings[i]); | 93 message.Set(i + 1, strings[i]); |
94 } | 94 } |
95 | 95 |
96 PostMessage(message); | 96 PostMessage(message); |
97 } | 97 } |
98 | 98 |
99 void PostArrayMessage(const char* command) { | 99 void PostArrayMessage(const char* command) { |
100 PostArrayMessage(command, StringVector()); | 100 PostArrayMessage(command, StringVector()); |
101 } | 101 } |
102 | 102 |
103 void PostArrayMessage(const char* command, std::string s) { | 103 void PostArrayMessage(const char* command, const std::string& s) { |
104 StringVector sv; | 104 StringVector sv; |
105 sv.push_back(s); | 105 sv.push_back(s); |
106 PostArrayMessage(command, sv); | 106 PostArrayMessage(command, sv); |
107 } | 107 } |
108 | 108 |
109 /// Handler for messages coming in from the browser via postMessage(). The | 109 /// Handler for messages coming in from the browser via postMessage(). The |
110 /// @a var_message can contain anything: a JSON string; a string that encodes | 110 /// @a var_message can contain anything: a JSON string; a string that encodes |
111 /// method names and arguments; etc. | 111 /// method names and arguments; etc. |
112 /// | 112 /// |
113 /// Here we use messages to communicate with the user interface | 113 /// Here we use messages to communicate with the user interface |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 }; | 384 }; |
385 | 385 |
386 namespace pp { | 386 namespace pp { |
387 /// Factory function called by the browser when the module is first loaded. | 387 /// Factory function called by the browser when the module is first loaded. |
388 /// The browser keeps a singleton of this module. It calls the | 388 /// The browser keeps a singleton of this module. It calls the |
389 /// CreateInstance() method on the object you return to make instances. There | 389 /// CreateInstance() method on the object you return to make instances. There |
390 /// is one instance per <embed> tag on the page. This is the main binding | 390 /// is one instance per <embed> tag on the page. This is the main binding |
391 /// point for your NaCl module with the browser. | 391 /// point for your NaCl module with the browser. |
392 Module* CreateModule() { return new FileIoModule(); } | 392 Module* CreateModule() { return new FileIoModule(); } |
393 } // namespace pp | 393 } // namespace pp |
OLD | NEW |