Chromium Code Reviews| 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 MOJO_SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_ | |
| 6 #define MOJO_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 "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 namespace service { | |
| 15 | |
| 16 class ConnectionManager; | |
| 17 class ViewManagerServiceImpl; | |
| 18 | |
| 19 // ClientConnection encapsulates the state needed for a single client connected | |
| 20 // to the view manager. | |
| 21 class ClientConnection { | |
| 22 public: | |
| 23 explicit ClientConnection(scoped_ptr<ViewManagerServiceImpl> service); | |
| 24 virtual ~ClientConnection(); | |
| 25 | |
| 26 ViewManagerServiceImpl* service() { return service_.get(); } | |
| 27 const ViewManagerServiceImpl* service() const { return service_.get(); } | |
| 28 | |
| 29 ViewManagerClient* client() { return client_; } | |
| 30 | |
| 31 protected: | |
| 32 void set_client(ViewManagerClient* client) { client_ = client; } | |
| 33 | |
| 34 private: | |
| 35 scoped_ptr<ViewManagerServiceImpl> service_; | |
| 36 ViewManagerClient* client_; | |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(ClientConnection); | |
| 39 }; | |
| 40 | |
| 41 // Bindings implementation of ClientConnection. | |
| 42 class DefaultClientConnection : public ClientConnection, public ErrorHandler { | |
| 43 public: | |
| 44 DefaultClientConnection(ConnectionManager* connection_manager, | |
| 45 scoped_ptr<ViewManagerServiceImpl> service_impl); | |
|
msw
2014/11/14 01:42:18
nit: make this match ClientConnection's |service|
sky
2014/11/14 20:56:03
Done.
| |
| 46 ~DefaultClientConnection() override; | |
| 47 | |
| 48 Binding<ViewManagerService>* binding() { return &binding_; } | |
|
msw
2014/11/14 01:42:18
nit: consider having two ctors (or two helper Bind
sky
2014/11/14 20:56:03
I'll do that in a subsequent patch when the delega
| |
| 49 | |
| 50 void SetClient() { set_client(binding_.client()); } | |
|
msw
2014/11/14 01:42:18
nit: consider set_client_from_binding()
sky
2014/11/14 20:56:03
Done.
| |
| 51 | |
| 52 private: | |
| 53 // InterfaceBindingDelegate: | |
|
msw
2014/11/14 01:42:18
nit: ErrorHandler
sky
2014/11/14 20:56:03
Done.
| |
| 54 void OnConnectionError() override; | |
| 55 | |
| 56 ConnectionManager* connection_manager_; | |
| 57 Binding<ViewManagerService> binding_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DefaultClientConnection); | |
| 60 }; | |
| 61 | |
| 62 } // namespace service | |
| 63 } // namespace mojo | |
| 64 | |
| 65 #endif // MOJO_SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_ | |
| OLD | NEW |