1 // Copyright 2018 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 #include "osp/impl/with_destruction_callback.h" 6 7 #include "util/osp_logging.h" 8 9 namespace openscreen { 10 namespace osp { 11 12 WithDestructionCallback::WithDestructionCallback() = default; 13 ~WithDestructionCallback()14WithDestructionCallback::~WithDestructionCallback() { 15 if (destruction_callback_function_) { 16 destruction_callback_function_(destruction_callback_state_); 17 } 18 } 19 SetDestructionCallback(WithDestructionCallback::DestructionCallbackFunctionPointer function,void * state)20void WithDestructionCallback::SetDestructionCallback( 21 WithDestructionCallback::DestructionCallbackFunctionPointer function, 22 void* state) { 23 OSP_DCHECK(!destruction_callback_function_); 24 destruction_callback_function_ = function; 25 destruction_callback_state_ = state; 26 } 27 28 } // namespace osp 29 } // namespace openscreen 30