Chromium Code Reviews| Index: remoting/client/chromoting_client_runtime.h |
| diff --git a/remoting/client/chromoting_client_runtime.h b/remoting/client/chromoting_client_runtime.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e2a219ab6ca071789d409580b3d076bc36d43528 |
| --- /dev/null |
| +++ b/remoting/client/chromoting_client_runtime.h |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_CONTEXT_H_ |
|
Lambros
2016/03/03 19:15:08
Fix header guard.
|
| +#define REMOTING_CLIENT_CHROMOTING_CLIENT_CONTEXT_H_ |
| + |
| +#include "base/bind.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
|
Lambros
2016/03/03 19:15:08
not used?
|
| +#include "base/memory/weak_ptr.h" |
|
Lambros
2016/03/03 19:15:08
not used?
|
| +#include "base/message_loop/message_loop.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| +#include "remoting/base/auto_thread.h" |
| +#include "remoting/base/url_request_context_getter.h" |
|
Lambros
2016/03/03 19:15:08
I think this should be "net/url_request/url_reques
|
| +#include "remoting/client/chromoting_client.h" |
|
Lambros
2016/03/03 19:15:08
not used? (this, and all the ones below as well)
|
| +#include "remoting/protocol/connection_to_host.h" |
| +#include "remoting/protocol/transport_context.h" |
| + |
| +namespace base { |
| +template<typename T> struct DefaultSingletonTraits; |
| +} |
| + |
| +// Houses the global resources on which the Chromoting components run |
| +// (e.g. message loops and task runners). |
| +namespace remoting { |
| + |
| +class ChromotingClientRuntime { |
| + public: |
| + // This class is instantiated at process initialization and persists until |
| + // we close. Its components are reused across |ChromotingJniInstance|s. |
|
Lambros
2016/03/03 19:15:08
Jni is specific to Android.
|
| + static ChromotingClientRuntime* GetInstance(); |
| + |
| + scoped_refptr<AutoThreadTaskRunner> network_task_runner() { |
| + return network_task_runner_; |
| + } |
| + |
| + scoped_refptr<AutoThreadTaskRunner> display_task_runner() { |
| + return ui_task_runner_; |
| + } |
| + |
| + scoped_refptr<AutoThreadTaskRunner> file_task_runner() { |
| + return file_task_runner_; |
| + } |
| + |
| + scoped_refptr<net::URLRequestContextGetter> url_requester() { |
| + return url_requester_; |
| + } |
| + |
| +protected: |
| + ChromotingClientRuntime(); |
| + // 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 ~ChromotingClientRuntime(); |
| + |
| + private: |
| + // Chromium code's connection to the app message loop. Once created the |
| + // MessageLoop will live for the life of the program. An attempt was made to |
| + // create the primary message loop earlier in the programs life, but a |
| + // MessageLoop requires ARC to be disabled. |
|
Lambros
2016/03/03 19:15:08
ARC is Mac-specific, but this file is cross-platfo
|
| + base::MessageLoop* ui_loop_; |
| + |
| + // References to native threads. |
| + scoped_refptr<AutoThreadTaskRunner> ui_task_runner_; |
| + scoped_refptr<AutoThreadTaskRunner> network_task_runner_; |
| + scoped_refptr<AutoThreadTaskRunner> file_task_runner_; |
| + |
| + scoped_refptr<net::URLRequestContextGetter> url_requester_; |
| + |
| + friend struct base::DefaultSingletonTraits<ChromotingClientRuntime>; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromotingClientRuntime); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_CLIENT_CHROMOTING_CLIENT_CONTEXT_H_ |