| 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 #include <jni.h> | 5 #include <jni.h> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "content/browser/android/content_view_statics.h" | 13 #include "content/browser/android/content_view_statics.h" |
| 14 #include "content/browser/renderer_host/render_process_host_impl.h" | 14 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 15 #include "content/common/android/address_parser.h" | |
| 16 #include "content/common/view_messages.h" | 15 #include "content/common/view_messages.h" |
| 17 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 18 #include "content/public/browser/render_process_host_observer.h" | 17 #include "content/public/browser/render_process_host_observer.h" |
| 19 #include "jni/ContentViewStatics_jni.h" | 18 #include "jni/ContentViewStatics_jni.h" |
| 20 | 19 |
| 21 using base::android::ConvertJavaStringToUTF16; | 20 using base::android::ConvertJavaStringToUTF16; |
| 22 using base::android::ConvertUTF16ToJavaString; | 21 using base::android::ConvertUTF16ToJavaString; |
| 23 using base::android::JavaParamRef; | 22 using base::android::JavaParamRef; |
| 24 using base::android::ScopedJavaLocalRef; | 23 using base::android::ScopedJavaLocalRef; |
| 25 | 24 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 84 } |
| 86 | 85 |
| 87 std::set<int /* RenderProcessHost id */> suspended_processes_; | 86 std::set<int /* RenderProcessHost id */> suspended_processes_; |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 base::LazyInstance<SuspendedProcessWatcher>::DestructorAtExit | 89 base::LazyInstance<SuspendedProcessWatcher>::DestructorAtExit |
| 91 g_suspended_processes_watcher = LAZY_INSTANCE_INITIALIZER; | 90 g_suspended_processes_watcher = LAZY_INSTANCE_INITIALIZER; |
| 92 | 91 |
| 93 } // namespace | 92 } // namespace |
| 94 | 93 |
| 95 // Returns the first substring consisting of the address of a physical location. | |
| 96 static ScopedJavaLocalRef<jstring> FindAddress( | |
| 97 JNIEnv* env, | |
| 98 const JavaParamRef<jclass>& clazz, | |
| 99 const JavaParamRef<jstring>& addr) { | |
| 100 base::string16 content_16 = ConvertJavaStringToUTF16(env, addr); | |
| 101 base::string16 result_16; | |
| 102 if (content::address_parser::FindAddress(content_16, &result_16)) | |
| 103 return ConvertUTF16ToJavaString(env, result_16); | |
| 104 return ScopedJavaLocalRef<jstring>(); | |
| 105 } | |
| 106 | |
| 107 static void SetWebKitSharedTimersSuspended(JNIEnv* env, | 94 static void SetWebKitSharedTimersSuspended(JNIEnv* env, |
| 108 const JavaParamRef<jclass>& obj, | 95 const JavaParamRef<jclass>& obj, |
| 109 jboolean suspend) { | 96 jboolean suspend) { |
| 110 if (suspend) { | 97 if (suspend) { |
| 111 g_suspended_processes_watcher.Pointer()->SuspendWebKitSharedTimers(); | 98 g_suspended_processes_watcher.Pointer()->SuspendWebKitSharedTimers(); |
| 112 } else { | 99 } else { |
| 113 g_suspended_processes_watcher.Pointer()->ResumeWebkitSharedTimers(); | 100 g_suspended_processes_watcher.Pointer()->ResumeWebkitSharedTimers(); |
| 114 } | 101 } |
| 115 } | 102 } |
| 116 | 103 |
| 117 namespace content { | 104 namespace content { |
| 118 | 105 |
| 119 bool RegisterWebViewStatics(JNIEnv* env) { | 106 bool RegisterWebViewStatics(JNIEnv* env) { |
| 120 return RegisterNativesImpl(env); | 107 return RegisterNativesImpl(env); |
| 121 } | 108 } |
| 122 | 109 |
| 123 } // namespace content | 110 } // namespace content |
| OLD | NEW |