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

Side by Side Diff: experimental/c_salt/instance.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
« no previous file with comments | « experimental/c_salt/image-inl.h ('k') | experimental/c_salt/instance.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 The Ginsu Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5 #ifndef C_SALT_INSTANCE_H_
6 #define C_SALT_INSTANCE_H_
7
8 #include <nacl/nacl_npapi.h>
9 #include <nacl/npruntime.h>
10 #include <nacl/npapi_extensions.h>
11
12 #include "boost/noncopyable.hpp"
13 #include "boost/scoped_ptr.hpp"
14 #include "c_salt/scriptable_native_object.h"
15 #include "c_salt/scripting_bridge.h"
16 #include "c_salt/scripting_bridge_ptrs.h"
17
18 namespace c_salt {
19
20 // The base class for the Native Client module instance. An Instance can
21 // publish a ScriptingBridge to the browser, that ScriptingBridge binds to
22 // methods and properties declared on this particulare Instance object. The
23 // Instance is also responsible for creating new ScriptingBridges as needed.
24 // Other objects are free to publish their own ScriptingBridges, that bind to
25 // those objects.
26 // Repeated calls to GetScriptingBridge() will simply increment
27 // a ref count of the published ScriptingBridge associated with this Instance.
28
29 // TODO(c_salt authors): Make this API agnostic. Also maybe don't force it to
30 // be a ScriptableNativeObject?
31 class Instance : public boost::noncopyable,
32 public ScriptableNativeObject {
33 public:
34 typedef enum {
35 URLLDR_NETWORK_ERROR = 1,
36 URLLDR_USER_BREAK = 2,
37 URLLDR_INTERNAL_ERROR = 3
38 } URLLoaderErrorCode;
39
40 explicit Instance(const NPP& npp_instance)
41 : is_loaded_(false), npp_instance_(npp_instance) {}
42 virtual ~Instance();
43
44 // Called during initialization to publish the module's method names that
45 // can be called from JavaScript.
46 virtual void InitializeMethods(ScriptingBridge* bridge);
47
48 // Called during initialization to publish the module's properties that can
49 // be called from JavaScript.
50 virtual void InitializeProperties(ScriptingBridge* bridge);
51
52 // Called the first time this module instance is loaded into the browser
53 // document. When this method is called, all the Pepper devices are
54 // available to the module instance.
55 virtual bool InstanceDidLoad(int width, int height);
56
57 // Called when there is a valid browser window for rendering, or whenever the
58 // in-browser view changes size.
59 virtual void WindowDidChangeSize(int width, int height);
60
61 // Receive an event from the browser. Return |false| if the module does not
62 // handle the event.
63 virtual bool ReceiveEvent(const NPPepperEvent& event);
64
65 // Create a ScriptingBridge that will expose the object to the browser. The
66 // ScriptingBridge takes ownership of the object. When a new
67 // ScriptingBridge instance is created, both InitializeMethods() and
68 // InitializeProperties() are called on the ScriptableNativeObject.
69 void CreateScriptingBridgeForObject(
70 SharedScriptableNativeObject native_object);
71
72 // Accessor for the in-browser NPAPI instance associated with this Instance.
73 const NPP npp_instance() const {
74 return npp_instance_;
75 }
76
77 // Accessor/mutator for |is_loaded_|. This is used to determine when to call
78 // the InstanceDidLoad() method.
79 bool is_loaded() const {
80 return is_loaded_;
81 }
82 void set_is_loaded(bool flag) {
83 is_loaded_ = flag;
84 }
85
86 // Access to window object in the scripting bridge is necessary for now in
87 // order to support NPAPI coding for subclasses.
88 NPObject* WindowObject() const {
89 return scripting_bridge_->window_object();
90 }
91
92 // Callbacks for GetURL, GetURLNotify.
93 // Should go away with PPAPI v2.
94 // |data| is managed by c_salt, do not delete it, do not store pointer to it.
95 virtual void OnURLLoaded(const char* data, size_t data_sz) {}
96
97 // Called only in case of error.
98 virtual void OnURLLoadFailed(URLLoaderErrorCode error) {}
99
100 private:
101 bool is_loaded_;
102
103 boost::scoped_ptr<ScriptingBridge> scripting_bridge_;
104
105 // TODO(c_salt_authors): this needs to be turned into a BrowserInstanceImpl.
106 NPP npp_instance_;
107
108 Instance(); // Not implemented, do not use.
109 };
110
111 } // namespace c_salt
112
113 #endif // C_SALT_INSTANCE_H_
OLDNEW
« no previous file with comments | « experimental/c_salt/image-inl.h ('k') | experimental/c_salt/instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698