Chromium Code Reviews| Index: content/browser/renderer_host/java_bridge_dispatcher_host_manager.h |
| diff --git a/content/browser/renderer_host/java_bridge_dispatcher_host_manager.h b/content/browser/renderer_host/java_bridge_dispatcher_host_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..00dc2ad6cb4cf63eedb6912fb34b5776916e3e63 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/java_bridge_dispatcher_host_manager.h |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2011 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. |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H_ |
| +#define CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H_ |
| +#pragma once |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/string16.h" |
| +#include "content/browser/tab_contents/tab_contents_observer.h" |
| + |
| +#include <map> |
|
jam
2011/10/21 16:18:21
nit: this goes first
|
| + |
| +class JavaBridgeDispatcherHost; |
| +class RenderViewHost; |
| +struct NPObject; |
| + |
| +// This class handles injecting Java objects into all of the RenderViews |
| +// associated with a TabContents. It manages a set of JavaBridgeDispatcherHost |
| +// objects, one per RenderViewHost. |
| +class JavaBridgeDispatcherHostManager : public TabContentsObserver { |
| + public: |
| + JavaBridgeDispatcherHostManager(TabContents* tab_contents); |
| + |
| + // These methods add or remove the object to each JavaBridgeDispatcherHost. |
| + // Each one holds a reference to the NPObject while the object is bound to |
| + // the corresponding RenderView. See JavaBridgeDispatcherHost for details. |
| + void AddNamedObject(const string16& name, NPObject* object); |
| + void RemoveNamedObject(const string16& name); |
| + |
| + // TabContentsObserver overrides |
| + virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| + virtual void RenderViewDeleted(RenderViewHost* render_view_host) OVERRIDE; |
| + virtual void TabContentsDestroyed(TabContents* tab_contents) OVERRIDE; |
| + |
| + private: |
| + friend class scoped_ptr<JavaBridgeDispatcherHostManager>; |
|
jam
2011/10/21 16:18:21
i haven't seen this pattern before with scoped_ptr
|
| + virtual ~JavaBridgeDispatcherHostManager(); |
| + |
| + typedef std::map<RenderViewHost*, scoped_refptr<JavaBridgeDispatcherHost> > |
| + InstanceMap; |
| + InstanceMap instances_; |
| + typedef std::map<string16, NPObject*> ObjectMap; |
| + ObjectMap objects_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(JavaBridgeDispatcherHostManager); |
| +}; |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_JAVA_BRIDGE_DISPATCHER_HOST_MANAGER_H_ |