| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "dbus/bus.h" | 6 #include "dbus/bus.h" |
| 7 #include "dbus/exported_object.h" | 7 #include "dbus/exported_object.h" |
| 8 #include "dbus/message.h" | 8 #include "dbus/message.h" |
| 9 #include "dbus/object_path.h" | 9 #include "dbus/object_path.h" |
| 10 #include "mojo/embedder/channel_init.h" | 10 #include "mojo/embedder/channel_init.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 void TakeDBusServiceOwnership(); | 43 void TakeDBusServiceOwnership(); |
| 44 | 44 |
| 45 const std::string service_name_; | 45 const std::string service_name_; |
| 46 scoped_refptr<dbus::Bus> bus_; | 46 scoped_refptr<dbus::Bus> bus_; |
| 47 dbus::ExportedObject* exported_object_; // Owned by bus_; | 47 dbus::ExportedObject* exported_object_; // Owned by bus_; |
| 48 scoped_ptr<embedder::ChannelInit> channel_init_; | 48 scoped_ptr<embedder::ChannelInit> channel_init_; |
| 49 DISALLOW_COPY_AND_ASSIGN(DBusExternalServiceBase); | 49 DISALLOW_COPY_AND_ASSIGN(DBusExternalServiceBase); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 template <class ServiceImpl> | 52 template <class ServiceImpl> |
| 53 class DBusExternalService : public DBusExternalServiceBase, | 53 class DBusExternalService |
| 54 public ApplicationDelegate { | 54 : public DBusExternalServiceBase, |
| 55 public ApplicationDelegate, |
| 56 public InterfaceFactory<typename ServiceImpl::Implements> { |
| 55 public: | 57 public: |
| 56 explicit DBusExternalService(const std::string& service_name) | 58 explicit DBusExternalService(const std::string& service_name) |
| 57 : DBusExternalServiceBase(service_name) { | 59 : DBusExternalServiceBase(service_name) { |
| 58 } | 60 } |
| 59 virtual ~DBusExternalService() {} | 61 virtual ~DBusExternalService() {} |
| 60 | 62 |
| 61 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 63 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 62 MOJO_OVERRIDE { | 64 MOJO_OVERRIDE { |
| 63 connection->AddService<ServiceImpl>(); | 65 connection->AddServiceFactory(this); |
| 64 return true; | 66 return true; |
| 65 } | 67 } |
| 66 | 68 |
| 69 virtual void Create(ApplicationConnection* connection, |
| 70 InterfaceRequest<typename ServiceImpl::Implements> |
| 71 request) MOJO_OVERRIDE { |
| 72 mojo::BindToRequest(new ServiceImpl, &request); |
| 73 } |
| 74 |
| 67 protected: | 75 protected: |
| 68 virtual void Connect(ScopedMessagePipeHandle client_handle) OVERRIDE { | 76 virtual void Connect(ScopedMessagePipeHandle client_handle) OVERRIDE { |
| 69 external_service_.reset(BindToPipe(new Impl(this), client_handle.Pass())); | 77 external_service_.reset(BindToPipe(new Impl(this), client_handle.Pass())); |
| 70 } | 78 } |
| 71 | 79 |
| 72 virtual void Disconnect() OVERRIDE { | 80 virtual void Disconnect() OVERRIDE { |
| 73 external_service_.reset(); | 81 external_service_.reset(); |
| 74 } | 82 } |
| 75 | 83 |
| 76 private: | 84 private: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 87 } | 95 } |
| 88 private: | 96 private: |
| 89 DBusExternalService* service_; | 97 DBusExternalService* service_; |
| 90 scoped_ptr<Application> app_; | 98 scoped_ptr<Application> app_; |
| 91 }; | 99 }; |
| 92 | 100 |
| 93 scoped_ptr<Impl> external_service_; | 101 scoped_ptr<Impl> external_service_; |
| 94 }; | 102 }; |
| 95 | 103 |
| 96 } // namespace mojo | 104 } // namespace mojo |
| OLD | NEW |