Index: net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java |
diff --git a/net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java b/net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..626b335f011e0aa02f7e8c0ac23f610d53c8bd93 |
--- /dev/null |
+++ b/net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.net; |
+ |
+import android.util.Log; |
+ |
+import org.chromium.base.ActivityStatus; |
+import org.chromium.base.CalledByNative; |
+import org.chromium.base.JNINamespace; |
+import org.chromium.base.NativeClassQualifiedName; |
+ |
+/** |
+ * Used by the SimpleIndex in net/disk_cache/simple/ to listens to changes in |
Philippe
2013/04/22 11:35:48
Nit: the char limit is 100 in Java.
felipeg
2013/04/22 16:14:32
Done.
|
+ * the android app state such as the app going to the background or foreground. |
+ */ |
+// extends BroadcastReceiver |
Philippe
2013/04/22 11:35:48
You can remove this line.
felipeg
2013/04/22 16:14:32
Done.
|
+public class SimpleCacheActivityStatusNotifier |
+ implements ActivityStatus.StateListener { |
+ @CalledByNative |
+ static public SimpleCacheActivityStatusNotifier NewInstance(int nativePtr) { |
Philippe
2013/04/22 11:35:48
Nit: s/NewInstance/newInstance
felipeg
2013/04/22 16:14:32
Done.
|
+ return new SimpleCacheActivityStatusNotifier(nativePtr); |
Philippe
2013/04/22 11:35:48
Nit: 4 space indent in Java (here and in a few oth
felipeg
2013/04/22 16:14:32
Done.
|
+ } |
+ |
+ public SimpleCacheActivityStatusNotifier(int nativePtr) { |
Philippe
2013/04/22 11:35:48
You can make this constructor private since this c
Philippe
2013/04/22 11:59:34
As we discussed this constructor is called on the
felipeg
2013/04/22 16:14:32
Done.
felipeg
2013/04/22 16:14:32
Done.
|
+ this.mNativePtr = nativePtr; |
+ ActivityStatus.registerStateListener(this); |
+ } |
+ |
+ // ActivityStatus.StateListener |
+ @Override |
+ public void onActivityStateChange(int state) { |
+ if (state == ActivityStatus.RESUMED || |
+ state == ActivityStatus.PAUSED || |
Philippe
2013/04/22 11:35:48
You can remove support for the PAUSED and DESTROYE
felipeg
2013/04/22 16:14:32
Done.
|
+ state == ActivityStatus.STOPPED || |
+ state == ActivityStatus.DESTROYED) { |
+ assert mNativePtr != 0; |
+ nativeNotifyActivityStatusChanged(mNativePtr, state); |
Philippe
2013/04/22 11:59:34
As we discussed this is called on the UI thread wh
felipeg
2013/04/22 16:14:32
Done.
|
+ } |
+ } |
+ |
+ @NativeClassQualifiedName("net::SimpleCacheActivityStatusNotifier") |
+ private native void nativeNotifyActivityStatusChanged(int nativePtr, int newActivityStatus); |
+ |
+ // Pointer to native object. |
+ private int mNativePtr = 0; |
Philippe
2013/04/22 11:35:48
Nit: attributes go first usually in Java. You can
felipeg
2013/04/22 16:14:32
Done.
|
+} |