[Sync] Fix invalidations on Android.
[chromium-blink-merge.git] / mojo / services / view_manager / client_connection.h
blob83fa864b9d3b757c04caf0e15acd1acc93489705
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.
5 #ifndef SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_
6 #define SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_
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_manager.mojom.h"
13 namespace view_manager {
15 class ConnectionManager;
16 class ViewManagerServiceImpl;
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();
26 ViewManagerServiceImpl* service() { return service_.get(); }
27 const ViewManagerServiceImpl* service() const { return service_.get(); }
29 mojo::ViewManagerClient* client() { return client_; }
31 private:
32 scoped_ptr<ViewManagerServiceImpl> service_;
33 mojo::ViewManagerClient* client_;
35 DISALLOW_COPY_AND_ASSIGN(ClientConnection);
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;
49 private:
50 // ErrorHandler:
51 void OnConnectionError() override;
53 ConnectionManager* connection_manager_;
54 mojo::Binding<mojo::ViewManagerService> binding_;
55 mojo::ViewManagerClientPtr client_;
57 DISALLOW_COPY_AND_ASSIGN(DefaultClientConnection);
60 } // namespace view_manager
62 #endif // SERVICES_VIEW_MANAGER_CLIENT_CONNECTION_H_