From 2ba3ce740c528484a77e44fcbea5689564b7ce8c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 22 Apr 2013 16:16:55 +0800 Subject: [PATCH] Remove RemoteObject, C++ layer should only have basic bridges. --- atom.gyp | 3 -- common/api/api_messages.h | 2 +- common/api/atom_extensions.h | 2 - renderer/api/atom_api_remote_object.cc | 78 ---------------------------------- renderer/api/atom_api_remote_object.h | 47 -------------------- 5 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 renderer/api/atom_api_remote_object.cc delete mode 100644 renderer/api/atom_api_remote_object.h diff --git a/atom.gyp b/atom.gyp index 9df27fd..0f3b3ed 100644 --- a/atom.gyp +++ b/atom.gyp @@ -9,7 +9,6 @@ 'browser/api/lib/atom.coffee', 'browser/api/lib/window.coffee', 'browser/atom/atom.coffee', - 'renderer/api/lib/remote_object.coffee', ], 'lib_sources': [ 'app/atom_main_delegate.cc', @@ -53,8 +52,6 @@ 'common/options_switches.h', 'common/v8_value_converter_impl.cc', 'common/v8_value_converter_impl.h', - 'renderer/api/atom_api_remote_object.cc', - 'renderer/api/atom_api_remote_object.h', 'renderer/atom_render_view_observer.cc', 'renderer/atom_render_view_observer.h', 'renderer/atom_renderer_client.cc', diff --git a/common/api/api_messages.h b/common/api/api_messages.h index 05f9011..f10ff54 100644 --- a/common/api/api_messages.h +++ b/common/api/api_messages.h @@ -16,7 +16,7 @@ #define IPC_MESSAGE_START ShellMsgStart IPC_SYNC_MESSAGE_CONTROL2_1(AtomViewHostMsg_Allocate_Object, - std::string /* type name */, + std::string /* module */, DictionaryValue /* options */, int /* object id */) diff --git a/common/api/atom_extensions.h b/common/api/atom_extensions.h index 104f3e6..47bdd37 100644 --- a/common/api/atom_extensions.h +++ b/common/api/atom_extensions.h @@ -10,6 +10,4 @@ NODE_EXT_LIST_START NODE_EXT_LIST_ITEM(atom_browser_window) -NODE_EXT_LIST_ITEM(atom_renderer_remote_object) - NODE_EXT_LIST_END diff --git a/renderer/api/atom_api_remote_object.cc b/renderer/api/atom_api_remote_object.cc deleted file mode 100644 index 030675a..0000000 --- a/renderer/api/atom_api_remote_object.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "renderer/api/atom_api_remote_object.h" - -#include "base/logging.h" - -namespace atom { - -namespace api { - -RemoteObject::RemoteObject(v8::Handle wrapper, - const std::string& type) - : id_(-1) { - // TODO apply for new object in browser. - Wrap(wrapper); -} - -RemoteObject::RemoteObject(v8::Handle wrapper, int id) - : id_(id) { - Wrap(wrapper); -} - -RemoteObject::~RemoteObject() { - Destroy(); -} - -void RemoteObject::Destroy() { - DCHECK(id_ > 0); - - // TODO release me in browser. -} - -// static -v8::Handle RemoteObject::New(const v8::Arguments &args) { - v8::HandleScope scope; - - if (args[0]->IsString()) - new RemoteObject(args.This(), *v8::String::Utf8Value(args[0])); - else if (args[0]->IsNumber()) - new RemoteObject(args.This(), args[0]->IntegerValue()); - else - return node::ThrowTypeError("Bad argument"); - - return args.This(); -} - -// static -v8::Handle RemoteObject::Destroy(const v8::Arguments &args) { - RemoteObject* self = ObjectWrap::Unwrap(args.This()); - - // TODO try to call remote object's destroy method first. - - delete self; - - return v8::Undefined(); -} - -// static -void RemoteObject::Initialize(v8::Handle target) { - v8::HandleScope scope; - - v8::Local t = - v8::FunctionTemplate::New(RemoteObject::New); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->SetClassName(v8::String::NewSymbol("RemoteObject")); - - NODE_SET_PROTOTYPE_METHOD(t, "destroy", Destroy); - - target->Set(v8::String::NewSymbol("RemoteObject"), t->GetFunction()); -} - -} // namespace api - -} // namespace atom - -NODE_MODULE(atom_renderer_remote_object, atom::api::RemoteObject::Initialize) diff --git a/renderer/api/atom_api_remote_object.h b/renderer/api/atom_api_remote_object.h deleted file mode 100644 index a9e09ce..0000000 --- a/renderer/api/atom_api_remote_object.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ATOM_RENDERER_ATOM_API_REMOTE_OBJECT_H_ -#define ATOM_RENDERER_ATOM_API_REMOTE_OBJECT_H_ - -#include - -#include "base/basictypes.h" -#include "vendor/node/src/node_object_wrap.h" - -namespace atom { - -namespace api { - -// Every instance of RemoteObject represents an object in browser. -class RemoteObject : public node::ObjectWrap { - public: - virtual ~RemoteObject(); - - static void Initialize(v8::Handle target); - - // Tell browser to destroy this object. - void Destroy(); - - int id() const { return id_; } - - protected: - explicit RemoteObject(v8::Handle wrapper, - const std::string& type); - explicit RemoteObject(v8::Handle wrapper, int id); - - private: - static v8::Handle New(const v8::Arguments &args); - static v8::Handle Destroy(const v8::Arguments &args); - - int id_; - - DISALLOW_COPY_AND_ASSIGN(RemoteObject); -}; - -} // namespace api - -} // namespace atom - -#endif // ATOM_RENDERER_ATOM_API_REMOTE_OBJECT_H_ -- 2.7.4