OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/it2me/it2me_confirmation_dialog_proxy.h" | 5 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 11 #include "base/location.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
12 | 14 |
13 namespace remoting { | 15 namespace remoting { |
14 | 16 |
15 class It2MeConfirmationDialogProxy::Core { | 17 class It2MeConfirmationDialogProxy::Core { |
16 public: | 18 public: |
(...skipping 27 matching lines...) Expand all Loading... |
44 }; | 46 }; |
45 | 47 |
46 It2MeConfirmationDialogProxy::Core::Core( | 48 It2MeConfirmationDialogProxy::Core::Core( |
47 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 49 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
48 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
49 base::WeakPtr<It2MeConfirmationDialogProxy> parent, | 51 base::WeakPtr<It2MeConfirmationDialogProxy> parent, |
50 scoped_ptr<It2MeConfirmationDialog> dialog) | 52 scoped_ptr<It2MeConfirmationDialog> dialog) |
51 : ui_task_runner_(ui_task_runner), | 53 : ui_task_runner_(ui_task_runner), |
52 caller_task_runner_(caller_task_runner), | 54 caller_task_runner_(caller_task_runner), |
53 parent_(parent), | 55 parent_(parent), |
54 dialog_(dialog.Pass()) { | 56 dialog_(std::move(dialog)) { |
55 } | 57 } |
56 | 58 |
57 It2MeConfirmationDialogProxy::Core::~Core() { | 59 It2MeConfirmationDialogProxy::Core::~Core() { |
58 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 60 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
59 } | 61 } |
60 | 62 |
61 void It2MeConfirmationDialogProxy::Core::Show() { | 63 void It2MeConfirmationDialogProxy::Core::Show() { |
62 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 64 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
63 | 65 |
64 dialog_->Show(base::Bind(&It2MeConfirmationDialogProxy::Core::ReportResult, | 66 dialog_->Show(base::Bind(&It2MeConfirmationDialogProxy::Core::ReportResult, |
65 base::Unretained(this))); | 67 base::Unretained(this))); |
66 } | 68 } |
67 | 69 |
68 void It2MeConfirmationDialogProxy::Core::ReportResult( | 70 void It2MeConfirmationDialogProxy::Core::ReportResult( |
69 It2MeConfirmationDialog::Result result) { | 71 It2MeConfirmationDialog::Result result) { |
70 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 72 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
71 caller_task_runner_->PostTask( | 73 caller_task_runner_->PostTask( |
72 FROM_HERE, | 74 FROM_HERE, |
73 base::Bind(&It2MeConfirmationDialogProxy::ReportResult, parent_, result)); | 75 base::Bind(&It2MeConfirmationDialogProxy::ReportResult, parent_, result)); |
74 } | 76 } |
75 | 77 |
76 It2MeConfirmationDialogProxy::It2MeConfirmationDialogProxy( | 78 It2MeConfirmationDialogProxy::It2MeConfirmationDialogProxy( |
77 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 79 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
78 scoped_ptr<It2MeConfirmationDialog> dialog) | 80 scoped_ptr<It2MeConfirmationDialog> dialog) |
79 : weak_factory_(this) { | 81 : weak_factory_(this) { |
80 core_.reset(new Core(ui_task_runner, base::ThreadTaskRunnerHandle::Get(), | 82 core_.reset(new Core(ui_task_runner, base::ThreadTaskRunnerHandle::Get(), |
81 weak_factory_.GetWeakPtr(), dialog.Pass())); | 83 weak_factory_.GetWeakPtr(), std::move(dialog))); |
82 } | 84 } |
83 | 85 |
84 It2MeConfirmationDialogProxy::~It2MeConfirmationDialogProxy() { | 86 It2MeConfirmationDialogProxy::~It2MeConfirmationDialogProxy() { |
85 DCHECK(core_->caller_task_runner()->BelongsToCurrentThread()); | 87 DCHECK(core_->caller_task_runner()->BelongsToCurrentThread()); |
86 | 88 |
87 auto ui_task_runner = core_->ui_task_runner(); | 89 auto ui_task_runner = core_->ui_task_runner(); |
88 ui_task_runner->DeleteSoon(FROM_HERE, core_.release()); | 90 ui_task_runner->DeleteSoon(FROM_HERE, core_.release()); |
89 } | 91 } |
90 | 92 |
91 void It2MeConfirmationDialogProxy::Show( | 93 void It2MeConfirmationDialogProxy::Show( |
92 const It2MeConfirmationDialog::ResultCallback& callback) { | 94 const It2MeConfirmationDialog::ResultCallback& callback) { |
93 DCHECK(core_->caller_task_runner()->BelongsToCurrentThread()); | 95 DCHECK(core_->caller_task_runner()->BelongsToCurrentThread()); |
94 | 96 |
95 callback_ = callback; | 97 callback_ = callback; |
96 core_->ui_task_runner()->PostTask(FROM_HERE, | 98 core_->ui_task_runner()->PostTask(FROM_HERE, |
97 base::Bind(&Core::Show, | 99 base::Bind(&Core::Show, |
98 base::Unretained(core_.get()))); | 100 base::Unretained(core_.get()))); |
99 } | 101 } |
100 | 102 |
101 void It2MeConfirmationDialogProxy::ReportResult( | 103 void It2MeConfirmationDialogProxy::ReportResult( |
102 It2MeConfirmationDialog::Result result) { | 104 It2MeConfirmationDialog::Result result) { |
103 DCHECK(core_->caller_task_runner()->BelongsToCurrentThread()); | 105 DCHECK(core_->caller_task_runner()->BelongsToCurrentThread()); |
104 base::ResetAndReturn(&callback_).Run(result); | 106 base::ResetAndReturn(&callback_).Run(result); |
105 } | 107 } |
106 | 108 |
107 } // namespace remoting | 109 } // namespace remoting |
OLD | NEW |