| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 net::HttpServer* server, | 80 net::HttpServer* server, |
| 81 int connection_id, | 81 int connection_id, |
| 82 DevToolsAgentHost* agent_host) | 82 DevToolsAgentHost* agent_host) |
| 83 : message_loop_(message_loop), | 83 : message_loop_(message_loop), |
| 84 server_(server), | 84 server_(server), |
| 85 connection_id_(connection_id), | 85 connection_id_(connection_id), |
| 86 agent_host_(agent_host) { | 86 agent_host_(agent_host) { |
| 87 agent_host_->AttachClient(this); | 87 agent_host_->AttachClient(this); |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual ~DevToolsAgentHostClientImpl() { | 90 ~DevToolsAgentHostClientImpl() override { |
| 91 if (agent_host_.get()) | 91 if (agent_host_.get()) |
| 92 agent_host_->DetachClient(); | 92 agent_host_->DetachClient(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual void AgentHostClosed( | 95 void AgentHostClosed(DevToolsAgentHost* agent_host, |
| 96 DevToolsAgentHost* agent_host, | 96 bool replaced_with_another_client) override { |
| 97 bool replaced_with_another_client) override { | |
| 98 DCHECK(agent_host == agent_host_.get()); | 97 DCHECK(agent_host == agent_host_.get()); |
| 99 agent_host_ = NULL; | 98 agent_host_ = NULL; |
| 100 | 99 |
| 101 base::DictionaryValue notification; | 100 base::DictionaryValue notification; |
| 102 notification.SetString( | 101 notification.SetString( |
| 103 devtools::Inspector::detached::kParamReason, | 102 devtools::Inspector::detached::kParamReason, |
| 104 replaced_with_another_client ? | 103 replaced_with_another_client ? |
| 105 "replaced_with_devtools" : "target_closed"); | 104 "replaced_with_devtools" : "target_closed"); |
| 106 std::string response = DevToolsProtocol::CreateNotification( | 105 std::string response = DevToolsProtocol::CreateNotification( |
| 107 devtools::Inspector::detached::kName, | 106 devtools::Inspector::detached::kName, |
| 108 notification.DeepCopy())->Serialize(); | 107 notification.DeepCopy())->Serialize(); |
| 109 message_loop_->PostTask( | 108 message_loop_->PostTask( |
| 110 FROM_HERE, | 109 FROM_HERE, |
| 111 base::Bind(&net::HttpServer::SendOverWebSocket, | 110 base::Bind(&net::HttpServer::SendOverWebSocket, |
| 112 base::Unretained(server_), | 111 base::Unretained(server_), |
| 113 connection_id_, | 112 connection_id_, |
| 114 response)); | 113 response)); |
| 115 | 114 |
| 116 message_loop_->PostTask( | 115 message_loop_->PostTask( |
| 117 FROM_HERE, | 116 FROM_HERE, |
| 118 base::Bind(&net::HttpServer::Close, | 117 base::Bind(&net::HttpServer::Close, |
| 119 base::Unretained(server_), | 118 base::Unretained(server_), |
| 120 connection_id_)); | 119 connection_id_)); |
| 121 } | 120 } |
| 122 | 121 |
| 123 virtual void DispatchProtocolMessage( | 122 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| 124 DevToolsAgentHost* agent_host, const std::string& message) override { | 123 const std::string& message) override { |
| 125 DCHECK(agent_host == agent_host_.get()); | 124 DCHECK(agent_host == agent_host_.get()); |
| 126 message_loop_->PostTask( | 125 message_loop_->PostTask( |
| 127 FROM_HERE, | 126 FROM_HERE, |
| 128 base::Bind(&net::HttpServer::SendOverWebSocket, | 127 base::Bind(&net::HttpServer::SendOverWebSocket, |
| 129 base::Unretained(server_), | 128 base::Unretained(server_), |
| 130 connection_id_, | 129 connection_id_, |
| 131 message)); | 130 message)); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void OnMessage(const std::string& message) { | 133 void OnMessage(const std::string& message) { |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 id.c_str(), | 959 id.c_str(), |
| 961 host); | 960 host); |
| 962 dictionary->SetString( | 961 dictionary->SetString( |
| 963 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 962 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
| 964 } | 963 } |
| 965 | 964 |
| 966 return dictionary; | 965 return dictionary; |
| 967 } | 966 } |
| 968 | 967 |
| 969 } // namespace content | 968 } // namespace content |
| OLD | NEW |