 Chromium Code Reviews
 Chromium Code Reviews Issue 2643483003:
  [Remoting Android] Refactor ClientTelemetryLogger  (Closed)
    
  
    Issue 2643483003:
  [Remoting Android] Refactor ClientTelemetryLogger  (Closed) 
  | OLD | NEW | 
|---|---|
| 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_CHROMOTING_JNI_RUNTIME_H_ | 5 #ifndef REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ | 
| 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_H_ | 6 #define REMOTING_CLIENT_JNI_CHROMOTING_JNI_RUNTIME_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/client/chromoting_client_runtime.h" | 16 #include "remoting/client/chromoting_client_runtime.h" | 
| 16 #include "remoting/client/client_telemetry_logger.h" | |
| 17 #include "remoting/client/jni/chromoting_jni_instance.h" | 17 #include "remoting/client/jni/chromoting_jni_instance.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> struct DefaultSingletonTraits; | 21 template<typename T> struct DefaultSingletonTraits; | 
| 22 } | 22 } | 
| 23 | 23 | 
| 24 namespace remoting { | 24 namespace remoting { | 
| 25 | 25 | 
| 26 bool RegisterChromotingJniRuntime(JNIEnv* env); | 26 bool RegisterChromotingJniRuntime(JNIEnv* env); | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 44 } | 44 } | 
| 45 | 45 | 
| 46 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { | 46 scoped_refptr<AutoThreadTaskRunner> display_task_runner() { | 
| 47 return runtime_->display_task_runner(); | 47 return runtime_->display_task_runner(); | 
| 48 } | 48 } | 
| 49 | 49 | 
| 50 scoped_refptr<net::URLRequestContextGetter> url_requester() { | 50 scoped_refptr<net::URLRequestContextGetter> url_requester() { | 
| 51 return runtime_->url_requester(); | 51 return runtime_->url_requester(); | 
| 52 } | 52 } | 
| 53 | 53 | 
| 54 // The runtime handles authentication and the caller should not call SetAuth*. | |
| 55 // The runtime itself will not send out any logs. Used on the network thread. | 54 // The runtime itself will not send out any logs. Used on the network thread. | 
| 
Sergey Ulanov
2017/01/19 00:50:38
Please explain in the comment how this is used.
 
Yuwei
2017/01/19 23:00:00
Done.
 | |
| 56 ClientTelemetryLogger* logger() { | 55 base::WeakPtr<TelemetryLogWriter> log_writer() { | 
| 
Sergey Ulanov
2017/01/19 00:50:38
This should be called GetLogWriter(). Also please
 
Yuwei
2017/01/19 23:00:00
Done.
 | |
| 57 DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread()); | 56 DCHECK(runtime_->network_task_runner()->BelongsToCurrentThread()); | 
| 58 DCHECK(logger_); | 57 DCHECK(log_writer_); | 
| 
Sergey Ulanov
2017/01/19 00:50:38
don't need this DCHECK. operartor->() in unique_pt
 
Yuwei
2017/01/19 23:00:00
Done.
 | |
| 59 return logger_.get(); | 58 return log_writer_->GetWeakPtr(); | 
| 60 } | 59 } | 
| 61 | 60 | 
| 62 // Fetch OAuth token for the telemetry logger. Call on UI thread. | 61 // Fetch OAuth token for the telemetry logger. Call on UI thread. | 
| 63 void FetchAuthToken(); | 62 void FetchAuthToken(); | 
| 64 | 63 | 
| 65 private: | 64 private: | 
| 66 ChromotingJniRuntime(); | 65 ChromotingJniRuntime(); | 
| 67 | 66 | 
| 68 // Forces a DisconnectFromHost() in case there is any active or failed | 67 // Forces a DisconnectFromHost() in case there is any active or failed | 
| 69 // connection, then proceeds to tear down the Chromium dependencies on which | 68 // connection, then proceeds to tear down the Chromium dependencies on which | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 80 | 79 | 
| 81 // Chromium code's connection to the app message loop. Once created the | 80 // Chromium code's connection to the app message loop. Once created the | 
| 82 // MessageLoop will live for the life of the program. | 81 // MessageLoop will live for the life of the program. | 
| 83 std::unique_ptr<base::MessageLoopForUI> ui_loop_; | 82 std::unique_ptr<base::MessageLoopForUI> ui_loop_; | 
| 84 | 83 | 
| 85 // Contains threads. | 84 // Contains threads. | 
| 86 // | 85 // | 
| 87 std::unique_ptr<ChromotingClientRuntime> runtime_; | 86 std::unique_ptr<ChromotingClientRuntime> runtime_; | 
| 88 | 87 | 
| 89 // For logging session stage changes and stats. | 88 // For logging session stage changes and stats. | 
| 90 std::unique_ptr<ClientTelemetryLogger> logger_; | 89 std::unique_ptr<TelemetryLogWriter> log_writer_; | 
| 91 | 90 | 
| 92 friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>; | 91 friend struct base::DefaultSingletonTraits<ChromotingJniRuntime>; | 
| 93 | 92 | 
| 94 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); | 93 DISALLOW_COPY_AND_ASSIGN(ChromotingJniRuntime); | 
| 95 }; | 94 }; | 
| 96 | 95 | 
| 97 } // namespace remoting | 96 } // namespace remoting | 
| 98 | 97 | 
| 99 #endif | 98 #endif | 
| OLD | NEW |