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

Side by Side Diff: remoting/client/chromoting_client_runtime.h

Issue 1764503002: Adding container class for chromoting client runtimes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android and iOS both use MessageLoopForUI directly now. Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_
6 #define REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h"
11 #include "net/url_request/url_request_context_getter.h"
12 #include "remoting/base/auto_thread.h"
13 #include "remoting/client/chromoting_client_runtime.h"
14
15 namespace base {
16 template <typename T>
17 struct DefaultSingletonTraits;
18 }
19
20 // Houses the global resources on which the Chromoting components run
21 // (e.g. message loops and task runners).
22 namespace remoting {
23
24 class ChromotingClientRuntime {
25 public:
26 // This class is instantiated at process initialization and persists until
27 // we close. Its components are reused across |ChromotingClientRuntime|s.
28 static ChromotingClientRuntime* GetInstance();
29
30 scoped_refptr<AutoThreadTaskRunner> network_task_runner() {
31 return network_task_runner_;
32 }
33
34 scoped_refptr<AutoThreadTaskRunner> ui_task_runner() {
35 return ui_task_runner_;
36 }
37
38 scoped_refptr<AutoThreadTaskRunner> display_task_runner() {
39 return display_task_runner_;
40 }
41
42 scoped_refptr<AutoThreadTaskRunner> file_task_runner() {
43 return file_task_runner_;
44 }
45
46 scoped_refptr<net::URLRequestContextGetter> url_requester() {
47 return url_requester_;
48 }
49
50 protected:
51 ChromotingClientRuntime();
52 // Forces a DisconnectFromHost() in case there is any active or failed
53 // connection, then proceeds to tear down the Chromium dependencies on which
54 // all sessions depended. Because destruction only occurs at application exit
55 // after all connections have terminated, it is safe to make unretained
56 // cross-thread calls on the class.
57 virtual ~ChromotingClientRuntime();
58
59 private:
60 // Chromium code's connection to the app message loop. Once created the
61 // MessageLoop will live for the life of the program.
62 scoped_ptr<base::MessageLoopForUI> ui_loop_;
63
64 // References to native threads.
65 scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
66
67 scoped_refptr<AutoThreadTaskRunner> display_task_runner_;
68 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
69 scoped_refptr<AutoThreadTaskRunner> file_task_runner_;
70
71 scoped_refptr<net::URLRequestContextGetter> url_requester_;
72
73 friend struct base::DefaultSingletonTraits<ChromotingClientRuntime>;
74
75 DISALLOW_COPY_AND_ASSIGN(ChromotingClientRuntime);
76 };
77
78 } // namespace remoting
79
80 #endif // REMOTING_CLIENT_CHROMOTING_CLIENT_RUNTIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698