| OLD | NEW |
| 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 "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/thread.h" | 12 #include "base/thread.h" |
| 13 #include "base/waitable_event.h" | 13 #include "base/waitable_event.h" |
| 14 #include "chrome/service/cloud_print/cloud_print_proxy.h" |
| 14 #include "chrome/service/remoting/remoting_directory_service.h" | 15 #include "chrome/service/remoting/remoting_directory_service.h" |
| 15 | 16 |
| 16 class CloudPrintProxy; | |
| 17 class JsonPrefStore; | 17 class JsonPrefStore; |
| 18 class ServiceIPCServer; | 18 class ServiceIPCServer; |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class NetworkChangeNotifier; | 21 class NetworkChangeNotifier; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace remoting { | 24 namespace remoting { |
| 25 class ChromotingHost; | 25 class ChromotingHost; |
| 26 class ChromotingHostContext; | 26 class ChromotingHostContext; |
| 27 class HostKeyPair; | 27 class HostKeyPair; |
| 28 class JsonHostConfig; | 28 class JsonHostConfig; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // The ServiceProcess does not inherit from ChildProcess because this | 31 // The ServiceProcess does not inherit from ChildProcess because this |
| 32 // process can live independently of the browser process. | 32 // process can live independently of the browser process. |
| 33 class ServiceProcess : public RemotingDirectoryService::Client { | 33 class ServiceProcess : public RemotingDirectoryService::Client, |
| 34 public CloudPrintProxy::Client { |
| 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. |
| 39 bool Initialize(MessageLoop* message_loop); | 40 bool Initialize(MessageLoop* message_loop); |
| 40 bool Teardown(); | 41 bool Teardown(); |
| 41 // TODO(sanjeevr): Change various parts of the code such as | 42 // TODO(sanjeevr): Change various parts of the code such as |
| 42 // net::ProxyService::CreateSystemProxyConfigService to take in | 43 // net::ProxyService::CreateSystemProxyConfigService to take in |
| 43 // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can | 44 // MessageLoopProxy* instead of MessageLoop*. When we have done that, we can |
| (...skipping 22 matching lines...) Expand all Loading... |
| 66 // thread shutting down. | 67 // thread shutting down. |
| 67 base::WaitableEvent* shutdown_event() { | 68 base::WaitableEvent* shutdown_event() { |
| 68 return &shutdown_event_; | 69 return &shutdown_event_; |
| 69 } | 70 } |
| 70 | 71 |
| 71 // Shutdown the service process. This is likely triggered by a IPC message. | 72 // Shutdown the service process. This is likely triggered by a IPC message. |
| 72 void Shutdown(); | 73 void Shutdown(); |
| 73 | 74 |
| 74 CloudPrintProxy* GetCloudPrintProxy(); | 75 CloudPrintProxy* GetCloudPrintProxy(); |
| 75 | 76 |
| 77 // CloudPrintProxy::Client implementation. |
| 78 virtual void OnCloudPrintProxyEnabled(); |
| 79 virtual void OnCloudPrintProxyDisabled(); |
| 80 |
| 76 #if defined(ENABLE_REMOTING) | 81 #if defined(ENABLE_REMOTING) |
| 77 // Return the reference to the chromoting host only if it has started. | 82 // Return the reference to the chromoting host only if it has started. |
| 78 remoting::ChromotingHost* GetChromotingHost() { return chromoting_host_; } | 83 remoting::ChromotingHost* GetChromotingHost() { return chromoting_host_; } |
| 79 | 84 |
| 80 // Enable chromoting host with the tokens. | 85 // Enable chromoting host with the tokens. |
| 81 // Return true if successful. | 86 // Return true if successful. |
| 82 bool EnableChromotingHostWithTokens(const std::string& login, | 87 bool EnableChromotingHostWithTokens(const std::string& login, |
| 83 const std::string& remoting_token, | 88 const std::string& remoting_token, |
| 84 const std::string& talk_token); | 89 const std::string& talk_token); |
| 85 | 90 |
| 86 // Start running the chromoting host asynchronously. | 91 // Start running the chromoting host asynchronously. |
| 87 // Return true if chromoting host has started. | 92 // Return true if chromoting host has started. |
| 88 bool StartChromotingHost(); | 93 bool StartChromotingHost(); |
| 89 | 94 |
| 90 // Shutdown chromoting host. Return true if chromoting host was shutdown. | 95 // Shutdown chromoting host. Return true if chromoting host was shutdown. |
| 91 // The shutdown process will happen asynchronously. | 96 // The shutdown process will happen asynchronously. |
| 92 bool ShutdownChromotingHost(); | 97 bool ShutdownChromotingHost(); |
| 93 | 98 |
| 94 // RemotingDirectoryService::Client implementation. | 99 // RemotingDirectoryService::Client implementation. |
| 95 virtual void OnRemotingHostAdded(); | 100 virtual void OnRemotingHostAdded(); |
| 96 virtual void OnRemotingDirectoryError(); | 101 virtual void OnRemotingDirectoryError(); |
| 97 #endif | 102 #endif |
| 98 | 103 |
| 99 private: | 104 private: |
| 105 // Called exactly ONCE per process instance for each service that gets |
| 106 // enabled in this process. |
| 107 void OnServiceEnabled(); |
| 108 // Called exactly ONCE per process instance for each service that gets |
| 109 // disabled in this process (note that shutdown != disabled). |
| 110 void OnServiceDisabled(); |
| 111 |
| 112 bool AddServiceProcessToAutoStart(); |
| 113 bool RemoveServiceProcessFromAutoStart(); |
| 114 |
| 100 #if defined(ENABLE_REMOTING) | 115 #if defined(ENABLE_REMOTING) |
| 101 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromoting); | 116 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromoting); |
| 102 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); | 117 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); |
| 103 | 118 |
| 104 // Save authenication token to the json config file. | 119 // Save authenication token to the json config file. |
| 105 void SaveChromotingConfig( | 120 void SaveChromotingConfig( |
| 106 const std::string& login, | 121 const std::string& login, |
| 107 const std::string& token, | 122 const std::string& token, |
| 108 const std::string& host_id, | 123 const std::string& host_id, |
| 109 const std::string& host_name, | 124 const std::string& host_name, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 136 std::string remoting_token_; | 151 std::string remoting_token_; |
| 137 std::string talk_token_; | 152 std::string talk_token_; |
| 138 #endif | 153 #endif |
| 139 | 154 |
| 140 // An event that will be signalled when we shutdown. | 155 // An event that will be signalled when we shutdown. |
| 141 base::WaitableEvent shutdown_event_; | 156 base::WaitableEvent shutdown_event_; |
| 142 | 157 |
| 143 // Pointer to the main message loop that host this object. | 158 // Pointer to the main message loop that host this object. |
| 144 MessageLoop* main_message_loop_; | 159 MessageLoop* main_message_loop_; |
| 145 | 160 |
| 161 // Count of currently enabled services in this process. |
| 162 int enabled_services_; |
| 163 |
| 146 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); | 164 DISALLOW_COPY_AND_ASSIGN(ServiceProcess); |
| 147 }; | 165 }; |
| 148 | 166 |
| 149 extern ServiceProcess* g_service_process; | 167 extern ServiceProcess* g_service_process; |
| 150 | 168 |
| 151 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ | 169 #endif // CHROME_SERVICE_SERVICE_PROCESS_H_ |
| OLD | NEW |