Commit 59a25f2b authored by Robert Liao's avatar Robert Liao Committed by Chromium LUCI CQ

Refactor the Way Clients Obtain Interfaces from the Debug Client

The Windbg Extensions API is spread across multiple interfaces, making
a template based getter more convenient than statically defined
interface getters.

BUG=1168231

Change-Id: Id9789641074b842ebcb086d386c58fffabdf104a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2637270Reviewed-by: default avatarWei Li <weili@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
Auto-Submit: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845207}
parent 7eb8b268
...@@ -20,9 +20,9 @@ HRESULT ChromeExtsCommand::Initialize(IDebugClient* debug_client, ...@@ -20,9 +20,9 @@ HRESULT ChromeExtsCommand::Initialize(IDebugClient* debug_client,
DCHECK(args); DCHECK(args);
args_ = args; args_ = args;
debug_client_ = debug_client; debug_client_ = debug_client;
HRESULT hr = debug_client_->QueryInterface(IID_PPV_ARGS(&debug_control_)); debug_control_ = GetDebugClientAs<IDebugControl>();
if (FAILED(hr)) { if (!debug_control_) {
return hr; return E_FAIL;
} }
return S_OK; return S_OK;
} }
......
...@@ -58,8 +58,14 @@ class ChromeExtsCommand { ...@@ -58,8 +58,14 @@ class ChromeExtsCommand {
HRESULT PrintErrorV(const char* format, va_list ap); HRESULT PrintErrorV(const char* format, va_list ap);
const std::string& args() const { return args_; } const std::string& args() const { return args_; }
IDebugClient* debug_client() { return debug_client_.Get(); }
IDebugControl* debug_control() { return debug_control_.Get(); } // Returns the Debug Client as T, null ComPtr<T> otherwise.
template <typename T>
ComPtr<T> GetDebugClientAs() {
ComPtr<T> target_interface;
debug_client_.As(&target_interface);
return target_interface;
}
private: private:
std::string args_; std::string args_;
......
...@@ -25,8 +25,8 @@ HRESULT HwndCommand::Execute() { ...@@ -25,8 +25,8 @@ HRESULT HwndCommand::Execute() {
// and truncate the displayed hwnds to 32-bit below. // and truncate the displayed hwnds to 32-bit below.
// See https://msdn.microsoft.com/en-us/library/aa384203.aspx // See https://msdn.microsoft.com/en-us/library/aa384203.aspx
DEBUG_VALUE value; DEBUG_VALUE value;
HRESULT hr = debug_control()->Evaluate(args().c_str(), DEBUG_VALUE_INT64, HRESULT hr = GetDebugClientAs<IDebugControl>()->Evaluate(
&value, nullptr); args().c_str(), DEBUG_VALUE_INT64, &value, nullptr);
if (FAILED(hr)) { if (FAILED(hr)) {
PrintErrorf("Unable to evaluate %s\n", args().c_str()); PrintErrorf("Unable to evaluate %s\n", args().c_str());
return hr; return hr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment