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

Unified Diff: remoting/client/jni/jni_display_handler.h

Issue 2007123003: [Android Client] Break down multi-threaded classes by thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: remoting/client/jni/jni_display_handler.h
diff --git a/remoting/client/jni/jni_display_handler.h b/remoting/client/jni/jni_display_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..ff4fdd4ad8ce03378ba9ee61c91b987cfd57e026
--- /dev/null
+++ b/remoting/client/jni/jni_display_handler.h
@@ -0,0 +1,61 @@
+// 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 REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_
+#define REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "remoting/proto/control.pb.h"
+
+namespace remoting {
+
+// Handles display operations. Must be called and deleted on the display thread
+// unless otherwise noted.
+class JniDisplayHandler {
+ public:
+ JniDisplayHandler(scoped_refptr<base::SingleThreadTaskRunner> display_runner,
+ base::android::ScopedJavaGlobalRef<jobject> java_display);
+
+ // Must be deleted on the display thread.
+ ~JniDisplayHandler();
+
+ // Creates a new Bitmap object to store a video frame. Can be called on any
+ // thread.
+ base::android::ScopedJavaLocalRef<jobject> NewBitmap(int width, int height);
+
+ // Updates video frame bitmap. |bitmap| must be an instance of
+ // android.graphics.Bitmap.
+ void UpdateFrameBitmap(base::android::ScopedJavaGlobalRef<jobject> bitmap);
+
+ // Updates cursor shape.
+ void UpdateCursorShape(const protocol::CursorShapeInfo& cursor_shape);
+
+ // Draws the latest image buffer onto the canvas.
+ void RedrawCanvas();
+
+ // Returns a display thread weak pointer to the object.
+ base::WeakPtr<JniDisplayHandler> GetWeakPtr();
+
+ static bool RegisterJni(JNIEnv* env);
+
+ void Destroy(JNIEnv* env,
Lambros 2016/05/28 00:43:06 What thread calls this? Looks like the implementat
Yuwei 2016/06/01 21:30:11 Done. Added comments.
+ const base::android::JavaParamRef<jobject>& caller);
+
+ void ScheduleRedraw(JNIEnv* env,
Lambros 2016/05/28 00:43:06 Add comment that this is called on the UI thread.
Yuwei 2016/06/01 21:30:11 I just wrote "can be called on any thread"...
+ const base::android::JavaParamRef<jobject>& caller);
+
+ private:
+ scoped_refptr<base::SingleThreadTaskRunner> display_runner_;
+
+ base::android::ScopedJavaGlobalRef<jobject> java_display_;
+ base::WeakPtrFactory<JniDisplayHandler> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(JniDisplayHandler);
Lambros 2016/05/28 00:43:06 Blank line above DISALLOW...
Yuwei 2016/06/01 21:30:11 Done.
+};
+
+} // namespace remoting
+#endif // REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_
Lambros 2016/05/28 00:43:05 Blank line above #endif
Yuwei 2016/06/01 21:30:11 Done.

Powered by Google App Engine
This is Rietveld 408576698