Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: remoting/host/host_window_proxy.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/host_window_proxy.h ('k') | remoting/host/input_injector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "remoting/host/host_window_proxy.h" 5 #include "remoting/host/host_window_proxy.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "remoting/host/client_session_control.h" 14 #include "remoting/host/client_session_control.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 // Runs an instance of |HostWindow| on the |ui_task_runner_| thread. 19 // Runs an instance of |HostWindow| on the |ui_task_runner_| thread.
20 class HostWindowProxy::Core 20 class HostWindowProxy::Core
21 : public base::RefCountedThreadSafe<Core>, 21 : public base::RefCountedThreadSafe<Core>,
22 public ClientSessionControl { 22 public ClientSessionControl {
23 public: 23 public:
24 Core(scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 24 Core(scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
25 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 25 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
26 scoped_ptr<HostWindow> host_window); 26 std::unique_ptr<HostWindow> host_window);
27 27
28 // Starts |host_window_| on the |ui_task_runner_| thread. 28 // Starts |host_window_| on the |ui_task_runner_| thread.
29 void Start(const base::WeakPtr<ClientSessionControl>& client_session_control); 29 void Start(const base::WeakPtr<ClientSessionControl>& client_session_control);
30 30
31 // Destroys |host_window_| on the |ui_task_runner_| thread. 31 // Destroys |host_window_| on the |ui_task_runner_| thread.
32 void Stop(); 32 void Stop();
33 33
34 private: 34 private:
35 friend class base::RefCountedThreadSafe<Core>; 35 friend class base::RefCountedThreadSafe<Core>;
36 ~Core() override; 36 ~Core() override;
(...skipping 15 matching lines...) Expand all
52 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 52 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
53 53
54 // Stores the client's JID so it can be read on the |ui_task_runner_| thread. 54 // Stores the client's JID so it can be read on the |ui_task_runner_| thread.
55 std::string client_jid_; 55 std::string client_jid_;
56 56
57 // Used to notify the caller about the local user's actions on 57 // Used to notify the caller about the local user's actions on
58 // the |caller_task_runner| thread. 58 // the |caller_task_runner| thread.
59 base::WeakPtr<ClientSessionControl> client_session_control_; 59 base::WeakPtr<ClientSessionControl> client_session_control_;
60 60
61 // The wrapped |HostWindow| instance running on the |ui_task_runner_| thread. 61 // The wrapped |HostWindow| instance running on the |ui_task_runner_| thread.
62 scoped_ptr<HostWindow> host_window_; 62 std::unique_ptr<HostWindow> host_window_;
63 63
64 // Used to create the control pointer passed to |host_window_|. 64 // Used to create the control pointer passed to |host_window_|.
65 base::WeakPtrFactory<ClientSessionControl> weak_factory_; 65 base::WeakPtrFactory<ClientSessionControl> weak_factory_;
66 66
67 DISALLOW_COPY_AND_ASSIGN(Core); 67 DISALLOW_COPY_AND_ASSIGN(Core);
68 }; 68 };
69 69
70 HostWindowProxy::HostWindowProxy( 70 HostWindowProxy::HostWindowProxy(
71 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 71 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
73 scoped_ptr<HostWindow> host_window) { 73 std::unique_ptr<HostWindow> host_window) {
74 DCHECK(caller_task_runner->BelongsToCurrentThread()); 74 DCHECK(caller_task_runner->BelongsToCurrentThread());
75 75
76 // Detach |host_window| from the calling thread so that |Core| could run it on 76 // Detach |host_window| from the calling thread so that |Core| could run it on
77 // the |ui_task_runner_| thread. 77 // the |ui_task_runner_| thread.
78 host_window->DetachFromThread(); 78 host_window->DetachFromThread();
79 core_ = new Core(caller_task_runner, ui_task_runner, std::move(host_window)); 79 core_ = new Core(caller_task_runner, ui_task_runner, std::move(host_window));
80 } 80 }
81 81
82 HostWindowProxy::~HostWindowProxy() { 82 HostWindowProxy::~HostWindowProxy() {
83 DCHECK(CalledOnValidThread()); 83 DCHECK(CalledOnValidThread());
84 84
85 core_->Stop(); 85 core_->Stop();
86 } 86 }
87 87
88 void HostWindowProxy::Start( 88 void HostWindowProxy::Start(
89 const base::WeakPtr<ClientSessionControl>& client_session_control) { 89 const base::WeakPtr<ClientSessionControl>& client_session_control) {
90 DCHECK(CalledOnValidThread()); 90 DCHECK(CalledOnValidThread());
91 91
92 core_->Start(client_session_control); 92 core_->Start(client_session_control);
93 } 93 }
94 94
95 HostWindowProxy::Core::Core( 95 HostWindowProxy::Core::Core(
96 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 96 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
97 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 97 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
98 scoped_ptr<HostWindow> host_window) 98 std::unique_ptr<HostWindow> host_window)
99 : caller_task_runner_(caller_task_runner), 99 : caller_task_runner_(caller_task_runner),
100 ui_task_runner_(ui_task_runner), 100 ui_task_runner_(ui_task_runner),
101 host_window_(std::move(host_window)), 101 host_window_(std::move(host_window)),
102 weak_factory_(this) { 102 weak_factory_(this) {
103 DCHECK(caller_task_runner->BelongsToCurrentThread()); 103 DCHECK(caller_task_runner->BelongsToCurrentThread());
104 } 104 }
105 105
106 void HostWindowProxy::Core::Start( 106 void HostWindowProxy::Core::Start(
107 const base::WeakPtr<ClientSessionControl>& client_session_control) { 107 const base::WeakPtr<ClientSessionControl>& client_session_control) {
108 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 108 DCHECK(caller_task_runner_->BelongsToCurrentThread());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 caller_task_runner_->PostTask( 173 caller_task_runner_->PostTask(
174 FROM_HERE, base::Bind(&Core::SetDisableInputs, this, disable_inputs)); 174 FROM_HERE, base::Bind(&Core::SetDisableInputs, this, disable_inputs));
175 return; 175 return;
176 } 176 }
177 177
178 if (client_session_control_.get()) 178 if (client_session_control_.get())
179 client_session_control_->SetDisableInputs(disable_inputs); 179 client_session_control_->SetDisableInputs(disable_inputs);
180 } 180 }
181 181
182 } // namespace remoting 182 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_window_proxy.h ('k') | remoting/host/input_injector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698