Chromium Code Reviews| Index: remoting/ios/bridge/client_bridge.h |
| diff --git a/remoting/client/jni/chromoting_jni_runtime.h b/remoting/ios/bridge/client_bridge.h |
| similarity index 57% |
| copy from remoting/client/jni/chromoting_jni_runtime.h |
| copy to remoting/ios/bridge/client_bridge.h |
| index bb356a13616e33bc814d28589bdefec7c486dea2..aff2d53ca12d70cb4cad6fd42902927256ad4593 100644 |
| --- a/remoting/client/jni/chromoting_jni_runtime.h |
| +++ b/remoting/ios/bridge/client_bridge.h |
| @@ -1,35 +1,42 @@ |
| -// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Copyright 2014 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_CHROMOTING_JNI_RUNTIME_H_ |
| -#define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ |
| +#ifndef REMOTING_IOS_BRIDGE_CLIENT_BRIDGE_H_ |
| +#define REMOTING_IOS_BRIDGE_CLIENT_BRDIGE_H_ |
| -#include <jni.h> |
| #include <string> |
| -#include "base/android/scoped_java_ref.h" |
| -#include "base/at_exit.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/message_loop/message_loop.h" |
| #include "net/url_request/url_request_context_getter.h" |
| #include "remoting/base/auto_thread.h" |
| -#include "remoting/client/jni/chromoting_jni_instance.h" |
| #include "remoting/protocol/connection_to_host.h" |
| +#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| -template<typename T> struct DefaultSingletonTraits; |
| +#include "remoting/ios/bridge/client_instance.h" |
| +#include "remoting/ios/bridge/frame_consumer_bridge_callback.h" |
| -namespace remoting { |
| +#if defined(__OBJC__) |
| +@class ClientController; |
| +#else // __OBJC__ |
| +class ClientController; |
| +#endif // __OBJC__ |
| -bool RegisterJni(JNIEnv* env); |
| +namespace remoting { |
| // Houses the global resources on which the Chromoting components run |
| -// (e.g. message loops and task runners). Proxies outgoing JNI calls from its |
| -// ChromotingJniInstance member to Java. All its methods should be invoked |
| +// (e.g. message loops and task runners). Proxies outgoing OBJ_C calls from its |
| +// ClientInstance member to C++. All its methods should be invoked |
| // exclusively from the UI thread unless otherwise noted. |
| -class ChromotingJniRuntime { |
| +class ClientBridge : public base::RefCounted<ClientBridge> { |
|
dcaiafa
2014/03/19 01:14:15
Does it really need to be ref-counted? I would pre
aboone
2014/03/21 16:42:07
Changed to a SupportWeakPtr<>
|
| public: |
| - // This class is instantiated at process initialization and persists until |
| - // we close. Its components are reused across |ChromotingJniInstance|s. |
| - static ChromotingJniRuntime* GetInstance(); |
| + ClientBridge(); |
| + |
| + // Forces a DisconnectFromHost() in case there is any active or failed |
| + // connection, then proceeds to tear down the Chromium dependencies on which |
| + // all sessions depended. |
| + virtual ~ClientBridge(); |
|
dcaiafa
2014/03/19 01:14:15
Make destructor private, and friend base::RefCount
aboone
2014/03/21 16:42:07
Requirements after change to using a WeakPtr are d
|
| scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { |
| return ui_task_runner_; |
| @@ -39,10 +46,6 @@ class ChromotingJniRuntime { |
| return network_task_runner_; |
| } |
| - scoped_refptr<AutoThreadTaskRunner> display_task_runner() { |
| - return display_task_runner_; |
| - } |
| - |
| scoped_refptr<net::URLRequestContextGetter> url_requester() { |
| return url_requester_; |
| } |
| @@ -57,7 +60,8 @@ class ChromotingJniRuntime { |
| const char* host_id, |
| const char* host_pubkey, |
| const char* pairing_id, |
| - const char* pairing_secret); |
| + const char* pairing_secret, |
| + ClientController* controller); |
| // Terminates any ongoing connection attempt and cleans up by nullifying |
| // |session_|. This is a no-op unless |session| is currently non-null. |
| @@ -65,7 +69,7 @@ class ChromotingJniRuntime { |
| // Returns the client for the currently-active session. Do not call if |
| // |session| is null. |
| - scoped_refptr<ChromotingJniInstance> session() { |
| + scoped_refptr<ClientInstance> session() { |
| DCHECK(session_); |
| return session_; |
| } |
| @@ -82,55 +86,38 @@ class ChromotingJniRuntime { |
| const std::string& id, |
| const std::string& secret); |
| - // Creates a new Bitmap object to store a video frame. |
| - base::android::ScopedJavaLocalRef<jobject> NewBitmap( |
| - webrtc::DesktopSize size); |
| - |
| - // Updates video frame bitmap. |bitmap| must be an instance of |
| - // android.graphics.Bitmap. Call on the display thread. |
| - void UpdateFrameBitmap(jobject bitmap); |
| - |
| // Updates cursor shape. Call on display thread. |
|
dcaiafa
2014/03/19 01:14:15
nit: There doesn't seem to be a display thread lik
aboone
2014/03/21 16:42:07
Done.
|
| void UpdateCursorShape(const protocol::CursorShapeInfo& cursor_shape); |
| // Draws the latest image buffer onto the canvas. Call on the display thread. |
| - void RedrawCanvas(); |
| + void RedrawCanvas(const webrtc::DesktopSize& view_size, |
| + webrtc::DesktopFrame* buffer, |
| + const webrtc::DesktopRegion& region); |
| - private: |
| - ChromotingJniRuntime(); |
| + FrameConsumerBridgeCallback BindToFrameConsumerBridgeCallback(); |
| - // Forces a DisconnectFromHost() in case there is any active or failed |
| - // connection, then proceeds to tear down the Chromium dependencies on which |
| - // all sessions depended. Because destruction only occurs at application exit |
| - // after all connections have terminated, it is safe to make unretained |
| - // cross-thread calls on the class. |
| - virtual ~ChromotingJniRuntime(); |
| - |
| - // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. |
| + private: |
| + // Detaches OBJ_C from the current thread, then signals. Doesn't own |waiter|. |
| void DetachFromVmAndSignal(base::WaitableEvent* waiter); |
| - // Used by the Chromium libraries to clean up the base and net libraries' JNI |
| - // bindings. It must persist for the lifetime of the singleton. |
| - scoped_ptr<base::AtExitManager> at_exit_manager_; |
| - |
| - // Chromium code's connection to the Java message loop. |
| + // Chromium code's connection to the OBJ_C message loop. |
| scoped_ptr<base::MessageLoopForUI> ui_loop_; |
| // References to native threads. |
| scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
| scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
| - scoped_refptr<AutoThreadTaskRunner> display_task_runner_; |
| scoped_refptr<net::URLRequestContextGetter> url_requester_; |
| - // Contains all connection-specific state. |
| - scoped_refptr<ChromotingJniInstance> session_; |
| + // Contains connection-specific state. |
| + scoped_refptr<ClientInstance> session_; |
| - friend struct DefaultSingletonTraits<ChromotingJniRuntime>; |
| + // Ponter to the OBJ_C side of the bridge |
| + ClientController* controller_; |
| - DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); |
| + DISALLOW_COPY_AND_ASSIGN(ClientBridge); |
| }; |
| } // namespace remoting |
| -#endif |
| +#endif // REMOTING_IOS_BRIDGE_CLIENT_BRDIGE_H_ |