Chris Hamilton | 77da59d | 2019-06-04 15:59:32 | [diff] [blame] | 1 | // Copyright 2019 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 | |
Sigurdur Asgeirsson | 51d9d24 | 2019-10-07 20:38:34 | [diff] [blame^] | 5 | #ifndef COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_NODE_H_ |
| 6 | #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_NODE_H_ |
Chris Hamilton | 77da59d | 2019-06-04 15:59:32 | [diff] [blame] | 7 | |
| 8 | #include <cstdint> |
| 9 | |
| 10 | #include "base/macros.h" |
| 11 | |
| 12 | namespace performance_manager { |
| 13 | |
| 14 | class Graph; |
| 15 | |
| 16 | // Interface that all nodes must implement. |
| 17 | // TODO(chrisha): Move NodeTypeEnum to the public interface and expose it here, |
| 18 | // then add FromNode casts on the public node interfaces. |
| 19 | class Node { |
| 20 | public: |
| 21 | Node(); |
| 22 | virtual ~Node(); |
| 23 | |
| 24 | // Returns the graph to which this node belongs. |
| 25 | virtual Graph* GetGraph() const = 0; |
| 26 | |
| 27 | // The following functions are implementation detail and should not need to be |
| 28 | // used by external clients. They provide the ability to safely downcast to |
| 29 | // the underlying implementation. |
| 30 | virtual uintptr_t GetImplType() const = 0; |
| 31 | virtual const void* GetImpl() const = 0; |
| 32 | |
Chris Hamilton | c2f1bdb | 2019-08-15 15:10:01 | [diff] [blame] | 33 | // Returns the serialization ID of the given |node|. This is a stable and |
| 34 | // opaque value that will always refer only to this node, and never be reused |
| 35 | // over the lifetime of the browser. |
| 36 | // TODO(chrisha): Deprecate this, and move the logic inside of the only |
| 37 | // client using it. |
| 38 | static int64_t GetSerializationId(const Node* node); |
| 39 | |
Chris Hamilton | 77da59d | 2019-06-04 15:59:32 | [diff] [blame] | 40 | private: |
| 41 | DISALLOW_COPY_AND_ASSIGN(Node); |
| 42 | }; |
| 43 | |
| 44 | } // namespace performance_manager |
| 45 | |
Sigurdur Asgeirsson | 51d9d24 | 2019-10-07 20:38:34 | [diff] [blame^] | 46 | #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_GRAPH_NODE_H_ |