diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-05-09 14:22:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-05-09 15:11:45 +0000 |
commit | 2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch) | |
tree | e75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/base/android | |
parent | a4f3d46271c57e8155ba912df46a05559d14726e (diff) | |
download | qtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz |
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion.
Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/base/android')
-rw-r--r-- | chromium/base/android/application_status_listener_unittest.cc | 6 | ||||
-rw-r--r-- | chromium/base/android/build_info.cc | 9 | ||||
-rw-r--r-- | chromium/base/android/content_uri_utils.cc | 3 | ||||
-rw-r--r-- | chromium/base/android/library_loader/library_loader_hooks.h | 4 | ||||
-rw-r--r-- | chromium/base/android/path_utils.cc | 3 | ||||
-rw-r--r-- | chromium/base/android/record_histogram.cc | 255 | ||||
-rw-r--r-- | chromium/base/android/scoped_java_ref.h | 7 |
7 files changed, 164 insertions, 123 deletions
diff --git a/chromium/base/android/application_status_listener_unittest.cc b/chromium/base/android/application_status_listener_unittest.cc index ce78bf9c862..896bbe89389 100644 --- a/chromium/base/android/application_status_listener_unittest.cc +++ b/chromium/base/android/application_status_listener_unittest.cc @@ -3,10 +3,12 @@ // found in the LICENSE file. #include "base/android/application_status_listener.h" + +#include <memory> + #include "base/bind.h" #include "base/callback_forward.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/synchronization/waitable_event.h" @@ -92,7 +94,7 @@ class MultiThreadedTest { base::WaitableEvent event_; base::Thread thread_; base::MessageLoop main_; - scoped_ptr<ApplicationStatusListener> listener_; + std::unique_ptr<ApplicationStatusListener> listener_; }; } // namespace diff --git a/chromium/base/android/build_info.cc b/chromium/base/android/build_info.cc index 2d3ef278ee2..5fa6c6c7ea8 100644 --- a/chromium/base/android/build_info.cc +++ b/chromium/base/android/build_info.cc @@ -16,8 +16,15 @@ namespace { -// The caller takes ownership of the returned const char*. +// We are leaking these strings. const char* StrDupJString(const base::android::JavaRef<jstring>& java_string) { + // Some of the Java methods on BuildInfo can return null + // (https://crbug.com/601081), which can't be represented as a std::string, so + // use an empty string instead. + // TODO(bauerb): Do this only for methods that can legitimately return null. + if (java_string.is_null()) + return ""; + std::string str = ConvertJavaStringToUTF8(java_string); return strdup(str.c_str()); } diff --git a/chromium/base/android/content_uri_utils.cc b/chromium/base/android/content_uri_utils.cc index 195598bfb3f..31f7b4fffbf 100644 --- a/chromium/base/android/content_uri_utils.cc +++ b/chromium/base/android/content_uri_utils.cc @@ -43,6 +43,9 @@ std::string GetContentUriMimeType(const FilePath& content_uri) { ScopedJavaLocalRef<jstring> j_mime = Java_ContentUriUtils_getMimeType( env, base::android::GetApplicationContext(), j_uri.obj()); + if (j_mime.is_null()) + return std::string(); + return base::android::ConvertJavaStringToUTF8(env, j_mime.obj()); } diff --git a/chromium/base/android/library_loader/library_loader_hooks.h b/chromium/base/android/library_loader/library_loader_hooks.h index ca3c5a20ae8..1ed09bd54f0 100644 --- a/chromium/base/android/library_loader/library_loader_hooks.h +++ b/chromium/base/android/library_loader/library_loader_hooks.h @@ -21,8 +21,10 @@ enum LibraryProcessType { PROCESS_BROWSER = 1, // Shared library is running in child process. PROCESS_CHILD = 2, - // Shared library is running in webview process. + // Shared library is running in the app that uses webview. PROCESS_WEBVIEW = 3, + // Shared library is running in child process as part of webview. + PROCESS_WEBVIEW_CHILD = 4, }; // Record any pending renderer histogram value as a histogram. Pending values diff --git a/chromium/base/android/path_utils.cc b/chromium/base/android/path_utils.cc index 85e29de8bfa..b76544949ed 100644 --- a/chromium/base/android/path_utils.cc +++ b/chromium/base/android/path_utils.cc @@ -45,8 +45,7 @@ bool GetCacheDirectory(FilePath* result) { bool GetThumbnailCacheDirectory(FilePath* result) { JNIEnv* env = AttachCurrentThread(); ScopedJavaLocalRef<jstring> path = - Java_PathUtils_getThumbnailCacheDirectoryPath(env, - GetApplicationContext()); + Java_PathUtils_getThumbnailCacheDirectory(env, GetApplicationContext()); FilePath thumbnail_cache_path(ConvertJavaStringToUTF8(path)); *result = thumbnail_cache_path; return true; diff --git a/chromium/base/android/record_histogram.cc b/chromium/base/android/record_histogram.cc index ea88f312a9e..3c51fe27089 100644 --- a/chromium/base/android/record_histogram.cc +++ b/chromium/base/android/record_histogram.cc @@ -7,6 +7,7 @@ #include <stdint.h> #include <map> +#include <string> #include "base/android/jni_android.h" #include "base/android/jni_string.h" @@ -15,6 +16,7 @@ #include "base/metrics/histogram.h" #include "base/metrics/sparse_histogram.h" #include "base/metrics/statistics_recorder.h" +#include "base/strings/stringprintf.h" #include "base/synchronization/lock.h" #include "base/time/time.h" #include "jni/RecordHistogram_jni.h" @@ -29,31 +31,61 @@ class HistogramCache { public: HistogramCache() {} + std::string HistogramConstructionParamsToString(HistogramBase* histogram) { + std::string params_str = histogram->histogram_name(); + switch (histogram->GetHistogramType()) { + case HISTOGRAM: + case LINEAR_HISTOGRAM: + case BOOLEAN_HISTOGRAM: + case CUSTOM_HISTOGRAM: { + Histogram* hist = static_cast<Histogram*>(histogram); + params_str += StringPrintf("/%d/%d/%d", hist->declared_min(), + hist->declared_max(), hist->bucket_count()); + break; + } + case SPARSE_HISTOGRAM: + break; + } + return params_str; + } + + void CheckHistogramArgs(JNIEnv* env, + jstring j_histogram_name, + int32_t expected_min, + int32_t expected_max, + int32_t expected_bucket_count, + HistogramBase* histogram) { + DCHECK(histogram->HasConstructionArguments(expected_min, expected_max, + expected_bucket_count)) + << ConvertJavaStringToUTF8(env, j_histogram_name) << "/" << expected_min + << "/" << expected_max << "/" << expected_bucket_count << " vs. " + << HistogramConstructionParamsToString(histogram); + } + HistogramBase* BooleanHistogram(JNIEnv* env, jstring j_histogram_name, - jint j_histogram_key) { + jlong j_histogram_key) { DCHECK(j_histogram_name); - DCHECK(j_histogram_key); - HistogramBase* histogram = FindLocked(j_histogram_key); + HistogramBase* histogram = HistogramFromKey(j_histogram_key); if (histogram) return histogram; std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); histogram = BooleanHistogram::FactoryGet( histogram_name, HistogramBase::kUmaTargetedHistogramFlag); - return InsertLocked(j_histogram_key, histogram); + return histogram; } HistogramBase* EnumeratedHistogram(JNIEnv* env, jstring j_histogram_name, - jint j_histogram_key, + jlong j_histogram_key, jint j_boundary) { DCHECK(j_histogram_name); - DCHECK(j_histogram_key); - HistogramBase* histogram = FindLocked(j_histogram_key); - int boundary = static_cast<int>(j_boundary); + HistogramBase* histogram = HistogramFromKey(j_histogram_key); + int32_t boundary = static_cast<int32_t>(j_boundary); if (histogram) { - DCHECK(histogram->HasConstructionArguments(1, boundary, boundary + 1)); + CheckHistogramArgs(env, j_histogram_name, 1, boundary, boundary + 1, + histogram); return histogram; } @@ -61,23 +93,23 @@ class HistogramCache { histogram = LinearHistogram::FactoryGet(histogram_name, 1, boundary, boundary + 1, HistogramBase::kUmaTargetedHistogramFlag); - return InsertLocked(j_histogram_key, histogram); + return histogram; } HistogramBase* CustomCountHistogram(JNIEnv* env, jstring j_histogram_name, - jint j_histogram_key, + jlong j_histogram_key, jint j_min, jint j_max, jint j_num_buckets) { DCHECK(j_histogram_name); - DCHECK(j_histogram_key); - int64_t min = static_cast<int64_t>(j_min); - int64_t max = static_cast<int64_t>(j_max); - int num_buckets = static_cast<int>(j_num_buckets); - HistogramBase* histogram = FindLocked(j_histogram_key); + int32_t min = static_cast<int32_t>(j_min); + int32_t max = static_cast<int32_t>(j_max); + int32_t num_buckets = static_cast<int32_t>(j_num_buckets); + HistogramBase* histogram = HistogramFromKey(j_histogram_key); if (histogram) { - DCHECK(histogram->HasConstructionArguments(min, max, num_buckets)); + CheckHistogramArgs(env, j_histogram_name, min, max, num_buckets, + histogram); return histogram; } @@ -85,23 +117,23 @@ class HistogramCache { histogram = Histogram::FactoryGet(histogram_name, min, max, num_buckets, HistogramBase::kUmaTargetedHistogramFlag); - return InsertLocked(j_histogram_key, histogram); + return histogram; } HistogramBase* LinearCountHistogram(JNIEnv* env, jstring j_histogram_name, - jint j_histogram_key, + jlong j_histogram_key, jint j_min, jint j_max, jint j_num_buckets) { DCHECK(j_histogram_name); - DCHECK(j_histogram_key); - int64_t min = static_cast<int64_t>(j_min); - int64_t max = static_cast<int64_t>(j_max); - int num_buckets = static_cast<int>(j_num_buckets); - HistogramBase* histogram = FindLocked(j_histogram_key); + int32_t min = static_cast<int32_t>(j_min); + int32_t max = static_cast<int32_t>(j_max); + int32_t num_buckets = static_cast<int32_t>(j_num_buckets); + HistogramBase* histogram = HistogramFromKey(j_histogram_key); if (histogram) { - DCHECK(histogram->HasConstructionArguments(min, max, num_buckets)); + CheckHistogramArgs(env, j_histogram_name, min, max, num_buckets, + histogram); return histogram; } @@ -109,38 +141,37 @@ class HistogramCache { histogram = LinearHistogram::FactoryGet(histogram_name, min, max, num_buckets, HistogramBase::kUmaTargetedHistogramFlag); - return InsertLocked(j_histogram_key, histogram); + return histogram; } HistogramBase* SparseHistogram(JNIEnv* env, jstring j_histogram_name, - jint j_histogram_key) { + jlong j_histogram_key) { DCHECK(j_histogram_name); - DCHECK(j_histogram_key); - HistogramBase* histogram = FindLocked(j_histogram_key); + HistogramBase* histogram = HistogramFromKey(j_histogram_key); if (histogram) return histogram; std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); histogram = SparseHistogram::FactoryGet( histogram_name, HistogramBase::kUmaTargetedHistogramFlag); - return InsertLocked(j_histogram_key, histogram); + return histogram; } HistogramBase* CustomTimesHistogram(JNIEnv* env, jstring j_histogram_name, - jint j_histogram_key, - jlong j_min, - jlong j_max, + jlong j_histogram_key, + jint j_min, + jint j_max, jint j_bucket_count) { DCHECK(j_histogram_name); - DCHECK(j_histogram_key); - HistogramBase* histogram = FindLocked(j_histogram_key); - int64_t min = static_cast<int64_t>(j_min); - int64_t max = static_cast<int64_t>(j_max); - int bucket_count = static_cast<int>(j_bucket_count); + HistogramBase* histogram = HistogramFromKey(j_histogram_key); + int32_t min = static_cast<int32_t>(j_min); + int32_t max = static_cast<int32_t>(j_max); + int32_t bucket_count = static_cast<int32_t>(j_bucket_count); if (histogram) { - DCHECK(histogram->HasConstructionArguments(min, max, bucket_count)); + CheckHistogramArgs(env, j_histogram_name, min, max, bucket_count, + histogram); return histogram; } @@ -150,112 +181,108 @@ class HistogramCache { // TimeDelta arguments. histogram = Histogram::FactoryGet(histogram_name, min, max, bucket_count, HistogramBase::kUmaTargetedHistogramFlag); - return InsertLocked(j_histogram_key, histogram); + return histogram; } private: - HistogramBase* FindLocked(jint j_histogram_key) { - base::AutoLock locked(lock_); - auto histogram_it = histograms_.find(j_histogram_key); - return histogram_it != histograms_.end() ? histogram_it->second : nullptr; - } - - HistogramBase* InsertLocked(jint j_histogram_key, HistogramBase* histogram) { - base::AutoLock locked(lock_); - histograms_.insert(std::make_pair(j_histogram_key, histogram)); - return histogram; + // Convert a jlong |histogram_key| from Java to a HistogramBase* via a cast. + // The Java side caches these in a map (see RecordHistogram.java), which is + // safe to do since C++ Histogram objects are never freed. + static HistogramBase* HistogramFromKey(jlong j_histogram_key) { + return reinterpret_cast<HistogramBase*>(j_histogram_key); } - base::Lock lock_; - std::map<jint, HistogramBase*> histograms_; - DISALLOW_COPY_AND_ASSIGN(HistogramCache); }; -base::LazyInstance<HistogramCache>::Leaky g_histograms; +LazyInstance<HistogramCache>::Leaky g_histograms; } // namespace -void RecordBooleanHistogram(JNIEnv* env, - const JavaParamRef<jclass>& clazz, - const JavaParamRef<jstring>& j_histogram_name, - jint j_histogram_key, - jboolean j_sample) { +jlong RecordBooleanHistogram(JNIEnv* env, + const JavaParamRef<jclass>& clazz, + const JavaParamRef<jstring>& j_histogram_name, + jlong j_histogram_key, + jboolean j_sample) { bool sample = static_cast<bool>(j_sample); - g_histograms.Get() - .BooleanHistogram(env, j_histogram_name, j_histogram_key) - ->AddBoolean(sample); + HistogramBase* histogram = g_histograms.Get().BooleanHistogram( + env, j_histogram_name, j_histogram_key); + histogram->AddBoolean(sample); + return reinterpret_cast<jlong>(histogram); } -void RecordEnumeratedHistogram(JNIEnv* env, - const JavaParamRef<jclass>& clazz, - const JavaParamRef<jstring>& j_histogram_name, - jint j_histogram_key, - jint j_sample, - jint j_boundary) { +jlong RecordEnumeratedHistogram(JNIEnv* env, + const JavaParamRef<jclass>& clazz, + const JavaParamRef<jstring>& j_histogram_name, + jlong j_histogram_key, + jint j_sample, + jint j_boundary) { int sample = static_cast<int>(j_sample); - g_histograms.Get() - .EnumeratedHistogram(env, j_histogram_name, j_histogram_key, j_boundary) - ->Add(sample); + HistogramBase* histogram = g_histograms.Get().EnumeratedHistogram( + env, j_histogram_name, j_histogram_key, j_boundary); + histogram->Add(sample); + return reinterpret_cast<jlong>(histogram); } -void RecordCustomCountHistogram(JNIEnv* env, - const JavaParamRef<jclass>& clazz, - const JavaParamRef<jstring>& j_histogram_name, - jint j_histogram_key, - jint j_sample, - jint j_min, - jint j_max, - jint j_num_buckets) { +jlong RecordCustomCountHistogram(JNIEnv* env, + const JavaParamRef<jclass>& clazz, + const JavaParamRef<jstring>& j_histogram_name, + jlong j_histogram_key, + jint j_sample, + jint j_min, + jint j_max, + jint j_num_buckets) { int sample = static_cast<int>(j_sample); - g_histograms.Get() - .CustomCountHistogram(env, j_histogram_name, j_histogram_key, j_min, - j_max, j_num_buckets) - ->Add(sample); + HistogramBase* histogram = g_histograms.Get().CustomCountHistogram( + env, j_histogram_name, j_histogram_key, j_min, j_max, j_num_buckets); + histogram->Add(sample); + return reinterpret_cast<jlong>(histogram); } -void RecordLinearCountHistogram(JNIEnv* env, - const JavaParamRef<jclass>& clazz, - const JavaParamRef<jstring>& j_histogram_name, - jint j_histogram_key, - jint j_sample, - jint j_min, - jint j_max, - jint j_num_buckets) { +jlong RecordLinearCountHistogram(JNIEnv* env, + const JavaParamRef<jclass>& clazz, + const JavaParamRef<jstring>& j_histogram_name, + jlong j_histogram_key, + jint j_sample, + jint j_min, + jint j_max, + jint j_num_buckets) { int sample = static_cast<int>(j_sample); - g_histograms.Get() - .LinearCountHistogram(env, j_histogram_name, j_histogram_key, j_min, - j_max, j_num_buckets) - ->Add(sample); + HistogramBase* histogram = g_histograms.Get().LinearCountHistogram( + env, j_histogram_name, j_histogram_key, j_min, j_max, j_num_buckets); + histogram->Add(sample); + return reinterpret_cast<jlong>(histogram); } -void RecordSparseHistogram(JNIEnv* env, - const JavaParamRef<jclass>& clazz, - const JavaParamRef<jstring>& j_histogram_name, - jint j_histogram_key, - jint j_sample) { - int sample = static_cast<int>(j_sample); - g_histograms.Get() - .SparseHistogram(env, j_histogram_name, j_histogram_key) - ->Add(sample); +jlong RecordSparseHistogram(JNIEnv* env, + const JavaParamRef<jclass>& clazz, + const JavaParamRef<jstring>& j_histogram_name, + jlong j_histogram_key, + jint j_sample) { + int sample = static_cast<int>(j_sample); + HistogramBase* histogram = g_histograms.Get().SparseHistogram( + env, j_histogram_name, j_histogram_key); + histogram->Add(sample); + return reinterpret_cast<jlong>(histogram); } -void RecordCustomTimesHistogramMilliseconds( +jlong RecordCustomTimesHistogramMilliseconds( JNIEnv* env, const JavaParamRef<jclass>& clazz, const JavaParamRef<jstring>& j_histogram_name, - jint j_histogram_key, - jlong j_duration, - jlong j_min, - jlong j_max, + jlong j_histogram_key, + jint j_duration, + jint j_min, + jint j_max, jint j_num_buckets) { - g_histograms.Get() - .CustomTimesHistogram(env, j_histogram_name, j_histogram_key, j_min, - j_max, j_num_buckets) - ->AddTime(TimeDelta::FromMilliseconds(static_cast<int64_t>(j_duration))); + HistogramBase* histogram = g_histograms.Get().CustomTimesHistogram( + env, j_histogram_name, j_histogram_key, j_min, j_max, j_num_buckets); + histogram->AddTime( + TimeDelta::FromMilliseconds(static_cast<int64_t>(j_duration))); + return reinterpret_cast<jlong>(histogram); } void Initialize(JNIEnv* env, const JavaParamRef<jclass>&) { @@ -278,7 +305,7 @@ jint GetHistogramValueCountForTesting( return 0; } - scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); + std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); return samples->GetCount(static_cast<int>(sample)); } diff --git a/chromium/base/android/scoped_java_ref.h b/chromium/base/android/scoped_java_ref.h index 8dcf2bca039..a1b4b13f6da 100644 --- a/chromium/base/android/scoped_java_ref.h +++ b/chromium/base/android/scoped_java_ref.h @@ -8,10 +8,11 @@ #include <jni.h> #include <stddef.h> +#include <type_traits> + #include "base/base_export.h" #include "base/logging.h" #include "base/macros.h" -#include "base/template_util.h" namespace base { namespace android { @@ -193,7 +194,7 @@ class ScopedJavaLocalRef : public JavaRef<T> { template<typename U> void Reset(JNIEnv* env, U obj) { - static_assert(base::is_convertible<U, T>::value, + static_assert(std::is_convertible<U, T>::value, "U must be convertible to T"); env_ = this->SetNewLocalRef(env, obj); } @@ -264,7 +265,7 @@ class ScopedJavaGlobalRef : public JavaRef<T> { template<typename U> void Reset(JNIEnv* env, U obj) { - static_assert(base::is_convertible<U, T>::value, + static_assert(std::is_convertible<U, T>::value, "U must be convertible to T"); this->SetNewGlobalRef(env, obj); } |