Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ | 5 #ifndef CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ |
| 6 #define CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ | 6 #define CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <queue> | 11 #include <queue> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/cancelable_callback.h" | 17 #include "base/cancelable_callback.h" |
| 18 #include "base/id_map.h" | 18 #include "base/id_map.h" |
| 19 #include "base/memory/singleton.h" | 19 #include "base/memory/singleton.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/process/process.h" | 21 #include "base/process/process.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "content/public/browser/notification_observer.h" | 23 #include "chrome/browser/upgrade_observer.h" |
| 24 #include "content/public/browser/notification_registrar.h" | |
| 25 #include "ipc/ipc_channel_proxy.h" | 24 #include "ipc/ipc_channel_proxy.h" |
| 26 #include "ipc/ipc_listener.h" | 25 #include "ipc/ipc_listener.h" |
| 27 #include "ipc/ipc_sender.h" | 26 #include "ipc/ipc_sender.h" |
| 28 | 27 |
| 29 namespace base { | 28 namespace base { |
| 30 class CommandLine; | 29 class CommandLine; |
| 31 } | 30 } |
| 32 | 31 |
| 33 namespace cloud_print { | 32 namespace cloud_print { |
| 34 struct CloudPrintProxyInfo; | 33 struct CloudPrintProxyInfo; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 45 // | 44 // |
| 46 // It is used to start and terminate the service process. It is also used | 45 // It is used to start and terminate the service process. It is also used |
| 47 // to send and receive IPC messages from the service process. | 46 // to send and receive IPC messages from the service process. |
| 48 // | 47 // |
| 49 // THREADING | 48 // THREADING |
| 50 // | 49 // |
| 51 // This class is accessed on the UI thread through some UI actions. It then | 50 // This class is accessed on the UI thread through some UI actions. It then |
| 52 // talks to the IPC channel on the IO thread. | 51 // talks to the IPC channel on the IO thread. |
| 53 class ServiceProcessControl : public IPC::Sender, | 52 class ServiceProcessControl : public IPC::Sender, |
| 54 public IPC::Listener, | 53 public IPC::Listener, |
| 55 public content::NotificationObserver { | 54 public UpgradeObserver { |
| 56 public: | 55 public: |
| 57 enum ServiceProcessEvent { | 56 enum ServiceProcessEvent { |
| 58 SERVICE_EVENT_INITIALIZE, | 57 SERVICE_EVENT_INITIALIZE, |
| 59 SERVICE_EVENT_ENABLED_ON_LAUNCH, | 58 SERVICE_EVENT_ENABLED_ON_LAUNCH, |
| 60 SERVICE_EVENT_ENABLE, | 59 SERVICE_EVENT_ENABLE, |
| 61 SERVICE_EVENT_DISABLE, | 60 SERVICE_EVENT_DISABLE, |
| 62 SERVICE_EVENT_DISABLE_BY_POLICY, | 61 SERVICE_EVENT_DISABLE_BY_POLICY, |
| 63 SERVICE_EVENT_LAUNCH, | 62 SERVICE_EVENT_LAUNCH, |
| 64 SERVICE_EVENT_LAUNCHED, | 63 SERVICE_EVENT_LAUNCHED, |
| 65 SERVICE_EVENT_LAUNCH_FAILED, | 64 SERVICE_EVENT_LAUNCH_FAILED, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 virtual void Disconnect(); | 106 virtual void Disconnect(); |
| 108 | 107 |
| 109 // IPC::Listener implementation. | 108 // IPC::Listener implementation. |
| 110 bool OnMessageReceived(const IPC::Message& message) override; | 109 bool OnMessageReceived(const IPC::Message& message) override; |
| 111 void OnChannelConnected(int32_t peer_pid) override; | 110 void OnChannelConnected(int32_t peer_pid) override; |
| 112 void OnChannelError() override; | 111 void OnChannelError() override; |
| 113 | 112 |
| 114 // IPC::Sender implementation | 113 // IPC::Sender implementation |
| 115 bool Send(IPC::Message* message) override; | 114 bool Send(IPC::Message* message) override; |
| 116 | 115 |
| 117 // content::NotificationObserver implementation. | 116 // UpgradeObserver implementation. |
| 118 void Observe(int type, | 117 void OnUpgradeRecommended() override; |
| 119 const content::NotificationSource& source, | |
| 120 const content::NotificationDetails& details) override; | |
| 121 | 118 |
| 122 // Send a shutdown message to the service process. IPC channel will be | 119 // Send a shutdown message to the service process. IPC channel will be |
| 123 // destroyed after calling this method. | 120 // destroyed after calling this method. |
| 124 // Return true if the message was sent. | 121 // Return true if the message was sent. |
| 125 // Virtual for testing. | 122 // Virtual for testing. |
| 126 virtual bool Shutdown(); | 123 virtual bool Shutdown(); |
| 127 | 124 |
| 128 // Send request for cloud print proxy info (enabled state, email, proxy id). | 125 // Send request for cloud print proxy info (enabled state, email, proxy id). |
| 129 // The callback gets the information when received. | 126 // The callback gets the information when received. |
| 130 // Returns true if request was sent. Callback will be called only in case of | 127 // Returns true if request was sent. Callback will be called only in case of |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 PrintersCallback printers_callback_; | 231 PrintersCallback printers_callback_; |
| 235 | 232 |
| 236 // Callback that gets invoked when a status message is received from | 233 // Callback that gets invoked when a status message is received from |
| 237 // the cloud print proxy. | 234 // the cloud print proxy. |
| 238 CloudPrintProxyInfoCallback cloud_print_info_callback_; | 235 CloudPrintProxyInfoCallback cloud_print_info_callback_; |
| 239 | 236 |
| 240 // Callback that gets invoked when a message with histograms is received from | 237 // Callback that gets invoked when a message with histograms is received from |
| 241 // the service process. | 238 // the service process. |
| 242 base::Closure histograms_callback_; | 239 base::Closure histograms_callback_; |
| 243 | 240 |
| 244 content::NotificationRegistrar registrar_; | |
| 245 | |
| 246 // Callback that gets invoked if service didn't reply in time. | 241 // Callback that gets invoked if service didn't reply in time. |
| 247 base::CancelableClosure histograms_timeout_callback_; | 242 base::CancelableClosure histograms_timeout_callback_; |
| 248 | 243 |
| 244 // Whether to start listening to upgrade detector. | |
| 245 bool enable_upgrade_observer_; | |
| 246 | |
| 249 base::WeakPtrFactory<ServiceProcessControl> weak_factory_; | 247 base::WeakPtrFactory<ServiceProcessControl> weak_factory_; |
| 250 }; | 248 }; |
|
sky
2017/06/08 18:09:52
DISALLOW... (while you are here).
weidongg
2017/06/08 18:58:07
https://engdoc.corp.google.com/eng/doc/devguide/cp
sky
2017/06/08 21:28:00
See chromium-dev discussions. I don't see this cod
weidongg
2017/06/08 22:18:25
Added. Thanks.
| |
| 251 | 249 |
| 252 #endif // CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ | 250 #endif // CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ |
| OLD | NEW |