Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / renderer / browser_plugin / browser_plugin_bindings.h
blob91e8ced84390c0a5f56263d455e2c2f8ab197bb9
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__
8 #include "base/memory/scoped_vector.h"
9 #include "base/memory/weak_ptr.h"
10 #include "ppapi/shared_impl/resource.h"
11 #include "third_party/npapi/bindings/npruntime.h"
13 namespace content {
15 class BrowserPlugin;
16 class BrowserPluginMethodBinding;
17 class BrowserPluginPropertyBinding;
19 class BrowserPluginBindings {
20 public:
21 // BrowserPluginNPObject is a simple struct that adds a pointer back to a
22 // BrowserPluginBindings instance. This way, we can use an NPObject to allow
23 // JavaScript interactions without forcing BrowserPluginBindings to inherit
24 // from NPObject.
25 struct BrowserPluginNPObject : public NPObject {
26 BrowserPluginNPObject();
27 ~BrowserPluginNPObject();
29 base::WeakPtr<BrowserPluginBindings> message_channel;
32 explicit BrowserPluginBindings(BrowserPlugin* instance);
33 ~BrowserPluginBindings();
35 NPObject* np_object() const { return np_object_; }
37 BrowserPlugin* instance() const { return instance_; }
39 bool HasMethod(NPIdentifier name) const;
41 bool InvokeMethod(NPIdentifier name,
42 const NPVariant* args,
43 uint32 arg_count,
44 NPVariant* result);
46 bool HasProperty(NPIdentifier name) const;
47 bool SetProperty(NPObject* np_obj,
48 NPIdentifier name,
49 const NPVariant* variant);
50 bool GetProperty(NPIdentifier name, NPVariant* result);
51 bool RemoveProperty(NPObject *np_obj, NPIdentifier name);
52 private:
53 BrowserPlugin* instance_;
54 // The NPObject we use to expose postMessage to JavaScript.
55 BrowserPluginNPObject* np_object_;
57 typedef ScopedVector<BrowserPluginMethodBinding> BindingList;
58 BindingList method_bindings_;
59 typedef ScopedVector<BrowserPluginPropertyBinding> PropertyBindingList;
60 PropertyBindingList property_bindings_;
62 // This is used to ensure pending tasks will not fire after this object is
63 // destroyed.
64 base::WeakPtrFactory<BrowserPluginBindings> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(BrowserPluginBindings);
69 } // namespace content
71 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_BINDINGS_H__