diff options
-rw-r--r-- | remoting/android/java/AndroidManifest.xml | 7 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.cc | 99 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_instance.h | 16 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_runtime.cc (renamed from remoting/client/jni/chromoting_jni.cc) | 27 | ||||
-rw-r--r-- | remoting/client/jni/chromoting_jni_runtime.h (renamed from remoting/client/jni/chromoting_jni.h) | 16 | ||||
-rw-r--r-- | remoting/client/jni/jni_frame_consumer.cc | 44 | ||||
-rw-r--r-- | remoting/client/jni/jni_frame_consumer.h | 15 | ||||
-rw-r--r-- | remoting/client/jni/jni_interface.cc | 18 | ||||
-rw-r--r-- | remoting/remoting.gyp | 4 | ||||
-rw-r--r-- | remoting/resources/strings.xml | 2 |
10 files changed, 125 insertions, 123 deletions
diff --git a/remoting/android/java/AndroidManifest.xml b/remoting/android/java/AndroidManifest.xml index 10bccfd..8753253 100644 --- a/remoting/android/java/AndroidManifest.xml +++ b/remoting/android/java/AndroidManifest.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.chromium.chromoting" - android:versionCode="1" - android:versionName="0.01"> + android:versionCode="2" + android:versionName="0.02"> <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/> <uses-permission android:name="android.permission.GET_ACCOUNTS"/> @@ -18,6 +18,7 @@ </intent-filter> </activity> <activity android:name="Desktop" - android:configChanges="orientation|screenSize"/> + android:configChanges="orientation|screenSize" + android:theme="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"/> </application> </manifest> diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc index fcb4db3..8dc3b17 100644 --- a/remoting/client/jni/chromoting_jni_instance.cc +++ b/remoting/client/jni/chromoting_jni_instance.cc @@ -7,7 +7,7 @@ #include "base/bind.h" #include "base/logging.h" #include "remoting/client/audio_player.h" -#include "remoting/client/jni/chromoting_jni.h" +#include "remoting/client/jni/chromoting_jni_runtime.h" #include "remoting/protocol/libjingle_transport_factory.h" // TODO(solb) Move into location shared with client plugin. @@ -17,21 +17,21 @@ const bool CHAT_USE_TLS = true; namespace remoting { -ChromotingJniInstance::ChromotingJniInstance(const char* username, +ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, + const char* username, const char* auth_token, const char* host_jid, const char* host_id, - const char* host_pubkey) { - DCHECK(ChromotingJni::GetInstance()-> - ui_task_runner()->BelongsToCurrentThread()); - - username_ = username; - auth_token_ = auth_token; - host_jid_ = host_jid; - host_id_ = host_id; - host_pubkey_ = host_pubkey; - - ChromotingJni::GetInstance()->display_task_runner()->PostTask( + const char* host_pubkey) + : jni_runtime_(jni_runtime), + username_(username), + auth_token_(auth_token), + host_jid_(host_jid), + host_id_(host_id), + host_pubkey_(host_pubkey) { + DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); + + jni_runtime_->display_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::ConnectToHostOnDisplayThread, this)); @@ -40,9 +40,8 @@ ChromotingJniInstance::ChromotingJniInstance(const char* username, ChromotingJniInstance::~ChromotingJniInstance() {} void ChromotingJniInstance::Cleanup() { - if (!ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()) { - ChromotingJni::GetInstance()->display_task_runner()->PostTask( + if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->display_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::Cleanup, this)); return; @@ -54,32 +53,31 @@ void ChromotingJniInstance::Cleanup() { // The weak pointers must be invalidated on the same thread they were used. view_weak_factory_->InvalidateWeakPtrs(); - ChromotingJni::GetInstance()->network_task_runner()->PostTask(FROM_HERE, + jni_runtime_->network_task_runner()->PostTask( + FROM_HERE, base::Bind(&ChromotingJniInstance::DisconnectFromHostOnNetworkThread, this)); } void ChromotingJniInstance::ProvideSecret(const char* pin) { - DCHECK(ChromotingJni::GetInstance()-> - ui_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->ui_task_runner()->BelongsToCurrentThread()); DCHECK(!pin_callback_.is_null()); // We invoke the string constructor to ensure |pin| gets copied *before* the // asynchronous run, since Java might want it back as soon as we return. - ChromotingJni::GetInstance()->network_task_runner()->PostTask(FROM_HERE, - base::Bind(pin_callback_, pin)); + jni_runtime_->network_task_runner()->PostTask(FROM_HERE, + base::Bind(pin_callback_, pin)); } void ChromotingJniInstance::RedrawDesktop() { - if (!ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()) { - ChromotingJni::GetInstance()->display_task_runner()->PostTask( + if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->display_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::RedrawDesktop, this)); return; } - ChromotingJni::GetInstance()->RedrawCanvas(); + jni_runtime_->RedrawCanvas(); } void ChromotingJniInstance::PerformMouseAction( @@ -87,9 +85,8 @@ void ChromotingJniInstance::PerformMouseAction( int y, protocol::MouseEvent_MouseButton button, bool buttonDown) { - if(!ChromotingJni::GetInstance()-> - network_task_runner()->BelongsToCurrentThread()) { - ChromotingJni::GetInstance()->network_task_runner()->PostTask( + if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->network_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::PerformMouseAction, this, @@ -113,10 +110,8 @@ void ChromotingJniInstance::PerformMouseAction( void ChromotingJniInstance::OnConnectionState( protocol::ConnectionToHost::State state, protocol::ErrorCode error) { - if (!ChromotingJni::GetInstance()-> - ui_task_runner()->BelongsToCurrentThread()) { - ChromotingJni::GetInstance()-> - ui_task_runner()->PostTask( + if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->ui_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::OnConnectionState, this, @@ -125,7 +120,7 @@ void ChromotingJniInstance::OnConnectionState( return; } - ChromotingJni::GetInstance()->ReportConnectionStatus(state, error); + jni_runtime_->ReportConnectionStatus(state, error); } void ChromotingJniInstance::OnConnectionReady(bool ready) { @@ -164,25 +159,22 @@ void ChromotingJniInstance::SetCursorShape( } void ChromotingJniInstance::ConnectToHostOnDisplayThread() { - DCHECK(ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->display_task_runner()->BelongsToCurrentThread()); - frame_consumer_ = new FrameConsumerProxy( - ChromotingJni::GetInstance()->display_task_runner()); - view_.reset(new JniFrameConsumer()); + frame_consumer_ = new FrameConsumerProxy(jni_runtime_->display_task_runner()); + view_.reset(new JniFrameConsumer(jni_runtime_)); view_weak_factory_.reset(new base::WeakPtrFactory<JniFrameConsumer>( view_.get())); frame_consumer_->Attach(view_weak_factory_->GetWeakPtr()); - ChromotingJni::GetInstance()->network_task_runner()->PostTask( + jni_runtime_->network_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this)); } void ChromotingJniInstance::ConnectToHostOnNetworkThread() { - DCHECK(ChromotingJni::GetInstance()-> - network_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); client_config_.reset(new ClientConfig()); client_config_->host_jid = host_jid_; @@ -199,7 +191,7 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() { protocol::AuthenticationMethod::FromString("spake2_plain")); client_context_.reset(new ClientContext( - ChromotingJni::GetInstance()->network_task_runner().get())); + jni_runtime_->network_task_runner().get())); client_context_->Start(); connection_.reset(new protocol::ConnectionToHost(true)); @@ -218,26 +210,24 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() { signaling_config_->port = CHAT_PORT; signaling_config_->use_tls = CHAT_USE_TLS; - signaling_.reset(new XmppSignalStrategy( - ChromotingJni::GetInstance()->url_requester(), - username_, - auth_token_, - "oauth2", - *signaling_config_)); + signaling_.reset(new XmppSignalStrategy(jni_runtime_->url_requester(), + username_, + auth_token_, + "oauth2", + *signaling_config_)); network_settings_.reset(new NetworkSettings( NetworkSettings::NAT_TRAVERSAL_OUTGOING)); scoped_ptr<protocol::TransportFactory> fact( protocol::LibjingleTransportFactory::Create( *network_settings_, - ChromotingJni::GetInstance()->url_requester())); + jni_runtime_->url_requester())); client_->Start(signaling_.get(), fact.Pass()); } void ChromotingJniInstance::DisconnectFromHostOnNetworkThread() { - DCHECK(ChromotingJni::GetInstance()-> - network_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); username_ = ""; auth_token_ = ""; @@ -253,9 +243,8 @@ void ChromotingJniInstance::DisconnectFromHostOnNetworkThread() { void ChromotingJniInstance::FetchSecret( bool pairable, const protocol::SecretFetchedCallback& callback) { - if (!ChromotingJni::GetInstance()-> - ui_task_runner()->BelongsToCurrentThread()) { - ChromotingJni::GetInstance()->ui_task_runner()->PostTask( + if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->ui_task_runner()->PostTask( FROM_HERE, base::Bind(&ChromotingJniInstance::FetchSecret, this, @@ -265,7 +254,7 @@ void ChromotingJniInstance::FetchSecret( } pin_callback_ = callback; - ChromotingJni::GetInstance()->DisplayAuthenticationPrompt(); + jni_runtime_->DisplayAuthenticationPrompt(); } } // namespace remoting diff --git a/remoting/client/jni/chromoting_jni_instance.h b/remoting/client/jni/chromoting_jni_instance.h index 1c113cf..6b332e4 100644 --- a/remoting/client/jni/chromoting_jni_instance.h +++ b/remoting/client/jni/chromoting_jni_instance.h @@ -37,12 +37,13 @@ class ChromotingJniInstance public base::RefCountedThreadSafe<ChromotingJniInstance> { public: // Initiates a connection with the specified host. Call from the UI thread. - ChromotingJniInstance( - const char* username, - const char* auth_token, - const char* host_jid, - const char* host_id, - const char* host_pubkey); + // The instance does not take ownership of |jni_runtime|. + ChromotingJniInstance(ChromotingJniRuntime* jni_runtime, + const char* username, + const char* auth_token, + const char* host_jid, + const char* host_id, + const char* host_pubkey); // Terminates the current connection (if it hasn't already failed) and cleans // up. Must be called before destruction. @@ -97,6 +98,9 @@ class ChromotingJniInstance void FetchSecret(bool pairable, const protocol::SecretFetchedCallback& callback); + // Used to obtain task runner references and make calls to Java methods. + ChromotingJniRuntime* jni_runtime_; + // This group of variables is to be used on the display thread. scoped_refptr<FrameConsumerProxy> frame_consumer_; scoped_ptr<JniFrameConsumer> view_; diff --git a/remoting/client/jni/chromoting_jni.cc b/remoting/client/jni/chromoting_jni_runtime.cc index 647ac5a..a9751d4 100644 --- a/remoting/client/jni/chromoting_jni.cc +++ b/remoting/client/jni/chromoting_jni_runtime.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "remoting/client/jni/chromoting_jni.h" +#include "remoting/client/jni/chromoting_jni_runtime.h" #include "base/android/base_jni_registrar.h" #include "base/android/jni_android.h" @@ -17,11 +17,11 @@ const char* const JAVA_CLASS = "org/chromium/chromoting/jni/JniInterface"; namespace remoting { // static -ChromotingJni* ChromotingJni::GetInstance() { - return Singleton<ChromotingJni>::get(); +ChromotingJniRuntime* ChromotingJniRuntime::GetInstance() { + return Singleton<ChromotingJniRuntime>::get(); } -ChromotingJni::ChromotingJni() { +ChromotingJniRuntime::ChromotingJniRuntime() { // Obtain a reference to the Java environment. (Future calls to this function // made from the same thread return the same stored reference instead of // repeating the work of attaching to the JVM.) @@ -58,7 +58,7 @@ ChromotingJni::ChromotingJni() { class_ = static_cast<jclass>(env->NewGlobalRef(env->FindClass(JAVA_CLASS))); } -ChromotingJni::~ChromotingJni() { +ChromotingJniRuntime::~ChromotingJniRuntime() { // The singleton should only ever be destroyed on the main thread. DCHECK(ui_task_runner_->BelongsToCurrentThread()); @@ -71,21 +71,22 @@ ChromotingJni::~ChromotingJni() { // TODO(solb): crbug.com/259594 Detach all threads from JVM here. } -void ChromotingJni::ConnectToHost(const char* username, +void ChromotingJniRuntime::ConnectToHost(const char* username, const char* auth_token, const char* host_jid, const char* host_id, const char* host_pubkey) { DCHECK(ui_task_runner_->BelongsToCurrentThread()); DCHECK(!session_); - session_ = new ChromotingJniInstance(username, + session_ = new ChromotingJniInstance(this, + username, auth_token, host_jid, host_id, host_pubkey); } -void ChromotingJni::DisconnectFromHost() { +void ChromotingJniRuntime::DisconnectFromHost() { DCHECK(ui_task_runner_->BelongsToCurrentThread()); if (session_) { session_->Cleanup(); @@ -93,7 +94,7 @@ void ChromotingJni::DisconnectFromHost() { } } -void ChromotingJni::ReportConnectionStatus( +void ChromotingJniRuntime::ReportConnectionStatus( protocol::ConnectionToHost::State state, protocol::ErrorCode error) { DCHECK(ui_task_runner_->BelongsToCurrentThread()); @@ -106,7 +107,7 @@ void ChromotingJni::ReportConnectionStatus( error); } -void ChromotingJni::DisplayAuthenticationPrompt() { +void ChromotingJniRuntime::DisplayAuthenticationPrompt() { DCHECK(ui_task_runner_->BelongsToCurrentThread()); JNIEnv* env = base::android::AttachCurrentThread(); @@ -115,7 +116,9 @@ void ChromotingJni::DisplayAuthenticationPrompt() { env->GetStaticMethodID(class_, "displayAuthenticationPrompt", "()V")); } -void ChromotingJni::UpdateImageBuffer(int width, int height, jobject buffer) { +void ChromotingJniRuntime::UpdateImageBuffer(int width, + int height, + jobject buffer) { DCHECK(display_task_runner_->BelongsToCurrentThread()); JNIEnv* env = base::android::AttachCurrentThread(); @@ -133,7 +136,7 @@ void ChromotingJni::UpdateImageBuffer(int width, int height, jobject buffer) { buffer); } -void ChromotingJni::RedrawCanvas() { +void ChromotingJniRuntime::RedrawCanvas() { DCHECK(display_task_runner_->BelongsToCurrentThread()); JNIEnv* env = base::android::AttachCurrentThread(); diff --git a/remoting/client/jni/chromoting_jni.h b/remoting/client/jni/chromoting_jni_runtime.h index 197cf39..ec85d7c 100644 --- a/remoting/client/jni/chromoting_jni.h +++ b/remoting/client/jni/chromoting_jni_runtime.h @@ -2,8 +2,8 @@ // 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_H_ -#define REMOTING_CLIENT_JNI_CHROMOTING_JNI_H_ +#ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ +#define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ #include <jni.h> @@ -21,11 +21,11 @@ namespace remoting { // (e.g. message loops and task runners). Proxies outgoing JNI calls from its // ChromotingJniInstance member to Java. All its methods should be invoked // exclusively from the UI thread unless otherwise noted. -class ChromotingJni { +class ChromotingJniRuntime { public: // This class is instantiated at process initialization and persists until // we close. Its components are reused across |ChromotingJniInstance|s. - static ChromotingJni* GetInstance(); + static ChromotingJniRuntime* GetInstance(); scoped_refptr<AutoThreadTaskRunner> ui_task_runner() { return ui_task_runner_; @@ -77,14 +77,14 @@ class ChromotingJni { void RedrawCanvas(); private: - ChromotingJni(); + ChromotingJniRuntime(); // 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 ~ChromotingJni(); + virtual ~ChromotingJniRuntime(); // Reference to the Java class into which we make JNI calls. jclass class_; @@ -106,9 +106,9 @@ class ChromotingJni { // Contains all connection-specific state. scoped_refptr<ChromotingJniInstance> session_; - friend struct DefaultSingletonTraits<ChromotingJni>; + friend struct DefaultSingletonTraits<ChromotingJniRuntime>; - DISALLOW_COPY_AND_ASSIGN(ChromotingJni); + DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); }; } // namespace remoting diff --git a/remoting/client/jni/jni_frame_consumer.cc b/remoting/client/jni/jni_frame_consumer.cc index ee8ef94..8f8cfc6 100644 --- a/remoting/client/jni/jni_frame_consumer.cc +++ b/remoting/client/jni/jni_frame_consumer.cc @@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/synchronization/waitable_event.h" #include "remoting/client/frame_producer.h" -#include "remoting/client/jni/chromoting_jni.h" +#include "remoting/client/jni/chromoting_jni_runtime.h" #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" namespace { @@ -41,14 +41,15 @@ DirectDesktopFrame::~DirectDesktopFrame() {} namespace remoting { -JniFrameConsumer::JniFrameConsumer() - : provide_buffer_(true), +JniFrameConsumer::JniFrameConsumer(ChromotingJniRuntime* jni_runtime) + : jni_runtime_(jni_runtime), + in_dtor_(false), frame_producer_(NULL) { } JniFrameConsumer::~JniFrameConsumer() { // Stop giving the producer a buffer to work with. - provide_buffer_ = false; + in_dtor_ = true; // Don't destroy the object until we've deleted the buffer. base::WaitableEvent done_event(true, false); @@ -65,35 +66,36 @@ void JniFrameConsumer::ApplyBuffer(const SkISize& view_size, const SkIRect& clip_area, webrtc::DesktopFrame* buffer, const SkRegion& region) { - DCHECK(ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->display_task_runner()->BelongsToCurrentThread()); - ChromotingJni::GetInstance()->RedrawCanvas(); + scoped_ptr<webrtc::DesktopFrame> buffer_scoped(buffer); + jni_runtime_->RedrawCanvas(); if (view_size.width() > view_size_.width() || view_size.height() > view_size_.height()) { LOG(INFO) << "Existing buffer is too small"; view_size_ = view_size; - delete buffer; + + // Manually destroy the old buffer before allocating a new one to prevent + // our memory footprint from temporarily ballooning. + buffer_scoped.reset(); AllocateBuffer(); } // Supply |frame_producer_| with a buffer to render the next frame into. - if (provide_buffer_) - frame_producer_->DrawBuffer(buffer); + if (!in_dtor_) + frame_producer_->DrawBuffer(buffer_scoped.release()); } void JniFrameConsumer::ReturnBuffer(webrtc::DesktopFrame* buffer) { - DCHECK(ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->display_task_runner()->BelongsToCurrentThread()); LOG(INFO) << "Returning image buffer"; delete buffer; } void JniFrameConsumer::SetSourceSize(const SkISize& source_size, const SkIPoint& dpi) { - DCHECK(ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()); + DCHECK(jni_runtime_->display_task_runner()->BelongsToCurrentThread()); // We currently render the desktop 1:1 and perform pan/zoom scaling // and cropping on the managed canvas. @@ -108,10 +110,9 @@ void JniFrameConsumer::SetSourceSize(const SkISize& source_size, void JniFrameConsumer::AllocateBuffer() { // Only do anything if we're not being destructed. - if (provide_buffer_) { - if (!ChromotingJni::GetInstance()-> - display_task_runner()->BelongsToCurrentThread()) { - ChromotingJni::GetInstance()->display_task_runner()->PostTask(FROM_HERE, + if (!in_dtor_) { + if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { + jni_runtime_->display_task_runner()->PostTask(FROM_HERE, base::Bind(&JniFrameConsumer::AllocateBuffer, base::Unretained(this))); return; @@ -121,10 +122,9 @@ void JniFrameConsumer::AllocateBuffer() { view_size_.height()); // Update Java's reference to the buffer and record of its dimensions. - ChromotingJni::GetInstance()->UpdateImageBuffer( - view_size_.width(), - view_size_.height(), - buffer->buffer()); + jni_runtime_->UpdateImageBuffer(view_size_.width(), + view_size_.height(), + buffer->buffer()); frame_producer_->DrawBuffer(buffer); } diff --git a/remoting/client/jni/jni_frame_consumer.h b/remoting/client/jni/jni_frame_consumer.h index b74681f..38ff86c 100644 --- a/remoting/client/jni/jni_frame_consumer.h +++ b/remoting/client/jni/jni_frame_consumer.h @@ -14,13 +14,15 @@ class DesktopFrame; } // namespace webrtc namespace remoting { -class ChromotingJni; +class ChromotingJniRuntime; class FrameProducer; // FrameConsumer implementation that draws onto a JNI direct byte buffer. class JniFrameConsumer : public FrameConsumer { public: - JniFrameConsumer(); + // The instance does not take ownership of |jni_runtime|. + explicit JniFrameConsumer(ChromotingJniRuntime* jni_runtime); + virtual ~JniFrameConsumer(); // This must be called once before the producer's source size is set. @@ -38,9 +40,12 @@ class JniFrameConsumer : public FrameConsumer { private: // Variables are to be used from the display thread. - // Whether to allocate/provide the producer with a buffer when able. This - // goes to false during destruction so that we don't leak memory. - bool provide_buffer_; + // Used to obtain task runner references and make calls to Java methods. + ChromotingJniRuntime* jni_runtime_; + + // Whether we're currently in the constructor, and should deallocate the + // buffer instead of passing it back to the producer. + bool in_dtor_; FrameProducer* frame_producer_; SkISize view_size_; diff --git a/remoting/client/jni/jni_interface.cc b/remoting/client/jni/jni_interface.cc index f9859af..5dc462d 100644 --- a/remoting/client/jni/jni_interface.cc +++ b/remoting/client/jni/jni_interface.cc @@ -5,8 +5,8 @@ // This file defines functions that implement the static methods declared in a // closely-related Java class in the platform-specific user interface // implementation. In effect, it is the entry point for all JNI calls *into* -// the C++ codebase from Java. The separate ChromotingJni class serves as the -// corresponding exit point, and is responsible for making all JNI calls +// the C++ codebase from Java. The separate ChromotingJniRuntime class serves +// as the corresponding exit point, and is responsible for making all JNI calls // *out of* the C++ codebase into Java. #include <jni.h> @@ -15,8 +15,8 @@ #include "base/command_line.h" #include "base/memory/ref_counted.h" #include "google_apis/google_api_keys.h" -#include "remoting/client/jni/chromoting_jni.h" #include "remoting/client/jni/chromoting_jni_instance.h" +#include "remoting/client/jni/chromoting_jni_runtime.h" // Class and package name of the Java class that declares this file's functions. #define JNI_IMPLEMENTATION(method) \ @@ -42,7 +42,7 @@ JNIEXPORT void JNICALL JNI_IMPLEMENTATION(loadNative)(JNIEnv* env, CommandLine::Init(0, NULL); // Create the singleton now so that the Chromoting threads will be set up. - remoting::ChromotingJni::GetInstance(); + remoting::ChromotingJniRuntime::GetInstance(); } JNIEXPORT jstring JNICALL JNI_IMPLEMENTATION(getApiKey)(JNIEnv* env, @@ -76,7 +76,7 @@ JNIEXPORT void JNICALL JNI_IMPLEMENTATION(connectNative)( const char* host_id_cstr = env->GetStringUTFChars(host_id_jstr, NULL); const char* host_pubkey_cstr = env->GetStringUTFChars(host_pubkey_jstr, NULL); - remoting::ChromotingJni::GetInstance()->ConnectToHost( + remoting::ChromotingJniRuntime::GetInstance()->ConnectToHost( username_cstr, auth_token_cstr, host_jid_cstr, @@ -92,7 +92,7 @@ JNIEXPORT void JNICALL JNI_IMPLEMENTATION(connectNative)( JNIEXPORT void JNICALL JNI_IMPLEMENTATION(disconnectNative)(JNIEnv* env, jobject that) { - remoting::ChromotingJni::GetInstance()->DisconnectFromHost(); + remoting::ChromotingJniRuntime::GetInstance()->DisconnectFromHost(); } JNIEXPORT void JNICALL JNI_IMPLEMENTATION(authenticationResponse)( @@ -101,7 +101,7 @@ JNIEXPORT void JNICALL JNI_IMPLEMENTATION(authenticationResponse)( jstring pin_jstr) { const char* pin_cstr = env->GetStringUTFChars(pin_jstr, NULL); - remoting::ChromotingJni::GetInstance()-> + remoting::ChromotingJniRuntime::GetInstance()-> session()->ProvideSecret(pin_cstr); env->ReleaseStringUTFChars(pin_jstr, pin_cstr); @@ -110,7 +110,7 @@ JNIEXPORT void JNICALL JNI_IMPLEMENTATION(authenticationResponse)( JNIEXPORT void JNICALL JNI_IMPLEMENTATION(scheduleRedrawNative)( JNIEnv* env, jobject that) { - remoting::ChromotingJni::GetInstance()->session()->RedrawDesktop(); + remoting::ChromotingJniRuntime::GetInstance()->session()->RedrawDesktop(); } JNIEXPORT void JNICALL JNI_IMPLEMENTATION(mouseActionNative)( @@ -120,7 +120,7 @@ JNIEXPORT void JNICALL JNI_IMPLEMENTATION(mouseActionNative)( jint y, jint which_button, jboolean button_down) { - remoting::ChromotingJni::GetInstance()->session()->PerformMouseAction( + remoting::ChromotingJniRuntime::GetInstance()->session()->PerformMouseAction( x, y, static_cast<remoting::protocol::MouseEvent_MouseButton>(which_button), diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index fb52c13..121002d 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -1690,10 +1690,10 @@ '../google_apis/google_apis.gyp:google_apis', ], 'sources': [ - 'client/jni/chromoting_jni.cc', - 'client/jni/chromoting_jni.h', 'client/jni/chromoting_jni_instance.cc', 'client/jni/chromoting_jni_instance.h', + 'client/jni/chromoting_jni_runtime.cc', + 'client/jni/chromoting_jni_runtime.h', 'client/jni/jni_frame_consumer.cc', 'client/jni/jni_frame_consumer.h', 'client/jni/jni_interface.cc', diff --git a/remoting/resources/strings.xml b/remoting/resources/strings.xml index 284c2ed..e2efc8e 100644 --- a/remoting/resources/strings.xml +++ b/remoting/resources/strings.xml @@ -25,7 +25,7 @@ <string name="error_auth_failed">Authentication with specified account failed</string> <string name="error_cataloging_hosts">Unable to display host list</string> <string name="error_displaying_host">Unable to display host entry</string> - <string name="error_unexpected_response">Unexpected response from directory server</string> + <string name="error_unexpected_response">Account has no remote desktop hosts registered</string> <string name="error_reading_host">Unable to read host entry</string> <!--Protocol states (see remoting/protocol/connection_to_host.h)--> |