summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-23 17:27:11 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-23 17:27:11 +0000
commit3fa1e6f635218c2838ad9de205bd8e32df3a9905 (patch)
tree801c6b87785c6e8e0d4ee6d3ce1e11f68a38c632 /chrome_frame
parent24ea8f46ed38cf3ddd5f465c3e6d10c7a1d2ca1f (diff)
downloadchromium_src-3fa1e6f635218c2838ad9de205bd8e32df3a9905.zip
chromium_src-3fa1e6f635218c2838ad9de205bd8e32df3a9905.tar.gz
chromium_src-3fa1e6f635218c2838ad9de205bd8e32df3a9905.tar.bz2
Log WebBrowser event method names rather than DISPID integer values for more comprehensible logs, and log the method and path received by the test web server when it handles a request. Such logging is no longer limited to debug builds.
BUG=none TEST=run any GCF test with --v=1 and watch the events fly by Review URL: http://codereview.chromium.org/9272004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118694 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/test/ie_event_sink.cc124
-rw-r--r--chrome_frame/test/ie_event_sink.h10
-rw-r--r--chrome_frame/test/test_server.cc4
3 files changed, 128 insertions, 10 deletions
diff --git a/chrome_frame/test/ie_event_sink.cc b/chrome_frame/test/ie_event_sink.cc
index 1fd9d45..dde9ebe 100644
--- a/chrome_frame/test/ie_event_sink.cc
+++ b/chrome_frame/test/ie_event_sink.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -7,6 +7,11 @@
#include <shlguid.h>
#include <shobjidl.h>
+#include <map>
+#include <utility>
+
+#include "base/lazy_instance.h"
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
@@ -18,6 +23,114 @@
using base::win::ScopedBstr;
+namespace {
+
+// A lookup table from DISPID to DWebBrowserEvents and/or DWebBrowserEvents2
+// method name.
+class DispIdNameTable {
+ public:
+ DispIdNameTable();
+ ~DispIdNameTable();
+
+ // Returns the method name corresponding to |dispid| or, if none is known,
+ // the string "DISPID |dispid|".
+ std::string Lookup(DISPID dispid) const;
+
+ private:
+ std::map<DISPID,const char*> dispid_to_name_;
+ DISALLOW_COPY_AND_ASSIGN(DispIdNameTable);
+};
+
+DispIdNameTable::DispIdNameTable() {
+ static const struct {
+ DISPID dispid;
+ const char* name;
+ } kIdToName[] = {
+ // DWebBrowserEvents
+ { 100, "BeforeNavigate" },
+ { 101, "NavigateComplete" },
+ { 102, "StatusTextChange" },
+ { 108, "ProgressChange" },
+ { 104, "DownloadComplete" },
+ { 105, "CommandStateChange" },
+ { 106, "DownloadBegin" },
+ { 107, "NewWindow" },
+ { 113, "TitleChange" },
+ { 200, "FrameBeforeNavigate" },
+ { 201, "FrameNavigateComplete" },
+ { 204, "FrameNewWindow" },
+ { 103, "Quit" },
+ { 109, "WindowMove" },
+ { 110, "WindowResize" },
+ { 111, "WindowActivate" },
+ { 112, "PropertyChange" },
+ // DWebBrowserEvents2
+ { 250, "BeforeNavigate2" },
+ { 251, "NewWindow2" },
+ { 252, "NavigateComplete2" },
+ { 259, "DocumentComplete" },
+ { 253, "OnQuit" },
+ { 254, "OnVisible" },
+ { 255, "OnToolBar" },
+ { 256, "OnMenuBar" },
+ { 257, "OnStatusBar" },
+ { 258, "OnFullScreen" },
+ { 260, "OnTheaterMode" },
+ { 262, "WindowSetResizable" },
+ { 264, "WindowSetLeft" },
+ { 265, "WindowSetTop" },
+ { 266, "WindowSetWidth" },
+ { 267, "WindowSetHeight" },
+ { 263, "WindowClosing" },
+ { 268, "ClientToHostWindow" },
+ { 269, "SetSecureLockIcon" },
+ { 270, "FileDownload" },
+ { 271, "NavigateError" },
+ { 225, "PrintTemplateInstantiation" },
+ { 226, "PrintTemplateTeardown" },
+ { 227, "UpdatePageStatus" },
+ { 272, "PrivacyImpactedStateChange" },
+ { 273, "NewWindow3" },
+ { 282, "SetPhishingFilterStatus" },
+ { 283, "WindowStateChanged" },
+ { 284, "NewProcess" },
+ { 285, "ThirdPartyUrlBlocked" },
+ { 286, "RedirectXDomainBlocked" },
+ // Present in ExDispid.h but not ExDisp.idl
+ { 114, "TitleIconChange" },
+ { 261, "OnAddressBar" },
+ { 281, "ViewUpdate" },
+ };
+ size_t index_of_duplicate = 0;
+ DISPID duplicate_dispid = 0;
+ for (size_t i = 0; i < arraysize(kIdToName); ++i) {
+ if (!dispid_to_name_.insert(std::make_pair(kIdToName[i].dispid,
+ kIdToName[i].name)).second &&
+ index_of_duplicate == 0) {
+ index_of_duplicate = i;
+ duplicate_dispid = kIdToName[i].dispid;
+ }
+ }
+ DCHECK_EQ(static_cast<size_t>(0), index_of_duplicate)
+ << "Duplicate name for DISPID " << duplicate_dispid
+ << " at kIdToName[" << index_of_duplicate << "]";
+}
+
+DispIdNameTable::~DispIdNameTable() {
+}
+
+std::string DispIdNameTable::Lookup(DISPID dispid) const {
+ std::map<DISPID,const char*>::const_iterator it =
+ dispid_to_name_.find(dispid);
+ if (it != dispid_to_name_.end())
+ return it->second;
+ return std::string("DISPID ").append(base::IntToString(dispid));
+}
+
+base::LazyInstance<DispIdNameTable> g_dispIdToName = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
namespace chrome_frame_test {
const int kDefaultWaitForIEToTerminateMs = 10 * 1000;
@@ -551,6 +664,15 @@ STDMETHODIMP_(void) IEEventSink::OnQuit() {
listener_->OnQuit();
}
+STDMETHODIMP IEEventSink::Invoke(DISPID dispid, REFIID riid, LCID lcid,
+ WORD flags, DISPPARAMS* params,
+ VARIANT* result, EXCEPINFO* except_info,
+ UINT* arg_error) {
+ VLOG(1) << __FUNCTION__ << L" event: " << g_dispIdToName.Get().Lookup(dispid);
+ return DispEventsImpl::Invoke(dispid, riid, lcid, flags, params, result,
+ except_info, arg_error);
+}
+
HRESULT IEEventSink::OnLoad(const VARIANT* param) {
DVLOG(1) << __FUNCTION__ << " " << param->bstrVal;
base::win::ScopedVariant stack_object(*param);
diff --git a/chrome_frame/test/ie_event_sink.h b/chrome_frame/test/ie_event_sink.h
index 2a0496d..d9c0e6f 100644
--- a/chrome_frame/test/ie_event_sink.h
+++ b/chrome_frame/test/ie_event_sink.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -211,19 +211,13 @@ END_SINK_MAP()
VARIANT_BOOL* cancel);
STDMETHOD_(void, OnQuit)();
-#ifndef NDEBUG
STDMETHOD(Invoke)(DISPID dispid,
REFIID riid, LCID lcid,
WORD flags,
DISPPARAMS* params,
VARIANT* result,
EXCEPINFO* except_info,
- UINT* arg_error) {
- DVLOG(1) << __FUNCTION__ << L" disp id :" << dispid;
- return DispEventsImpl::Invoke(dispid, riid, lcid, flags, params, result,
- except_info, arg_error);
- }
-#endif // _DEBUG
+ UINT* arg_error);
// IChromeFrame callbacks
HRESULT OnLoad(const VARIANT* param);
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index cddcd2c..4b7b2a2 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -277,6 +277,8 @@ void HTTPTestServer::DidRead(net::ListenSocket* socket,
std::string str(data, len);
connection->r_.OnDataReceived(str);
if (connection->r_.AllContentReceived()) {
+ VLOG(1) << __FUNCTION__ << ": " << connection->r_.method() << " "
+ << connection->r_.path();
std::wstring path = UTF8ToWide(connection->r_.path());
if (LowerCaseEqualsASCII(connection->r_.method(), "post"))
this->Post(connection, path, connection->r_);