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 <algorithm> | 5 #include <algorithm> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 342 } |
343 | 343 |
344 ~DevToolsAgentHostClientImpl() override { | 344 ~DevToolsAgentHostClientImpl() override { |
345 if (agent_host_.get()) | 345 if (agent_host_.get()) |
346 agent_host_->DetachClient(); | 346 agent_host_->DetachClient(); |
347 } | 347 } |
348 | 348 |
349 void AgentHostClosed(DevToolsAgentHost* agent_host, | 349 void AgentHostClosed(DevToolsAgentHost* agent_host, |
350 bool replaced_with_another_client) override { | 350 bool replaced_with_another_client) override { |
351 DCHECK(agent_host == agent_host_.get()); | 351 DCHECK(agent_host == agent_host_.get()); |
352 agent_host_ = NULL; | |
353 | 352 |
354 base::DictionaryValue notification; | 353 base::Callback<void(const std::string&)> raw_message_callback( |
355 notification.SetString( | 354 base::Bind(&DevToolsAgentHostClientImpl::DispatchProtocolMessage, |
356 devtools::Inspector::detached::kParamReason, | 355 base::Unretained(this), base::Unretained(agent_host))); |
357 replaced_with_another_client ? | 356 devtools::inspector::Client inspector(raw_message_callback); |
358 "replaced_with_devtools" : "target_closed"); | 357 inspector.Detached(devtools::inspector::DetachedParams::Create() |
359 std::string response = DevToolsProtocol::CreateNotification( | 358 ->set_reason(replaced_with_another_client ? |
360 devtools::Inspector::detached::kName, | 359 "replaced_with_devtools" : "target_closed")); |
361 notification.DeepCopy())->Serialize(); | |
362 message_loop_->PostTask( | |
363 FROM_HERE, | |
364 base::Bind(&ServerWrapper::SendOverWebSocket, | |
365 base::Unretained(server_wrapper_), | |
366 connection_id_, | |
367 response)); | |
368 | 360 |
| 361 agent_host_ = nullptr; |
369 message_loop_->PostTask( | 362 message_loop_->PostTask( |
370 FROM_HERE, | 363 FROM_HERE, |
371 base::Bind(&ServerWrapper::Close, | 364 base::Bind(&ServerWrapper::Close, |
372 base::Unretained(server_wrapper_), | 365 base::Unretained(server_wrapper_), |
373 connection_id_)); | 366 connection_id_)); |
374 } | 367 } |
375 | 368 |
376 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 369 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
377 const std::string& message) override { | 370 const std::string& message) override { |
378 DCHECK(agent_host == agent_host_.get()); | 371 DCHECK(agent_host == agent_host_.get()); |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 id.c_str(), | 1125 id.c_str(), |
1133 host); | 1126 host); |
1134 dictionary->SetString( | 1127 dictionary->SetString( |
1135 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 1128 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
1136 } | 1129 } |
1137 | 1130 |
1138 return dictionary; | 1131 return dictionary; |
1139 } | 1132 } |
1140 | 1133 |
1141 } // namespace content | 1134 } // namespace content |
OLD | NEW |