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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 class ServiceProcessState; | 22 class ServiceProcessState; |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 class NetworkChangeNotifier; | 25 class NetworkChangeNotifier; |
26 } | 26 } |
27 | 27 |
28 class CommandLine; | 28 class CommandLine; |
29 | 29 |
30 // The ServiceProcess does not inherit from ChildProcess because this | 30 // The ServiceProcess does not inherit from ChildProcess because this |
31 // process can live independently of the browser process. | 31 // process can live independently of the browser process. |
| 32 // ServiceProcess Design Notes |
| 33 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/servi
ce-processes |
32 class ServiceProcess : public CloudPrintProxy::Client { | 34 class ServiceProcess : public CloudPrintProxy::Client { |
33 public: | 35 public: |
34 ServiceProcess(); | 36 ServiceProcess(); |
35 virtual ~ServiceProcess(); | 37 virtual ~ServiceProcess(); |
36 | 38 |
37 // 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. |
38 // ServiceProcess takes ownership of |state|. | 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, |
41 ServiceProcessState* state); | 43 ServiceProcessState* state); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 94 |
93 // CloudPrintProxy::Client implementation. | 95 // CloudPrintProxy::Client implementation. |
94 virtual void OnCloudPrintProxyEnabled(bool persist_state); | 96 virtual void OnCloudPrintProxyEnabled(bool persist_state); |
95 virtual void OnCloudPrintProxyDisabled(bool persist_state); | 97 virtual void OnCloudPrintProxyDisabled(bool persist_state); |
96 | 98 |
97 ServiceURLRequestContextGetter* GetServiceURLRequestContextGetter(); | 99 ServiceURLRequestContextGetter* GetServiceURLRequestContextGetter(); |
98 | 100 |
99 private: | 101 private: |
100 // Schedule a call to ShutdownIfNeeded. | 102 // Schedule a call to ShutdownIfNeeded. |
101 void ScheduleShutdownCheck(); | 103 void ScheduleShutdownCheck(); |
| 104 |
102 // Shuts down the process if no services are enabled and no clients are | 105 // Shuts down the process if no services are enabled and no clients are |
103 // connected. | 106 // connected. |
104 void ShutdownIfNeeded(); | 107 void ShutdownIfNeeded(); |
| 108 |
105 // Called exactly ONCE per process instance for each service that gets | 109 // Called exactly ONCE per process instance for each service that gets |
106 // enabled in this process. | 110 // enabled in this process. |
107 void OnServiceEnabled(); | 111 void OnServiceEnabled(); |
| 112 |
108 // Called exactly ONCE per process instance for each service that gets | 113 // Called exactly ONCE per process instance for each service that gets |
109 // disabled in this process (note that shutdown != disabled). | 114 // disabled in this process (note that shutdown != disabled). |
110 void OnServiceDisabled(); | 115 void OnServiceDisabled(); |
111 | 116 |
| 117 // Terminate forces the service process to quit. |
| 118 void Terminate(); |
| 119 |
112 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 120 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
113 scoped_ptr<base::Thread> io_thread_; | 121 scoped_ptr<base::Thread> io_thread_; |
114 scoped_ptr<base::Thread> file_thread_; | 122 scoped_ptr<base::Thread> file_thread_; |
115 scoped_ptr<CloudPrintProxy> cloud_print_proxy_; | 123 scoped_ptr<CloudPrintProxy> cloud_print_proxy_; |
116 scoped_ptr<ServiceProcessPrefs> service_prefs_; | 124 scoped_ptr<ServiceProcessPrefs> service_prefs_; |
117 scoped_ptr<ServiceIPCServer> ipc_server_; | 125 scoped_ptr<ServiceIPCServer> ipc_server_; |
118 scoped_ptr<ServiceProcessState> service_process_state_; | 126 scoped_ptr<ServiceProcessState> service_process_state_; |
119 | 127 |
120 // An event that will be signalled when we shutdown. | 128 // An event that will be signalled when we shutdown. |
121 base::WaitableEvent shutdown_event_; | 129 base::WaitableEvent shutdown_event_; |
(...skipping 12 matching lines...) Expand all Loading... |
134 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); | 142 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); |
135 }; | 143 }; |
136 | 144 |
137 // Disable refcounting for runnable method because it is really not needed | 145 // Disable refcounting for runnable method because it is really not needed |
138 // when we post tasks on the main message loop. | 146 // when we post tasks on the main message loop. |
139 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); | 147 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcess); |
140 | 148 |
141 extern ServiceProcess* g_service_process; | 149 extern ServiceProcess* g_service_process; |
142 | 150 |
143 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ | 151 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ |
OLD | NEW |