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

Unified Diff: net/android/simple_cache_activity_status_notifier.cc

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/simple_cache_activity_status_notifier.cc
diff --git a/net/android/simple_cache_activity_status_notifier.cc b/net/android/simple_cache_activity_status_notifier.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de7209f3de79230612ef3f56b0702f56ef988644
--- /dev/null
+++ b/net/android/simple_cache_activity_status_notifier.cc
@@ -0,0 +1,52 @@
+// 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.
+
+#include "net/android/simple_cache_activity_status_notifier.h"
+
+#include "base/android/jni_android.h"
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
+#include "base/logging.h"
+#include "base/message_loop.h"
+#include "base/message_loop_proxy.h"
+#include "base/task_runner.h"
+
+#include "jni/SimpleCacheActivityStatusNotifier_jni.h"
+
+namespace net {
+
+SimpleCacheActivityStatusNotifier::SimpleCacheActivityStatusNotifier(
+ base::SingleThreadTaskRunner* callback_runner,
+ const ActivityStatusChangedCallback& notify_callback) :
+ callback_runner_(callback_runner),
+ notify_callback_(notify_callback) {
+ // TODO(felipeg): Do we have to call DetachFromVM somewhere ? I don't see
+ // other code doing that.
+ JNIEnv* env = base::android::AttachCurrentThread();
+ CHECK(env);
+ java_obj_.Reset(
+ Java_SimpleCacheActivityStatusNotifier_NewInstance(
+ env, reinterpret_cast<jint>(this)));
+}
+
+SimpleCacheActivityStatusNotifier::~SimpleCacheActivityStatusNotifier() {}
+
+void SimpleCacheActivityStatusNotifier::NotifyActivityStatusChanged(
+ JNIEnv* env,
+ jobject obj,
+ jint new_activity_status) {
+ if (callback_runner_.get() && !notify_callback_.is_null()) {
gavinp 2013/04/19 15:58:55 Lose this .get()
felipeg 2013/04/19 17:10:15 Done.
+ callback_runner_->PostTask(FROM_HERE, base::Bind(notify_callback_,
+ new_activity_status));
+ }
+}
+
+// static
+bool SimpleCacheActivityStatusNotifier::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // net

Powered by Google App Engine
This is Rietveld 408576698