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

Side by Side Diff: remoting/client/jni/jni_client.h

Issue 2338473002: [Remoting Android] JniGlDisplayHandler calls invalidate() on UI thread (Closed)
Patch Set: add null-check in deleter Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_CLIENT_JNI_JNI_CLIENT_H_ 5 #ifndef REMOTING_CLIENT_JNI_JNI_CLIENT_H_
6 #define REMOTING_CLIENT_JNI_JNI_CLIENT_H_ 6 #define REMOTING_CLIENT_JNI_JNI_CLIENT_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "remoting/client/jni/display_updater_factory.h"
13 #include "remoting/protocol/connection_to_host.h" 14 #include "remoting/protocol/connection_to_host.h"
14 #include "remoting/protocol/cursor_shape_stub.h" 15 #include "remoting/protocol/cursor_shape_stub.h"
15 16
16 namespace remoting { 17 namespace remoting {
17 18
18 class ChromotingJniRuntime; 19 class ChromotingJniRuntime;
19 class ChromotingJniInstance; 20 class ChromotingJniInstance;
20 class DisplayUpdaterFactory;
21 class JniPairingSecretFetcher; 21 class JniPairingSecretFetcher;
22 22
23 // Houses resources scoped to a session and exposes JNI interface to the 23 // Houses resources scoped to a session and exposes JNI interface to the
24 // Java client during a session. All its methods should be invoked exclusively 24 // Java client during a session. All its methods should be invoked exclusively
25 // from the UI thread unless otherwise noted. 25 // from the UI thread unless otherwise noted.
26 class JniClient { 26 class JniClient {
27 public: 27 public:
28 JniClient(ChromotingJniRuntime* runtime, 28 JniClient(ChromotingJniRuntime* runtime,
29 base::android::ScopedJavaGlobalRef<jobject> java_client); 29 base::android::ScopedJavaGlobalRef<jobject> java_client);
30 virtual ~JniClient(); 30 virtual ~JniClient();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // TODO(yuweih): Instead of exposing a weak pointer in the public API, 150 // TODO(yuweih): Instead of exposing a weak pointer in the public API,
151 // consider handling task posting inside the client. 151 // consider handling task posting inside the client.
152 base::WeakPtr<JniClient> GetWeakPtr(); 152 base::WeakPtr<JniClient> GetWeakPtr();
153 153
154 private: 154 private:
155 ChromotingJniRuntime* runtime_; 155 ChromotingJniRuntime* runtime_;
156 156
157 // Reference to the Java client object. 157 // Reference to the Java client object.
158 base::android::ScopedJavaGlobalRef<jobject> java_client_; 158 base::android::ScopedJavaGlobalRef<jobject> java_client_;
159 159
160 std::unique_ptr<DisplayUpdaterFactory> display_handler_; 160 std::unique_ptr<DisplayUpdaterFactory, DisplayUpdaterFactory::Deleter>
Sergey Ulanov 2016/09/19 21:14:56 I'd prefer to avoid non-default deleters with uniq
Yuwei 2016/09/19 22:30:37 I think the issue here is not just about deleting
Yuwei 2016/09/19 22:38:32 Alternatively we can separate stuffs on the displa
161 display_handler_;
161 162
162 // Deleted on UI thread. 163 // Deleted on UI thread.
163 std::unique_ptr<JniPairingSecretFetcher> secret_fetcher_; 164 std::unique_ptr<JniPairingSecretFetcher> secret_fetcher_;
164 165
165 // Deleted on Network thread. 166 // Deleted on Network thread.
166 std::unique_ptr<ChromotingJniInstance> session_; 167 std::unique_ptr<ChromotingJniInstance> session_;
167 168
168 // Holds pointer for the UI thread. 169 // Holds pointer for the UI thread.
169 base::WeakPtr<JniClient> weak_ptr_; 170 base::WeakPtr<JniClient> weak_ptr_;
170 base::WeakPtrFactory<JniClient> weak_factory_; 171 base::WeakPtrFactory<JniClient> weak_factory_;
171 172
172 DISALLOW_COPY_AND_ASSIGN(JniClient); 173 DISALLOW_COPY_AND_ASSIGN(JniClient);
173 }; 174 };
174 175
175 } // namespace remoting 176 } // namespace remoting
176 177
177 #endif // REMOTING_CLIENT_JNI_JNI_CLIENT_H_ 178 #endif // REMOTING_CLIENT_JNI_JNI_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698