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

Side by Side Diff: content/browser/android/java/gin_java_bridge_dispatcher_host.cc

Issue 1547043002: [Android] Fix GinJavaBridgeMessageFilter registration issue in Java Bridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses review inputs. Created 4 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/android/java/gin_java_bridge_dispatcher_host.h" 5 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/browser/android/java/gin_java_bound_object_delegate.h" 10 #include "content/browser/android/java/gin_java_bound_object_delegate.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 } 74 }
75 75
76 void GinJavaBridgeDispatcherHost::WebContentsDestroyed() { 76 void GinJavaBridgeDispatcherHost::WebContentsDestroyed() {
77 scoped_refptr<GinJavaBridgeMessageFilter> filter = 77 scoped_refptr<GinJavaBridgeMessageFilter> filter =
78 GinJavaBridgeMessageFilter::FromHost(this, false); 78 GinJavaBridgeMessageFilter::FromHost(this, false);
79 if (filter) 79 if (filter)
80 filter->RemoveHost(this); 80 filter->RemoveHost(this);
81 } 81 }
82 82
83 void GinJavaBridgeDispatcherHost::RenderProcessGone(
84 base::TerminationStatus status) {
85 GinJavaBridgeMessageFilter::RemoveFilter(this);
86 }
87
88 void GinJavaBridgeDispatcherHost::RenderViewHostChanged(
89 RenderViewHost* old_host,
90 RenderViewHost* new_host) {
91 scoped_refptr<GinJavaBridgeMessageFilter> filter =
92 GinJavaBridgeMessageFilter::FromHost(this, false);
93 if (!filter)
94 InstallFilterAndRegisterAllRoutingIds();
95 }
96
83 GinJavaBoundObject::ObjectID GinJavaBridgeDispatcherHost::AddObject( 97 GinJavaBoundObject::ObjectID GinJavaBridgeDispatcherHost::AddObject(
84 const base::android::JavaRef<jobject>& object, 98 const base::android::JavaRef<jobject>& object,
85 const base::android::JavaRef<jclass>& safe_annotation_clazz, 99 const base::android::JavaRef<jclass>& safe_annotation_clazz,
86 bool is_named, 100 bool is_named,
87 int32_t holder) { 101 int32_t holder) {
88 // Can be called on any thread. Calls come from the UI thread via 102 // Can be called on any thread. Calls come from the UI thread via
89 // AddNamedObject, and from the background thread, when injected Java 103 // AddNamedObject, and from the background thread, when injected Java
90 // object's method returns a Java object. 104 // object's method returns a Java object.
91 DCHECK(is_named || holder); 105 DCHECK(is_named || holder);
92 JNIEnv* env = base::android::AttachCurrentThread(); 106 JNIEnv* env = base::android::AttachCurrentThread();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 if (iter == objects_.end()) 373 if (iter == objects_.end())
360 return; 374 return;
361 JavaObjectWeakGlobalRef ref = 375 JavaObjectWeakGlobalRef ref =
362 RemoveHolderAndAdvanceLocked(routing_id, &iter); 376 RemoveHolderAndAdvanceLocked(routing_id, &iter);
363 if (!ref.is_empty()) { 377 if (!ref.is_empty()) {
364 RemoveFromRetainedObjectSetLocked(ref); 378 RemoveFromRetainedObjectSetLocked(ref);
365 } 379 }
366 } 380 }
367 381
368 } // namespace content 382 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698