OLD | NEW |
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 #include "content/browser/devtools/devtools_http_handler_impl.h" | 5 #include "content/browser/devtools/devtools_http_handler_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 virtual DevToolsAgentHost* ForIdentifier(const std::string& id) OVERRIDE { | 87 virtual DevToolsAgentHost* ForIdentifier(const std::string& id) OVERRIDE { |
88 return DevToolsAgentHost::GetForId(id); | 88 return DevToolsAgentHost::GetForId(id); |
89 } | 89 } |
90 }; | 90 }; |
91 | 91 |
92 // An internal implementation of DevToolsClientHost that delegates | 92 // An internal implementation of DevToolsClientHost that delegates |
93 // messages sent for DevToolsClient to a DebuggerShell instance. | 93 // messages sent for DevToolsClient to a DebuggerShell instance. |
94 class DevToolsClientHostImpl : public DevToolsClientHost { | 94 class DevToolsClientHostImpl : public DevToolsClientHost { |
95 public: | 95 public: |
96 DevToolsClientHostImpl( | 96 DevToolsClientHostImpl(base::MessageLoop* message_loop, |
97 MessageLoop* message_loop, | 97 net::HttpServer* server, |
98 net::HttpServer* server, | 98 int connection_id) |
99 int connection_id) | |
100 : message_loop_(message_loop), | 99 : message_loop_(message_loop), |
101 server_(server), | 100 server_(server), |
102 connection_id_(connection_id), | 101 connection_id_(connection_id), |
103 is_closed_(false), | 102 is_closed_(false), |
104 detach_reason_("target_closed") { | 103 detach_reason_("target_closed") {} |
105 } | |
106 | 104 |
107 virtual ~DevToolsClientHostImpl() {} | 105 virtual ~DevToolsClientHostImpl() {} |
108 | 106 |
109 // DevToolsClientHost interface | 107 // DevToolsClientHost interface |
110 virtual void InspectedContentsClosing() OVERRIDE { | 108 virtual void InspectedContentsClosing() OVERRIDE { |
111 if (is_closed_) | 109 if (is_closed_) |
112 return; | 110 return; |
113 is_closed_ = true; | 111 is_closed_ = true; |
114 | 112 |
115 std::string response = DevToolsProtocol::CreateNotification( | 113 std::string response = DevToolsProtocol::CreateNotification( |
(...skipping 17 matching lines...) Expand all Loading... |
133 server_, | 131 server_, |
134 connection_id_, | 132 connection_id_, |
135 data)); | 133 data)); |
136 } | 134 } |
137 | 135 |
138 virtual void ReplacedWithAnotherClient() OVERRIDE { | 136 virtual void ReplacedWithAnotherClient() OVERRIDE { |
139 detach_reason_ = "replaced_with_devtools"; | 137 detach_reason_ = "replaced_with_devtools"; |
140 } | 138 } |
141 | 139 |
142 private: | 140 private: |
143 MessageLoop* message_loop_; | 141 base::MessageLoop* message_loop_; |
144 net::HttpServer* server_; | 142 net::HttpServer* server_; |
145 int connection_id_; | 143 int connection_id_; |
146 bool is_closed_; | 144 bool is_closed_; |
147 std::string detach_reason_; | 145 std::string detach_reason_; |
148 }; | 146 }; |
149 | 147 |
150 static base::TimeTicks GetLastSelectedTime(RenderViewHost* rvh) { | 148 static base::TimeTicks GetLastSelectedTime(RenderViewHost* rvh) { |
151 WebContents* web_contents = rvh->GetDelegate()->GetAsWebContents(); | 149 WebContents* web_contents = rvh->GetDelegate()->GetAsWebContents(); |
152 if (!web_contents) | 150 if (!web_contents) |
153 return base::TimeTicks(); | 151 return base::TimeTicks(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return; | 195 return; |
198 thread_.reset(new base::Thread(kDevToolsHandlerThreadName)); | 196 thread_.reset(new base::Thread(kDevToolsHandlerThreadName)); |
199 BrowserThread::PostTask( | 197 BrowserThread::PostTask( |
200 BrowserThread::FILE, FROM_HERE, | 198 BrowserThread::FILE, FROM_HERE, |
201 base::Bind(&DevToolsHttpHandlerImpl::StartHandlerThread, this)); | 199 base::Bind(&DevToolsHttpHandlerImpl::StartHandlerThread, this)); |
202 } | 200 } |
203 | 201 |
204 // Runs on FILE thread. | 202 // Runs on FILE thread. |
205 void DevToolsHttpHandlerImpl::StartHandlerThread() { | 203 void DevToolsHttpHandlerImpl::StartHandlerThread() { |
206 base::Thread::Options options; | 204 base::Thread::Options options; |
207 options.message_loop_type = MessageLoop::TYPE_IO; | 205 options.message_loop_type = base::MessageLoop::TYPE_IO; |
208 if (!thread_->StartWithOptions(options)) { | 206 if (!thread_->StartWithOptions(options)) { |
209 BrowserThread::PostTask( | 207 BrowserThread::PostTask( |
210 BrowserThread::UI, FROM_HERE, | 208 BrowserThread::UI, FROM_HERE, |
211 base::Bind(&DevToolsHttpHandlerImpl::ResetHandlerThread, this)); | 209 base::Bind(&DevToolsHttpHandlerImpl::ResetHandlerThread, this)); |
212 return; | 210 return; |
213 } | 211 } |
214 | 212 |
215 thread_->message_loop()->PostTask( | 213 thread_->message_loop()->PostTask( |
216 FROM_HERE, | 214 FROM_HERE, |
217 base::Bind(&DevToolsHttpHandlerImpl::Init, this)); | 215 base::Bind(&DevToolsHttpHandlerImpl::Init, this)); |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 host.c_str(), | 884 host.c_str(), |
887 kPageUrlPrefix, | 885 kPageUrlPrefix, |
888 id.c_str())); | 886 id.c_str())); |
889 std::string devtools_frontend_url = GetFrontendURLInternal( | 887 std::string devtools_frontend_url = GetFrontendURLInternal( |
890 id.c_str(), | 888 id.c_str(), |
891 host); | 889 host); |
892 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 890 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
893 } | 891 } |
894 | 892 |
895 } // namespace content | 893 } // namespace content |
OLD | NEW |