1 // Copyright 2019 The Dawn Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef DAWNWIRE_CLIENT_OBJECTBASE_H_ 16 #define DAWNWIRE_CLIENT_OBJECTBASE_H_ 17 18 #include <dawn/webgpu.h> 19 20 #include "common/LinkedList.h" 21 #include "dawn_wire/ObjectType_autogen.h" 22 23 namespace dawn_wire { namespace client { 24 25 class Client; 26 27 // All objects on the client side have: 28 // - A pointer to the Client to get where to serialize commands 29 // - The external reference count 30 // - An ID that is used to refer to this object when talking with the server side 31 // - A next/prev pointer. They are part of a linked list of objects of the same type. 32 struct ObjectBase : public LinkNode<ObjectBase> { ObjectBaseObjectBase33 ObjectBase(Client* client, uint32_t refcount, uint32_t id) 34 : client(client), refcount(refcount), id(id) { 35 } 36 ~ObjectBaseObjectBase37 ~ObjectBase() { 38 RemoveFromList(); 39 } 40 CancelCallbacksForDisconnectObjectBase41 virtual void CancelCallbacksForDisconnect() { 42 } 43 44 Client* const client; 45 uint32_t refcount; 46 const uint32_t id; 47 }; 48 49 }} // namespace dawn_wire::client 50 51 #endif // DAWNWIRE_CLIENT_OBJECTBASE_H_ 52