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

Unified Diff: services/view_manager/ids.h

Issue 1536713004: Revert "Delete the ViewManager and WindowManager services." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/view_manager/gesture_manager_unittest.cc ('k') | services/view_manager/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/view_manager/ids.h
diff --git a/services/view_manager/ids.h b/services/view_manager/ids.h
new file mode 100644
index 0000000000000000000000000000000000000000..b3058546708fcd7dde15514c04e0946124a59a09
--- /dev/null
+++ b/services/view_manager/ids.h
@@ -0,0 +1,62 @@
+// 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 SERVICES_VIEW_MANAGER_IDS_H_
+#define SERVICES_VIEW_MANAGER_IDS_H_
+
+#include "mojo/services/view_manager/cpp/types.h"
+#include "mojo/services/view_manager/cpp/util.h"
+
+namespace view_manager {
+
+// Connection id is used to indicate no connection. That is, no
+// ViewManagerServiceImpl ever gets this id.
+const mojo::ConnectionSpecificId kInvalidConnectionId = 0;
+
+// Adds a bit of type safety to view ids.
+struct ViewId {
+ ViewId(mojo::ConnectionSpecificId connection_id,
+ mojo::ConnectionSpecificId view_id)
+ : connection_id(connection_id), view_id(view_id) {}
+ ViewId() : connection_id(0), view_id(0) {}
+
+ bool operator==(const ViewId& other) const {
+ return other.connection_id == connection_id &&
+ other.view_id == view_id;
+ }
+
+ bool operator!=(const ViewId& other) const {
+ return !(*this == other);
+ }
+
+ mojo::ConnectionSpecificId connection_id;
+ mojo::ConnectionSpecificId view_id;
+};
+
+inline ViewId ViewIdFromTransportId(mojo::Id id) {
+ return ViewId(mojo::HiWord(id), mojo::LoWord(id));
+}
+
+inline mojo::Id ViewIdToTransportId(const ViewId& id) {
+ return (id.connection_id << 16) | id.view_id;
+}
+
+inline ViewId RootViewId() {
+ return ViewId(kInvalidConnectionId, 1);
+}
+
+// Returns a ViewId that is reserved to indicate no view. That is, no view will
+// ever be created with this id.
+inline ViewId InvalidViewId() {
+ return ViewId(kInvalidConnectionId, 0);
+}
+
+// All cloned views use this id.
+inline ViewId ClonedViewId() {
+ return ViewId(kInvalidConnectionId, 2);
+}
+
+} // namespace view_manager
+
+#endif // SERVICES_VIEW_MANAGER_IDS_H_
« no previous file with comments | « services/view_manager/gesture_manager_unittest.cc ('k') | services/view_manager/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698