blob: 6f82b2f58ace3edef4a5b517a6eacd87d8977720 (
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
|
// Copyright 2014 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 MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_
#define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_
#include <map>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/services/public/cpp/view_manager/view_tree_node.h"
namespace mojo {
class Shell;
namespace view_manager {
class View;
class ViewManagerSynchronizer;
class ViewTreeNode;
// Approximately encapsulates the View Manager service.
// Owns a synchronizer that keeps a client model in sync with the service.
// Owned by the creator.
//
// TODO: displays
class ViewManager {
public:
explicit ViewManager(Shell* shell);
~ViewManager();
// Connects to the View Manager service. This method must be called before
// using any other View Manager lib class or function.
// Blocks on establishing the connection and subsequently receiving a node
// tree from the service.
// TODO(beng): blocking is currently achieved by running a nested runloop,
// which will dispatch all messages on all pipes while blocking.
// we should instead wait on the client pipe receiving a
// connection established message.
// TODO(beng): this method could optionally not block if supplied a callback.
void Init();
ViewTreeNode* tree() { return tree_; }
ViewTreeNode* GetNodeById(TransportNodeId id);
View* GetViewById(TransportViewId id);
private:
friend class ViewManagerPrivate;
typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap;
typedef std::map<TransportViewId, View*> IdToViewMap;
Shell* shell_;
scoped_ptr<ViewManagerSynchronizer> synchronizer_;
ViewTreeNode* tree_;
IdToNodeMap nodes_;
IdToViewMap views_;
DISALLOW_COPY_AND_ASSIGN(ViewManager);
};
} // namespace view_manager
} // namespace mojo
#endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_
|