Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: content/shell/android/shell_manager.cc

Issue 1294333002: Fix wrong usages of ScopedJavaLocalRef::Release(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment to Release() explaining it should not be used to call java methods Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/shell/android/shell_manager.h ('k') | content/shell/browser/shell_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/shell/android/shell_manager.h" 5 #include "content/shell/android/shell_manager.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 GlobalState() {} 24 GlobalState() {}
25 base::android::ScopedJavaGlobalRef<jobject> j_shell_manager; 25 base::android::ScopedJavaGlobalRef<jobject> j_shell_manager;
26 }; 26 };
27 27
28 base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER; 28 base::LazyInstance<GlobalState> g_global_state = LAZY_INSTANCE_INITIALIZER;
29 29
30 } // namespace 30 } // namespace
31 31
32 namespace content { 32 namespace content {
33 33
34 jobject CreateShellView(Shell* shell) { 34 ScopedJavaLocalRef<jobject> CreateShellView(Shell* shell) {
35 JNIEnv* env = base::android::AttachCurrentThread(); 35 JNIEnv* env = base::android::AttachCurrentThread();
36 jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj(); 36 jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj();
37 return Java_ShellManager_createShell( 37 return Java_ShellManager_createShell(env, j_shell_manager,
38 env, 38 reinterpret_cast<intptr_t>(shell));
39 j_shell_manager,
40 reinterpret_cast<intptr_t>(shell)).Release();
41 } 39 }
42 40
43 void RemoveShellView(jobject shell_view) { 41 void RemoveShellView(jobject shell_view) {
44 JNIEnv* env = base::android::AttachCurrentThread(); 42 JNIEnv* env = base::android::AttachCurrentThread();
45 jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj(); 43 jobject j_shell_manager = g_global_state.Get().j_shell_manager.obj();
46 Java_ShellManager_removeShell(env, j_shell_manager, shell_view); 44 Java_ShellManager_removeShell(env, j_shell_manager, shell_view);
47 } 45 }
48 46
49 // Register native methods 47 // Register native methods
50 bool RegisterShellManager(JNIEnv* env) { 48 bool RegisterShellManager(JNIEnv* env) {
51 return RegisterNativesImpl(env); 49 return RegisterNativesImpl(env);
52 } 50 }
53 51
54 static void Init(JNIEnv* env, jclass clazz, jobject obj) { 52 static void Init(JNIEnv* env, jclass clazz, jobject obj) {
55 g_global_state.Get().j_shell_manager.Reset( 53 g_global_state.Get().j_shell_manager.Reset(
56 base::android::ScopedJavaLocalRef<jobject>(env, obj)); 54 base::android::ScopedJavaLocalRef<jobject>(env, obj));
57 } 55 }
58 56
59 void LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) { 57 void LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) {
60 ShellBrowserContext* browserContext = 58 ShellBrowserContext* browserContext =
61 ShellContentBrowserClient::Get()->browser_context(); 59 ShellContentBrowserClient::Get()->browser_context();
62 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); 60 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
63 Shell::CreateNewWindow(browserContext, 61 Shell::CreateNewWindow(browserContext,
64 url, 62 url,
65 NULL, 63 NULL,
66 gfx::Size()); 64 gfx::Size());
67 } 65 }
68 66
69 } // namespace content 67 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/android/shell_manager.h ('k') | content/shell/browser/shell_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698