Set up V8 bindings for extension/app APIs when they're first used, not on
context creation. This should gives us a significant reduction in extension/app
startup time and slightly better memory usage.

It also gives us better error messages, the chance to complete the 
implementation of API features, and eventually the ability to expose select
extension APIs (e.g. extension.sendMessage) to web pages.

Resubmitting: changes made to resubmit this patch reviewed in: https://codereview.chromium.org/12378077/

BUG=163678,120070,55316,177163
[email protected]

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=186643

Review URL: https://chromiumcodereview.appspot.com/11571014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187143 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/test/base/module_system_test.cc b/chrome/test/base/module_system_test.cc
index 9eef4da..c1f6517 100644
--- a/chrome/test/base/module_system_test.cc
+++ b/chrome/test/base/module_system_test.cc
@@ -7,7 +7,7 @@
 #include "base/callback.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/string_piece.h"
-#include "chrome/renderer/extensions/native_handler.h"
+#include "chrome/renderer/extensions/object_backed_native_handler.h"
 #include "ui/base/resource/resource_bundle.h"
 
 #include <map>
@@ -15,12 +15,13 @@
 
 using extensions::ModuleSystem;
 using extensions::NativeHandler;
+using extensions::ObjectBackedNativeHandler;
 
 // Native JS functions for doing asserts.
-class AssertNatives : public NativeHandler {
+class AssertNatives : public ObjectBackedNativeHandler {
  public:
-  explicit AssertNatives(v8::Isolate* isolate)
-      : NativeHandler(isolate),
+  explicit AssertNatives(v8::Handle<v8::Context> context)
+      : ObjectBackedNativeHandler(context),
         assertion_made_(false),
         failed_(false) {
     RouteFunction("AssertTrue", base::Bind(&AssertNatives::AssertTrue,
@@ -88,8 +89,8 @@
       source_map_(new StringSourceMap()),
       should_assertions_be_made_(true) {
   context_->Enter();
-  assert_natives_ = new AssertNatives(context_->GetIsolate());
-  module_system_.reset(new ModuleSystem(context_, source_map_.get()));
+  assert_natives_ = new AssertNatives(context_.get());
+  module_system_.reset(new ModuleSystem(context_.get(), source_map_.get()));
   module_system_->RegisterNativeHandler("assert", scoped_ptr<NativeHandler>(
       assert_natives_));
   module_system_->set_exception_handler(
@@ -99,7 +100,6 @@
 ModuleSystemTest::~ModuleSystemTest() {
   module_system_.reset();
   context_->Exit();
-  context_.Dispose(context_->GetIsolate());
 }
 
 void ModuleSystemTest::RegisterModule(const std::string& name,