| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_ANDROID_BUILD_INFO_H_ | 5 #ifndef BASE_ANDROID_BUILD_INFO_H_ |
| 6 #define BASE_ANDROID_BUILD_INFO_H_ | 6 #define BASE_ANDROID_BUILD_INFO_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 namespace android { | 15 namespace android { |
| 16 | 16 |
| 17 // BuildInfo is a singleton class that stores android build and device | 17 // BuildInfo is a singleton class that stores android build and device |
| 18 // information. It will be called from Android specific java code and gets used | 18 // information. It will be called from Android specific code and gets used |
| 19 // primarily in crash reporting. | 19 // primarily in crash reporting. |
| 20 | 20 |
| 21 // It is also used to store the last java exception seen during JNI. | 21 // It is also used to store the last java exception seen during JNI. |
| 22 // TODO(nileshagrawal): Find a better place to store this info. | 22 // TODO(nileshagrawal): Find a better place to store this info. |
| 23 class BuildInfo { | 23 class BuildInfo { |
| 24 public: | 24 public: |
| 25 | 25 |
| 26 ~BuildInfo() {} | 26 ~BuildInfo() {} |
| 27 | 27 |
| 28 // Static factory method for getting the singleton BuildInfo instance. | 28 // Static factory method for getting the singleton BuildInfo instance. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 const char* package_version_code() const { | 58 const char* package_version_code() const { |
| 59 return package_version_code_; | 59 return package_version_code_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 const char* package_version_name() const { | 62 const char* package_version_name() const { |
| 63 return package_version_name_; | 63 return package_version_name_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 const char* package_label() const { |
| 67 return package_label_; |
| 68 } |
| 69 |
| 66 const char* java_exception_info() const { | 70 const char* java_exception_info() const { |
| 67 return java_exception_info_; | 71 return java_exception_info_; |
| 68 } | 72 } |
| 69 | 73 |
| 70 void set_java_exception_info(const std::string& info); | 74 void set_java_exception_info(const std::string& info); |
| 71 | 75 |
| 72 static bool RegisterBindings(JNIEnv* env); | 76 static bool RegisterBindings(JNIEnv* env); |
| 73 | 77 |
| 74 private: | 78 private: |
| 75 friend struct BuildInfoSingletonTraits; | 79 friend struct BuildInfoSingletonTraits; |
| 76 | 80 |
| 77 explicit BuildInfo(JNIEnv* env); | 81 explicit BuildInfo(JNIEnv* env); |
| 78 | 82 |
| 79 // Const char* is used instead of std::strings because these values must be | 83 // Const char* is used instead of std::strings because these values must be |
| 80 // available even if the process is in a crash state. Sadly | 84 // available even if the process is in a crash state. Sadly |
| 81 // std::string.c_str() doesn't guarantee that memory won't be allocated when | 85 // std::string.c_str() doesn't guarantee that memory won't be allocated when |
| 82 // it is called. | 86 // it is called. |
| 83 const char* const device_; | 87 const char* const device_; |
| 84 const char* const model_; | 88 const char* const model_; |
| 85 const char* const brand_; | 89 const char* const brand_; |
| 86 const char* const android_build_id_; | 90 const char* const android_build_id_; |
| 87 const char* const android_build_fp_; | 91 const char* const android_build_fp_; |
| 88 const char* const package_version_code_; | 92 const char* const package_version_code_; |
| 89 const char* const package_version_name_; | 93 const char* const package_version_name_; |
| 94 const char* const package_label_; |
| 90 // This is set via set_java_exception_info, not at constructor time. | 95 // This is set via set_java_exception_info, not at constructor time. |
| 91 const char* java_exception_info_; | 96 const char* java_exception_info_; |
| 92 | 97 |
| 93 DISALLOW_COPY_AND_ASSIGN(BuildInfo); | 98 DISALLOW_COPY_AND_ASSIGN(BuildInfo); |
| 94 }; | 99 }; |
| 95 | 100 |
| 96 } // namespace android | 101 } // namespace android |
| 97 } // namespace base | 102 } // namespace base |
| 98 | 103 |
| 99 #endif // BASE_ANDROID_BUILD_INFO_H_ | 104 #endif // BASE_ANDROID_BUILD_INFO_H_ |
| OLD | NEW |