1d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// found in the LICENSE file. 4d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 5d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#ifndef TraceLocation_h 6d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#define TraceLocation_h 7d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 8d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// This is intentionally similar to base/location.h 9d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// that we could easily replace usage of TraceLocation 10d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// with base::Location after merging into Chromium. 11d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 12c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 13d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 14d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class TraceLocation { 15d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)public: 16d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Currenetly only store the bits used in Blink, base::Location stores more. 17d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // These char*s are not copied and must live for the duration of the program. 18d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) TraceLocation(const char* functionName, const char* fileName) 19d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) : m_functionName(functionName) 20d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) , m_fileName(fileName) 21d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { } 22d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 23d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) TraceLocation() 24d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) : m_functionName("unknown") 25d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) , m_fileName("unknown") 26d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) { } 27d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 28d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) const char* functionName() const { return m_functionName; } 29d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) const char* fileName() const { return m_fileName; } 30d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 31d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)private: 32d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) const char* m_functionName; 33d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) const char* m_fileName; 34d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)}; 35d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 36c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)#define FROM_HERE ::blink::TraceLocation(__FUNCTION__, __FILE__) 37e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)} // namespace blink 38d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 39d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#endif // TraceLocation_h 40