summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 09:26:51 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 09:26:51 +0000
commite8cb11fd2839d912f73a97621898c1397cd7ef40 (patch)
tree307a74b44abe7ae2e2a633104ae1c692bc448610 /ui/views
parente18572dbc07df93a8890027734e46be4f1bf8bad (diff)
downloadchromium_src-e8cb11fd2839d912f73a97621898c1397cd7ef40.zip
chromium_src-e8cb11fd2839d912f73a97621898c1397cd7ef40.tar.gz
chromium_src-e8cb11fd2839d912f73a97621898c1397cd7ef40.tar.bz2
Keyboard shortcut to log views, layers, windows
Needed to troubleshoot end-user UI lockups on Chrome OS Ash. BUG=196626 TEST=manual, hit Ctrl-Alt-Shift-U and see more info in the logs TBR=sky@chromium.org for logging-only changes in ui/* Review URL: https://chromiumcodereview.appspot.com/12494011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188561 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/debug_utils.cc80
-rw-r--r--ui/views/debug_utils.h4
2 files changed, 40 insertions, 44 deletions
diff --git a/ui/views/debug_utils.cc b/ui/views/debug_utils.cc
index 8259d62..adeadd6 100644
--- a/ui/views/debug_utils.cc
+++ b/ui/views/debug_utils.cc
@@ -4,72 +4,72 @@
#include "ui/views/debug_utils.h"
+#include <iostream>
+
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "ui/views/view.h"
-#ifndef NDEBUG
-#include <iostream>
-#endif
-
-#ifndef NDEBUG
-
namespace views {
namespace {
-void PrintViewHierarchyImp(const View* view, int indent) {
- std::wostringstream buf;
+void PrintViewHierarchyImp(const View* view,
+ int indent,
+ std::wostringstream* out) {
int ind = indent;
while (ind-- > 0)
- buf << L' ';
- buf << UTF8ToWide(view->GetClassName());
- buf << L' ';
- buf << view->id();
- buf << L' ';
- buf << view->x() << L"," << view->y() << L",";
- buf << view->bounds().right() << L"," << view->bounds().bottom();
- buf << L' ';
- buf << view;
-
- DVLOG(1) << buf.str();
- std::cout << buf.str() << std::endl;
+ *out << L' ';
+ *out << UTF8ToWide(view->GetClassName());
+ *out << L' ';
+ *out << view->id();
+ *out << L' ';
+ *out << view->x() << L"," << view->y() << L",";
+ *out << view->bounds().right() << L"," << view->bounds().bottom();
+ *out << L' ';
+ *out << view;
+ *out << L'\n';
for (int i = 0, count = view->child_count(); i < count; ++i)
- PrintViewHierarchyImp(view->child_at(i), indent + 2);
+ PrintViewHierarchyImp(view->child_at(i), indent + 2, out);
}
-void PrintFocusHierarchyImp(const View* view, int indent) {
- std::wostringstream buf;
+void PrintFocusHierarchyImp(const View* view,
+ int indent,
+ std::wostringstream* out) {
int ind = indent;
while (ind-- > 0)
- buf << L' ';
- buf << UTF8ToWide(view->GetClassName());
- buf << L' ';
- buf << view->id();
- buf << L' ';
- buf << view->GetClassName().c_str();
- buf << L' ';
- buf << view;
-
- DVLOG(1) << buf.str();
- std::cout << buf.str() << std::endl;
+ *out << L' ';
+ *out << UTF8ToWide(view->GetClassName());
+ *out << L' ';
+ *out << view->id();
+ *out << L' ';
+ *out << view->GetClassName().c_str();
+ *out << L' ';
+ *out << view;
+ *out << L'\n';
if (view->child_count() > 0)
- PrintFocusHierarchyImp(view->child_at(0), indent + 2);
+ PrintFocusHierarchyImp(view->child_at(0), indent + 2, out);
const View* next_focusable = view->GetNextFocusableView();
if (next_focusable)
- PrintFocusHierarchyImp(next_focusable, indent);
+ PrintFocusHierarchyImp(next_focusable, indent, out);
}
} // namespace
void PrintViewHierarchy(const View* view) {
- PrintViewHierarchyImp(view, 0);
+ std::wostringstream out;
+ out << L"View hierarchy:\n";
+ PrintViewHierarchyImp(view, 0, &out);
+ // Error so users in the field can generate and upload logs.
+ LOG(ERROR) << out.str();
}
void PrintFocusHierarchy(const View* view) {
- PrintFocusHierarchyImp(view, 0);
+ std::wostringstream out;
+ out << L"Focus hierarchy:\n";
+ PrintFocusHierarchyImp(view, 0, &out);
+ // Error so users in the field can generate and upload logs.
+ LOG(ERROR) << out.str();
}
} // namespace views
-
-#endif // NDEBUG
diff --git a/ui/views/debug_utils.h b/ui/views/debug_utils.h
index 2f574a1..feb4aaa 100644
--- a/ui/views/debug_utils.h
+++ b/ui/views/debug_utils.h
@@ -11,16 +11,12 @@ namespace views {
class View;
-#ifndef NDEBUG
-
// Log the view hierarchy.
VIEWS_EXPORT void PrintViewHierarchy(const View* view);
// Log the focus traversal hierarchy.
VIEWS_EXPORT void PrintFocusHierarchy(const View* view);
-#endif // NDEBUG
-
} // namespace views
#endif // UI_VIEWS_DEBUG_UTILS_H_