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

Unified Diff: base/android/activity_status.cc

Issue 159173002: Refactor ActivityStatus to not store current activity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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: base/android/activity_status.cc
diff --git a/base/android/activity_status.cc b/base/android/activity_status.cc
deleted file mode 100644
index 4d0be32ef93202a34b636916cf1e9fda640cdd8b..0000000000000000000000000000000000000000
--- a/base/android/activity_status.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 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 "base/android/activity_status.h"
-
-#include <jni.h>
-
-#include "base/memory/singleton.h"
-#include "jni/ActivityStatus_jni.h"
-
-namespace base {
-namespace android {
-
-ActivityStatus::Listener::Listener(
- const ActivityStatus::StateChangeCallback& callback)
- : callback_(callback) {
- ActivityStatus::GetInstance()->RegisterListener(this);
-}
-
-ActivityStatus::Listener::~Listener() {
- ActivityStatus::GetInstance()->UnregisterListener(this);
-}
-
-void ActivityStatus::Listener::Notify(ActivityState state) {
- callback_.Run(state);
-}
-
-// static
-ActivityStatus* ActivityStatus::GetInstance() {
- return Singleton<ActivityStatus,
- LeakySingletonTraits<ActivityStatus> >::get();
-}
-
-static void OnActivityStateChange(JNIEnv* env, jclass clazz, int new_state) {
- ActivityStatus* activity_status = ActivityStatus::GetInstance();
- ActivityState activity_state = static_cast<ActivityState>(new_state);
- activity_status->OnActivityStateChange(activity_state);
-}
-
-bool ActivityStatus::RegisterBindings(JNIEnv* env) {
- return RegisterNativesImpl(env);
-}
-
-ActivityStatus::ActivityStatus()
- : observers_(new ObserverListThreadSafe<Listener>()) {
- Java_ActivityStatus_registerThreadSafeNativeStateListener(
- base::android::AttachCurrentThread());
-}
-
-ActivityStatus::~ActivityStatus() {}
-
-void ActivityStatus::RegisterListener(Listener* listener) {
- observers_->AddObserver(listener);
-}
-
-void ActivityStatus::UnregisterListener(Listener* listener) {
- observers_->RemoveObserver(listener);
-}
-
-void ActivityStatus::OnActivityStateChange(ActivityState new_state) {
- observers_->Notify(&ActivityStatus::Listener::Notify, new_state);
-}
-
-} // namespace android
-} // namespace base

Powered by Google App Engine
This is Rietveld 408576698