summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools/bound_object.cc
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 09:53:27 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 09:53:27 +0000
commitb004209b94e258e9ca5a2356e4bd108f8443e142 (patch)
tree5f0170dfafbaa7b3a7e0fc48e502396e6e09004e /webkit/glue/devtools/bound_object.cc
parentbc296f37929b762850ce2c3b317f8542bdace2a1 (diff)
downloadchromium_src-b004209b94e258e9ca5a2356e4bd108f8443e142.zip
chromium_src-b004209b94e258e9ca5a2356e4bd108f8443e142.tar.gz
chromium_src-b004209b94e258e9ca5a2356e4bd108f8443e142.tar.bz2
DevTools: Migrate to InspectorController for network and console events.
- introduced bound object on the agent side; - established remote dispatch of WebInspector calls - using fake InspectorFrontend for serializing events and sending them over the ipc - removed net agents from both sides - moved GetResource stuff to tools agent Assumes following is landed: https://bugs.webkit.org/show_bug.cgi?id=26010 Review URL: http://codereview.chromium.org/113836 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/devtools/bound_object.cc')
-rw-r--r--webkit/glue/devtools/bound_object.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/webkit/glue/devtools/bound_object.cc b/webkit/glue/devtools/bound_object.cc
new file mode 100644
index 0000000..e786b7fb
--- /dev/null
+++ b/webkit/glue/devtools/bound_object.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2009 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.
+
+#include "config.h"
+
+#include <string>
+
+#include "v8_proxy.h"
+#include "webkit/glue/devtools/bound_object.h"
+
+using namespace WebCore;
+
+BoundObject::BoundObject(
+ v8::Handle<v8::Context> context,
+ void* v8_this,
+ const char* object_name)
+ : context_(context),
+ object_name_(object_name) {
+ v8::HandleScope scope;
+ v8::Context::Scope context_scope(context);
+ v8_this_ = v8::Persistent<v8::External>::New(v8::External::New(v8_this));
+
+ v8::Local<v8::FunctionTemplate> local_template =
+ v8::FunctionTemplate::New(V8Proxy::CheckNewLegal);
+ host_template_ = v8::Persistent<v8::FunctionTemplate>::New(local_template);
+ host_template_->SetClassName(v8::String::New(object_name));
+}
+
+BoundObject::~BoundObject() {
+ bound_object_.Dispose();
+ host_template_.Dispose();
+ v8_this_.Dispose();
+}
+
+void BoundObject::AddProtoFunction(
+ const char* name,
+ v8::InvocationCallback callback) {
+ v8::HandleScope scope;
+ v8::Local<v8::Signature> signature = v8::Signature::New(host_template_);
+ v8::Local<v8::ObjectTemplate> proto = host_template_->PrototypeTemplate();
+ proto->Set(
+ v8::String::New(name),
+ v8::FunctionTemplate::New(
+ callback,
+ v8_this_,
+ signature),
+ static_cast<v8::PropertyAttribute>(v8::DontDelete));
+}
+
+void BoundObject::Build() {
+ v8::HandleScope scope;
+ v8::Context::Scope frame_scope(context_);
+
+ v8::Local<v8::Function> constructor = host_template_->GetFunction();
+ bound_object_ = v8::Persistent<v8::Object>::New(
+ SafeAllocation::NewInstance(constructor));
+
+ v8::Handle<v8::Object> global = context_->Global();
+ global->Set(v8::String::New(object_name_), bound_object_);
+}