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

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

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 months 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
« no previous file with comments | « mojo/services/view_manager/display_manager.cc ('k') | mojo/services/view_manager/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SERVICES_VIEW_MANAGER_IDS_H_
6 #define SERVICES_VIEW_MANAGER_IDS_H_
7
8 #include "third_party/mojo_services/src/view_manager/public/cpp/types.h"
9 #include "third_party/mojo_services/src/view_manager/public/cpp/util.h"
10
11 namespace view_manager {
12
13 // Connection id is used to indicate no connection. That is, no
14 // ViewManagerServiceImpl ever gets this id.
15 const mojo::ConnectionSpecificId kInvalidConnectionId = 0;
16
17 // Adds a bit of type safety to view ids.
18 struct ViewId {
19 ViewId(mojo::ConnectionSpecificId connection_id,
20 mojo::ConnectionSpecificId view_id)
21 : connection_id(connection_id), view_id(view_id) {}
22 ViewId() : connection_id(0), view_id(0) {}
23
24 bool operator==(const ViewId& other) const {
25 return other.connection_id == connection_id &&
26 other.view_id == view_id;
27 }
28
29 bool operator!=(const ViewId& other) const {
30 return !(*this == other);
31 }
32
33 mojo::ConnectionSpecificId connection_id;
34 mojo::ConnectionSpecificId view_id;
35 };
36
37 inline ViewId ViewIdFromTransportId(mojo::Id id) {
38 return ViewId(mojo::HiWord(id), mojo::LoWord(id));
39 }
40
41 inline mojo::Id ViewIdToTransportId(const ViewId& id) {
42 return (id.connection_id << 16) | id.view_id;
43 }
44
45 inline ViewId RootViewId() {
46 return ViewId(kInvalidConnectionId, 1);
47 }
48
49 // Returns a ViewId that is reserved to indicate no view. That is, no view will
50 // ever be created with this id.
51 inline ViewId InvalidViewId() {
52 return ViewId(kInvalidConnectionId, 0);
53 }
54
55 // All cloned views use this id.
56 inline ViewId ClonedViewId() {
57 return ViewId(kInvalidConnectionId, 2);
58 }
59
60 } // namespace view_manager
61
62 #endif // SERVICES_VIEW_MANAGER_IDS_H_
OLDNEW
« no previous file with comments | « mojo/services/view_manager/display_manager.cc ('k') | mojo/services/view_manager/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698