Roll src/third_party/WebKit 6b63e20:35e1984 (svn 201060:201061)
[chromium-blink-merge.git] / components / view_manager / client_connection.h
blobf35adda21ea3249bcb8d7bbce999e15424a43365
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 COMPONENTS_VIEW_MANAGER_CLIENT_CONNECTION_H_
6 #define COMPONENTS_VIEW_MANAGER_CLIENT_CONNECTION_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/view_manager/public/interfaces/view_manager.mojom.h"
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
12 namespace view_manager {
14 class ConnectionManager;
15 class ViewManagerServiceImpl;
17 // ClientConnection encapsulates the state needed for a single client connected
18 // to the view manager.
19 class ClientConnection {
20 public:
21 ClientConnection(scoped_ptr<ViewManagerServiceImpl> service,
22 mojo::ViewManagerClient* client);
23 virtual ~ClientConnection();
25 ViewManagerServiceImpl* service() { return service_.get(); }
26 const ViewManagerServiceImpl* service() const { return service_.get(); }
28 mojo::ViewManagerClient* client() { return client_; }
30 private:
31 scoped_ptr<ViewManagerServiceImpl> service_;
32 mojo::ViewManagerClient* client_;
34 DISALLOW_COPY_AND_ASSIGN(ClientConnection);
37 // Bindings implementation of ClientConnection.
38 class DefaultClientConnection : public ClientConnection {
39 public:
40 DefaultClientConnection(
41 scoped_ptr<ViewManagerServiceImpl> service_impl,
42 ConnectionManager* connection_manager,
43 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
44 mojo::ViewManagerClientPtr client);
45 ~DefaultClientConnection() override;
47 private:
48 ConnectionManager* connection_manager_;
49 mojo::Binding<mojo::ViewManagerService> binding_;
50 mojo::ViewManagerClientPtr client_;
52 DISALLOW_COPY_AND_ASSIGN(DefaultClientConnection);
55 } // namespace view_manager
57 #endif // COMPONENTS_VIEW_MANAGER_CLIENT_CONNECTION_H_