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

Side by Side Diff: chrome/service/service_process.h

Issue 5955001: Remove chromoting host registration from service process. More IPCs to control (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merges Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/service/service_ipc_server.cc ('k') | chrome/service/service_process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_SERVICE_SERVICE_PROCESS_H_ 5 #ifndef CHROME_SERVICE_SERVICE_PROCESS_H_
6 #define CHROME_SERVICE_SERVICE_PROCESS_H_ 6 #define CHROME_SERVICE_SERVICE_PROCESS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "base/thread.h" 14 #include "base/thread.h"
15 #include "base/waitable_event.h" 15 #include "base/waitable_event.h"
16 #include "chrome/service/cloud_print/cloud_print_proxy.h" 16 #include "chrome/service/cloud_print/cloud_print_proxy.h"
17 #include "chrome/service/remoting/remoting_directory_service.h" 17 #include "chrome/service/remoting/chromoting_host_manager.h"
18 18
19 class ServiceProcessPrefs; 19 class ServiceProcessPrefs;
20 class ServiceIPCServer; 20 class ServiceIPCServer;
21 21
22 namespace net { 22 namespace net {
23 class NetworkChangeNotifier; 23 class NetworkChangeNotifier;
24 } 24 }
25 25
26 namespace remoting {
27 class ChromotingHost;
28 class ChromotingHostContext;
29 class HostKeyPair;
30 class JsonHostConfig;
31 }
32
33 class CommandLine; 26 class CommandLine;
34 27
35 // The ServiceProcess does not inherit from ChildProcess because this 28 // The ServiceProcess does not inherit from ChildProcess because this
36 // process can live independently of the browser process. 29 // process can live independently of the browser process.
37 class ServiceProcess : public RemotingDirectoryService::Client, 30 class ServiceProcess : public CloudPrintProxy::Client,
38 public CloudPrintProxy::Client { 31 public remoting::ChromotingHostManager::Observer {
39 public: 32 public:
40 ServiceProcess(); 33 ServiceProcess();
41 ~ServiceProcess(); 34 ~ServiceProcess();
42 35
43 // Initialize the ServiceProcess with the message loop that it should run on. 36 // Initialize the ServiceProcess with the message loop that it should run on.
44 bool Initialize(MessageLoop* message_loop, const CommandLine& command_line); 37 bool Initialize(MessageLoop* message_loop, const CommandLine& command_line);
45 bool Teardown(); 38 bool Teardown();
46 // TODO(sanjeevr): Change various parts of the code such as 39 // TODO(sanjeevr): Change various parts of the code such as
47 // net::ProxyService::CreateSystemProxyConfigService to take in 40 // net::ProxyService::CreateSystemProxyConfigService to take in
48 // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can 41 // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // true indicates that the IPC server should continue listening for new 78 // true indicates that the IPC server should continue listening for new
86 // connections. 79 // connections.
87 bool HandleClientDisconnect(); 80 bool HandleClientDisconnect();
88 81
89 CloudPrintProxy* GetCloudPrintProxy(); 82 CloudPrintProxy* GetCloudPrintProxy();
90 83
91 // CloudPrintProxy::Client implementation. 84 // CloudPrintProxy::Client implementation.
92 virtual void OnCloudPrintProxyEnabled(); 85 virtual void OnCloudPrintProxyEnabled();
93 virtual void OnCloudPrintProxyDisabled(); 86 virtual void OnCloudPrintProxyDisabled();
94 87
88 // ChromotingHostManager::Observer interface.
89 virtual void OnRemotingHostEnabled();
90 virtual void OnRemotingHostDisabled();
91
95 #if defined(ENABLE_REMOTING) 92 #if defined(ENABLE_REMOTING)
96 // Return the reference to the chromoting host only if it has started. 93 // Return the reference to the chromoting host only if it has started.
97 remoting::ChromotingHost* GetChromotingHost() { return chromoting_host_; } 94 remoting::ChromotingHostManager* remoting_host_manager() {
98 95 return remoting_host_manager_;
99 // Enable chromoting host with the tokens. 96 }
100 // Return true if successful.
101 bool EnableChromotingHostWithTokens(const std::string& login,
102 const std::string& remoting_token,
103 const std::string& talk_token);
104
105 // Start running the chromoting host asynchronously.
106 // Return true if chromoting host has started.
107 bool StartChromotingHost();
108
109 // Shutdown chromoting host. Return true if chromoting host was shutdown.
110 // The shutdown process will happen asynchronously.
111 bool ShutdownChromotingHost();
112
113 // RemotingDirectoryService::Client implementation.
114 virtual void OnRemotingHostAdded();
115 virtual void OnRemotingDirectoryError();
116 #endif 97 #endif
117 98
118 private: 99 private:
119 // Schedule a call to ShutdownIfNeeded. 100 // Schedule a call to ShutdownIfNeeded.
120 void ScheduleShutdownCheck(); 101 void ScheduleShutdownCheck();
121 // Shuts down the process if no services are enabled and no clients are 102 // Shuts down the process if no services are enabled and no clients are
122 // connected. 103 // connected.
123 void ShutdownIfNeeded(); 104 void ShutdownIfNeeded();
124 // Called exactly ONCE per process instance for each service that gets 105 // Called exactly ONCE per process instance for each service that gets
125 // enabled in this process. 106 // enabled in this process.
126 void OnServiceEnabled(); 107 void OnServiceEnabled();
127 // Called exactly ONCE per process instance for each service that gets 108 // Called exactly ONCE per process instance for each service that gets
128 // disabled in this process (note that shutdown != disabled). 109 // disabled in this process (note that shutdown != disabled).
129 void OnServiceDisabled(); 110 void OnServiceDisabled();
130 111
131 #if defined(ENABLE_REMOTING)
132 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromoting);
133 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown);
134
135 // Save authenication token to the json config file.
136 void SaveChromotingConfig(
137 const std::string& login,
138 const std::string& token,
139 const std::string& host_id,
140 const std::string& host_name,
141 remoting::HostKeyPair* host_key_pair);
142
143 // Load settings for chromoting from json file.
144 void LoadChromotingConfig();
145
146 // This method is called when chromoting is shutting down. This is virtual
147 // for used in the test.
148 virtual void OnChromotingHostShutdown();
149 #endif
150
151 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 112 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
152 scoped_ptr<base::Thread> io_thread_; 113 scoped_ptr<base::Thread> io_thread_;
153 scoped_ptr<base::Thread> file_thread_; 114 scoped_ptr<base::Thread> file_thread_;
154 scoped_ptr<CloudPrintProxy> cloud_print_proxy_; 115 scoped_ptr<CloudPrintProxy> cloud_print_proxy_;
155 scoped_ptr<ServiceProcessPrefs> service_prefs_; 116 scoped_ptr<ServiceProcessPrefs> service_prefs_;
156 scoped_ptr<ServiceIPCServer> ipc_server_; 117 scoped_ptr<ServiceIPCServer> ipc_server_;
157 118
158 #if defined(ENABLE_REMOTING)
159 scoped_refptr<remoting::JsonHostConfig> chromoting_config_;
160 scoped_ptr<remoting::ChromotingHostContext> chromoting_context_;
161 scoped_refptr<remoting::ChromotingHost> chromoting_host_;
162 scoped_ptr<RemotingDirectoryService> remoting_directory_;
163
164 // Temporary storage for remoting credentials. The content is cleared
165 // after it is saved.
166 std::string remoting_login_;
167 std::string remoting_token_;
168 std::string talk_token_;
169 #endif
170
171 // An event that will be signalled when we shutdown. 119 // An event that will be signalled when we shutdown.
172 base::WaitableEvent shutdown_event_; 120 base::WaitableEvent shutdown_event_;
173 121
174 // Pointer to the main message loop that host this object. 122 // Pointer to the main message loop that host this object.
175 MessageLoop* main_message_loop_; 123 MessageLoop* main_message_loop_;
176 124
177 // Count of currently enabled services in this process. 125 // Count of currently enabled services in this process.
178 int enabled_services_; 126 int enabled_services_;
179 127
180 // Speficies whether a product update is available. 128 // Speficies whether a product update is available.
181 bool update_available_; 129 bool update_available_;
182 130
131 #if defined(ENABLE_REMOTING)
132 scoped_refptr<remoting::ChromotingHostManager> remoting_host_manager_;
133 #endif
134
183 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); 135 DISALLOW_COPY_AND_ASSIGN(ServiceProcess);
184 }; 136 };
185 137
186 extern ServiceProcess* g_service_process; 138 extern ServiceProcess* g_service_process;
187 139
188 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ 140 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_
OLDNEW
« no previous file with comments | « chrome/service/service_ipc_server.cc ('k') | chrome/service/service_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698