blob: 8003e4787d7e052f7e82630e382e9f73ec6df46d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MUS_COMPOSITOR_MUS_CONNECTION_H_
#define CONTENT_RENDERER_MUS_COMPOSITOR_MUS_CONNECTION_H_
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "components/mus/public/cpp/input_event_handler.h"
#include "components/mus/public/cpp/window.h"
#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/cpp/window_tree_delegate.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
namespace content {
class InputHandlerManager;
// CompositorMusConnection manages the connection to the Mandoline UI Service
// (Mus) on the compositor thread. For operations that need to happen on the
// main thread, CompositorMusConnection deals with passing information across
// threads. CompositorMusConnection is constructed on the main thread. By
// default all other methods are assumed to run on the compositor thread unless
// explicited suffixed with OnMainThread.
class CONTENT_EXPORT CompositorMusConnection
: NON_EXPORTED_BASE(public mus::WindowTreeDelegate),
NON_EXPORTED_BASE(public mus::InputEventHandler),
public base::RefCountedThreadSafe<CompositorMusConnection> {
public:
// Created on main thread.
CompositorMusConnection(
int routing_id,
const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request,
InputHandlerManager* input_handler_manager);
// Attaches the provided |surface_binding| with the mus::Window for the
// renderer once it becomes available.
void AttachSurfaceOnMainThread(
scoped_ptr<mus::WindowSurfaceBinding> surface_binding);
private:
friend class CompositorMusConnectionTest;
friend class base::RefCountedThreadSafe<CompositorMusConnection>;
~CompositorMusConnection() override;
void AttachSurfaceOnCompositorThread(
scoped_ptr<mus::WindowSurfaceBinding> surface_binding);
void CreateWindowTreeConnectionOnCompositorThread(
mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request);
void OnConnectionLostOnMainThread();
void OnWindowInputEventOnMainThread(
scoped_ptr<blink::WebInputEvent> web_event,
const base::Callback<void(bool)>& ack);
void OnWindowInputEventAckOnMainThread(const base::Callback<void(bool)>& ack,
bool handled);
// WindowTreeDelegate implementation:
void OnConnectionLost(mus::WindowTreeConnection* connection) override;
void OnEmbed(mus::Window* root) override;
// InputEventHandler implementation:
void OnWindowInputEvent(
mus::Window* window,
const ui::Event& event,
scoped_ptr<base::Callback<void(bool)>>* ack_callback) override;
const int routing_id_;
mus::Window* root_;
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
InputHandlerManager* const input_handler_manager_;
scoped_ptr<mus::WindowSurfaceBinding> window_surface_binding_;
DISALLOW_COPY_AND_ASSIGN(CompositorMusConnection);
};
} // namespace content
#endif // CONTENT_RENDERER_MUS_COMPOSITOR_MUS_CONNECTION_H_
|