OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/protocol/network_handler.h" | 5 #include "content/browser/devtools/protocol/network_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 const ResourceRequest& request) { | 614 const ResourceRequest& request) { |
615 if (!enabled_) | 615 if (!enabled_) |
616 return; | 616 return; |
617 const std::string version_id(base::IntToString(worker_version_id)); | 617 const std::string version_id(base::IntToString(worker_version_id)); |
618 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); | 618 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); |
619 net::HttpRequestHeaders headers; | 619 net::HttpRequestHeaders headers; |
620 headers.AddHeadersFromString(request.headers); | 620 headers.AddHeadersFromString(request.headers); |
621 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) | 621 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) |
622 headers_dict->setString(it.name(), it.value()); | 622 headers_dict->setString(it.name(), it.value()); |
623 frontend_->RequestWillBeSent( | 623 frontend_->RequestWillBeSent( |
624 request_id, version_id /* frameId */, version_id /* loaderId */, | 624 request_id, "" /* loaderId */, request.url.spec() /* documentURL */, |
625 "" /* documentURL */, | |
626 Network::Request::Create() | 625 Network::Request::Create() |
627 .SetUrl(request.url.spec()) | 626 .SetUrl(request.url.spec()) |
628 .SetMethod(request.method) | 627 .SetMethod(request.method) |
629 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) | 628 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) |
630 .SetInitialPriority(resourcePriority(request.priority)) | 629 .SetInitialPriority(resourcePriority(request.priority)) |
631 .SetReferrerPolicy(referrerPolicy(request.referrer_policy)) | 630 .SetReferrerPolicy(referrerPolicy(request.referrer_policy)) |
632 .Build(), | 631 .Build(), |
633 base::TimeTicks::Now().ToInternalValue() / | 632 base::TimeTicks::Now().ToInternalValue() / |
634 static_cast<double>(base::Time::kMicrosecondsPerSecond), | 633 static_cast<double>(base::Time::kMicrosecondsPerSecond), |
635 base::Time::Now().ToDoubleT(), | 634 base::Time::Now().ToDoubleT(), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 684 } |
686 if (head.devtools_info->response_headers.size()) | 685 if (head.devtools_info->response_headers.size()) |
687 response->SetHeaders(getHeaders(head.devtools_info->response_headers)); | 686 response->SetHeaders(getHeaders(head.devtools_info->response_headers)); |
688 if (!head.devtools_info->response_headers_text.empty()) | 687 if (!head.devtools_info->response_headers_text.empty()) |
689 response->SetHeadersText(head.devtools_info->response_headers_text); | 688 response->SetHeadersText(head.devtools_info->response_headers_text); |
690 } | 689 } |
691 response->SetProtocol(getProtocol(url, head)); | 690 response->SetProtocol(getProtocol(url, head)); |
692 response->SetRemoteIPAddress(head.socket_address.HostForURL()); | 691 response->SetRemoteIPAddress(head.socket_address.HostForURL()); |
693 response->SetRemotePort(head.socket_address.port()); | 692 response->SetRemotePort(head.socket_address.port()); |
694 frontend_->ResponseReceived( | 693 frontend_->ResponseReceived( |
695 request_id, version_id /* frameId */, version_id /* loaderId */, | 694 request_id, "" /* loaderId */, |
696 base::TimeTicks::Now().ToInternalValue() / | 695 base::TimeTicks::Now().ToInternalValue() / |
697 static_cast<double>(base::Time::kMicrosecondsPerSecond), | 696 static_cast<double>(base::Time::kMicrosecondsPerSecond), |
698 Page::ResourceTypeEnum::Other, std::move(response)); | 697 Page::ResourceTypeEnum::Other, std::move(response)); |
699 } | 698 } |
700 | 699 |
701 void NetworkHandler::NavigationPreloadCompleted( | 700 void NetworkHandler::NavigationPreloadCompleted( |
702 const std::string& request_id, | 701 const std::string& request_id, |
703 const ResourceRequestCompletionStatus& completion_status) { | 702 const ResourceRequestCompletionStatus& completion_status) { |
704 if (!enabled_) | 703 if (!enabled_) |
705 return; | 704 return; |
(...skipping 25 matching lines...) Expand all Loading... |
731 base::IntToString(++next_id); | 730 base::IntToString(++next_id); |
732 std::string error_string = net::ErrorToString(error_code); | 731 std::string error_string = net::ErrorToString(error_code); |
733 bool cancelled = error_code == net::Error::ERR_ABORTED; | 732 bool cancelled = error_code == net::Error::ERR_ABORTED; |
734 | 733 |
735 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); | 734 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); |
736 net::HttpRequestHeaders headers; | 735 net::HttpRequestHeaders headers; |
737 headers.AddHeadersFromString(begin_params.headers); | 736 headers.AddHeadersFromString(begin_params.headers); |
738 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) | 737 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) |
739 headers_dict->setString(it.name(), it.value()); | 738 headers_dict->setString(it.name(), it.value()); |
740 frontend_->RequestWillBeSent( | 739 frontend_->RequestWillBeSent( |
741 request_id, request_id /* frameId */, request_id /* loaderId */, | 740 request_id, "" /* loaderId */, common_params.url.spec(), |
742 common_params.url.spec(), | |
743 Network::Request::Create() | 741 Network::Request::Create() |
744 .SetUrl(common_params.url.spec()) | 742 .SetUrl(common_params.url.spec()) |
745 .SetMethod(common_params.method) | 743 .SetMethod(common_params.method) |
746 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) | 744 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) |
747 // Note: the priority value is copied from | 745 // Note: the priority value is copied from |
748 // ResourceDispatcherHostImpl::BeginNavigationRequest but there isn't | 746 // ResourceDispatcherHostImpl::BeginNavigationRequest but there isn't |
749 // a good way of sharing this. | 747 // a good way of sharing this. |
750 .SetInitialPriority(resourcePriority(net::HIGHEST)) | 748 .SetInitialPriority(resourcePriority(net::HIGHEST)) |
751 .SetReferrerPolicy(referrerPolicy(common_params.referrer.policy)) | 749 .SetReferrerPolicy(referrerPolicy(common_params.referrer.policy)) |
752 .Build(), | 750 .Build(), |
(...skipping 12 matching lines...) Expand all Loading... |
765 static_cast<double>(base::Time::kMicrosecondsPerSecond), | 763 static_cast<double>(base::Time::kMicrosecondsPerSecond), |
766 Page::ResourceTypeEnum::Document, error_string, cancelled); | 764 Page::ResourceTypeEnum::Document, error_string, cancelled); |
767 } | 765 } |
768 | 766 |
769 std::string NetworkHandler::UserAgentOverride() const { | 767 std::string NetworkHandler::UserAgentOverride() const { |
770 return enabled_ ? user_agent_ : std::string(); | 768 return enabled_ ? user_agent_ : std::string(); |
771 } | 769 } |
772 | 770 |
773 } // namespace protocol | 771 } // namespace protocol |
774 } // namespace content | 772 } // namespace content |
OLD | NEW |