Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: chrome/browser/debugger/devtools_http_protocol_handler.h

Issue 7274031: Wholesale move of debugger sources to content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add OWNERS and DEPS. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_
6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_
7 #pragma once
8
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "net/server/http_server.h"
16 #include "net/url_request/url_request.h"
17
18 class DevToolsClientHost;
19 class DevToolsHttpServer;
20 class TabContents;
21 class TabContentsWrapper;
22
23 class DevToolsHttpProtocolHandler
24 : public net::HttpServer::Delegate,
25 public net::URLRequest::Delegate,
26 public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> {
27 public:
28 typedef std::vector<TabContentsWrapper*> InspectableTabs;
29 class TabContentsProvider {
30 public:
31 TabContentsProvider() {}
32 virtual ~TabContentsProvider() {}
33 virtual InspectableTabs GetInspectableTabs() = 0;
34 private:
35 DISALLOW_COPY_AND_ASSIGN(TabContentsProvider);
36 };
37
38 // Takes ownership over |provider|.
39 static scoped_refptr<DevToolsHttpProtocolHandler> Start(
40 const std::string& ip,
41 int port,
42 const std::string& frontend_url,
43 TabContentsProvider* provider);
44
45 // Called from the main thread in order to stop protocol handler.
46 // Will schedule tear down task on IO thread.
47 void Stop();
48
49 private:
50 friend class base::RefCountedThreadSafe<DevToolsHttpProtocolHandler>;
51
52 DevToolsHttpProtocolHandler(const std::string& ip,
53 int port,
54 const std::string& frontend_url,
55 TabContentsProvider* provider);
56 virtual ~DevToolsHttpProtocolHandler();
57 void Start();
58
59 // net::HttpServer::Delegate implementation.
60 virtual void OnHttpRequest(int connection_id,
61 const net::HttpServerRequestInfo& info);
62 virtual void OnWebSocketRequest(int connection_id,
63 const net::HttpServerRequestInfo& info);
64 virtual void OnWebSocketMessage(int connection_id,
65 const std::string& data);
66 virtual void OnClose(int connection_id);
67
68 virtual void OnJsonRequestUI(int connection_id,
69 const net::HttpServerRequestInfo& info);
70 virtual void OnWebSocketRequestUI(int connection_id,
71 const net::HttpServerRequestInfo& info);
72 virtual void OnWebSocketMessageUI(int connection_id,
73 const std::string& data);
74 virtual void OnCloseUI(int connection_id);
75
76 // net::URLRequest::Delegate implementation.
77 virtual void OnResponseStarted(net::URLRequest* request);
78 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read);
79
80 void Init();
81 void Teardown();
82 void Bind(net::URLRequest* request, int connection_id);
83 void RequestCompleted(net::URLRequest* request);
84
85 void Send200(int connection_id,
86 const std::string& data,
87 const std::string& mime_type = "text/html");
88 void Send404(int connection_id);
89 void Send500(int connection_id,
90 const std::string& message);
91 void AcceptWebSocket(int connection_id,
92 const net::HttpServerRequestInfo& request);
93
94 TabContents* GetTabContents(int session_id);
95
96 std::string ip_;
97 int port_;
98 std::string overridden_frontend_url_;
99 scoped_refptr<net::HttpServer> server_;
100 typedef std::map<net::URLRequest*, int>
101 RequestToSocketMap;
102 RequestToSocketMap request_to_connection_io_;
103 typedef std::map<int, std::set<net::URLRequest*> >
104 ConnectionToRequestsMap;
105 ConnectionToRequestsMap connection_to_requests_io_;
106 typedef std::map<net::URLRequest*, scoped_refptr<net::IOBuffer> >
107 BuffersMap;
108 BuffersMap request_to_buffer_io_;
109 typedef std::map<int, DevToolsClientHost*>
110 ConnectionToClientHostMap;
111 ConnectionToClientHostMap connection_to_client_host_ui_;
112 scoped_ptr<TabContentsProvider> tab_contents_provider_;
113 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler);
114 };
115
116 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_HTTP_PROTOCOL_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698