Commit d683ecda authored by yurys@chromium.org's avatar yurys@chromium.org

Add content API for DevTools HTTP handler

BUG=104625
TEST=Existing tests

Review URL: http://codereview.chromium.org/8554008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112662 0039d316-1c4b-4281-b951-d872f2087c98
parent 5bff94bb
......@@ -12,9 +12,11 @@
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/resource/resource_bundle.h"
DevToolsHttpProtocolHandler::InspectableTabs
using content::DevToolsHttpHandlerDelegate;
DevToolsHttpHandlerDelegate::InspectableTabs
BrowserListTabContentsProvider::GetInspectableTabs() {
DevToolsHttpProtocolHandler::InspectableTabs tabs;
DevToolsHttpHandlerDelegate::InspectableTabs tabs;
for (BrowserList::const_iterator it = BrowserList::begin(),
end = BrowserList::end(); it != end; ++it) {
TabStripModel* model = (*it)->tabstrip_model();
......
......@@ -6,19 +6,23 @@
#define CHROME_BROWSER_DEBUGGER_BROWSER_LIST_TABCONTENTS_PROVIDER_H_
#include <string>
#include "content/browser/debugger/devtools_http_protocol_handler.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "content/public/browser/devtools_http_handler_delegate.h"
class BrowserListTabContentsProvider
: public DevToolsHttpProtocolHandler::Delegate {
: public content::DevToolsHttpHandlerDelegate {
public:
BrowserListTabContentsProvider() {}
virtual ~BrowserListTabContentsProvider() {}
// DevToolsHttpProtocolHandler::Delegate overrides.
virtual DevToolsHttpProtocolHandler::InspectableTabs
virtual DevToolsHttpHandlerDelegate::InspectableTabs
GetInspectableTabs() OVERRIDE;
virtual std::string GetDiscoveryPageHTML() OVERRIDE;
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(BrowserListTabContentsProvider);
};
......
......@@ -8,6 +8,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/devtools_ui.h"
#include "content/public/browser/devtools_http_handler.h"
RemoteDebuggingServer::RemoteDebuggingServer(Profile* profile,
const std::string& ip,
......@@ -17,10 +18,10 @@ RemoteDebuggingServer::RemoteDebuggingServer(Profile* profile,
DevToolsUI::RegisterDevToolsDataSource(profile);
devtools_http_handler_ =
DevToolsHttpProtocolHandler::Start(ip,
port,
frontend_url,
new BrowserListTabContentsProvider());
content::DevToolsHttpHandler::Start(ip,
port,
frontend_url,
new BrowserListTabContentsProvider());
}
RemoteDebuggingServer::~RemoteDebuggingServer() {
......
......@@ -9,23 +9,24 @@
#include <string>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/browser/debugger/devtools_http_protocol_handler.h"
class DevToolsHttpProtocolHandler;
class Profile;
namespace content {
class DevToolsHttpHandler;
}
class RemoteDebuggingServer {
public:
RemoteDebuggingServer(Profile* profile,
const std::string& ip,
int port,
const std::string& frontend_url);
const std::string& ip,
int port,
const std::string& frontend_url);
virtual ~RemoteDebuggingServer();
private:
scoped_refptr<DevToolsHttpProtocolHandler> devtools_http_handler_;
content::DevToolsHttpHandler* devtools_http_handler_;
DISALLOW_COPY_AND_ASSIGN(RemoteDebuggingServer);
};
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_
#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_
#ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_
#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_
#pragma once
#include <map>
......@@ -14,65 +14,38 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/content_export.h"
#include "content/public/browser/devtools_http_handler.h"
#include "net/server/http_server.h"
#include "net/url_request/url_request.h"
class TabContents;
namespace content {
class DevToolsClientHost;
}
namespace net {
class URLRequestContext;
}
class DevToolsHttpProtocolHandler
: public net::HttpServer::Delegate,
public net::URLRequest::Delegate,
public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> {
public:
typedef std::vector<TabContents*> InspectableTabs;
class Delegate {
public:
Delegate() {}
virtual ~Delegate() {}
// Should return the list of inspectable tabs. Called on the UI thread.
virtual InspectableTabs GetInspectableTabs() = 0;
// Should return discovery page HTML that should list available tabs
// and provide attach links. Called on the IO thread.
virtual std::string GetDiscoveryPageHTML() = 0;
// Should return URL request context for issuing requests against devtools
// webui or NULL if no context is available. Called on the IO thread.
virtual net::URLRequestContext* GetURLRequestContext() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
// Takes ownership over |delegate|.
CONTENT_EXPORT static scoped_refptr<DevToolsHttpProtocolHandler> Start(
const std::string& ip,
int port,
const std::string& frontend_url,
Delegate* delegate);
// Called from the main thread in order to stop protocol handler.
// Will schedule tear down task on IO thread.
CONTENT_EXPORT void Stop();
namespace content {
class DevToolsClientHost;
class DevToolsHttpHandlerImpl
: public DevToolsHttpHandler,
public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>,
public net::HttpServer::Delegate,
public net::URLRequest::Delegate {
private:
friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>;
DevToolsHttpProtocolHandler(const std::string& ip,
int port,
const std::string& frontend_url,
Delegate* delegate);
virtual ~DevToolsHttpProtocolHandler();
friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>;
friend class DevToolsHttpHandler;
DevToolsHttpHandlerImpl(const std::string& ip,
int port,
const std::string& frontend_url,
DevToolsHttpHandlerDelegate* delegate);
virtual ~DevToolsHttpHandlerImpl();
void Start();
// DevToolsHttpHandler implementation.
virtual void Stop() OVERRIDE;
// net::HttpServer::Delegate implementation.
virtual void OnHttpRequest(int connection_id,
const net::HttpServerRequestInfo& info) OVERRIDE;
......@@ -126,8 +99,11 @@ class DevToolsHttpProtocolHandler
typedef std::map<int, content::DevToolsClientHost*>
ConnectionToClientHostMap;
ConnectionToClientHostMap connection_to_client_host_ui_;
scoped_ptr<Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler);
scoped_ptr<DevToolsHttpHandlerDelegate> delegate_;
scoped_refptr<DevToolsHttpHandlerImpl> protect_ptr_;
DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl);
};
#endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_
} // namespace content
#endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_HTTP_HANDLER_IMPL_H_
......@@ -34,6 +34,8 @@
'public/browser/devtools_agent_host_registry.h',
'public/browser/devtools_client_host.h',
'public/browser/devtools_frontend_window_delegate.h',
'public/browser/devtools_http_handler.h',
'public/browser/devtools_http_handler_delegate.h',
'public/browser/devtools_manager.h',
'public/browser/download_manager_delegate.h',
'public/browser/intents_host.h',
......@@ -113,8 +115,8 @@
'browser/debugger/devtools_agent_host.h',
'browser/debugger/devtools_frontend_host.cc',
'browser/debugger/devtools_frontend_host.h',
'browser/debugger/devtools_http_protocol_handler.cc',
'browser/debugger/devtools_http_protocol_handler.h',
'browser/debugger/devtools_http_handler_impl.cc',
'browser/debugger/devtools_http_handler_impl.h',
'browser/debugger/devtools_manager_impl.cc',
'browser/debugger/devtools_manager_impl.h',
'browser/debugger/devtools_netlog_observer.cc',
......
// Copyright (c) 2011 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 CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
#define CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
#pragma once
#include <string>
#include "content/common/content_export.h"
namespace content {
class DevToolsHttpHandlerDelegate;
// This class is used for managing DevTools remote debugging server.
// Clients can connect to the specified ip:port and start debugging
// this browser.
class DevToolsHttpHandler {
public:
// Takes ownership over |delegate|.
CONTENT_EXPORT static DevToolsHttpHandler* Start(
const std::string& ip,
int port,
const std::string& frontend_url,
DevToolsHttpHandlerDelegate* delegate);
// Called from the main thread in order to stop protocol handler.
virtual void Stop() = 0;
protected:
virtual ~DevToolsHttpHandler() {}
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_H_
// Copyright (c) 2011 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 CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_
#define CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_
#pragma once
#include <string>
#include <vector>
class TabContents;
namespace net {
class URLRequestContext;
}
namespace content {
class DevToolsHttpHandlerDelegate {
public:
typedef std::vector<TabContents*> InspectableTabs;
virtual ~DevToolsHttpHandlerDelegate() {}
// Should return the list of inspectable tabs. Called on the UI thread.
virtual InspectableTabs GetInspectableTabs() = 0;
// Should return discovery page HTML that should list available tabs
// and provide attach links. Called on the IO thread.
virtual std::string GetDiscoveryPageHTML() = 0;
// Should return URL request context for issuing requests against devtools
// webui or NULL if no context is available. Called on the IO thread.
virtual net::URLRequestContext* GetURLRequestContext() = 0;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_DEVTOOLS_HTTP_HANDLER_DELEGATE_H_
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