Merge changes I2a437363,I27226885 into main

* changes:
  Use std::function instead of base::function_ref
  Use std::unique_ptr instead of ScopeGuard