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

Unified Diff: remoting/client/chromoting_client_runtime.h

Issue 2745583008: Refactoring out the chromoting jni runtime class in favor of chromoting client runtime. (Closed)
Patch Set: Unit tests need to link with android. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/chromoting_client_runtime.h
diff --git a/remoting/client/chromoting_client_runtime.h b/remoting/client/chromoting_client_runtime.h
index 69efb0dfc2843472a20b879d686420c6a69274aa..e9ad61497913440841bafdee902d03960a553471 100644
--- a/remoting/client/chromoting_client_runtime.h
+++ b/remoting/client/chromoting_client_runtime.h
@@ -8,11 +8,17 @@
#include <memory>
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/singleton.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/base/auto_thread.h"
+#include "remoting/base/telemetry_log_writer.h"
namespace base {
class MessageLoopForUI;
+
+template <typename T>
+struct DefaultSingletonTraits;
Sergey Ulanov 2017/03/14 19:09:37 Do you need this, given that this file includes ba
nicholss 2017/03/14 22:56:44 I was not suppose to have base/singleton in this h
} // namespace base
// Houses the global resources on which the Chromoting components run
@@ -21,28 +27,18 @@ namespace remoting {
class ChromotingClientRuntime {
public:
- // Caller to create is responsible for creating and attaching a new ui thread
- // for use. Example:
- //
- // On Android, the UI thread is managed by Java, so we need to attach and
- // start a special type of message loop to allow Chromium code to run tasks.
- //
- // base::MessageLoopForUI *ui_loop = new base::MessageLoopForUI();
- // ui_loop_->Start();
- // std::unique_ptr<ChromotingClientRuntime> runtime =
- // ChromotingClientRuntime::Create(ui_loop);
- //
- // On iOS we created a new message loop and now attach it.
- //
- // base::MessageLoopForUI *ui_loop = new base::MessageLoopForUI();
- // ui_loop_->Attach();
- // std::unique_ptr<ChromotingClientRuntime> runtime =
- // ChromotingClientRuntime::Create(ui_loop);
- //
- static std::unique_ptr<ChromotingClientRuntime> Create(
- base::MessageLoopForUI* ui_loop);
-
- ~ChromotingClientRuntime();
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ virtual void RuntimeWillShutdown() = 0;
+ virtual void RuntimeDidShutdown() = 0;
+ virtual void RequestAuthTokenForLogger() = 0;
+ };
+
+ static ChromotingClientRuntime* GetInstance();
+
+ void SetDelegate(ChromotingClientRuntime::Delegate* delegate);
scoped_refptr<AutoThreadTaskRunner> network_task_runner() {
return network_task_runner_;
@@ -64,14 +60,23 @@ class ChromotingClientRuntime {
return url_requester_;
}
+ // TODO(nicholss): This should return a base::weak_ptr<TelemetryLogWriter>
Sergey Ulanov 2017/03/14 19:09:37 This class owns the log_writer, so I think returni
nicholss 2017/03/14 22:56:44 Ok thanks
Yuwei 2017/03/16 08:38:53 WeakPtr is not necessary as long as the runtime di
+ // At some point the application should set the auth closure when auth is
+ // possible.
+ // TODO(nicholss): GetLogWriter is not like the above methods, change to
Sergey Ulanov 2017/03/14 19:09:37 Yes, log_writer() would be a better name
nicholss 2017/03/14 22:56:44 Done.
+ // log_writer?
+ TelemetryLogWriter* GetLogWriter();
Sergey Ulanov 2017/03/14 19:09:37 Unlike other stuff this class stores the log write
Sergey Ulanov 2017/03/14 19:09:37 Change return type to ChromotingEventLogWriter
nicholss 2017/03/14 22:56:44 Done.
nicholss 2017/03/14 22:56:44 Done.
+
private:
ChromotingClientRuntime();
- ChromotingClientRuntime(
- scoped_refptr<AutoThreadTaskRunner> ui_task_runner,
- scoped_refptr<AutoThreadTaskRunner> display_task_runner,
- scoped_refptr<AutoThreadTaskRunner> network_task_runner,
- scoped_refptr<AutoThreadTaskRunner> file_task_runner,
- scoped_refptr<net::URLRequestContextGetter> url_requester);
+ virtual ~ChromotingClientRuntime();
+
+ void CreateLogWriter();
+ void RequestAuthTokenForLogger();
+
+ // Chromium code's connection to the app message loop. Once created the
+ // MessageLoop will live for the life of the program.
+ std::unique_ptr<base::MessageLoopForUI> ui_loop_;
// References to native threads.
scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
@@ -82,6 +87,13 @@ class ChromotingClientRuntime {
scoped_refptr<net::URLRequestContextGetter> url_requester_;
+ // For logging session stage changes and stats.
+ std::unique_ptr<TelemetryLogWriter> log_writer_;
+
+ ChromotingClientRuntime::Delegate* delegate_;
+
+ friend struct base::DefaultSingletonTraits<ChromotingClientRuntime>;
+
DISALLOW_COPY_AND_ASSIGN(ChromotingClientRuntime);
};

Powered by Google App Engine
This is Rietveld 408576698