Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: content/browser/devtools/devtools_http_handler_impl.cc

Issue 13305002: Remove redundant DevToolsManager methods and clean up its clients. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 return; 597 return;
598 } 598 }
599 599
600 std::string page_id = request.path.substr(strlen(kPageUrlPrefix)); 600 std::string page_id = request.path.substr(strlen(kPageUrlPrefix));
601 DevToolsAgentHost* agent = binding_->ForIdentifier(page_id); 601 DevToolsAgentHost* agent = binding_->ForIdentifier(page_id);
602 if (!agent) { 602 if (!agent) {
603 Send500(connection_id, "No such target id: " + page_id); 603 Send500(connection_id, "No such target id: " + page_id);
604 return; 604 return;
605 } 605 }
606 606
607 DevToolsManager* manager = DevToolsManager::GetInstance(); 607 if (agent->IsAttached()) {
608 if (manager->GetDevToolsClientHostFor(agent)) {
609 Send500(connection_id, 608 Send500(connection_id,
610 "Target with given id is being inspected: " + page_id); 609 "Target with given id is being inspected: " + page_id);
611 return; 610 return;
612 } 611 }
613 612
614 DevToolsClientHostImpl* client_host = 613 DevToolsClientHostImpl* client_host =
615 new DevToolsClientHostImpl(thread_->message_loop(), 614 new DevToolsClientHostImpl(thread_->message_loop(),
616 server_, 615 server_,
617 connection_id); 616 connection_id);
618 connection_to_client_host_ui_[connection_id] = client_host; 617 connection_to_client_host_ui_[connection_id] = client_host;
619 618
620 manager->RegisterDevToolsClientHostFor(agent, client_host); 619 DevToolsManager::GetInstance()->
620 RegisterDevToolsClientHostFor(agent, client_host);
621 621
622 AcceptWebSocket(connection_id, request); 622 AcceptWebSocket(connection_id, request);
623 } 623 }
624 624
625 void DevToolsHttpHandlerImpl::OnWebSocketMessageUI( 625 void DevToolsHttpHandlerImpl::OnWebSocketMessageUI(
626 int connection_id, 626 int connection_id,
627 const std::string& data) { 627 const std::string& data) {
628 if (browser_target_ && connection_id == browser_target_->connection_id()) { 628 if (browser_target_ && connection_id == browser_target_->connection_id()) {
629 std::string json_response = browser_target_->HandleMessage(data); 629 std::string json_response = browser_target_->HandleMessage(data);
630 630
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 NavigationController& controller = web_contents->GetController(); 807 NavigationController& controller = web_contents->GetController();
808 NavigationEntry* entry = controller.GetActiveEntry(); 808 NavigationEntry* entry = controller.GetActiveEntry();
809 if (entry != NULL && entry->GetURL().is_valid()) { 809 if (entry != NULL && entry->GetURL().is_valid()) {
810 dictionary->SetString(kTargetFaviconUrlField, 810 dictionary->SetString(kTargetFaviconUrlField,
811 entry->GetFavicon().url.spec()); 811 entry->GetFavicon().url.spec());
812 } 812 }
813 } 813 }
814 dictionary->SetString(kTargetDescriptionField, 814 dictionary->SetString(kTargetDescriptionField,
815 delegate_->GetViewDescription(rvh)); 815 delegate_->GetViewDescription(rvh));
816 816
817 if (!DevToolsManager::GetInstance()->GetDevToolsClientHostFor(agent)) 817 if (!agent->IsAttached())
818 SerializeDebuggerURLs(dictionary, id, host); 818 SerializeDebuggerURLs(dictionary, id, host);
819 return dictionary; 819 return dictionary;
820 } 820 }
821 821
822 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializeWorkerInfo( 822 base::DictionaryValue* DevToolsHttpHandlerImpl::SerializeWorkerInfo(
823 const WorkerService::WorkerInfo& worker, 823 const WorkerService::WorkerInfo& worker,
824 const std::string& host) { 824 const std::string& host) {
825 base::DictionaryValue* dictionary = new base::DictionaryValue; 825 base::DictionaryValue* dictionary = new base::DictionaryValue;
826 826
827 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetForWorker( 827 scoped_refptr<DevToolsAgentHost> agent(DevToolsAgentHost::GetForWorker(
828 worker.process_id, worker.route_id)); 828 worker.process_id, worker.route_id));
829 829
830 std::string id = binding_->GetIdentifier(agent); 830 std::string id = binding_->GetIdentifier(agent);
831 831
832 dictionary->SetString(kTargetIdField, id); 832 dictionary->SetString(kTargetIdField, id);
833 dictionary->SetString(kTargetTypeField, kTargetTypeOther); 833 dictionary->SetString(kTargetTypeField, kTargetTypeOther);
834 dictionary->SetString(kTargetTitleField, 834 dictionary->SetString(kTargetTitleField,
835 UTF16ToUTF8(net::EscapeForHTML(worker.name))); 835 UTF16ToUTF8(net::EscapeForHTML(worker.name)));
836 dictionary->SetString(kTargetUrlField, worker.url.spec()); 836 dictionary->SetString(kTargetUrlField, worker.url.spec());
837 dictionary->SetString(kTargetDescriptionField, 837 dictionary->SetString(kTargetDescriptionField,
838 base::StringPrintf("Worker pid:%d", base::GetProcId(worker.handle))); 838 base::StringPrintf("Worker pid:%d", base::GetProcId(worker.handle)));
839 839
840 if (!DevToolsManager::GetInstance()->GetDevToolsClientHostFor(agent)) 840 if (!agent->IsAttached())
841 SerializeDebuggerURLs(dictionary, id, host); 841 SerializeDebuggerURLs(dictionary, id, host);
842 return dictionary; 842 return dictionary;
843 } 843 }
844 844
845 void DevToolsHttpHandlerImpl::SerializeDebuggerURLs( 845 void DevToolsHttpHandlerImpl::SerializeDebuggerURLs(
846 base::DictionaryValue* dictionary, 846 base::DictionaryValue* dictionary,
847 const std::string& id, 847 const std::string& id,
848 const std::string& host) { 848 const std::string& host) {
849 dictionary->SetString(kTargetWebSocketDebuggerUrlField, 849 dictionary->SetString(kTargetWebSocketDebuggerUrlField,
850 base::StringPrintf("ws://%s%s%s", 850 base::StringPrintf("ws://%s%s%s",
851 host.c_str(), 851 host.c_str(),
852 kPageUrlPrefix, 852 kPageUrlPrefix,
853 id.c_str())); 853 id.c_str()));
854 std::string devtools_frontend_url = GetFrontendURLInternal( 854 std::string devtools_frontend_url = GetFrontendURLInternal(
855 id.c_str(), 855 id.c_str(),
856 host); 856 host);
857 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url); 857 dictionary->SetString(kTargetDevtoolsFrontendUrlField, devtools_frontend_url);
858 } 858 }
859 859
860 } // namespace content 860 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_external_agent_proxy_impl.cc ('k') | content/browser/devtools/devtools_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698