summaryrefslogtreecommitdiffstats
path: root/chrome/browser/debugger
diff options
context:
space:
mode:
authorIain Merrick <husky@google.com>2010-11-01 12:19:54 +0000
committerIain Merrick <husky@google.com>2010-11-03 10:21:10 +0000
commit731df977c0511bca2206b5f333555b1205ff1f43 (patch)
tree0e750b949b3f00a1ac11fda25d3c2de512f2b465 /chrome/browser/debugger
parent5add15e10e7bb80512f2c597ca57221314abe577 (diff)
downloadexternal_chromium-731df977c0511bca2206b5f333555b1205ff1f43.zip
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.gz
external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.bz2
Merge Chromium at r63472 : Initial merge by git.
Change-Id: Ifb9ee821af006a5f2211e81471be93ae440a1f5a
Diffstat (limited to 'chrome/browser/debugger')
-rw-r--r--chrome/browser/debugger/debugger_remote_service.cc6
-rw-r--r--chrome/browser/debugger/devtools_http_protocol_handler.cc46
-rw-r--r--chrome/browser/debugger/devtools_manager.cc53
-rw-r--r--chrome/browser/debugger/devtools_manager.h4
-rw-r--r--chrome/browser/debugger/devtools_netlog_observer.cc133
-rw-r--r--chrome/browser/debugger/devtools_netlog_observer.h57
-rw-r--r--chrome/browser/debugger/devtools_protocol_handler.cc24
-rw-r--r--chrome/browser/debugger/devtools_remote_listen_socket_unittest.cc18
-rw-r--r--chrome/browser/debugger/devtools_remote_message.cc10
-rw-r--r--chrome/browser/debugger/devtools_remote_message.h8
-rw-r--r--chrome/browser/debugger/devtools_sanity_unittest.cc9
-rw-r--r--chrome/browser/debugger/devtools_window.cc40
-rw-r--r--chrome/browser/debugger/devtools_window.h1
-rw-r--r--chrome/browser/debugger/extension_ports_remote_service.cc35
-rw-r--r--chrome/browser/debugger/extension_ports_remote_service.h4
-rw-r--r--chrome/browser/debugger/inspectable_tab_proxy.cc16
-rw-r--r--chrome/browser/debugger/inspectable_tab_proxy.h14
17 files changed, 364 insertions, 114 deletions
diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc
index 4c3341b..3d102d5 100644
--- a/chrome/browser/debugger/debugger_remote_service.cc
+++ b/chrome/browser/debugger/debugger_remote_service.cc
@@ -331,9 +331,7 @@ bool DebuggerRemoteService::DispatchEvaluateJavascript(
}
std::string javascript;
content->GetString(kDataKey, &javascript);
- render_view_host->Send(
- new ViewMsg_ScriptEvalRequest(render_view_host->routing_id(),
- L"",
- UTF8ToWide(javascript)));
+ render_view_host->ExecuteJavascriptInWebFrame(std::wstring(),
+ UTF8ToWide(javascript));
return false;
}
diff --git a/chrome/browser/debugger/devtools_http_protocol_handler.cc b/chrome/browser/debugger/devtools_http_protocol_handler.cc
index 4ab1a79..5f01335 100644
--- a/chrome/browser/debugger/devtools_http_protocol_handler.cc
+++ b/chrome/browser/debugger/devtools_http_protocol_handler.cc
@@ -12,7 +12,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
-#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/browser_thread.h"
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/profile.h"
@@ -40,8 +40,8 @@ class DevToolsClientHostImpl : public DevToolsClientHost {
// DevToolsClientHost interface
virtual void InspectedTabClosing() {
- ChromeThread::PostTask(
- ChromeThread::IO,
+ BrowserThread::PostTask(
+ BrowserThread::IO,
FROM_HERE,
NewRunnableMethod(socket_,
&HttpListenSocket::Close));
@@ -74,14 +74,14 @@ DevToolsHttpProtocolHandler::~DevToolsHttpProtocolHandler() {
}
void DevToolsHttpProtocolHandler::Start() {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &DevToolsHttpProtocolHandler::Init));
}
void DevToolsHttpProtocolHandler::Stop() {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &DevToolsHttpProtocolHandler::Teardown));
}
@@ -90,8 +90,8 @@ void DevToolsHttpProtocolHandler::OnHttpRequest(
const HttpServerRequestInfo& info) {
if (info.path == "" || info.path == "/") {
// Pages discovery request.
- ChromeThread::PostTask(
- ChromeThread::UI,
+ BrowserThread::PostTask(
+ BrowserThread::UI,
FROM_HERE,
NewRunnableMethod(this,
&DevToolsHttpProtocolHandler::OnHttpRequestUI,
@@ -117,8 +117,8 @@ void DevToolsHttpProtocolHandler::OnHttpRequest(
void DevToolsHttpProtocolHandler::OnWebSocketRequest(
HttpListenSocket* socket,
const HttpServerRequestInfo& request) {
- ChromeThread::PostTask(
- ChromeThread::UI,
+ BrowserThread::PostTask(
+ BrowserThread::UI,
FROM_HERE,
NewRunnableMethod(
this,
@@ -129,8 +129,8 @@ void DevToolsHttpProtocolHandler::OnWebSocketRequest(
void DevToolsHttpProtocolHandler::OnWebSocketMessage(HttpListenSocket* socket,
const std::string& data) {
- ChromeThread::PostTask(
- ChromeThread::UI,
+ BrowserThread::PostTask(
+ BrowserThread::UI,
FROM_HERE,
NewRunnableMethod(
this,
@@ -154,8 +154,8 @@ void DevToolsHttpProtocolHandler::OnClose(HttpListenSocket* socket) {
socket_to_requests_io_.erase(socket);
}
- ChromeThread::PostTask(
- ChromeThread::UI,
+ BrowserThread::PostTask(
+ BrowserThread::UI,
FROM_HERE,
NewRunnableMethod(
this,
@@ -367,8 +367,8 @@ void DevToolsHttpProtocolHandler::RequestCompleted(URLRequest* request) {
void DevToolsHttpProtocolHandler::Send200(HttpListenSocket* socket,
const std::string& data,
const std::string& mime_type) {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(socket,
&HttpListenSocket::Send200,
data,
@@ -376,16 +376,16 @@ void DevToolsHttpProtocolHandler::Send200(HttpListenSocket* socket,
}
void DevToolsHttpProtocolHandler::Send404(HttpListenSocket* socket) {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(socket,
&HttpListenSocket::Send404));
}
void DevToolsHttpProtocolHandler::Send500(HttpListenSocket* socket,
const std::string& message) {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(socket,
&HttpListenSocket::Send500,
message));
@@ -394,8 +394,8 @@ void DevToolsHttpProtocolHandler::Send500(HttpListenSocket* socket,
void DevToolsHttpProtocolHandler::AcceptWebSocket(
HttpListenSocket* socket,
const HttpServerRequestInfo& request) {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(socket,
&HttpListenSocket::AcceptWebSocket,
request));
diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc
index 5116d85..e141baf 100644
--- a/chrome/browser/debugger/devtools_manager.cc
+++ b/chrome/browser/debugger/devtools_manager.cc
@@ -11,8 +11,10 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browsing_instance.h"
#include "chrome/browser/child_process_security_policy.h"
-#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/debugger/devtools_client_host.h"
+#include "chrome/browser/debugger/devtools_netlog_observer.h"
+#include "chrome/browser/debugger/devtools_window.h"
+#include "chrome/browser/io_thread.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -145,7 +147,8 @@ void DevToolsManager::ToggleDevToolsWindow(
void DevToolsManager::RuntimePropertyChanged(RenderViewHost* inspected_rvh,
const std::string& name,
const std::string& value) {
- RuntimePropertiesMap::iterator it = runtime_properties_map_.find(inspected_rvh);
+ RuntimePropertiesMap::iterator it =
+ runtime_properties_map_.find(inspected_rvh);
if (it == runtime_properties_map_.end()) {
std::pair<RenderViewHost*, DevToolsRuntimeProperties> value(
inspected_rvh,
@@ -185,7 +188,6 @@ void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) {
Source<Profile>(inspected_rvh->site_instance()->GetProcess()->profile()),
Details<RenderViewHost>(inspected_rvh));
- SendDetachToAgent(inspected_rvh);
UnbindClientHost(inspected_rvh, host);
}
@@ -203,25 +205,8 @@ void DevToolsManager::UnregisterDevToolsClientHostFor(
DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh);
if (!host)
return;
- SendDetachToAgent(inspected_rvh);
UnbindClientHost(inspected_rvh, host);
-
- if (inspected_rvh_for_reopen_ == inspected_rvh)
- inspected_rvh_for_reopen_ = NULL;
-
- // Issue tab closing event post unbound.
host->InspectedTabClosing();
-
- int process_id = inspected_rvh->process()->id();
- for (InspectedRvhToClientHostMap::iterator it =
- inspected_rvh_to_client_host_.begin();
- it != inspected_rvh_to_client_host_.end();
- ++it) {
- if (it->first->process()->id() == process_id)
- return;
- }
- // We've disconnected from the last renderer -> revoke cookie permissions.
- ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id);
}
void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh,
@@ -386,6 +371,13 @@ void DevToolsManager::BindClientHost(
DCHECK(client_host_to_inspected_rvh_.find(client_host) ==
client_host_to_inspected_rvh_.end());
+ if (client_host_to_inspected_rvh_.empty()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ NewRunnableFunction(&DevToolsNetLogObserver::Attach,
+ g_browser_process->io_thread()));
+ }
inspected_rvh_to_client_host_[inspected_rvh] = client_host;
client_host_to_inspected_rvh_[client_host] = inspected_rvh;
runtime_properties_map_[inspected_rvh] = runtime_properties;
@@ -401,4 +393,25 @@ void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh,
inspected_rvh_to_client_host_.erase(inspected_rvh);
client_host_to_inspected_rvh_.erase(client_host);
runtime_properties_map_.erase(inspected_rvh);
+
+ if (client_host_to_inspected_rvh_.empty()) {
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ NewRunnableFunction(&DevToolsNetLogObserver::Detach));
+ }
+ SendDetachToAgent(inspected_rvh);
+ if (inspected_rvh_for_reopen_ == inspected_rvh)
+ inspected_rvh_for_reopen_ = NULL;
+
+ int process_id = inspected_rvh->process()->id();
+ for (InspectedRvhToClientHostMap::iterator it =
+ inspected_rvh_to_client_host_.begin();
+ it != inspected_rvh_to_client_host_.end();
+ ++it) {
+ if (it->first->process()->id() == process_id)
+ return;
+ }
+ // We've disconnected from the last renderer -> revoke cookie permissions.
+ ChildProcessSecurityPolicy::GetInstance()->RevokeReadRawCookies(process_id);
}
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h
index 1c60a4d..2012d36 100644
--- a/chrome/browser/debugger/devtools_manager.h
+++ b/chrome/browser/debugger/devtools_manager.h
@@ -13,14 +13,18 @@
#include "chrome/browser/debugger/devtools_client_host.h"
#include "chrome/browser/debugger/devtools_toggle_action.h"
#include "chrome/common/devtools_messages.h"
+#include "webkit/glue/resource_loader_bridge.h"
namespace IPC {
class Message;
}
+class DevToolsNetLogObserver;
class GURL;
+class IOThread;
class PrefService;
class RenderViewHost;
+using webkit_glue::ResourceLoaderBridge;
// This class is a singleton that manages DevToolsClientHost instances and
// routes messages between developer tools clients and agents.
diff --git a/chrome/browser/debugger/devtools_netlog_observer.cc b/chrome/browser/debugger/devtools_netlog_observer.cc
new file mode 100644
index 0000000..776cc9f
--- /dev/null
+++ b/chrome/browser/debugger/devtools_netlog_observer.cc
@@ -0,0 +1,133 @@
+// Copyright (c) 2010 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.
+
+#include "chrome/browser/debugger/devtools_netlog_observer.h"
+
+#include "base/string_util.h"
+#include "chrome/browser/io_thread.h"
+#include "chrome/common/resource_response.h"
+#include "net/base/load_flags.h"
+#include "net/http/http_net_log_params.h"
+#include "net/http/http_response_headers.h"
+#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_netlog_params.h"
+#include "webkit/glue/resource_loader_bridge.h"
+
+const size_t kMaxNumEntries = 1000;
+
+DevToolsNetLogObserver* DevToolsNetLogObserver::instance_ = NULL;
+
+DevToolsNetLogObserver::DevToolsNetLogObserver(ChromeNetLog* chrome_net_log)
+ : ChromeNetLog::Observer(net::NetLog::LOG_ALL_BUT_BYTES),
+ chrome_net_log_(chrome_net_log) {
+ chrome_net_log_->AddObserver(this);
+}
+
+DevToolsNetLogObserver::~DevToolsNetLogObserver() {
+ chrome_net_log_->RemoveObserver(this);
+}
+
+DevToolsNetLogObserver::ResourceInfo*
+DevToolsNetLogObserver::GetResourceInfo(uint32 id) {
+ RequestToInfoMap::iterator it = request_to_info_.find(id);
+ if (it != request_to_info_.end())
+ return it->second;
+ return NULL;
+}
+
+void DevToolsNetLogObserver::OnAddEntry(net::NetLog::EventType type,
+ const base::TimeTicks& time,
+ const net::NetLog::Source& source,
+ net::NetLog::EventPhase phase,
+ net::NetLog::EventParameters* params) {
+ if (type == net::NetLog::TYPE_URL_REQUEST_START_JOB) {
+ if (phase != net::NetLog::PHASE_BEGIN)
+ return;
+ int load_flags = static_cast<URLRequestStartEventParameters*>(params)->
+ load_flags();
+ if (!(load_flags & net::LOAD_REPORT_RAW_HEADERS))
+ return;
+ if (request_to_info_.size() > kMaxNumEntries) {
+ LOG(WARNING) << "The raw headers observer url request count has grown "
+ "larger than expected, resetting";
+ request_to_info_.clear();
+ }
+ scoped_refptr<ResourceInfo> new_record = new ResourceInfo();
+ request_to_info_.insert(std::make_pair(source.id, new_record));
+ return;
+ }
+ if (type == net::NetLog::TYPE_REQUEST_ALIVE &&
+ phase == net::NetLog::PHASE_END) {
+ request_to_info_.erase(source.id);
+ return;
+ }
+ if (type != net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS &&
+ type != net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS)
+ return;
+
+ ResourceInfo* info = GetResourceInfo(source.id);
+ if (!info)
+ return;
+
+ switch (type) {
+ case net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS: {
+ const net::HttpRequestHeaders &request_headers =
+ static_cast<net::NetLogHttpRequestParameter*>(params)->GetHeaders();
+ for (net::HttpRequestHeaders::Iterator it(request_headers);
+ it.GetNext();) {
+ info->request_headers.push_back(std::make_pair(it.name(),
+ it.value()));
+ }
+ break;
+ }
+ case net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS: {
+ const net::HttpResponseHeaders& response_headers =
+ static_cast<net::NetLogHttpResponseParameter*>(params)->GetHeaders();
+ std::string name, value;
+ for (void* it = NULL;
+ response_headers.EnumerateHeaderLines(&it, &name, &value); ) {
+ info->response_headers.push_back(std::make_pair(name, value));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void DevToolsNetLogObserver::Attach(IOThread* io_thread) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!instance_);
+
+ instance_ = new DevToolsNetLogObserver(io_thread->globals()->net_log.get());
+}
+
+void DevToolsNetLogObserver::Detach() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(instance_);
+
+ delete instance_;
+ instance_ = NULL;
+}
+
+DevToolsNetLogObserver* DevToolsNetLogObserver::GetInstance() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ return instance_;
+}
+
+// static
+void DevToolsNetLogObserver::PopulateResponseInfo(URLRequest* request,
+ ResourceResponse* response) {
+ if (!(request->load_flags() & net::LOAD_REPORT_RAW_HEADERS))
+ return;
+
+ uint32 source_id = request->net_log().source().id;
+ DevToolsNetLogObserver* dev_tools_net_log_observer =
+ DevToolsNetLogObserver::GetInstance();
+ if (!dev_tools_net_log_observer)
+ return;
+ response->response_head.devtools_info =
+ dev_tools_net_log_observer->GetResourceInfo(source_id);
+}
diff --git a/chrome/browser/debugger/devtools_netlog_observer.h b/chrome/browser/debugger/devtools_netlog_observer.h
new file mode 100644
index 0000000..78317ad
--- /dev/null
+++ b/chrome/browser/debugger/devtools_netlog_observer.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_
+#define CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_
+#pragma once
+
+#include "base/hash_tables.h"
+#include "base/ref_counted.h"
+#include "chrome/browser/net/chrome_net_log.h"
+#include "webkit/glue/resource_loader_bridge.h"
+
+class IOThread;
+class URLRequest;
+struct ResourceResponse;
+
+// DevToolsNetLogObserver watches the NetLog event stream and collects the
+// stuff that may be of interest to DevTools. Currently, this only includes
+// actual HTTP/SPDY headers sent and received over the network.
+class DevToolsNetLogObserver: public ChromeNetLog::Observer {
+ typedef webkit_glue::ResourceDevToolsInfo ResourceInfo;
+
+ public:
+ // Observer implementation:
+ virtual void OnAddEntry(net::NetLog::EventType type,
+ const base::TimeTicks& time,
+ const net::NetLog::Source& source,
+ net::NetLog::EventPhase phase,
+ net::NetLog::EventParameters* params);
+
+ static void Attach(IOThread* thread);
+ static void Detach();
+
+ // Must be called on the IO thread. May return NULL if no observers
+ // are active.
+ static DevToolsNetLogObserver* GetInstance();
+ static void PopulateResponseInfo(URLRequest*, ResourceResponse*);
+
+ private:
+ typedef base::hash_map<uint32, scoped_refptr<ResourceInfo> >
+ RequestToInfoMap;
+
+ static DevToolsNetLogObserver* instance_;
+
+ explicit DevToolsNetLogObserver(ChromeNetLog* chrome_net_log);
+ ~DevToolsNetLogObserver();
+
+ ResourceInfo* GetResourceInfo(uint32 id);
+
+ ChromeNetLog* chrome_net_log_;
+ RequestToInfoMap request_to_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetLogObserver);
+};
+
+#endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_
diff --git a/chrome/browser/debugger/devtools_protocol_handler.cc b/chrome/browser/debugger/devtools_protocol_handler.cc
index 4a73efa..3d5300e 100644
--- a/chrome/browser/debugger/devtools_protocol_handler.cc
+++ b/chrome/browser/debugger/devtools_protocol_handler.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/debugger/devtools_protocol_handler.h"
#include "base/logging.h"
-#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/browser_thread.h"
#include "chrome/browser/debugger/inspectable_tab_proxy.h"
#include "chrome/browser/debugger/devtools_remote_message.h"
#include "chrome/browser/debugger/devtools_remote_listen_socket.h"
@@ -25,8 +25,8 @@ DevToolsProtocolHandler::~DevToolsProtocolHandler() {
}
void DevToolsProtocolHandler::Start() {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &DevToolsProtocolHandler::Init));
}
@@ -36,8 +36,8 @@ void DevToolsProtocolHandler::Init() {
}
void DevToolsProtocolHandler::Stop() {
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &DevToolsProtocolHandler::Teardown));
tool_to_listener_map_.clear(); // Releases all scoped_refptr's to listeners
}
@@ -72,9 +72,9 @@ void DevToolsProtocolHandler::HandleMessage(
NOTREACHED(); // an unsupported tool, bail out
return;
}
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- ChromeThread::PostTask(
- ChromeThread::UI, FROM_HERE,
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
it->second.get(), &DevToolsRemoteListener::HandleMessage, message));
}
@@ -86,19 +86,19 @@ void DevToolsProtocolHandler::Send(const DevToolsRemoteMessage& message) {
}
void DevToolsProtocolHandler::OnAcceptConnection(ListenSocket *connection) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
connection_ = connection;
}
void DevToolsProtocolHandler::OnConnectionLost() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
connection_ = NULL;
for (ToolToListenerMap::const_iterator it = tool_to_listener_map_.begin(),
end = tool_to_listener_map_.end();
it != end;
++it) {
- ChromeThread::PostTask(
- ChromeThread::UI, FROM_HERE,
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
NewRunnableMethod(
it->second.get(), &DevToolsRemoteListener::OnConnectionLost));
}
diff --git a/chrome/browser/debugger/devtools_remote_listen_socket_unittest.cc b/chrome/browser/debugger/devtools_remote_listen_socket_unittest.cc
index 2fa5212..a3eb3ef 100644
--- a/chrome/browser/debugger/devtools_remote_listen_socket_unittest.cc
+++ b/chrome/browser/debugger/devtools_remote_listen_socket_unittest.cc
@@ -10,6 +10,7 @@
#endif
#include "base/eintr_wrapper.h"
+#include "base/test/test_timeouts.h"
#include "net/base/net_util.h"
#include "testing/platform_test.h"
@@ -41,7 +42,6 @@ static const char* kTwoMessages =
static const int kMaxQueueSize = 20;
static const char* kLoopback = "127.0.0.1";
-static const int kDefaultTimeoutMs = 5000;
#if defined(OS_POSIX)
static const char* kSemaphoreName = "chromium.listen_socket";
#endif
@@ -73,7 +73,7 @@ void DevToolsRemoteListenSocketTester::SetUp() {
this, &DevToolsRemoteListenSocketTester::Listen));
// verify Listen succeeded
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_FALSE(server_ == NULL);
ASSERT_EQ(ACTION_LISTEN, last_action_.type());
@@ -90,7 +90,7 @@ void DevToolsRemoteListenSocketTester::SetUp() {
ASSERT_NE(ret, SOCKET_ERROR);
net::SetNonBlocking(test_socket_);
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_ACCEPT, last_action_.type());
}
@@ -102,12 +102,12 @@ void DevToolsRemoteListenSocketTester::TearDown() {
int ret = HANDLE_EINTR(close(test_socket_));
ASSERT_EQ(ret, 0);
#endif
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_CLOSE, last_action_.type());
loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &DevToolsRemoteListenSocketTester::Shutdown));
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_SHUTDOWN, last_action_.type());
#if defined(OS_WIN)
@@ -263,7 +263,7 @@ void DevToolsRemoteListenSocketTester::TestClientSend() {
// sleep for 10ms to test message split between \r and \n
PlatformThread::Sleep(10);
ASSERT_TRUE(Send(test_socket_, kSimpleMessagePart2));
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_READ_MESSAGE, last_action_.type());
const DevToolsRemoteMessage& message = last_action_.message();
ASSERT_STREQ("V8Debugger", message.GetHeaderWithEmptyDefault(
@@ -276,7 +276,7 @@ void DevToolsRemoteListenSocketTester::TestClientSend() {
}
ASSERT_TRUE(Send(test_socket_, kTwoMessages));
{
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_READ_MESSAGE, last_action_.type());
const DevToolsRemoteMessage& message = last_action_.message();
ASSERT_STREQ("DevToolsService", message.tool().c_str());
@@ -289,7 +289,7 @@ void DevToolsRemoteListenSocketTester::TestClientSend() {
}
}
{
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_READ_MESSAGE, last_action_.type());
const DevToolsRemoteMessage& message = last_action_.message();
ASSERT_STREQ("V8Debugger", message.GetHeaderWithEmptyDefault(
@@ -306,7 +306,7 @@ void DevToolsRemoteListenSocketTester::TestClientSend() {
void DevToolsRemoteListenSocketTester::TestServerSend() {
loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &DevToolsRemoteListenSocketTester::SendFromTester));
- ASSERT_TRUE(NextAction(kDefaultTimeoutMs));
+ ASSERT_TRUE(NextAction(TestTimeouts::action_timeout_ms()));
ASSERT_EQ(ACTION_SEND, last_action_.type());
// TODO(erikkay): Without this sleep, the recv seems to fail a small amount
// of the time. I could fix this by making the socket blocking, but then
diff --git a/chrome/browser/debugger/devtools_remote_message.cc b/chrome/browser/debugger/devtools_remote_message.cc
index eb63009..6d82a28 100644
--- a/chrome/browser/debugger/devtools_remote_message.cc
+++ b/chrome/browser/debugger/devtools_remote_message.cc
@@ -17,6 +17,16 @@ DevToolsRemoteMessageBuilder& DevToolsRemoteMessageBuilder::instance() {
return instance_;
}
+DevToolsRemoteMessage::DevToolsRemoteMessage() {}
+
+DevToolsRemoteMessage::DevToolsRemoteMessage(const HeaderMap& headers,
+ const std::string& content)
+ : header_map_(headers),
+ content_(content) {
+}
+
+DevToolsRemoteMessage::~DevToolsRemoteMessage() {}
+
const std::string DevToolsRemoteMessage::GetHeader(
const std::string& header_name,
const std::string& default_value) const {
diff --git a/chrome/browser/debugger/devtools_remote_message.h b/chrome/browser/debugger/devtools_remote_message.h
index bea9ae5..e836164 100644
--- a/chrome/browser/debugger/devtools_remote_message.h
+++ b/chrome/browser/debugger/devtools_remote_message.h
@@ -35,11 +35,9 @@ class DevToolsRemoteMessage {
static const char kEmptyValue[];
// Constructs an empty message with no content or headers.
- DevToolsRemoteMessage() {}
- DevToolsRemoteMessage(const HeaderMap& headers, const std::string& content)
- : header_map_(headers),
- content_(content) {}
- virtual ~DevToolsRemoteMessage() {}
+ DevToolsRemoteMessage();
+ DevToolsRemoteMessage(const HeaderMap& headers, const std::string& content);
+ virtual ~DevToolsRemoteMessage();
const HeaderMap& headers() const {
return header_map_;
diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc
index dbaa4e2..3f6393d 100644
--- a/chrome/browser/debugger/devtools_sanity_unittest.cc
+++ b/chrome/browser/debugger/devtools_sanity_unittest.cc
@@ -254,8 +254,15 @@ class DevToolsExtensionDebugTest : public DevToolsSanityTest,
FilePath test_extensions_dir_;
};
+// Fails after WebKit roll 69808:70011, http://crbug.com/59727.
+#if defined(OS_LINUX) || defined(OS_WIN)
+#define MAYBE_TestEnableResourcesTab DISABLED_TestEnableResourcesTab
+#else
+#define MAYBE_TestEnableResourcesTab TestEnableResourcesTab
+#endif // defined(OS_LINUX) || defined(OS_WIN)
+
// Tests resources panel enabling.
-IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestEnableResourcesTab) {
+IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestEnableResourcesTab) {
RunTest("testEnableResourcesTab", kSimplePage);
}
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index a185444..b4a3181 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -124,13 +124,19 @@ void DevToolsWindow::InspectedTabClosing() {
void DevToolsWindow::Show(DevToolsToggleAction action) {
if (docked_) {
- // Just tell inspected browser to update splitter.
- BrowserWindow* inspected_window = GetInspectedBrowserWindow();
- if (inspected_window) {
+ Browser* inspected_browser;
+ int inspected_tab_index;
+ // Tell inspected browser to update splitter and switch to inspected panel.
+ if (FindInspectedBrowserAndTabIndex(&inspected_browser,
+ &inspected_tab_index)) {
+ BrowserWindow* inspected_window = inspected_browser->window();
tab_contents_->set_delegate(this);
inspected_window->UpdateDevTools();
SetAttachedWindow();
tab_contents_->view()->SetInitialFocus();
+ inspected_window->Show();
+ TabStripModel* tabstrip_model = inspected_browser->tabstrip_model();
+ tabstrip_model->SelectTabContentsAt(inspected_tab_index, true);
ScheduleAction(action);
return;
} else {
@@ -228,18 +234,26 @@ void DevToolsWindow::CreateDevToolsBrowser() {
TabStripModel::ADD_SELECTED);
}
-BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() {
+bool DevToolsWindow::FindInspectedBrowserAndTabIndex(Browser** browser,
+ int* tab) {
+ const NavigationController& controller = inspected_tab_->controller();
for (BrowserList::const_iterator it = BrowserList::begin();
it != BrowserList::end(); ++it) {
- Browser* browser = *it;
- for (int i = 0; i < browser->tab_count(); ++i) {
- TabContents* tab_contents = browser->GetTabContentsAt(i);
- if (tab_contents == inspected_tab_) {
- return browser->window();
- }
+ int tab_index = (*it)->GetIndexOfController(&controller);
+ if (tab_index != TabStripModel::kNoTab) {
+ *browser = *it;
+ *tab = tab_index;
+ return true;
}
}
- return NULL;
+ return false;
+}
+
+BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() {
+ Browser* browser = NULL;
+ int tab;
+ return FindInspectedBrowserAndTabIndex(&browser, &tab) ?
+ browser->window() : NULL;
}
void DevToolsWindow::SetAttachedWindow() {
@@ -251,6 +265,10 @@ void DevToolsWindow::SetAttachedWindow() {
void DevToolsWindow::AddDevToolsExtensionsToClient() {
+ if (inspected_tab_) {
+ FundamentalValue tabId(inspected_tab_->controller().session_id().id());
+ CallClientFunction(L"WebInspector.setInspectedTabId", tabId);
+ }
ListValue results;
const ExtensionsService* extension_service = tab_contents_->profile()->
GetOriginalProfile()->GetExtensionsService();
diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h
index 89914a6..85d7e84 100644
--- a/chrome/browser/debugger/devtools_window.h
+++ b/chrome/browser/debugger/devtools_window.h
@@ -54,6 +54,7 @@ class DevToolsWindow
private:
void CreateDevToolsBrowser();
+ bool FindInspectedBrowserAndTabIndex(Browser**, int* tab);
BrowserWindow* GetInspectedBrowserWindow();
void SetAttachedWindow();
diff --git a/chrome/browser/debugger/extension_ports_remote_service.cc b/chrome/browser/debugger/extension_ports_remote_service.cc
index 29cc11f..3596187 100644
--- a/chrome/browser/debugger/extension_ports_remote_service.cc
+++ b/chrome/browser/debugger/extension_ports_remote_service.cc
@@ -203,7 +203,7 @@ void ExtensionPortsRemoteService::HandleMessage(
}
void ExtensionPortsRemoteService::OnConnectionLost() {
- LOG(INFO) << "OnConnectionLost";
+ VLOG(1) << "OnConnectionLost";
DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
DCHECK(service_);
for (PortIdSet::iterator it = openPortIds_.begin();
@@ -238,9 +238,9 @@ bool ExtensionPortsRemoteService::Send(IPC::Message *message) {
}
void ExtensionPortsRemoteService::OnExtensionMessageInvoke(
+ const std::string& extension_id,
const std::string& function_name,
const ListValue& args,
- bool requires_incognito_access,
const GURL& event_url) {
if (function_name == ExtensionMessageService::kDispatchOnMessage) {
DCHECK_EQ(args.GetSize(), 2u);
@@ -264,8 +264,7 @@ void ExtensionPortsRemoteService::OnExtensionMessageInvoke(
void ExtensionPortsRemoteService::OnExtensionMessage(
const std::string& message, int port_id) {
- LOG(INFO) << "Message event: from port " << port_id
- << ", < " << message << ">";
+ VLOG(1) << "Message event: from port " << port_id << ", < " << message << ">";
// Transpose the information into a JSON message for the external client.
DictionaryValue content;
content.SetString(kCommandKey, kOnMessage);
@@ -281,7 +280,7 @@ void ExtensionPortsRemoteService::OnExtensionMessage(
}
void ExtensionPortsRemoteService::OnExtensionPortDisconnected(int port_id) {
- LOG(INFO) << "Disconnect event for port " << port_id;
+ VLOG(1) << "Disconnect event for port " << port_id;
openPortIds_.erase(port_id);
DictionaryValue content;
content.SetString(kCommandKey, kOnDisconnect);
@@ -316,32 +315,32 @@ void ExtensionPortsRemoteService::ConnectCommand(
if (it != navcon_map.end())
tab_contents = it->second->tab_contents();
if (!tab_contents) {
- LOG(INFO) << "tab not found: " << tab_id;
+ VLOG(1) << "tab not found: " << tab_id;
response->SetInteger(kResultKey, RESULT_TAB_NOT_FOUND);
return;
}
// Ask the ExtensionMessageService to open the channel.
- LOG(INFO) << "Connect: extension_id <" << extension_id
- << ">, channel_name <" << channel_name << ">"
- << ", tab " << tab_id;
+ VLOG(1) << "Connect: extension_id <" << extension_id
+ << ">, channel_name <" << channel_name
+ << ">, tab " << tab_id;
DCHECK(service_);
port_id = service_->OpenSpecialChannelToTab(
extension_id, channel_name, tab_contents, this);
} else { // no tab: channel to an extension' background page / toolstrip.
// Ask the ExtensionMessageService to open the channel.
- LOG(INFO) << "Connect: extension_id <" << extension_id
- << ">, channel_name <" << channel_name << ">";
+ VLOG(1) << "Connect: extension_id <" << extension_id
+ << ">, channel_name <" << channel_name << ">";
DCHECK(service_);
port_id = service_->OpenSpecialChannelToExtension(
extension_id, channel_name, "null", this);
}
if (port_id == -1) {
// Failure: probably the extension ID doesn't exist.
- LOG(INFO) << "Connect failed";
+ VLOG(1) << "Connect failed";
response->SetInteger(kResultKey, RESULT_CONNECT_FAILED);
return;
}
- LOG(INFO) << "Connected: port " << port_id;
+ VLOG(1) << "Connected: port " << port_id;
openPortIds_.insert(port_id);
// Reply to external client with the port ID assigned to the new channel.
DictionaryValue* reply_data = new DictionaryValue();
@@ -352,10 +351,10 @@ void ExtensionPortsRemoteService::ConnectCommand(
void ExtensionPortsRemoteService::DisconnectCommand(
int port_id, DictionaryValue* response) {
- LOG(INFO) << "Disconnect port " << port_id;
+ VLOG(1) << "Disconnect port " << port_id;
PortIdSet::iterator portEntry = openPortIds_.find(port_id);
if (portEntry == openPortIds_.end()) { // unknown port ID.
- LOG(INFO) << "unknown port: " << port_id;
+ VLOG(1) << "unknown port: " << port_id;
response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT);
return;
}
@@ -375,11 +374,11 @@ void ExtensionPortsRemoteService::PostMessageCommand(
std::string message;
// Stringified the JSON message body.
base::JSONWriter::Write(data, false, &message);
- LOG(INFO) << "postMessage: port " << port_id
- << ", message: <" << message << ">";
+ VLOG(1) << "postMessage: port " << port_id
+ << ", message: <" << message << ">";
PortIdSet::iterator portEntry = openPortIds_.find(port_id);
if (portEntry == openPortIds_.end()) { // Unknown port ID.
- LOG(INFO) << "unknown port: " << port_id;
+ VLOG(1) << "unknown port: " << port_id;
response->SetInteger(kResultKey, RESULT_UNKNOWN_PORT);
return;
}
diff --git a/chrome/browser/debugger/extension_ports_remote_service.h b/chrome/browser/debugger/extension_ports_remote_service.h
index 0b4c892..bd9b792 100644
--- a/chrome/browser/debugger/extension_ports_remote_service.h
+++ b/chrome/browser/debugger/extension_ports_remote_service.h
@@ -75,9 +75,9 @@ class ExtensionPortsRemoteService : public DevToolsRemoteListener,
const std::string& destination);
// Handles a message from the ExtensionMessageService.
- void OnExtensionMessageInvoke(const std::string& function_name,
+ void OnExtensionMessageInvoke(const std::string& extension_id,
+ const std::string& function_name,
const ListValue& args,
- bool requires_incognito_access,
const GURL& event_url);
// Handles a message sent from an extension through the
// ExtensionMessageService, to be passed to the external client.
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc
index 96d4e3e..ce8fd7f 100644
--- a/chrome/browser/debugger/inspectable_tab_proxy.cc
+++ b/chrome/browser/debugger/inspectable_tab_proxy.cc
@@ -15,6 +15,18 @@
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/common/devtools_messages.h"
+DevToolsClientHostImpl::DevToolsClientHostImpl(
+ int32 id,
+ DebuggerRemoteService* service,
+ InspectableTabProxy::IdToClientHostMap* map)
+ : id_(id),
+ service_(service),
+ map_(map) {}
+
+DevToolsClientHostImpl::~DevToolsClientHostImpl() {
+ map_->erase(this->id_);
+}
+
// The debugged tab has closed.
void DevToolsClientHostImpl::InspectedTabClosing() {
TabClosed();
@@ -49,6 +61,10 @@ void DevToolsClientHostImpl::TabClosed() {
service_->TabClosed(id_);
}
+InspectableTabProxy::InspectableTabProxy() {}
+
+InspectableTabProxy::~InspectableTabProxy() {}
+
const InspectableTabProxy::ControllersMap&
InspectableTabProxy::controllers_map() {
controllers_map_.clear();
diff --git a/chrome/browser/debugger/inspectable_tab_proxy.h b/chrome/browser/debugger/inspectable_tab_proxy.h
index af08232..8d02727 100644
--- a/chrome/browser/debugger/inspectable_tab_proxy.h
+++ b/chrome/browser/debugger/inspectable_tab_proxy.h
@@ -26,8 +26,8 @@ class InspectableTabProxy {
typedef base::hash_map<int32, NavigationController*> ControllersMap;
typedef base::hash_map<int32, DevToolsClientHostImpl*> IdToClientHostMap;
- InspectableTabProxy() {}
- virtual ~InspectableTabProxy() {}
+ InspectableTabProxy();
+ virtual ~InspectableTabProxy();
// Returns a map of NavigationControllerKeys to NavigationControllers
// for all Browser instances. Clients should not keep the result around
@@ -64,13 +64,9 @@ class DevToolsClientHostImpl : public DevToolsClientHost {
DevToolsClientHostImpl(
int32 id,
DebuggerRemoteService* service,
- InspectableTabProxy::IdToClientHostMap* map)
- : id_(id),
- service_(service),
- map_(map) {}
- ~DevToolsClientHostImpl() {
- map_->erase(this->id_);
- }
+ InspectableTabProxy::IdToClientHostMap* map);
+ ~DevToolsClientHostImpl();
+
DebuggerRemoteService* debugger_remote_service() {
return service_;
}