Chromium Code Reviews| 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..9d2375d2bb909f1fca0551296b4f01af1c99a4b7 |
| --- /dev/null |
| +++ b/media/base/android/media_server_crash_listener.h |
| @@ -0,0 +1,53 @@ |
| +// 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.h" |
| +#include "base/macros.h" |
| +#include "base/single_thread_task_runner.h" |
| + |
| +namespace media { |
| + |
| +// Uses a watchdog Android MediaPlayer to listen for media server crashes, and |
|
watk
2016/11/12 04:22:16
nit: MediaServer
tguilbert
2016/11/14 23:18:07
Done.
|
| +// to notify clients when crashes occur. |
| +// NOTE: The MediaServiceThrottler is the only client of this class, and it |
| +// manages the MediaServerCrashListener's lifetime carefully. There should not |
| +// be more than a single instance of this class per process. |
| +class MediaServerCrashListener { |
| + public: |
| + static bool RegisterMediaServerCrashListener(JNIEnv* env); |
| + |
| + MediaServerCrashListener( |
|
DaleCurtis
2016/11/11 23:32:16
Add some method comments to each of these.
tguilbert
2016/11/14 23:18:08
Done.
|
| + const base::Closure& on_server_crash_cb, |
| + scoped_refptr<base::SingleThreadTaskRunner> callback_thread); |
|
watk
2016/11/12 04:22:16
nit: it's a task runner not a thread.
tguilbert
2016/11/14 23:18:08
Done.
|
| + virtual ~MediaServerCrashListener(); |
|
DaleCurtis
2016/11/11 23:32:15
Remove virtual?
tguilbert
2016/11/14 23:18:08
Done.
|
| + |
| + void EnsureListening(); |
| + |
| + void OnMediaServerCrashDetected( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jobject>& obj); |
| + |
| + private: |
| + // Indicates if the Java counterpart of this class ever successfully started |
| + // listening for server crashes. |
| + bool is_listening_; |
| + |
| + base::Closure on_server_crash_cb_; |
| + |
| + // Thread on which the |on_server_crash_cb_| will be posted. |
|
watk
2016/11/12 04:22:16
s/thread on/task runner to/
tguilbert
2016/11/14 23:18:08
Done.
|
| + 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_ |