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

Side by Side Diff: content/browser/devtools/protocol/network_handler.cc

Issue 2900613002: Support DevTools for off-main-thread-fetch (Closed)
Patch Set: rebase Created 3 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base64.h" 10 #include "base/base64.h"
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 const ResourceRequest& request) { 672 const ResourceRequest& request) {
673 if (!enabled_) 673 if (!enabled_)
674 return; 674 return;
675 const std::string version_id(base::IntToString(worker_version_id)); 675 const std::string version_id(base::IntToString(worker_version_id));
676 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); 676 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create());
677 net::HttpRequestHeaders headers; 677 net::HttpRequestHeaders headers;
678 headers.AddHeadersFromString(request.headers); 678 headers.AddHeadersFromString(request.headers);
679 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) 679 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();)
680 headers_dict->setString(it.name(), it.value()); 680 headers_dict->setString(it.name(), it.value());
681 frontend_->RequestWillBeSent( 681 frontend_->RequestWillBeSent(
682 request_id, version_id /* frameId */, version_id /* loaderId */, 682 request_id, "" /* loader_id */, request.url.spec(),
683 "" /* documentURL */,
684 Network::Request::Create() 683 Network::Request::Create()
685 .SetUrl(request.url.spec()) 684 .SetUrl(request.url.spec())
686 .SetMethod(request.method) 685 .SetMethod(request.method)
687 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) 686 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr))
688 .SetInitialPriority(resourcePriority(request.priority)) 687 .SetInitialPriority(resourcePriority(request.priority))
689 .SetReferrerPolicy(referrerPolicy(request.referrer_policy)) 688 .SetReferrerPolicy(referrerPolicy(request.referrer_policy))
690 .Build(), 689 .Build(),
691 base::TimeTicks::Now().ToInternalValue() / 690 base::TimeTicks::Now().ToInternalValue() /
692 static_cast<double>(base::Time::kMicrosecondsPerSecond), 691 static_cast<double>(base::Time::kMicrosecondsPerSecond),
693 base::Time::Now().ToDoubleT(), 692 base::Time::Now().ToDoubleT(),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 } 742 }
744 if (head.devtools_info->response_headers.size()) 743 if (head.devtools_info->response_headers.size())
745 response->SetHeaders(getHeaders(head.devtools_info->response_headers)); 744 response->SetHeaders(getHeaders(head.devtools_info->response_headers));
746 if (!head.devtools_info->response_headers_text.empty()) 745 if (!head.devtools_info->response_headers_text.empty())
747 response->SetHeadersText(head.devtools_info->response_headers_text); 746 response->SetHeadersText(head.devtools_info->response_headers_text);
748 } 747 }
749 response->SetProtocol(getProtocol(url, head)); 748 response->SetProtocol(getProtocol(url, head));
750 response->SetRemoteIPAddress(head.socket_address.HostForURL()); 749 response->SetRemoteIPAddress(head.socket_address.HostForURL());
751 response->SetRemotePort(head.socket_address.port()); 750 response->SetRemotePort(head.socket_address.port());
752 frontend_->ResponseReceived( 751 frontend_->ResponseReceived(
753 request_id, version_id /* frameId */, version_id /* loaderId */, 752 request_id, "" /* loader_id */,
754 base::TimeTicks::Now().ToInternalValue() / 753 base::TimeTicks::Now().ToInternalValue() /
755 static_cast<double>(base::Time::kMicrosecondsPerSecond), 754 static_cast<double>(base::Time::kMicrosecondsPerSecond),
756 Page::ResourceTypeEnum::Other, std::move(response)); 755 Page::ResourceTypeEnum::Other, std::move(response));
757 } 756 }
758 757
759 void NetworkHandler::NavigationPreloadCompleted( 758 void NetworkHandler::NavigationPreloadCompleted(
760 const std::string& request_id, 759 const std::string& request_id,
761 const ResourceRequestCompletionStatus& completion_status) { 760 const ResourceRequestCompletionStatus& completion_status) {
762 if (!enabled_) 761 if (!enabled_)
763 return; 762 return;
(...skipping 25 matching lines...) Expand all
789 base::IntToString(++next_id); 788 base::IntToString(++next_id);
790 std::string error_string = net::ErrorToString(error_code); 789 std::string error_string = net::ErrorToString(error_code);
791 bool cancelled = error_code == net::Error::ERR_ABORTED; 790 bool cancelled = error_code == net::Error::ERR_ABORTED;
792 791
793 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); 792 std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create());
794 net::HttpRequestHeaders headers; 793 net::HttpRequestHeaders headers;
795 headers.AddHeadersFromString(begin_params.headers); 794 headers.AddHeadersFromString(begin_params.headers);
796 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) 795 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();)
797 headers_dict->setString(it.name(), it.value()); 796 headers_dict->setString(it.name(), it.value());
798 frontend_->RequestWillBeSent( 797 frontend_->RequestWillBeSent(
799 request_id, request_id /* frameId */, request_id /* loaderId */, 798 request_id, "" /* loader_id */, common_params.url.spec(),
800 common_params.url.spec(),
801 Network::Request::Create() 799 Network::Request::Create()
802 .SetUrl(common_params.url.spec()) 800 .SetUrl(common_params.url.spec())
803 .SetMethod(common_params.method) 801 .SetMethod(common_params.method)
804 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) 802 .SetHeaders(Object::fromValue(headers_dict.get(), nullptr))
805 // Note: the priority value is copied from 803 // Note: the priority value is copied from
806 // ResourceDispatcherHostImpl::BeginNavigationRequest but there isn't 804 // ResourceDispatcherHostImpl::BeginNavigationRequest but there isn't
807 // a good way of sharing this. 805 // a good way of sharing this.
808 .SetInitialPriority(resourcePriority(net::HIGHEST)) 806 .SetInitialPriority(resourcePriority(net::HIGHEST))
809 .SetReferrerPolicy(referrerPolicy(common_params.referrer.policy)) 807 .SetReferrerPolicy(referrerPolicy(common_params.referrer.policy))
810 .Build(), 808 .Build(),
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 .SetReferrerPolicy(referrerPolicy(request->referrer_policy())) 934 .SetReferrerPolicy(referrerPolicy(request->referrer_policy()))
937 .Build(); 935 .Build();
938 std::string post_data; 936 std::string post_data;
939 if (GetPostData(request, &post_data)) 937 if (GetPostData(request, &post_data))
940 request_object->SetPostData(std::move(post_data)); 938 request_object->SetPostData(std::move(post_data));
941 return request_object; 939 return request_object;
942 } 940 }
943 941
944 } // namespace protocol 942 } // namespace protocol
945 } // namespace content 943 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698