OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_ANDROID_SIMPLE_CACHE_ACTIVITY_STATUS_NOTIFIER_H_ |
| 6 #define NET_ANDROID_SIMPLE_CACHE_ACTIVITY_STATUS_NOTIFIER_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/android/jni_android.h" |
| 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/thread_checker.h" |
| 15 |
| 16 namespace base { |
| 17 class SingleThreadTaskRunner; |
| 18 } |
| 19 |
| 20 namespace net { |
| 21 |
| 22 // This class is the native twin of the class with same name in |
| 23 // SimpleCacheActivityStatusNotifier.java |
| 24 // This is used by the SimpleIndex in net/disk_cache/simple/ to listens to |
| 25 // changes in the android app state such as the app going to the background or |
| 26 // foreground. |
| 27 class SimpleCacheActivityStatusNotifier { |
| 28 public: |
| 29 // This enum must match the constants defined in |
| 30 // ./base/android/java/src/org/chromium/base/ActivityStatus.java |
| 31 enum ActivityStatus { |
| 32 CREATED = 1, |
| 33 STARTED = 2, |
| 34 RESUMED = 3, |
| 35 PAUSED = 4, |
| 36 STOPPED = 5, |
| 37 DESTROYED = 6 |
| 38 }; |
| 39 |
| 40 typedef base::Callback<void(ActivityStatus activity_status)> |
| 41 ActivityStatusChangedCallback; |
| 42 |
| 43 SimpleCacheActivityStatusNotifier( |
| 44 const ActivityStatusChangedCallback& notify_callback); |
| 45 |
| 46 ~SimpleCacheActivityStatusNotifier(); |
| 47 |
| 48 void NotifyActivityStatusChanged(JNIEnv* env, |
| 49 jobject obj, |
| 50 jint new_activity_status); |
| 51 |
| 52 static bool Register(JNIEnv* env); |
| 53 |
| 54 private: |
| 55 base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
| 56 const ActivityStatusChangedCallback notify_callback_; |
| 57 base::ThreadChecker thread_checker_; |
| 58 }; |
| 59 |
| 60 } // namespace net |
| 61 |
| 62 #endif // NET_ANDROID_SIMPLE_CACHE_ACTIVITY_STATUS_NOTIFIER_H_ |
OLD | NEW |