Chromium Code Reviews| Index: net/android/simple_cache_activity_status_notifier.h |
| diff --git a/net/android/simple_cache_activity_status_notifier.h b/net/android/simple_cache_activity_status_notifier.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3429f70457d67c2780103ed3a74d23a0133d3a3d |
| --- /dev/null |
| +++ b/net/android/simple_cache_activity_status_notifier.h |
| @@ -0,0 +1,62 @@ |
| +// 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. |
| + |
| +#ifndef NET_ANDROID_SIMPLE_CACHE_ACTIVITY_STATUS_NOTIFIER_H_ |
| +#define NET_ANDROID_SIMPLE_CACHE_ACTIVITY_STATUS_NOTIFIER_H_ |
| + |
| +#include <jni.h> |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/threading/thread_checker.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} |
| + |
| +namespace net { |
| + |
| +// This class is the native twin of the class with same name in |
| +// SimpleCacheActivityStatusNotifier.java |
| +// This is 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. |
| +class SimpleCacheActivityStatusNotifier { |
| +public: |
| + // This enum must match the constants defined in |
| + // ./base/android/java/src/org/chromium/base/ActivityStatus.java |
| + enum ActivityStatus { |
| + CREATED = 1, |
| + STARTED = 2, |
| + RESUMED = 3, |
| + PAUSED = 4, |
| + STOPPED = 5, |
| + DESTROYED = 6 |
| + }; |
| + |
| + typedef base::Callback<void(ActivityStatus activity_status)> |
| + ActivityStatusChangedCallback; |
|
Philippe
2013/04/23 11:34:25
Nit: this still needs to be indented.
felipeg
2013/04/23 13:10:13
Done.
|
| + |
| + SimpleCacheActivityStatusNotifier( |
| + const ActivityStatusChangedCallback& notify_callback); |
| + |
| + ~SimpleCacheActivityStatusNotifier(); |
| + |
| + void NotifyActivityStatusChanged(JNIEnv* env, |
| + jobject obj, |
| + jint new_activity_status); |
| + |
| + static bool Register(JNIEnv* env); |
| + |
| +private: |
| + base::android::ScopedJavaGlobalRef<jobject> java_obj_; |
| + scoped_refptr<base::SingleThreadTaskRunner> callback_runner_; |
| + ActivityStatusChangedCallback notify_callback_; |
| + base::ThreadChecker io_thread_checker_; |
|
gavinp
2013/04/23 11:02:04
Can't refer to io_thread in net/. I know we have t
felipeg
2013/04/23 13:10:13
Done.
|
| +}; |
| + |
| +} // namespace net |
|
Philippe
2013/04/23 11:34:25
Nit: blank line still needed below.
felipeg
2013/04/23 13:10:13
Done.
|
| +#endif // NET_ANDROID_SIMPLE_CACHE_ACTIVITY_STATUS_NOTIFIER_H_ |