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

Unified Diff: chrome/renderer/extensions/object_backed_native_handler.h

Issue 234413005: Move most of ChromeV8Context to a base ScriptContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: factor feature_channel out of module_system Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/object_backed_native_handler.h
diff --git a/chrome/renderer/extensions/object_backed_native_handler.h b/chrome/renderer/extensions/object_backed_native_handler.h
deleted file mode 100644
index 87bee004bf67acfbfbbc14e61a1ca3caafe1855b..0000000000000000000000000000000000000000
--- a/chrome/renderer/extensions/object_backed_native_handler.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) 2012 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 CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_
-#define CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_
-
-#include <string>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/memory/linked_ptr.h"
-#include "extensions/renderer/native_handler.h"
-#include "extensions/renderer/scoped_persistent.h"
-#include "v8/include/v8-util.h"
-#include "v8/include/v8.h"
-
-namespace extensions {
-class ChromeV8Context;
-
-// An ObjectBackedNativeHandler is a factory for JS objects with functions on
-// them that map to native C++ functions. Subclasses should call RouteFunction()
-// in their constructor to define functions on the created JS objects.
-class ObjectBackedNativeHandler : public NativeHandler {
- public:
- explicit ObjectBackedNativeHandler(ChromeV8Context* context);
- virtual ~ObjectBackedNativeHandler();
-
- // Create an object with bindings to the native functions defined through
- // RouteFunction().
- virtual v8::Handle<v8::Object> NewInstance() OVERRIDE;
-
- v8::Isolate* GetIsolate() const;
-
- protected:
- typedef base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)>
- HandlerFunction;
-
- // Installs a new 'route' from |name| to |handler_function|. This means that
- // NewInstance()s of this ObjectBackedNativeHandler will have a property
- // |name| which will be handled by |handler_function|.
- void RouteFunction(const std::string& name,
- const HandlerFunction& handler_function);
-
- ChromeV8Context* context() const { return context_; }
-
- virtual void Invalidate() OVERRIDE;
-
- private:
- // Callback for RouteFunction which routes the V8 call to the correct
- // base::Bound callback.
- static void Router(const v8::FunctionCallbackInfo<v8::Value>& args);
-
- // When RouteFunction is called we create a v8::Object to hold the data we
- // need when handling it in Router() - this is the base::Bound function to
- // route to.
- //
- // We need a v8::Object because it's possible for v8 to outlive the
- // base::Bound function; the lifetime of an ObjectBackedNativeHandler is the
- // lifetime of webkit's involvement with it, not the life of the v8 context.
- // A scenario when v8 will outlive us is if a frame holds onto the
- // contentWindow of an iframe after it's removed.
- //
- // So, we use v8::Objects here to hold that data, effectively refcounting
- // the data. When |this| is destroyed we remove the base::Bound function from
- // the object to indicate that it shoudn't be called.
- typedef v8::PersistentValueVector<v8::Object> RouterData;
- RouterData router_data_;
-
- ChromeV8Context* context_;
-
- ScopedPersistent<v8::ObjectTemplate> object_template_;
-
- DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler);
-};
-
-} // namespace extensions
-
-#endif // CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_
« no previous file with comments | « chrome/renderer/extensions/module_system_unittest.cc ('k') | chrome/renderer/extensions/object_backed_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698