jni_notification_presenter.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_CLIENT_JNI_JNI_NOTIFICATION_PRESENTER_H_
  5. #define REMOTING_CLIENT_JNI_JNI_NOTIFICATION_PRESENTER_H_
  6. #include <jni.h>
  7. #include "base/android/jni_weak_ref.h"
  8. #include "base/memory/scoped_refptr.h"
  9. #include "base/task/sequenced_task_runner.h"
  10. #include "remoting/client/notification/notification_client.h"
  11. #include "third_party/abseil-cpp/absl/types/optional.h"
  12. namespace remoting {
  13. // C++ counterpart for org.chromium.chromoting.jni.NotificationPresenter.
  14. class JniNotificationPresenter final {
  15. public:
  16. explicit JniNotificationPresenter(
  17. const JavaObjectWeakGlobalRef& java_presenter);
  18. JniNotificationPresenter(const JniNotificationPresenter&) = delete;
  19. JniNotificationPresenter& operator=(const JniNotificationPresenter&) = delete;
  20. ~JniNotificationPresenter();
  21. void FetchNotification(JNIEnv* env,
  22. const base::android::JavaParamRef<jstring>& username);
  23. void Destroy(JNIEnv* env);
  24. private:
  25. void OnNotificationFetched(absl::optional<NotificationMessage> notification);
  26. JavaObjectWeakGlobalRef java_presenter_;
  27. NotificationClient notification_client_;
  28. scoped_refptr<base::SequencedTaskRunner> sequence_;
  29. };
  30. } // namespace remoting
  31. #endif // REMOTING_CLIENT_JNI_JNI_NOTIFICATION_PRESENTER_H_