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

Unified Diff: net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java

Issue 14362009: Receive app notifications in SimpleCache, so we save our index file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
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
+ * the android app state such as the app going to the background or foreground.
+ */
+// extends BroadcastReceiver
+public class SimpleCacheActivityStatusNotifier
+ implements ActivityStatus.StateListener {
+ @CalledByNative
+ static public SimpleCacheActivityStatusNotifier NewInstance(int nativePtr) {
+ return new SimpleCacheActivityStatusNotifier(nativePtr);
+ }
+
+ public SimpleCacheActivityStatusNotifier(int nativePtr) {
+ this.mNativePtr = nativePtr;
+ ActivityStatus.registerStateListener(this);
+ }
+
+ // ActivityStatus.StateListener
+ @Override
+ public void onActivityStateChange(int state) {
+ if (state == ActivityStatus.RESUMED ||
+ state == ActivityStatus.PAUSED ||
+ state == ActivityStatus.STOPPED ||
+ state == ActivityStatus.DESTROYED) {
+ assert mNativePtr != 0;
+ nativeNotifyActivityStatusChanged(mNativePtr, state);
+ }
+ }
+
+ @NativeClassQualifiedName("net::SimpleCacheActivityStatusNotifier")
+ private native void nativeNotifyActivityStatusChanged(int nativePtr, int newActivityStatus);
+
+ // Pointer to native object.
+ private int mNativePtr = 0;
+}
« no previous file with comments | « no previous file | net/android/net_jni_registrar.cc » ('j') | net/android/simple_cache_activity_status_notifier.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698