Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: mojo/services/view_manager/ids.h

Issue 774473003: Move view_manager service implementation to //services (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_IDS_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_IDS_H_
7
8 #include "mojo/services/public/cpp/view_manager/types.h"
9 #include "mojo/services/public/cpp/view_manager/util.h"
10
11 namespace mojo {
12 namespace service {
13
14 // Connection id is used to indicate no connection. That is, no
15 // ViewManagerServiceImpl ever gets this id.
16 const ConnectionSpecificId kInvalidConnectionId = 0;
17
18 // Adds a bit of type safety to view ids.
19 struct ViewId {
20 ViewId(ConnectionSpecificId connection_id, ConnectionSpecificId view_id)
21 : connection_id(connection_id),
22 view_id(view_id) {}
23 ViewId() : connection_id(0), view_id(0) {}
24
25 bool operator==(const ViewId& other) const {
26 return other.connection_id == connection_id &&
27 other.view_id == view_id;
28 }
29
30 bool operator!=(const ViewId& other) const {
31 return !(*this == other);
32 }
33
34 ConnectionSpecificId connection_id;
35 ConnectionSpecificId view_id;
36 };
37
38 inline ViewId ViewIdFromTransportId(Id id) {
39 return ViewId(HiWord(id), LoWord(id));
40 }
41
42 inline Id ViewIdToTransportId(const ViewId& id) {
43 return (id.connection_id << 16) | id.view_id;
44 }
45
46 inline ViewId RootViewId() {
47 return ViewId(kInvalidConnectionId, 1);
48 }
49
50 // Returns a ViewId that is reserved to indicate no view. That is, no view will
51 // ever be created with this id.
52 inline ViewId InvalidViewId() {
53 return ViewId(kInvalidConnectionId, 0);
54 }
55
56 // All cloned views use this id.
57 inline ViewId ClonedViewId() {
58 return ViewId(kInvalidConnectionId, 2);
59 }
60
61 } // namespace service
62 } // namespace mojo
63
64 #endif // MOJO_SERVICES_VIEW_MANAGER_IDS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698