OLD | NEW |
1 // Copyright (c) 2010 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/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/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" | 17 #include "chrome/service/remoting/chromoting_host_manager.h" |
18 | 18 |
19 class ServiceProcessPrefs; | 19 class ServiceProcessPrefs; |
20 class ServiceIPCServer; | 20 class ServiceIPCServer; |
21 class CommandLine; | 21 class CommandLine; |
22 class ServiceURLRequestContextGetter; | 22 class ServiceURLRequestContextGetter; |
| 23 class ServiceProcessState; |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class NetworkChangeNotifier; | 26 class NetworkChangeNotifier; |
26 } | 27 } |
27 | 28 |
28 class CommandLine; | 29 class CommandLine; |
29 | 30 |
30 // The ServiceProcess does not inherit from ChildProcess because this | 31 // The ServiceProcess does not inherit from ChildProcess because this |
31 // process can live independently of the browser process. | 32 // process can live independently of the browser process. |
32 class ServiceProcess : public CloudPrintProxy::Client, | 33 class ServiceProcess : public CloudPrintProxy::Client, |
33 public remoting::ChromotingHostManager::Observer { | 34 public remoting::ChromotingHostManager::Observer { |
34 public: | 35 public: |
35 ServiceProcess(); | 36 ServiceProcess(); |
36 ~ServiceProcess(); | 37 ~ServiceProcess(); |
37 | 38 |
38 // Initialize the ServiceProcess with the message loop that it should run on. | 39 // Initialize the ServiceProcess with the message loop that it should run on. |
| 40 // ServiceProcess takes ownership of |state|. |
39 bool Initialize(MessageLoopForUI* message_loop, | 41 bool Initialize(MessageLoopForUI* message_loop, |
40 const CommandLine& command_line); | 42 const CommandLine& command_line, |
| 43 ServiceProcessState* state); |
41 bool Teardown(); | 44 bool Teardown(); |
42 // TODO(sanjeevr): Change various parts of the code such as | 45 // TODO(sanjeevr): Change various parts of the code such as |
43 // net::ProxyService::CreateSystemProxyConfigService to take in | 46 // net::ProxyService::CreateSystemProxyConfigService to take in |
44 // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can | 47 // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can |
45 // remove the io_thread() and file_thread() accessors and replace them with | 48 // remove the io_thread() and file_thread() accessors and replace them with |
46 // io_message_loop_proxy() and file_message_loop_proxy() respectively. | 49 // io_message_loop_proxy() and file_message_loop_proxy() respectively. |
47 | 50 |
48 // Returns the thread that we perform I/O coordination on (network requests, | 51 // Returns the thread that we perform I/O coordination on (network requests, |
49 // communication with renderers, etc. | 52 // communication with renderers, etc. |
50 // NOTE: You should ONLY use this to pass to IPC or other objects which must | 53 // NOTE: You should ONLY use this to pass to IPC or other objects which must |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Called exactly ONCE per process instance for each service that gets | 116 // Called exactly ONCE per process instance for each service that gets |
114 // disabled in this process (note that shutdown != disabled). | 117 // disabled in this process (note that shutdown != disabled). |
115 void OnServiceDisabled(); | 118 void OnServiceDisabled(); |
116 | 119 |
117 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 120 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
118 scoped_ptr<base::Thread> io_thread_; | 121 scoped_ptr<base::Thread> io_thread_; |
119 scoped_ptr<base::Thread> file_thread_; | 122 scoped_ptr<base::Thread> file_thread_; |
120 scoped_ptr<CloudPrintProxy> cloud_print_proxy_; | 123 scoped_ptr<CloudPrintProxy> cloud_print_proxy_; |
121 scoped_ptr<ServiceProcessPrefs> service_prefs_; | 124 scoped_ptr<ServiceProcessPrefs> service_prefs_; |
122 scoped_ptr<ServiceIPCServer> ipc_server_; | 125 scoped_ptr<ServiceIPCServer> ipc_server_; |
| 126 scoped_ptr<ServiceProcessState> service_process_state_; |
123 | 127 |
124 // An event that will be signalled when we shutdown. | 128 // An event that will be signalled when we shutdown. |
125 base::WaitableEvent shutdown_event_; | 129 base::WaitableEvent shutdown_event_; |
126 | 130 |
127 // Pointer to the main message loop that host this object. | 131 // Pointer to the main message loop that host this object. |
128 MessageLoop* main_message_loop_; | 132 MessageLoop* main_message_loop_; |
129 | 133 |
130 // Count of currently enabled services in this process. | 134 // Count of currently enabled services in this process. |
131 int enabled_services_; | 135 int enabled_services_; |
132 | 136 |
133 // Speficies whether a product update is available. | 137 // Speficies whether a product update is available. |
134 bool update_available_; | 138 bool update_available_; |
135 | 139 |
136 scoped_refptr<ServiceURLRequestContextGetter> request_context_getter_; | 140 scoped_refptr<ServiceURLRequestContextGetter> request_context_getter_; |
137 | 141 |
138 #if defined(ENABLE_REMOTING) | 142 #if defined(ENABLE_REMOTING) |
139 scoped_refptr<remoting::ChromotingHostManager> remoting_host_manager_; | 143 scoped_refptr<remoting::ChromotingHostManager> remoting_host_manager_; |
140 #endif | 144 #endif |
141 | 145 |
142 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); | 146 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); |
143 }; | 147 }; |
144 | 148 |
145 // Disable refcounting for runnable method because it is really not needed | 149 // Disable refcounting for runnable method because it is really not needed |
146 // when we post tasks on the main message loop. | 150 // when we post tasks on the main message loop. |
147 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 151 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
148 | 152 |
149 extern ServiceProcess* g_service_process; | 153 extern ServiceProcess* g_service_process; |
150 | 154 |
151 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ | 155 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ |
OLD | NEW |