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

Unified Diff: mojo/dbus/dbus_external_service.h

Issue 265793015: Mojo: Replace RemotePtr with InterfacePtr and InterfaceImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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: mojo/dbus/dbus_external_service.h
diff --git a/mojo/dbus/dbus_external_service.h b/mojo/dbus/dbus_external_service.h
index 1a33c4c7874bc44c182a0292c0d9ac6e44876795..c3e20e15538a9459e72d9a173a3166ca9c510635 100644
--- a/mojo/dbus/dbus_external_service.h
+++ b/mojo/dbus/dbus_external_service.h
@@ -8,8 +8,6 @@
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "mojo/common/channel_init.h"
-#include "mojo/public/cpp/bindings/interface.h"
-#include "mojo/public/cpp/bindings/remote_ptr.h"
#include "mojo/public/cpp/shell/application.h"
#include "mojo/public/interfaces/shell/shell.mojom.h"
#include "mojo/shell/external_service.mojom.h"
@@ -19,7 +17,7 @@ const char kMojoDBusImplPath[] = "/org/chromium/MojoImpl";
const char kMojoDBusInterface[] = "org.chromium.Mojo";
const char kMojoDBusConnectMethod[] = "ConnectChannel";
-class DBusExternalServiceBase : public mojo::ErrorHandler {
+class DBusExternalServiceBase {
public:
explicit DBusExternalServiceBase(const std::string& service_name);
virtual ~DBusExternalServiceBase();
@@ -28,15 +26,13 @@ class DBusExternalServiceBase : public mojo::ErrorHandler {
protected:
// TODO(cmasone): Enable multiple peers to connect/disconnect
- virtual void Connect(ScopedExternalServiceHostHandle client_handle) = 0;
+ virtual void Connect(ScopedMessagePipeHandle client_handle) = 0;
virtual void Disconnect() = 0;
private:
- virtual void OnError() OVERRIDE;
-
// Implementation of org.chromium.Mojo.ConnectChannel, exported over DBus.
// Takes a file descriptor and uses it to create a MessagePipe that is then
- // hooked to a RemotePtr<mojo::ExternalServiceHost>.
+ // hooked to an implementation of ExternalService.
void ConnectChannel(dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender sender);
@@ -47,13 +43,12 @@ class DBusExternalServiceBase : public mojo::ErrorHandler {
const std::string service_name_;
scoped_refptr<dbus::Bus> bus_;
dbus::ExportedObject* exported_object_; // Owned by bus_;
- scoped_ptr<mojo::common::ChannelInit> channel_init_;
+ scoped_ptr<common::ChannelInit> channel_init_;
DISALLOW_COPY_AND_ASSIGN(DBusExternalServiceBase);
};
template <class ServiceImpl>
-class DBusExternalService : public DBusExternalServiceBase,
- public mojo::ExternalService {
+class DBusExternalService : public DBusExternalServiceBase {
public:
explicit DBusExternalService(const std::string& service_name)
: DBusExternalServiceBase(service_name) {
@@ -61,25 +56,32 @@ class DBusExternalService : public DBusExternalServiceBase,
virtual ~DBusExternalService() {}
protected:
- virtual void Connect(ScopedExternalServiceHostHandle client_handle) OVERRIDE {
- external_service_host_.reset(client_handle.Pass(), this, this);
+ virtual void Connect(ScopedMessagePipeHandle client_handle) OVERRIDE {
+ external_service_.reset(BindToPipe(new Impl(this), client_handle.Pass()));
}
virtual void Disconnect() OVERRIDE {
- app_.reset();
- external_service_host_.reset();
+ external_service_.reset();
}
private:
- virtual void Activate(mojo::ScopedMessagePipeHandle client_handle) OVERRIDE {
- mojo::ScopedShellHandle shell_handle(
- mojo::ShellHandle(client_handle.release().value()));
- app_.reset(new mojo::Application(shell_handle.Pass()));
- app_->AddServiceConnector(new mojo::ServiceConnector<ServiceImpl>());
- }
+ class Impl : public InterfaceImpl<ExternalService> {
+ public:
+ explicit Impl(DBusExternalService* service) : service_(service) {
+ }
+ virtual void OnConnectionError() OVERRIDE {
+ service_->Disconnect();
+ }
+ virtual void Activate(ScopedMessagePipeHandle shell_handle) OVERRIDE {
+ app_.reset(new Application(shell_handle.Pass()));
+ app_->AddServiceConnector(new ServiceConnector<ServiceImpl>());
+ }
+ private:
+ DBusExternalService* service_;
+ scoped_ptr<Application> app_;
+ };
- mojo::RemotePtr<mojo::ExternalServiceHost> external_service_host_;
- scoped_ptr<mojo::Application> app_;
+ scoped_ptr<Impl> external_service_;
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698