OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/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/chromoting_host_manager.h" | |
18 | 17 |
19 class ServiceProcessPrefs; | 18 class ServiceProcessPrefs; |
20 class ServiceIPCServer; | 19 class ServiceIPCServer; |
21 class CommandLine; | 20 class CommandLine; |
22 class ServiceURLRequestContextGetter; | 21 class ServiceURLRequestContextGetter; |
23 class ServiceProcessState; | 22 class ServiceProcessState; |
24 | 23 |
25 namespace net { | 24 namespace net { |
26 class NetworkChangeNotifier; | 25 class NetworkChangeNotifier; |
27 } | 26 } |
28 | 27 |
29 class CommandLine; | 28 class CommandLine; |
30 | 29 |
31 // The ServiceProcess does not inherit from ChildProcess because this | 30 // The ServiceProcess does not inherit from ChildProcess because this |
32 // process can live independently of the browser process. | 31 // process can live independently of the browser process. |
33 class ServiceProcess : public CloudPrintProxy::Client, | 32 class ServiceProcess : public CloudPrintProxy::Client { |
34 public remoting::ChromotingHostManager::Observer { | |
35 public: | 33 public: |
36 ServiceProcess(); | 34 ServiceProcess(); |
37 ~ServiceProcess(); | 35 ~ServiceProcess(); |
38 | 36 |
39 // Initialize the ServiceProcess with the message loop that it should run on. | 37 // Initialize the ServiceProcess with the message loop that it should run on. |
40 // ServiceProcess takes ownership of |state|. | 38 // ServiceProcess takes ownership of |state|. |
41 bool Initialize(MessageLoopForUI* message_loop, | 39 bool Initialize(MessageLoopForUI* message_loop, |
42 const CommandLine& command_line, | 40 const CommandLine& command_line, |
43 ServiceProcessState* state); | 41 ServiceProcessState* state); |
44 bool Teardown(); | 42 bool Teardown(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // true indicates that the IPC server should continue listening for new | 82 // true indicates that the IPC server should continue listening for new |
85 // connections. | 83 // connections. |
86 bool HandleClientDisconnect(); | 84 bool HandleClientDisconnect(); |
87 | 85 |
88 CloudPrintProxy* GetCloudPrintProxy(); | 86 CloudPrintProxy* GetCloudPrintProxy(); |
89 | 87 |
90 // CloudPrintProxy::Client implementation. | 88 // CloudPrintProxy::Client implementation. |
91 virtual void OnCloudPrintProxyEnabled(bool persist_state); | 89 virtual void OnCloudPrintProxyEnabled(bool persist_state); |
92 virtual void OnCloudPrintProxyDisabled(bool persist_state); | 90 virtual void OnCloudPrintProxyDisabled(bool persist_state); |
93 | 91 |
94 // ChromotingHostManager::Observer interface. | |
95 virtual void OnChromotingHostEnabled(); | |
96 virtual void OnChromotingHostDisabled(); | |
97 | |
98 #if defined(ENABLE_REMOTING) | |
99 // Return the reference to the chromoting host only if it has started. | |
100 remoting::ChromotingHostManager* remoting_host_manager() { | |
101 return remoting_host_manager_; | |
102 } | |
103 #endif | |
104 | |
105 ServiceURLRequestContextGetter* GetServiceURLRequestContextGetter(); | 92 ServiceURLRequestContextGetter* GetServiceURLRequestContextGetter(); |
106 | 93 |
107 private: | 94 private: |
108 // Schedule a call to ShutdownIfNeeded. | 95 // Schedule a call to ShutdownIfNeeded. |
109 void ScheduleShutdownCheck(); | 96 void ScheduleShutdownCheck(); |
110 // Shuts down the process if no services are enabled and no clients are | 97 // Shuts down the process if no services are enabled and no clients are |
111 // connected. | 98 // connected. |
112 void ShutdownIfNeeded(); | 99 void ShutdownIfNeeded(); |
113 // Called exactly ONCE per process instance for each service that gets | 100 // Called exactly ONCE per process instance for each service that gets |
114 // enabled in this process. | 101 // enabled in this process. |
(...skipping 17 matching lines...) Expand all Loading... |
132 MessageLoop* main_message_loop_; | 119 MessageLoop* main_message_loop_; |
133 | 120 |
134 // Count of currently enabled services in this process. | 121 // Count of currently enabled services in this process. |
135 int enabled_services_; | 122 int enabled_services_; |
136 | 123 |
137 // Speficies whether a product update is available. | 124 // Speficies whether a product update is available. |
138 bool update_available_; | 125 bool update_available_; |
139 | 126 |
140 scoped_refptr<ServiceURLRequestContextGetter> request_context_getter_; | 127 scoped_refptr<ServiceURLRequestContextGetter> request_context_getter_; |
141 | 128 |
142 #if defined(ENABLE_REMOTING) | |
143 scoped_refptr<remoting::ChromotingHostManager> remoting_host_manager_; | |
144 #endif | |
145 | |
146 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); | 129 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); |
147 }; | 130 }; |
148 | 131 |
149 // Disable refcounting for runnable method because it is really not needed | 132 // Disable refcounting for runnable method because it is really not needed |
150 // when we post tasks on the main message loop. | 133 // when we post tasks on the main message loop. |
151 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 134 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
152 | 135 |
153 extern ServiceProcess* g_service_process; | 136 extern ServiceProcess* g_service_process; |
154 | 137 |
155 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ | 138 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ |
OLD | NEW |