From ac0b52d6461e27220a40137697c8d5ba245797b7 Mon Sep 17 00:00:00 2001 From: Bill Tutt Date: Mon, 4 May 2015 18:52:34 -0400 Subject: [PATCH] Return Async task for GetSource/GetText based on review. --- CefSharp.Core/Internals/CefFrameWrapper.cpp | 14 ++++++++------ CefSharp.Core/Internals/CefFrameWrapper.h | 4 ++-- CefSharp/IFrame.cs | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CefSharp.Core/Internals/CefFrameWrapper.cpp b/CefSharp.Core/Internals/CefFrameWrapper.cpp index 76573460f..55345a738 100644 --- a/CefSharp.Core/Internals/CefFrameWrapper.cpp +++ b/CefSharp.Core/Internals/CefFrameWrapper.cpp @@ -95,10 +95,11 @@ void CefFrameWrapper::ViewSource() // visitor. /// /*--cef()--*/ -void CefFrameWrapper::GetSource(IStringVisitor^ visitor) +Task^ CefFrameWrapper::GetSourceAsync() { - auto stringVisitor = new StringVisitor(visitor); - _frame->GetSource(stringVisitor); + auto taskStringVisitor = gcnew TaskStringVisitor(); + _frame->GetSource(new StringVisitor(taskStringVisitor)); + return taskStringVisitor->Task; } /// @@ -106,10 +107,11 @@ void CefFrameWrapper::GetSource(IStringVisitor^ visitor) // visitor. /// /*--cef()--*/ -void CefFrameWrapper::GetText(IStringVisitor^ visitor) +Task^ CefFrameWrapper::GetTextAsync() { - auto stringVisitor = new StringVisitor(visitor); - _frame->GetText(stringVisitor); + auto taskStringVisitor = gcnew TaskStringVisitor(); + _frame->GetText(new StringVisitor(taskStringVisitor)); + return taskStringVisitor->Task; } // TODO: Do we need this? diff --git a/CefSharp.Core/Internals/CefFrameWrapper.h b/CefSharp.Core/Internals/CefFrameWrapper.h index a96c60f4c..05d123347 100644 --- a/CefSharp.Core/Internals/CefFrameWrapper.h +++ b/CefSharp.Core/Internals/CefFrameWrapper.h @@ -94,14 +94,14 @@ namespace CefSharp // visitor. /// /*--cef()--*/ - virtual void GetSource(IStringVisitor^ visitor); + virtual Task^ GetSourceAsync(); /// // Retrieve this frame's display text as a string sent to the specified // visitor. /// /*--cef()--*/ - virtual void GetText(IStringVisitor^ visitor); + virtual Task^ GetTextAsync(); // TODO: Do we need this? /// diff --git a/CefSharp/IFrame.cs b/CefSharp/IFrame.cs index bc9ecc3ca..59b581ba4 100644 --- a/CefSharp/IFrame.cs +++ b/CefSharp/IFrame.cs @@ -72,14 +72,14 @@ namespace CefSharp // visitor. /// /*--cef()--*/ - void GetSource(IStringVisitor visitor); + Task GetSourceAsync(); /// // Retrieve this frame's display text as a string sent to the specified // visitor. /// /*--cef()--*/ - void GetText(IStringVisitor visitor); + Task GetTextAsync(); // TODO: Expose a public constructor to CefRequestWrapper maybe? ///