1 // Copyright 2019 Google LLC 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 FCP_TRACING_TEST_TRACING_SPAN_IMPL_H_ 16 #define FCP_TRACING_TEST_TRACING_SPAN_IMPL_H_ 17 18 #include "fcp/tracing/test_tracing_recorder_impl.h" 19 #include "fcp/tracing/tracing_span_impl.h" 20 21 namespace fcp { 22 namespace tracing_internal { 23 24 class TestTracingSpanImpl : public TracingSpanImpl { 25 public: 26 TestTracingSpanImpl(std::shared_ptr<TestTracingRecorderImpl> recorder, 27 TracingSpanId id); 28 TestTracingSpanImpl(TestTracingRecorderImpl* recorder, TracingSpanId id); 29 ~TestTracingSpanImpl() override; 30 31 void TraceImpl(flatbuffers::DetachedBuffer&& buf, 32 const TracingTraitsBase& traits) override; 33 TracingSpanRef Ref() override; 34 35 private: 36 TestTracingRecorderImpl* recorder_; 37 38 // For non-root span the following keeps recorder alive, if set, 39 // this holds the same value as recorder_. Since root span is owned directly 40 // by the recorder we can't store shared_ptr for it here to avoid a loop. 41 std::shared_ptr<TestTracingRecorderImpl> recorder_shared_ptr_; 42 43 TracingSpanId id_; 44 }; 45 46 } // namespace tracing_internal 47 } // namespace fcp 48 49 #endif // FCP_TRACING_TEST_TRACING_SPAN_IMPL_H_ 50