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

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

Issue 14081031: Revert 195845 "With this CL we can catch OnResume, OnPause, OnDe..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
« no previous file with comments | « no previous file | trunk/src/net/android/net_jni_registrar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java
===================================================================
--- trunk/src/net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java (revision 196356)
+++ trunk/src/net/android/java/src/org/chromium/net/SimpleCacheActivityStatusNotifier.java (working copy)
@@ -1,72 +0,0 @@
-// Copyright (c) 2013 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;
-
-import android.os.Handler;
-import android.os.Looper;
-
-/**
- * Used by the SimpleIndex in net/disk_cache/simple/ to listen to changes in the android app state
- * such as the app going to the background or foreground.
- */
-public class SimpleCacheActivityStatusNotifier implements ActivityStatus.StateListener {
- private int mNativePtr = 0;
- private final Looper mIoLooper;
-
- @CalledByNative
- public static SimpleCacheActivityStatusNotifier newInstance(int nativePtr) {
- return new SimpleCacheActivityStatusNotifier(nativePtr);
- }
-
- private SimpleCacheActivityStatusNotifier(int nativePtr) {
- this.mIoLooper = Looper.myLooper();
- this.mNativePtr = nativePtr;
- // Call the singleton's ActivityStatus in the UI thread.
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
- ActivityStatus.registerStateListener(SimpleCacheActivityStatusNotifier.this);
- }
- });
- }
-
- @CalledByNative
- public void prepareToBeDestroyed() {
- this.mNativePtr = 0;
- // Call the singleton's ActivityStatus in the UI thread.
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
- ActivityStatus.unregisterStateListener(SimpleCacheActivityStatusNotifier.this);
- }
- });
- }
-
- // ActivityStatus.StateListener
- @Override
- public void onActivityStateChange(final int state) {
- if (state == ActivityStatus.RESUMED ||
- state == ActivityStatus.STOPPED) {
- new Handler(mIoLooper).post(new Runnable() {
- @Override
- public void run() {
- if (SimpleCacheActivityStatusNotifier.this.mNativePtr != 0)
- nativeNotifyActivityStatusChanged(
- SimpleCacheActivityStatusNotifier.this.mNativePtr, state);
- }
- });
- }
- }
-
- @NativeClassQualifiedName("net::SimpleCacheActivityStatusNotifier")
- private native void nativeNotifyActivityStatusChanged(int nativePtr, int newActivityStatus);
-}
« no previous file with comments | « no previous file | trunk/src/net/android/net_jni_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698