OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_SERVICE_REMOTING_CHROMOTING_HOST_MANAGER_H_ |
| 6 #define CHROME_SERVICE_REMOTING_CHROMOTING_HOST_MANAGER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/ref_counted.h" |
| 11 #include "base/scoped_ptr.h" |
| 12 #include "remoting/host/chromoting_host.h" |
| 13 #include "remoting/host/chromoting_host_context.h" |
| 14 #include "remoting/host/host_config.h" |
| 15 |
| 16 namespace base { |
| 17 class MessageLoopProxy; |
| 18 } // namespace base |
| 19 |
| 20 namespace remoting { |
| 21 |
| 22 struct ChromotingHostInfo; |
| 23 |
| 24 // ChromotingHostManager manages chromoting host. It loads config and updates |
| 25 // config when necessary, and starts and stops the chromoting host. |
| 26 class ChromotingHostManager |
| 27 : public base::RefCountedThreadSafe<ChromotingHostManager> { |
| 28 public: |
| 29 |
| 30 // Interface for observer that is notified about the host being |
| 31 // enabled/disabled. Observer is specified in the constructor. |
| 32 class Observer { |
| 33 public: |
| 34 virtual ~Observer() {} |
| 35 virtual void OnChromotingHostEnabled() {} |
| 36 virtual void OnChromotingHostDisabled() {} |
| 37 }; |
| 38 |
| 39 // Caller keeps ownership of |observer|. |observer| must not be |
| 40 // destroyed while this object exists. |
| 41 ChromotingHostManager(Observer* observer); |
| 42 |
| 43 void Initialize(base::MessageLoopProxy* file_message_loop); |
| 44 void Teardown(); |
| 45 |
| 46 // Return the reference to the chromoting host only if it has started. |
| 47 remoting::ChromotingHost* GetChromotingHost() { return chromoting_host_; } |
| 48 |
| 49 // Updates credentials used for XMPP connection. |
| 50 void SetCredentials(const std::string& login, const std::string& token); |
| 51 |
| 52 bool IsEnabled(); |
| 53 |
| 54 // Start running the chromoting host asynchronously. |
| 55 void Enable(); |
| 56 |
| 57 // Stop chromoting host. The shutdown process will happen asynchronously. |
| 58 void Disable(); |
| 59 |
| 60 void GetHostInfo(ChromotingHostInfo* host_info); |
| 61 |
| 62 private: |
| 63 bool IsConfigInitialized(); |
| 64 void InitializeConfig(); |
| 65 |
| 66 void SetEnabled(bool enabled); |
| 67 void Start(); |
| 68 void Stop(); |
| 69 |
| 70 void OnShutdown(); |
| 71 |
| 72 Observer* observer_; |
| 73 |
| 74 scoped_refptr<remoting::MutableHostConfig> chromoting_config_; |
| 75 scoped_ptr<remoting::ChromotingHostContext> chromoting_context_; |
| 76 scoped_refptr<remoting::ChromotingHost> chromoting_host_; |
| 77 }; |
| 78 |
| 79 } // namespace remoting |
| 80 |
| 81 #endif // CHROME_SERVICE_REMOTING_CHROMOTING_HOST_MANAGER_H_ |
OLD | NEW |