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

Unified Diff: media/base/android/media_server_crash_listener.h

Issue 2471903002: Add MediaServiceThrottler (Closed)
Patch Set: Integrate throttler into MediaPlayerRender Created 4 years, 1 month 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: media/base/android/media_server_crash_listener.h
diff --git a/media/base/android/media_server_crash_listener.h b/media/base/android/media_server_crash_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..bc58eab0b1137caf68064eee36c93c7428045ebd
--- /dev/null
+++ b/media/base/android/media_server_crash_listener.h
@@ -0,0 +1,57 @@
+// Copyright 2016 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 MEDIA_BASE_ANDROID_MEDIA_SERVER_CRASH_LISTENER_H_
+#define MEDIA_BASE_ANDROID_MEDIA_SERVER_CRASH_LISTENER_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/memory/singleton.h"
+#include "base/single_thread_task_runner.h"
+
+namespace media {
+
+class MediaServerCrashListener {
+ public:
+ static bool RegisterMediaServerCrashListener(JNIEnv* env);
+
+ // Called to get the singleton MediaServerCrashListener instance.
+ static MediaServerCrashListener* GetInstance();
+ virtual ~MediaServerCrashListener();
+
+ // Starts listening for media server crashes.
+ // Can be called from any thread, but will post crashes to |callback_thread|.
+ void SetOnServerCrashCallback(
+ const base::Closure& on_server_crash_cb,
+ scoped_refptr<base::SingleThreadTaskRunner> callback_thread);
+
+ // Starts listening for media server crashes.
+ // Returns true if the media server successfully started listening, and false
+ // otherwise.
+ bool StartListening();
+
+ void OnMediaServerCrashDetected(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj);
+
+ void ClearOnServerCrashCallbackForTesting();
+
+ private:
+ friend struct base::DefaultSingletonTraits<MediaServerCrashListener>;
+ MediaServerCrashListener();
+
+ base::Closure on_server_crash_cb_;
+
+ scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_;
+
+ base::android::ScopedJavaGlobalRef<jobject> j_crash_listener_;
+ DISALLOW_COPY_AND_ASSIGN(MediaServerCrashListener);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ANDROID_MEDIA_SERVER_CRASH_LISTENER_H_

Powered by Google App Engine
This is Rietveld 408576698