Chromium Code Reviews| Index: webrtc/base/location.h |
| diff --git a/webrtc/base/location.h b/webrtc/base/location.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..457555862e06a49fd629bef07f909a0596a6f6e9 |
| --- /dev/null |
| +++ b/webrtc/base/location.h |
| @@ -0,0 +1,52 @@ |
| +/* |
| + * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#ifndef WEBRTC_BASE_LOCATION_H_ |
| +#define WEBRTC_BASE_LOCATION_H_ |
| + |
| +#include <string> |
| + |
| +namespace rtc { |
| + |
| +// Location provides basic info where of an object was constructed, or was |
| +// significantly brought to life. |
| +// This is a stripped down version of: |
| +// https://code.google.com/p/chromium/codesearch#chromium/src/base/location.h |
| +class Location { |
| + public: |
| + // Constructor should be called with a long-lived char*, such as __FILE__. |
| + // It assumes the provided value will persist as a global constant, and it |
| + // will not make a copy of it. |
| + Location(const char* function_name, const char* file_name, int line_number); |
| + Location(); |
| + Location(const Location& other); |
| + Location& operator=(const Location& other); |
| + |
| + const char* function_name() const { return function_name_; } |
| + const char* file_name() const { return file_name_; } |
| + int line_number() const { return line_number_; } |
| + |
| + std::string ToString() const; |
| + |
| + private: |
| + const char* function_name_; |
| + const char* file_name_; |
| + int line_number_; |
| +}; |
| + |
| +// Define a macro to record the current source location. |
| +#define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__FUNCTION__) |
|
tommi
2016/05/31 19:56:27
Sorry I didn't think of this before, but I think w
Taylor Brandstetter
2016/06/02 22:38:41
Definitely agree; done.
|
| + |
| +#define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ |
|
tommi
2016/05/31 19:56:27
and this one as well I guess. You could also shor
Taylor Brandstetter
2016/06/02 22:38:41
Done.
|
| + ::rtc::Location(function_name, __FILE__, __LINE__) |
| + |
| +} // namespace rtc |
| + |
| +#endif // WEBRTC_BASE_LOCATION_H_ |