OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_ |
| 6 #define SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "mojo/public/cpp/bindings/binding.h" |
| 10 #include "mojo/public/cpp/bindings/error_handler.h" |
| 11 #include "third_party/mojo_services/src/view_manager/public/interfaces/view_mana
ger.mojom.h" |
| 12 |
| 13 namespace view_manager { |
| 14 |
| 15 class ConnectionManager; |
| 16 class ViewManagerServiceImpl; |
| 17 |
| 18 // ClientConnection encapsulates the state needed for a single client connected |
| 19 // to the view manager. |
| 20 class ClientConnection { |
| 21 public: |
| 22 ClientConnection(scoped_ptr<ViewManagerServiceImpl> service, |
| 23 mojo::ViewManagerClient* client); |
| 24 virtual ~ClientConnection(); |
| 25 |
| 26 ViewManagerServiceImpl* service() { return service_.get(); } |
| 27 const ViewManagerServiceImpl* service() const { return service_.get(); } |
| 28 |
| 29 mojo::ViewManagerClient* client() { return client_; } |
| 30 |
| 31 private: |
| 32 scoped_ptr<ViewManagerServiceImpl> service_; |
| 33 mojo::ViewManagerClient* client_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(ClientConnection); |
| 36 }; |
| 37 |
| 38 // Bindings implementation of ClientConnection. |
| 39 class DefaultClientConnection : public ClientConnection, |
| 40 public mojo::ErrorHandler { |
| 41 public: |
| 42 DefaultClientConnection( |
| 43 scoped_ptr<ViewManagerServiceImpl> service_impl, |
| 44 ConnectionManager* connection_manager, |
| 45 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, |
| 46 mojo::ViewManagerClientPtr client); |
| 47 ~DefaultClientConnection() override; |
| 48 |
| 49 private: |
| 50 // ErrorHandler: |
| 51 void OnConnectionError() override; |
| 52 |
| 53 ConnectionManager* connection_manager_; |
| 54 mojo::Binding<mojo::ViewManagerService> binding_; |
| 55 mojo::ViewManagerClientPtr client_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(DefaultClientConnection); |
| 58 }; |
| 59 |
| 60 } // namespace view_manager |
| 61 |
| 62 #endif // SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_ |
OLD | NEW |