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

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

Issue 2753963002: Refactoring and rewriting the chromoting jni instance to be chromoting session. (Closed)
Patch Set: WeakPtr Factory now makes type ChromotingClientRuntime::Delegate. Created 3 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RUNTIME_DELEGATE_H_ 5 #ifndef REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_
6 #define REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ 6 #define REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "net/url_request/url_request_context_getter.h" 13 #include "net/url_request/url_request_context_getter.h"
14 #include "remoting/base/auto_thread.h" 14 #include "remoting/base/auto_thread.h"
15 #include "remoting/base/telemetry_log_writer.h" 15 #include "remoting/base/telemetry_log_writer.h"
16 #include "remoting/client/chromoting_client_runtime.h" 16 #include "remoting/client/chromoting_client_runtime.h"
17 #include "remoting/client/jni/chromoting_jni_instance.h" 17 #include "remoting/client/chromoting_session.h"
18 #include "remoting/protocol/connection_to_host.h" 18 #include "remoting/protocol/connection_to_host.h"
19 19
20 namespace base { 20 namespace base {
21 template <typename T> 21 template <typename T>
22 struct DefaultSingletonTraits; 22 struct DefaultSingletonTraits;
23 } 23 }
24 24
25 namespace remoting { 25 namespace remoting {
26 26
27 bool RegisterJniRuntimeDelegate(JNIEnv* env); 27 bool RegisterJniRuntimeDelegate(JNIEnv* env);
(...skipping 10 matching lines...) Expand all
38 static JniRuntimeDelegate* GetInstance(); 38 static JniRuntimeDelegate* GetInstance();
39 39
40 // Fetch OAuth token for the telemetry logger. Call on UI thread. 40 // Fetch OAuth token for the telemetry logger. Call on UI thread.
41 void FetchAuthToken(); 41 void FetchAuthToken();
42 42
43 // remoting::ChromotingClientRuntime::Delegate overrides. 43 // remoting::ChromotingClientRuntime::Delegate overrides.
44 void RuntimeWillShutdown() override; 44 void RuntimeWillShutdown() override;
45 void RuntimeDidShutdown() override; 45 void RuntimeDidShutdown() override;
46 void RequestAuthTokenForLogger() override; 46 void RequestAuthTokenForLogger() override;
47 47
48 base::WeakPtr<ChromotingClientRuntime::Delegate> GetWeakPtr();
49
48 private: 50 private:
49 JniRuntimeDelegate(); 51 JniRuntimeDelegate();
50 52
51 // Forces a DisconnectFromHost() in case there is any active or failed 53 // Forces a DisconnectFromHost() in case there is any active or failed
52 // connection, then proceeds to tear down the Chromium dependencies on which 54 // connection, then proceeds to tear down the Chromium dependencies on which
53 // all sessions depended. Because destruction only occurs at application exit 55 // all sessions depended. Because destruction only occurs at application exit
54 // after all connections have terminated, it is safe to make unretained 56 // after all connections have terminated, it is safe to make unretained
55 // cross-thread calls on the class. 57 // cross-thread calls on the class.
56 ~JniRuntimeDelegate() override; 58 ~JniRuntimeDelegate() override;
57 59
58 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|. 60 // Detaches JVM from the current thread, then signals. Doesn't own |waiter|.
59 void DetachFromVmAndSignal(base::WaitableEvent* waiter); 61 void DetachFromVmAndSignal(base::WaitableEvent* waiter);
60 62
61 ChromotingClientRuntime* runtime_; 63 ChromotingClientRuntime* runtime_;
62 64
65 base::WeakPtrFactory<ChromotingClientRuntime::Delegate> weak_factory_;
66
63 friend struct base::DefaultSingletonTraits<JniRuntimeDelegate>; 67 friend struct base::DefaultSingletonTraits<JniRuntimeDelegate>;
64 68
65 DISALLOW_COPY_AND_ASSIGN(JniRuntimeDelegate); 69 DISALLOW_COPY_AND_ASSIGN(JniRuntimeDelegate);
66 }; 70 };
67 71
68 } // namespace remoting 72 } // namespace remoting
69 73
70 #endif // REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_ 74 #endif // REMOTING_CLIENT_JNI_JNI_RUNTIME_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698