// Copyright 2016 Google Inc. All Rights Reserved. #ifndef WVCDM_PROFILER_PROFILED_SCOPE_H_ #define WVCDM_PROFILER_PROFILED_SCOPE_H_ #include #include "entry_writer.h" #include "oem_functions.h" namespace wvcdm { namespace oemprofiler { class ProfiledScope { public: explicit ProfiledScope(OEM_FUNCTION fid); explicit ProfiledScope(uint32_t sid, OEM_FUNCTION fid); ~ProfiledScope(); EntryWriter meta_data_; // All profiling data must be assigned to a session but some oem // crypto calls are not associated with crypto sessions. To gather // those functions' data, the global session id is used. Crypto.Session // Ids are unsigned 32 bit integers. To use those as a profiling session // id but also allow for a global id that won't conflict with them, // we use a -1 as the a proifiling session id is a signed 64 bit integer. static const int64_t kGlobalSID = -1; private: int64_t sid_; OEM_FUNCTION fid_; uint64_t start_time_; void Submit(int64_t sid, uint64_t end_time) const; uint64_t GetNowUS() const; // disallow copy and assign ProfiledScope(const ProfiledScope&); void operator=(const ProfiledScope&); }; } // namespace oemprofiler } // namespace wvcdm #endif