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_browser_target.h" | 5 #include "content/browser/devtools/devtools_browser_target.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "net/server/http_server.h" | 14 #include "net/server/http_server.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 DevToolsBrowserTarget::DevToolsBrowserTarget( | 18 DevToolsBrowserTarget::DevToolsBrowserTarget( |
19 net::HttpServer* http_server, | 19 base::WeakPtr<net::HttpServer> http_server, |
20 int connection_id) | 20 int connection_id) |
21 : message_loop_proxy_(base::MessageLoopProxy::current()), | 21 : message_loop_proxy_(base::MessageLoopProxy::current()), |
22 http_server_(http_server), | 22 http_server_(http_server), |
23 connection_id_(connection_id), | 23 connection_id_(connection_id), |
24 weak_factory_(this) { | 24 weak_factory_(this) { |
25 } | 25 } |
26 | 26 |
27 void DevToolsBrowserTarget::RegisterDomainHandler( | 27 void DevToolsBrowserTarget::RegisterDomainHandler( |
28 const std::string& domain, | 28 const std::string& domain, |
29 DevToolsProtocol::Handler* handler, | 29 DevToolsProtocol::Handler* handler, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 base::Bind(&DevToolsBrowserTarget::HandleCommandOnUIThread, | 79 base::Bind(&DevToolsBrowserTarget::HandleCommandOnUIThread, |
80 this, | 80 this, |
81 handler, | 81 handler, |
82 command)); | 82 command)); |
83 } | 83 } |
84 | 84 |
85 void DevToolsBrowserTarget::Detach() { | 85 void DevToolsBrowserTarget::Detach() { |
86 DCHECK_EQ(message_loop_proxy_, base::MessageLoopProxy::current()); | 86 DCHECK_EQ(message_loop_proxy_, base::MessageLoopProxy::current()); |
87 DCHECK(http_server_); | 87 DCHECK(http_server_); |
88 | 88 |
89 http_server_ = NULL; | 89 http_server_ = base::WeakPtr<net::HttpServer>(); |
90 | 90 |
91 std::vector<DevToolsProtocol::Handler*> ui_handlers; | 91 std::vector<DevToolsProtocol::Handler*> ui_handlers; |
92 for (std::set<std::string>::iterator domain_it = handle_on_ui_thread_.begin(); | 92 for (std::set<std::string>::iterator domain_it = handle_on_ui_thread_.begin(); |
93 domain_it != handle_on_ui_thread_.end(); | 93 domain_it != handle_on_ui_thread_.end(); |
94 ++domain_it) { | 94 ++domain_it) { |
95 DomainHandlerMap::iterator handler_it = handlers_.find(*domain_it); | 95 DomainHandlerMap::iterator handler_it = handlers_.find(*domain_it); |
96 CHECK(handler_it != handlers_.end()); | 96 CHECK(handler_it != handlers_.end()); |
97 ui_handlers.push_back(handler_it->second); | 97 ui_handlers.push_back(handler_it->second); |
98 handlers_.erase(handler_it); | 98 handlers_.erase(handler_it); |
99 } | 99 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 void DevToolsBrowserTarget::RespondFromUIThread(const std::string& message) { | 144 void DevToolsBrowserTarget::RespondFromUIThread(const std::string& message) { |
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
146 message_loop_proxy_->PostTask( | 146 message_loop_proxy_->PostTask( |
147 FROM_HERE, | 147 FROM_HERE, |
148 base::Bind(&DevToolsBrowserTarget::Respond, this, message)); | 148 base::Bind(&DevToolsBrowserTarget::Respond, this, message)); |
149 } | 149 } |
150 | 150 |
151 } // namespace content | 151 } // namespace content |
OLD | NEW |