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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop/message_loop_proxy.h" | 15 #include "base/message_loop/message_loop_proxy.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "content/browser/devtools/devtools_browser_target.h" | 20 #include "content/browser/devtools/devtools_browser_target.h" |
21 #include "content/browser/devtools/devtools_protocol.h" | 21 #include "content/browser/devtools/devtools_protocol.h" |
22 #include "content/browser/devtools/devtools_protocol_constants.h" | 22 #include "content/browser/devtools/devtools_protocol_constants.h" |
23 #include "content/browser/devtools/devtools_system_info_handler.h" | 23 #include "content/browser/devtools/devtools_system_info_handler.h" |
24 #include "content/browser/devtools/devtools_tracing_handler.h" | 24 #include "content/browser/devtools/devtools_tracing_handler.h" |
| 25 #include "content/browser/devtools/embedded_worker_devtools_manager.h" |
25 #include "content/browser/devtools/tethering_handler.h" | 26 #include "content/browser/devtools/tethering_handler.h" |
26 #include "content/common/devtools_messages.h" | 27 #include "content/common/devtools_messages.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/devtools_agent_host.h" | 29 #include "content/public/browser/devtools_agent_host.h" |
29 #include "content/public/browser/devtools_client_host.h" | 30 #include "content/public/browser/devtools_client_host.h" |
30 #include "content/public/browser/devtools_http_handler_delegate.h" | 31 #include "content/public/browser/devtools_http_handler_delegate.h" |
31 #include "content/public/browser/devtools_manager.h" | 32 #include "content/public/browser/devtools_manager.h" |
32 #include "content/public/browser/devtools_target.h" | 33 #include "content/public/browser/devtools_target.h" |
33 #include "content/public/common/content_client.h" | 34 #include "content/public/common/content_client.h" |
34 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 net::HTTP_NOT_FOUND, | 543 net::HTTP_NOT_FOUND, |
543 NULL, | 544 NULL, |
544 "Unknown command: " + command); | 545 "Unknown command: " + command); |
545 return; | 546 return; |
546 } | 547 } |
547 | 548 |
548 void DevToolsHttpHandlerImpl::OnTargetListReceived( | 549 void DevToolsHttpHandlerImpl::OnTargetListReceived( |
549 int connection_id, | 550 int connection_id, |
550 const std::string& host, | 551 const std::string& host, |
551 const DevToolsHttpHandlerDelegate::TargetList& targets) { | 552 const DevToolsHttpHandlerDelegate::TargetList& targets) { |
552 DevToolsHttpHandlerDelegate::TargetList sorted_targets = targets; | 553 EmbeddedWorkerDevToolsManager::GetInstance() |
| 554 ->GetAllServiceWorkerTargets( |
| 555 base::Bind(&DevToolsHttpHandlerImpl::OnServiceWorkersReceived, |
| 556 this, connection_id, host, targets)); |
| 557 } |
| 558 |
| 559 void DevToolsHttpHandlerImpl::OnServiceWorkersReceived( |
| 560 int connection_id, |
| 561 const std::string& host, |
| 562 const DevToolsHttpHandlerDelegate::TargetList& targets, |
| 563 const DevToolsHttpHandlerDelegate::TargetList& workers) { |
| 564 typedef DevToolsHttpHandlerDelegate::TargetList Targets; |
| 565 Targets sorted_targets(targets); |
| 566 std::copy(workers.begin(), workers.end(), back_inserter(sorted_targets)); |
| 567 |
553 std::sort(sorted_targets.begin(), sorted_targets.end(), TimeComparator); | 568 std::sort(sorted_targets.begin(), sorted_targets.end(), TimeComparator); |
554 | 569 |
555 STLDeleteValues(&target_map_); | 570 STLDeleteValues(&target_map_); |
556 base::ListValue list_value; | 571 base::ListValue list_value; |
557 for (DevToolsHttpHandlerDelegate::TargetList::const_iterator it = | 572 for (DevToolsHttpHandlerDelegate::TargetList::const_iterator it = |
558 sorted_targets.begin(); it != sorted_targets.end(); ++it) { | 573 sorted_targets.begin(); it != sorted_targets.end(); ++it) { |
559 DevToolsTarget* target = *it; | 574 DevToolsTarget* target = *it; |
560 target_map_[target->GetId()] = target; | 575 target_map_[target->GetId()] = target; |
561 list_value.Append(SerializeTarget(*target, host)); | 576 list_value.Append(SerializeTarget(*target, host)); |
562 } | 577 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 id.c_str(), | 829 id.c_str(), |
815 host); | 830 host); |
816 dictionary->SetString( | 831 dictionary->SetString( |
817 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); | 832 kTargetDevtoolsFrontendUrlField, devtools_frontend_url); |
818 } | 833 } |
819 | 834 |
820 return dictionary; | 835 return dictionary; |
821 } | 836 } |
822 | 837 |
823 } // namespace content | 838 } // namespace content |
OLD | NEW |