| Index: remoting/host/it2me/it2me_confirmation_dialog_proxy.cc
|
| diff --git a/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc b/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f5f0e05245299e503999b793baf2815c9dc6ac33
|
| --- /dev/null
|
| +++ b/remoting/host/it2me/it2me_confirmation_dialog_proxy.cc
|
| @@ -0,0 +1,73 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/callback_helpers.h"
|
| +#include "base/location.h"
|
| +
|
| +namespace remoting {
|
| +
|
| +It2MeConfirmationDialogProxy::It2MeConfirmationDialogProxy(
|
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
|
| + scoped_ptr<It2MeConfirmationDialog> dialog)
|
| + : weak_factory_(this) {
|
| + core_ = new Core(ui_task_runner, caller_task_runner,
|
| + weak_factory_.GetWeakPtr(), dialog.Pass());
|
| +}
|
| +
|
| +It2MeConfirmationDialogProxy::~It2MeConfirmationDialogProxy() {}
|
| +
|
| +void It2MeConfirmationDialogProxy::Show(
|
| + const It2MeConfirmationDialog::ResultCallback& callback) {
|
| + callback_ = callback;
|
| + core_->Show();
|
| +}
|
| +
|
| +It2MeConfirmationDialogProxy::Core::Core(
|
| + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
|
| + base::WeakPtr<It2MeConfirmationDialogProxy> parent,
|
| + scoped_ptr<It2MeConfirmationDialog> dialog)
|
| + : ui_task_runner_(ui_task_runner),
|
| + caller_task_runner_(caller_task_runner),
|
| + parent_(parent),
|
| + dialog_(dialog.Pass()) {
|
| +}
|
| +
|
| +void It2MeConfirmationDialogProxy::Core::Show() {
|
| + if (!ui_task_runner_->BelongsToCurrentThread()) {
|
| + ui_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&It2MeConfirmationDialogProxy::Core::Show, this));
|
| + return;
|
| + }
|
| + dialog_->Show(
|
| + base::Bind(&It2MeConfirmationDialogProxy::Core::ReportResult, this));
|
| +}
|
| +
|
| +It2MeConfirmationDialogProxy::Core::~Core() {}
|
| +
|
| +void It2MeConfirmationDialogProxy::Core::ReportResult(
|
| + It2MeConfirmationDialog::Result result) {
|
| + if (!caller_task_runner_->BelongsToCurrentThread()) {
|
| + caller_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&It2MeConfirmationDialogProxy::Core::ReportResult, this,
|
| + result));
|
| + return;
|
| + }
|
| +
|
| + if (parent_)
|
| + parent_->ReportResult(result);
|
| +}
|
| +
|
| +void It2MeConfirmationDialogProxy::ReportResult(
|
| + It2MeConfirmationDialog::Result result) {
|
| + base::ResetAndReturn(&callback_).Run(result);
|
| +}
|
| +
|
| +} // namespace remoting
|
|
|