Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
Sergey Ulanov
2013/04/02 19:04:22
2013
alexeypa (please no reviews)
2013/04/03 20:26:43
Done.
| |
| 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 REMOTING_HOST_HOST_WINDOW_H_ | |
| 6 #define REMOTING_HOST_HOST_WINDOW_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/threading/non_thread_safe.h" | |
| 15 #include "remoting/host/ui_strings.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class SingleThreadTaskRunner; | |
| 19 } | |
| 20 | |
| 21 namespace remoting { | |
| 22 | |
| 23 struct UiStrings; | |
| 24 | |
| 25 // Wraps a platform-specific implementation of HostWindow::Core managing its | |
| 26 // life time. | |
| 27 class HostWindow : public base::NonThreadSafe { | |
| 28 public: | |
| 29 ~HostWindow(); | |
| 30 | |
| 31 // Creates a platform-specific instance of the continue window. | |
| 32 // |continue_callback| is called when the user clicks on the | |
| 33 // Continue button to resume the session, or dismisses the window to | |
| 34 // disconnect the session. | |
| 35 static scoped_ptr<HostWindow> CreateContinueWindow( | |
| 36 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
| 37 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
| 38 const base::Callback<void(bool)>& continue_callback, | |
| 39 const UiStrings& ui_strings); | |
| 40 | |
| 41 // Creates a platform-specific instance of the disconnect window. | |
| 42 // |disconnect_callback| is called when the user clicks on the Disconnect | |
| 43 // button to disconnect the session. | |
| 44 static scoped_ptr<HostWindow> CreateDisconnectWindow( | |
| 45 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
| 46 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
| 47 const base::Closure& disconnect_callback, | |
| 48 const std::string& username, | |
| 49 const UiStrings& ui_strings); | |
| 50 | |
| 51 // HostWindow is a base class for all platform-dependent implementation of | |
| 52 // the disconnect and continue windows. | |
| 53 class Core : public base::RefCountedThreadSafe<Core> { | |
| 54 public: | |
| 55 Core(scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | |
| 56 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
| 57 const UiStrings& ui_strings); | |
| 58 | |
| 59 void Start(); | |
| 60 void Stop(); | |
| 61 | |
| 62 protected: | |
| 63 friend class base::RefCountedThreadSafe<Core>; | |
| 64 virtual ~Core(); | |
| 65 | |
| 66 virtual void StartOnUiThread() = 0; | |
| 67 virtual void StopOnUiThread() = 0; | |
| 68 | |
| 69 const scoped_refptr<base::SingleThreadTaskRunner>& | |
| 70 caller_task_runner() const { | |
| 71 return caller_task_runner_; | |
| 72 } | |
| 73 | |
| 74 const scoped_refptr<base::SingleThreadTaskRunner>& | |
| 75 ui_task_runner() const { | |
| 76 return ui_task_runner_; | |
| 77 } | |
| 78 | |
| 79 const UiStrings& ui_strings() const { return ui_strings_; } | |
| 80 | |
| 81 private: | |
| 82 // Task runner on which public methods of this class must be called. | |
| 83 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | |
| 84 | |
| 85 // Task runner on which |window_| is created. | |
| 86 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | |
| 87 | |
| 88 // Localized strings. | |
| 89 const UiStrings ui_strings_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(Core); | |
| 92 }; | |
| 93 | |
| 94 private: | |
| 95 HostWindow(scoped_refptr<Core> core); | |
| 96 | |
| 97 scoped_refptr<Core> core_; | |
| 98 | |
| 99 DISALLOW_COPY_AND_ASSIGN(HostWindow); | |
| 100 }; | |
| 101 | |
| 102 } // namespace remoting | |
| 103 | |
| 104 #endif // REMOTING_HOST_HOST_WINDOW_H_ | |
| OLD | NEW |