summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webdevtoolsagent_impl.cc
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 09:21:32 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 09:21:32 +0000
commitd6ee9e14d95013491f7f997644ff1daa80f0cbd7 (patch)
tree5c513ac7ae14b5291b2efdd9da2b46396a554671 /webkit/glue/webdevtoolsagent_impl.cc
parent7844fc5edc61e4e90509f90bf0ee0cb110889ca9 (diff)
downloadchromium_src-d6ee9e14d95013491f7f997644ff1daa80f0cbd7.zip
chromium_src-d6ee9e14d95013491f7f997644ff1daa80f0cbd7.tar.gz
chromium_src-d6ee9e14d95013491f7f997644ff1daa80f0cbd7.tar.bz2
DevTools: add basic console support.
Review URL: http://codereview.chromium.org/62050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13240 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webdevtoolsagent_impl.cc')
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index 690858c..5a4c4b4 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -35,6 +35,9 @@ using WebCore::Page;
using WebCore::ScriptValue;
using WebCore::String;
+// Maximum size of the console message cache.
+static const size_t kMaxConsoleMessages = 200;
+
WebDevToolsAgentImpl::WebDevToolsAgentImpl(
WebViewImpl* web_view_impl,
WebDevToolsAgentDelegate* delegate)
@@ -69,6 +72,16 @@ void WebDevToolsAgentImpl::Attach() {
dom_agent_impl_->SetDocument(doc, true);
net_agent_impl_->SetDocument(doc);
}
+
+ // Populate console.
+ for (Vector<ConsoleMessage>::iterator it = console_log_.begin();
+ it != console_log_.end(); ++it) {
+ tools_agent_delegate_stub_->AddMessageToConsole(
+ it->message,
+ it->source_id,
+ it->line_no);
+ }
+
attached_ = true;
}
@@ -114,6 +127,24 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame(
webview->GetMainFrame() == frame);
}
+void WebDevToolsAgentImpl::AddMessageToConsole(
+ const String& message,
+ const String& source_id,
+ unsigned int line_no) {
+ ConsoleMessage cm(message, source_id, line_no);
+ console_log_.append(cm);
+ if (console_log_.size() >= kMaxConsoleMessages) {
+ // Batch shifts to save ticks.
+ console_log_.remove(0, kMaxConsoleMessages / 5);
+ }
+ if (attached_) {
+ tools_agent_delegate_stub_->AddMessageToConsole(
+ message,
+ source_id,
+ line_no);
+ }
+}
+
void WebDevToolsAgentImpl::HighlightDOMNode(int node_id) {
if (!attached_) {
return;
@@ -159,6 +190,10 @@ void WebDevToolsAgentImpl::ExecuteUtilityFunction(
result);
}
+void WebDevToolsAgentImpl::ClearConsoleMessages() {
+ console_log_.clear();
+}
+
void WebDevToolsAgentImpl::DispatchMessageFromClient(
const std::string& raw_msg) {
OwnPtr<ListValue> message(