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