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