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

Side by Side Diff: content/browser/devtools/devtools_http_handler_impl.h

Issue 24995003: DevTools: Extract target discovery and manipulation from DevToolsHttpHandlerImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed json/new handler Created 7 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/public/browser/devtools_http_handler.h" 16 #include "content/public/browser/devtools_http_handler.h"
17 #include "content/public/browser/devtools_http_handler_delegate.h" 17 #include "content/public/browser/devtools_http_handler_delegate.h"
18 #include "content/public/browser/worker_service.h"
19 #include "net/http/http_status_code.h" 18 #include "net/http/http_status_code.h"
20 #include "net/server/http_server.h" 19 #include "net/server/http_server.h"
21 20
22 namespace base { 21 namespace base {
23 class DictionaryValue; 22 class DictionaryValue;
24 class ListValue; 23 class ListValue;
25 class Thread; 24 class Thread;
26 class Value; 25 class Value;
27 } 26 }
28 27
(...skipping 17 matching lines...) Expand all
46 45
47 // Takes ownership over |socket_factory|. 46 // Takes ownership over |socket_factory|.
48 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, 47 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory,
49 const std::string& frontend_url, 48 const std::string& frontend_url,
50 DevToolsHttpHandlerDelegate* delegate); 49 DevToolsHttpHandlerDelegate* delegate);
51 virtual ~DevToolsHttpHandlerImpl(); 50 virtual ~DevToolsHttpHandlerImpl();
52 void Start(); 51 void Start();
53 52
54 // DevToolsHttpHandler implementation. 53 // DevToolsHttpHandler implementation.
55 virtual void Stop() OVERRIDE; 54 virtual void Stop() OVERRIDE;
56 virtual void SetDevToolsAgentHostBinding( 55 virtual GURL GetFrontendURL() OVERRIDE;
57 DevToolsAgentHostBinding* binding) OVERRIDE;
58 virtual GURL GetFrontendURL(DevToolsAgentHost* agent_host) OVERRIDE;
59 56
60 // net::HttpServer::Delegate implementation. 57 // net::HttpServer::Delegate implementation.
61 virtual void OnHttpRequest(int connection_id, 58 virtual void OnHttpRequest(int connection_id,
62 const net::HttpServerRequestInfo& info) OVERRIDE; 59 const net::HttpServerRequestInfo& info) OVERRIDE;
63 virtual void OnWebSocketRequest( 60 virtual void OnWebSocketRequest(
64 int connection_id, 61 int connection_id,
65 const net::HttpServerRequestInfo& info) OVERRIDE; 62 const net::HttpServerRequestInfo& info) OVERRIDE;
66 virtual void OnWebSocketMessage(int connection_id, 63 virtual void OnWebSocketMessage(int connection_id,
67 const std::string& data) OVERRIDE; 64 const std::string& data) OVERRIDE;
68 virtual void OnClose(int connection_id) OVERRIDE; 65 virtual void OnClose(int connection_id) OVERRIDE;
69 66
70 void OnJsonRequestUI(int connection_id, 67 void OnJsonRequestUI(int connection_id,
71 const net::HttpServerRequestInfo& info); 68 const net::HttpServerRequestInfo& info);
72 void OnThumbnailRequestUI(int connection_id, const GURL& page_url); 69 void OnThumbnailRequestUI(int connection_id, const GURL& page_url);
73 void OnDiscoveryPageRequestUI(int connection_id); 70 void OnDiscoveryPageRequestUI(int connection_id);
74 71
75 void OnWebSocketRequestUI(int connection_id, 72 void OnWebSocketRequestUI(int connection_id,
76 const net::HttpServerRequestInfo& info); 73 const net::HttpServerRequestInfo& info);
77 void OnWebSocketMessageUI(int connection_id, const std::string& data); 74 void OnWebSocketMessageUI(int connection_id, const std::string& data);
78 void OnCloseUI(int connection_id); 75 void OnCloseUI(int connection_id);
79 76
80 void ResetHandlerThread(); 77 void ResetHandlerThread();
81 void ResetHandlerThreadAndRelease(); 78 void ResetHandlerThreadAndRelease();
82 79
83 typedef std::vector<WorkerService::WorkerInfo> WorkerInfoList; 80 void OnTargetListReceived(
81 int connection_id,
82 const std::string& host,
83 const DevToolsHttpHandlerDelegate::TargetList& targets);
84 84
85 WorkerInfoList CollectWorkerInfo(); 85 DevToolsTarget* GetTarget(const std::string& id);
86 void SendTargetList(int connection_id,
87 const std::string& host,
88 base::ListValue* target_list,
89 const WorkerInfoList& worker_info_list);
90 86
91 void Init(); 87 void Init();
92 void Teardown(); 88 void Teardown();
93 89
94 void StartHandlerThread(); 90 void StartHandlerThread();
95 void StopHandlerThread(); 91 void StopHandlerThread();
96 92
97 void SendJson(int connection_id, 93 void SendJson(int connection_id,
98 net::HttpStatusCode status_code, 94 net::HttpStatusCode status_code,
99 base::Value* value, 95 base::Value* value,
100 const std::string& message); 96 const std::string& message);
101 void Send200(int connection_id, 97 void Send200(int connection_id,
102 const std::string& data, 98 const std::string& data,
103 const std::string& mime_type); 99 const std::string& mime_type);
104 void Send404(int connection_id); 100 void Send404(int connection_id);
105 void Send500(int connection_id, 101 void Send500(int connection_id,
106 const std::string& message); 102 const std::string& message);
107 void AcceptWebSocket(int connection_id, 103 void AcceptWebSocket(int connection_id,
108 const net::HttpServerRequestInfo& request); 104 const net::HttpServerRequestInfo& request);
109 105
110 // Returns the front end url without the host at the beginning. 106 // Returns the front end url without the host at the beginning.
111 std::string GetFrontendURLInternal(const std::string rvh_id, 107 std::string GetFrontendURLInternal(const std::string target_id,
112 const std::string& host); 108 const std::string& host);
113 109
114 base::DictionaryValue* SerializePageInfo(RenderViewHost* rvh, 110 base::DictionaryValue* SerializeTarget(const DevToolsTarget& target,
115 const std::string& host); 111 const std::string& host);
116
117 base::DictionaryValue* SerializeWorkerInfo(
118 const WorkerService::WorkerInfo& worker,
119 const std::string& host);
120
121 void SerializeDebuggerURLs(base::DictionaryValue* dictionary,
122 const std::string& id,
123 const std::string& host);
124 112
125 // The thread used by the devtools handler to run server socket. 113 // The thread used by the devtools handler to run server socket.
126 scoped_ptr<base::Thread> thread_; 114 scoped_ptr<base::Thread> thread_;
127 115
128 std::string overridden_frontend_url_; 116 std::string overridden_frontend_url_;
129 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; 117 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_;
130 scoped_refptr<net::HttpServer> server_; 118 scoped_refptr<net::HttpServer> server_;
131 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; 119 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap;
132 ConnectionToClientHostMap connection_to_client_host_ui_; 120 ConnectionToClientHostMap connection_to_client_host_ui_;
133 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; 121 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_;
134 DevToolsAgentHostBinding* binding_; 122 typedef std::map<std::string, DevToolsTarget*> TargetMap;
135 scoped_ptr<DevToolsAgentHostBinding> default_binding_; 123 TargetMap target_map_;
136 scoped_refptr<DevToolsBrowserTarget> browser_target_; 124 scoped_refptr<DevToolsBrowserTarget> browser_target_;
137 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); 125 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl);
138 }; 126 };
139 127
140 } // namespace content 128 } // namespace content
141 129
142 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ 130 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/test/data/devtools/target_list/background.js ('k') | content/browser/devtools/devtools_http_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698