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