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 <vector> | 6 #include <vector> |
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" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 std::vector<int /* RenderProcessHost id */> suspended_processes_; | 90 std::vector<int /* RenderProcessHost id */> suspended_processes_; |
91 }; | 91 }; |
92 | 92 |
93 base::LazyInstance<SuspendedProcessWatcher> g_suspended_processes_watcher = | 93 base::LazyInstance<SuspendedProcessWatcher> g_suspended_processes_watcher = |
94 LAZY_INSTANCE_INITIALIZER; | 94 LAZY_INSTANCE_INITIALIZER; |
95 | 95 |
96 } // namespace | 96 } // namespace |
97 | 97 |
98 // Returns the first substring consisting of the address of a physical location. | 98 // Returns the first substring consisting of the address of a physical location. |
99 static jstring FindAddress(JNIEnv* env, jclass clazz, jstring addr) { | 99 static ScopedJavaLocalRef<jstring> FindAddress(JNIEnv* env, |
| 100 jclass clazz, |
| 101 jstring addr) { |
100 base::string16 content_16 = ConvertJavaStringToUTF16(env, addr); | 102 base::string16 content_16 = ConvertJavaStringToUTF16(env, addr); |
101 base::string16 result_16; | 103 base::string16 result_16; |
102 if (content::address_parser::FindAddress(content_16, &result_16)) | 104 if (content::address_parser::FindAddress(content_16, &result_16)) |
103 return ConvertUTF16ToJavaString(env, result_16).Release(); | 105 return ConvertUTF16ToJavaString(env, result_16); |
104 return NULL; | 106 return ScopedJavaLocalRef<jstring>(); |
105 } | 107 } |
106 | 108 |
107 static void SetWebKitSharedTimersSuspended(JNIEnv* env, | 109 static void SetWebKitSharedTimersSuspended(JNIEnv* env, |
108 jclass obj, | 110 jclass obj, |
109 jboolean suspend) { | 111 jboolean suspend) { |
110 if (suspend) { | 112 if (suspend) { |
111 g_suspended_processes_watcher.Pointer()->SuspendWebKitSharedTimers(); | 113 g_suspended_processes_watcher.Pointer()->SuspendWebKitSharedTimers(); |
112 } else { | 114 } else { |
113 g_suspended_processes_watcher.Pointer()->ResumeWebkitSharedTimers(); | 115 g_suspended_processes_watcher.Pointer()->ResumeWebkitSharedTimers(); |
114 } | 116 } |
115 } | 117 } |
116 | 118 |
117 namespace content { | 119 namespace content { |
118 | 120 |
119 bool RegisterWebViewStatics(JNIEnv* env) { | 121 bool RegisterWebViewStatics(JNIEnv* env) { |
120 return RegisterNativesImpl(env); | 122 return RegisterNativesImpl(env); |
121 } | 123 } |
122 | 124 |
123 } // namespace content | 125 } // namespace content |
OLD | NEW |