| OLD | NEW |
| 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/java_handler_thread.h" | 7 #include "base/android/java_handler_thread.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 // The JavaBridge needs to use a Java thread so the callback | 34 // The JavaBridge needs to use a Java thread so the callback |
| 35 // will happen on a thread with a prepared Looper. | 35 // will happen on a thread with a prepared Looper. |
| 36 class JavaBridgeThread : public base::android::JavaHandlerThread { | 36 class JavaBridgeThread : public base::android::JavaHandlerThread { |
| 37 public: | 37 public: |
| 38 JavaBridgeThread() : base::android::JavaHandlerThread("JavaBridge") { | 38 JavaBridgeThread() : base::android::JavaHandlerThread("JavaBridge") { |
| 39 Start(); | 39 Start(); |
| 40 } | 40 } |
| 41 virtual ~JavaBridgeThread() { | 41 ~JavaBridgeThread() override { Stop(); } |
| 42 Stop(); | |
| 43 } | |
| 44 static bool CurrentlyOn(); | 42 static bool CurrentlyOn(); |
| 45 }; | 43 }; |
| 46 | 44 |
| 47 base::LazyInstance<JavaBridgeThread> g_background_thread = | 45 base::LazyInstance<JavaBridgeThread> g_background_thread = |
| 48 LAZY_INSTANCE_INITIALIZER; | 46 LAZY_INSTANCE_INITIALIZER; |
| 49 | 47 |
| 50 // static | 48 // static |
| 51 bool JavaBridgeThread::CurrentlyOn() { | 49 bool JavaBridgeThread::CurrentlyOn() { |
| 52 return base::MessageLoop::current() == | 50 return base::MessageLoop::current() == |
| 53 g_background_thread.Get().message_loop(); | 51 g_background_thread.Get().message_loop(); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 if (iter == objects_.end()) | 479 if (iter == objects_.end()) |
| 482 return; | 480 return; |
| 483 JavaObjectWeakGlobalRef ref = | 481 JavaObjectWeakGlobalRef ref = |
| 484 RemoveHolderAndAdvanceLocked(GetCurrentRoutingID(), &iter); | 482 RemoveHolderAndAdvanceLocked(GetCurrentRoutingID(), &iter); |
| 485 if (!ref.is_empty()) { | 483 if (!ref.is_empty()) { |
| 486 RemoveFromRetainedObjectSetLocked(ref); | 484 RemoveFromRetainedObjectSetLocked(ref); |
| 487 } | 485 } |
| 488 } | 486 } |
| 489 | 487 |
| 490 } // namespace content | 488 } // namespace content |
| OLD | NEW |