Chromium Code Reviews| Index: base/android/build_info.h |
| diff --git a/base/android/build_info.h b/base/android/build_info.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..debe29b239984e2b656e97f4ca119d63474e763a |
| --- /dev/null |
| +++ b/base/android/build_info.h |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_ANDROID_BUILD_INFO_H_ |
| +#define BASE_ANDROID_BUILD_INFO_H_ |
| + |
| +#include <jni.h> |
| + |
| +#include <string> |
| + |
| +#include "base/memory/singleton.h" |
| + |
| +namespace base { |
| +namespace android { |
| + |
| +// BuildInfo is a singleton class that stores android build and device |
| +// information. |
| +class BuildInfo { |
| + public: |
| + |
| + ~BuildInfo() {} |
| + |
| + // Static factory method for getting the singleton BuildInfo instance. |
| + // Note that ownership is not conferred on the caller and the BuildInfo in |
| + // question isn't actually freed until shutdown. This is ok because there |
|
Mark Mentovai
2012/04/06 18:56:12
I would just let it leak, and use LeakySingletonTr
carlosvaldivia
2012/04/06 19:55:23
Done.
|
| + // should only be one instance of BuildInfo ever created. |
| + static BuildInfo* GetInstance(); |
| + |
| + // Const char* is used instead of std::strings because these values must be |
| + // available even if the process is in a crash state. Sadly |
| + // std::string.c_str() doesn't guarantee that memory won't be allocated when |
| + // it is called. |
| + const char* device() { |
|
Mark Mentovai
2012/04/06 18:56:12
These can be const methods, like
const char* de
carlosvaldivia
2012/04/06 19:55:23
Done.
|
| + return device_; |
| + } |
| + |
| + const char* model() { |
| + return model_; |
| + } |
| + |
| + const char* brand() { |
| + return brand_; |
| + } |
| + |
| + const char* android_build_id() { |
| + return android_build_id_; |
| + } |
| + |
| + const char* android_build_fp() { |
| + return android_build_fp_; |
| + } |
| + |
| + const char* package_version_code() { |
| + return package_version_code_; |
| + } |
| + |
| + const char* package_version_name() { |
| + return package_version_name_; |
| + } |
| + |
| + private: |
| + BuildInfo(); |
| + |
| + friend struct DefaultSingletonTraits<BuildInfo>; |
| + |
| + // Const char* is used instead of std::strings because these values must be |
| + // available even if the process is in a crash state. Sadly |
| + // std::string.c_str() doesn't guarantee that memory won't be allocated when |
| + // it is called. |
| + char* device_; |
| + char* model_; |
| + char* brand_; |
| + char* android_build_id_; |
| + char* android_build_fp_; |
| + char* package_version_code_; |
| + char* package_version_name_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BuildInfo); |
| + |
| +}; |
| + |
| +bool RegisterBuildInfo(JNIEnv* env); |
| + |
| +} // namespace android |
| +} // namespace base |
| + |
|
Mark Mentovai
2012/04/06 18:56:12
Remove one of these blank lines.
carlosvaldivia
2012/04/06 19:55:23
Done.
|
| + |
| +#endif // BASE_ANDROID_BUILD_INFO_H_ |