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

Side by Side Diff: content/test/cpp_binding_example.h

Issue 25378002: Move the rest of source files from webkit/renderer to content/renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CONTENT_TEST_CPP_BINDING_EXAMPLE_H_ 5 #ifndef CONTENT_TEST_CPP_BINDING_EXAMPLE_H_
6 #define CONTENT_TEST_CPP_BINDING_EXAMPLE_H_ 6 #define CONTENT_TEST_CPP_BINDING_EXAMPLE_H_
7 7
8 /* 8 /*
9 CppBindingExample class: 9 CppBindingExample class:
10 This provides an example of how to use the CppBoundClass to create methods 10 This provides an example of how to use the CppBoundClass to create methods
(...skipping 15 matching lines...) Expand all
26 document.writeln(example.echoType("Hello world!")); 26 document.writeln(example.echoType("Hello world!"));
27 document.writeln(example.plus(2, 3.1)); 27 document.writeln(example.plus(2, 3.1));
28 28
29 example.my_value = 15; 29 example.my_value = 15;
30 example.my_other_value = 2.1; 30 example.my_other_value = 2.1;
31 document.writeln(example.plus(example.my_value, example.my_other_value)); 31 document.writeln(example.plus(example.my_value, example.my_other_value));
32 } 32 }
33 </script> 33 </script>
34 */ 34 */
35 35
36 #include "webkit/renderer/cpp_bound_class.h" 36 #include "content/renderer/cpp_bound_class.h"
37 37
38 namespace content { 38 namespace content {
39 39
40 class CppBindingExample : public webkit_glue::CppBoundClass { 40 class CppBindingExample : public CppBoundClass {
41 public: 41 public:
42 // The default constructor initializes the property and method lists needed 42 // The default constructor initializes the property and method lists needed
43 // to bind this class to a JS object. 43 // to bind this class to a JS object.
44 CppBindingExample(); 44 CppBindingExample();
45 45
46 // 46 //
47 // These public member variables and methods implement the methods and 47 // These public member variables and methods implement the methods and
48 // properties that will be exposed to JavaScript. If needed, the class could 48 // properties that will be exposed to JavaScript. If needed, the class could
49 // also contain other methods or variables, which will be hidden from JS 49 // also contain other methods or variables, which will be hidden from JS
50 // as long as they're not mapped in the property and method lists created in 50 // as long as they're not mapped in the property and method lists created in
51 // the constructor. 51 // the constructor.
52 // 52 //
53 // The signatures of any methods to be bound must match 53 // The signatures of any methods to be bound must match
54 // CppBoundClass::Callback. 54 // CppBoundClass::Callback.
55 // 55 //
56 56
57 // Returns the value that was passed in as its first (only) argument. 57 // Returns the value that was passed in as its first (only) argument.
58 void echoValue(const webkit_glue::CppArgumentList& args, 58 void echoValue(const CppArgumentList& args, CppVariant* result);
59 webkit_glue::CppVariant* result);
60 59
61 // Returns a hard-coded value of the same type (bool, number (double), 60 // Returns a hard-coded value of the same type (bool, number (double),
62 // string, or null) that was passed in as an argument. 61 // string, or null) that was passed in as an argument.
63 void echoType(const webkit_glue::CppArgumentList& args, 62 void echoType(const CppArgumentList& args, CppVariant* result);
64 webkit_glue::CppVariant* result);
65 63
66 // Returns the sum of the (first) two arguments as a double, if they are both 64 // Returns the sum of the (first) two arguments as a double, if they are both
67 // numbers (integers or doubles). Otherwise returns null. 65 // numbers (integers or doubles). Otherwise returns null.
68 void plus(const webkit_glue::CppArgumentList& args, 66 void plus(const CppArgumentList& args, CppVariant* result);
69 webkit_glue::CppVariant* result);
70 67
71 // Always returns the same value -- an example of a read-only property. 68 // Always returns the same value -- an example of a read-only property.
72 void same(webkit_glue::CppVariant* result); 69 void same(CppVariant* result);
73 70
74 // Invoked when a nonexistent method is called on this example object, this 71 // Invoked when a nonexistent method is called on this example object, this
75 // prints an error message. 72 // prints an error message.
76 void fallbackMethod(const webkit_glue::CppArgumentList& args, 73 void fallbackMethod(const CppArgumentList& args, CppVariant* result);
77 webkit_glue::CppVariant* result);
78 74
79 // These properties will also be exposed to JavaScript. 75 // These properties will also be exposed to JavaScript.
80 webkit_glue::CppVariant my_value; 76 CppVariant my_value;
81 webkit_glue::CppVariant my_other_value; 77 CppVariant my_other_value;
82 }; 78 };
83 79
84 } // namespace content 80 } // namespace content
85 81
86 #endif // CONTENT_TEST_CPP_BINDING_EXAMPLE_H_ 82 #endif // CONTENT_TEST_CPP_BINDING_EXAMPLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698