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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2012913002: Deduping conversions between ResourceRequestBody/WebHTTPBody/ExplodedHttpBody. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@get-rid-of-exploded-http-body
Patch Set: Calling ResourceRequestBody::AppendFileRange with optional_body_file_path. Created 4 years, 6 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 | « content/renderer/http_body_conversions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #include "content/renderer/browser_plugin/browser_plugin_manager.h" 87 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
88 #include "content/renderer/child_frame_compositing_helper.h" 88 #include "content/renderer/child_frame_compositing_helper.h"
89 #include "content/renderer/context_menu_params_builder.h" 89 #include "content/renderer/context_menu_params_builder.h"
90 #include "content/renderer/devtools/devtools_agent.h" 90 #include "content/renderer/devtools/devtools_agent.h"
91 #include "content/renderer/dom_automation_controller.h" 91 #include "content/renderer/dom_automation_controller.h"
92 #include "content/renderer/effective_connection_type_helper.h" 92 #include "content/renderer/effective_connection_type_helper.h"
93 #include "content/renderer/external_popup_menu.h" 93 #include "content/renderer/external_popup_menu.h"
94 #include "content/renderer/gpu/gpu_benchmarking_extension.h" 94 #include "content/renderer/gpu/gpu_benchmarking_extension.h"
95 #include "content/renderer/history_controller.h" 95 #include "content/renderer/history_controller.h"
96 #include "content/renderer/history_serialization.h" 96 #include "content/renderer/history_serialization.h"
97 #include "content/renderer/http_body_conversions.h"
98 #include "content/renderer/image_downloader/image_downloader_impl.h" 97 #include "content/renderer/image_downloader/image_downloader_impl.h"
99 #include "content/renderer/ime_event_guard.h" 98 #include "content/renderer/ime_event_guard.h"
100 #include "content/renderer/internal_document_state_data.h" 99 #include "content/renderer/internal_document_state_data.h"
101 #include "content/renderer/manifest/manifest_manager.h" 100 #include "content/renderer/manifest/manifest_manager.h"
102 #include "content/renderer/media/audio_device_factory.h" 101 #include "content/renderer/media/audio_device_factory.h"
103 #include "content/renderer/media/media_permission_dispatcher.h" 102 #include "content/renderer/media/media_permission_dispatcher.h"
104 #include "content/renderer/media/media_stream_dispatcher.h" 103 #include "content/renderer/media/media_stream_dispatcher.h"
105 #include "content/renderer/media/media_stream_renderer_factory_impl.h" 104 #include "content/renderer/media/media_stream_renderer_factory_impl.h"
106 #include "content/renderer/media/midi_dispatcher.h" 105 #include "content/renderer/media/midi_dispatcher.h"
107 #include "content/renderer/media/render_media_log.h" 106 #include "content/renderer/media/render_media_log.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // passed back to the browser in the DidCommitProvisionalLoad and the 534 // passed back to the browser in the DidCommitProvisionalLoad and the
536 // DocumentLoadComplete IPCs. 535 // DocumentLoadComplete IPCs.
537 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); 536 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks();
538 request.setUiStartTime(ui_timestamp.InSecondsF()); 537 request.setUiStartTime(ui_timestamp.InSecondsF());
539 request.setInputPerfMetricReportPolicy( 538 request.setInputPerfMetricReportPolicy(
540 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( 539 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>(
541 common_params.report_type)); 540 common_params.report_type));
542 return request; 541 return request;
543 } 542 }
544 543
545 // Converts the HTTP body data stored in ResourceRequestBody format to a
546 // WebHTTPBody, which is then added to the WebURLRequest.
547 // PlzNavigate: used to add the POST data sent by the renderer at commit time
548 // to the WebURLRequest used to commit the navigation. This ensures that the
549 // POST data will be in the PageState sent to the browser on commit.
550 void AddHTTPBodyToRequest(WebURLRequest* request,
551 const scoped_refptr<ResourceRequestBody>& body) {
552 WebHTTPBody http_body;
553 http_body.initialize();
554 http_body.setIdentifier(body->identifier());
555 for (const ResourceRequestBody::Element& element : *(body->elements()))
556 AppendHttpBodyElement(element, &http_body);
557 request->setHTTPBody(http_body);
558 }
559
560 // Sanitizes the navigation_start timestamp for browser-initiated navigations, 544 // Sanitizes the navigation_start timestamp for browser-initiated navigations,
561 // where the browser possibly has a better notion of start time than the 545 // where the browser possibly has a better notion of start time than the
562 // renderer. In the case of cross-process navigations, this carries over the 546 // renderer. In the case of cross-process navigations, this carries over the
563 // time of finishing the onbeforeunload handler of the previous page. 547 // time of finishing the onbeforeunload handler of the previous page.
564 // TimeTicks is sometimes not monotonic across processes, and because 548 // TimeTicks is sometimes not monotonic across processes, and because
565 // |browser_navigation_start| is likely before this process existed, 549 // |browser_navigation_start| is likely before this process existed,
566 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by 550 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by
567 // clamping it to renderer_navigation_start, initialized earlier in the call 551 // clamping it to renderer_navigation_start, initialized earlier in the call
568 // stack. 552 // stack.
569 base::TimeTicks SanitizeNavigationTiming( 553 base::TimeTicks SanitizeNavigationTiming(
(...skipping 4784 matching lines...) Expand 10 before | Expand all | Expand 10 after
5354 : blink::WebFrameLoadType::Standard; 5338 : blink::WebFrameLoadType::Standard;
5355 blink::WebHistoryLoadType history_load_type = 5339 blink::WebHistoryLoadType history_load_type =
5356 blink::WebHistoryDifferentDocumentLoad; 5340 blink::WebHistoryDifferentDocumentLoad;
5357 bool should_load_request = false; 5341 bool should_load_request = false;
5358 WebHistoryItem item_for_history_navigation; 5342 WebHistoryItem item_for_history_navigation;
5359 WebURLRequest request = 5343 WebURLRequest request =
5360 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5344 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5361 frame_->isViewSourceModeEnabled()); 5345 frame_->isViewSourceModeEnabled());
5362 5346
5363 if (IsBrowserSideNavigationEnabled() && common_params.post_data) 5347 if (IsBrowserSideNavigationEnabled() && common_params.post_data)
5364 AddHTTPBodyToRequest(&request, common_params.post_data); 5348 request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
5365 5349
5366 // Used to determine whether this frame is actually loading a request as part 5350 // Used to determine whether this frame is actually loading a request as part
5367 // of a history navigation. 5351 // of a history navigation.
5368 bool has_history_navigation_in_frame = false; 5352 bool has_history_navigation_in_frame = false;
5369 5353
5370 #if defined(OS_ANDROID) 5354 #if defined(OS_ANDROID)
5371 request.setHasUserGesture(start_params.has_user_gesture); 5355 request.setHasUserGesture(start_params.has_user_gesture);
5372 #endif 5356 #endif
5373 5357
5374 // PlzNavigate: Make sure that Blink's loader will not try to use browser side 5358 // PlzNavigate: Make sure that Blink's loader will not try to use browser side
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
5447 start_params.extra_headers.end(), 5431 start_params.extra_headers.end(),
5448 "\n"); 5432 "\n");
5449 i.GetNext();) { 5433 i.GetNext();) {
5450 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), 5434 request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
5451 WebString::fromUTF8(i.values())); 5435 WebString::fromUTF8(i.values()));
5452 } 5436 }
5453 } 5437 }
5454 5438
5455 if (common_params.method == "POST" && !browser_side_navigation && 5439 if (common_params.method == "POST" && !browser_side_navigation &&
5456 common_params.post_data) { 5440 common_params.post_data) {
5457 AddHTTPBodyToRequest(&request, common_params.post_data); 5441 request.setHTTPBody(
5442 GetWebHTTPBodyForRequestBody(common_params.post_data));
5458 } 5443 }
5459 5444
5460 // A session history navigation should have been accompanied by state. 5445 // A session history navigation should have been accompanied by state.
5461 CHECK_EQ(request_params.page_id, -1); 5446 CHECK_EQ(request_params.page_id, -1);
5462 5447
5463 should_load_request = true; 5448 should_load_request = true;
5464 } 5449 }
5465 5450
5466 if (should_load_request) { 5451 if (should_load_request) {
5467 // Sanitize navigation start now that we know the load_type. 5452 // Sanitize navigation start now that we know the load_type.
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
6157 // event target. Potentially a Pepper plugin will receive the event. 6142 // event target. Potentially a Pepper plugin will receive the event.
6158 // In order to tell whether a plugin gets the last mouse event and which it 6143 // In order to tell whether a plugin gets the last mouse event and which it
6159 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6144 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6160 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6145 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6161 // |pepper_last_mouse_event_target_|. 6146 // |pepper_last_mouse_event_target_|.
6162 pepper_last_mouse_event_target_ = nullptr; 6147 pepper_last_mouse_event_target_ = nullptr;
6163 #endif 6148 #endif
6164 } 6149 }
6165 6150
6166 } // namespace content 6151 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/http_body_conversions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698