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

Side by Side Diff: content/renderer/history_serialization.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/public/common/page_state.cc ('k') | content/renderer/http_body_conversions.h » ('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/renderer/history_serialization.h" 5 #include "content/renderer/history_serialization.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/strings/nullable_string16.h" 9 #include "base/strings/nullable_string16.h"
10 #include "content/child/web_url_request_util.h"
10 #include "content/common/page_state_serialization.h" 11 #include "content/common/page_state_serialization.h"
11 #include "content/public/common/page_state.h" 12 #include "content/public/common/page_state.h"
12 #include "content/renderer/history_entry.h" 13 #include "content/renderer/history_entry.h"
13 #include "content/renderer/http_body_conversions.h"
14 #include "third_party/WebKit/public/platform/WebData.h" 14 #include "third_party/WebKit/public/platform/WebData.h"
15 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 15 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
16 #include "third_party/WebKit/public/platform/WebHTTPBody.h" 16 #include "third_party/WebKit/public/platform/WebHTTPBody.h"
17 #include "third_party/WebKit/public/platform/WebPoint.h" 17 #include "third_party/WebKit/public/platform/WebPoint.h"
18 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
19 #include "third_party/WebKit/public/platform/WebVector.h" 19 #include "third_party/WebKit/public/platform/WebVector.h"
20 #include "third_party/WebKit/public/web/WebHistoryItem.h" 20 #include "third_party/WebKit/public/web/WebHistoryItem.h"
21 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" 21 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
22 22
23 using blink::WebData; 23 using blink::WebData;
(...skipping 25 matching lines...) Expand all
49 state->visual_viewport_scroll_offset = item.visualViewportScrollOffset(); 49 state->visual_viewport_scroll_offset = item.visualViewportScrollOffset();
50 state->scroll_offset = item.scrollOffset(); 50 state->scroll_offset = item.scrollOffset();
51 state->item_sequence_number = item.itemSequenceNumber(); 51 state->item_sequence_number = item.itemSequenceNumber();
52 state->document_sequence_number = 52 state->document_sequence_number =
53 item.documentSequenceNumber(); 53 item.documentSequenceNumber();
54 state->page_scale_factor = item.pageScaleFactor(); 54 state->page_scale_factor = item.pageScaleFactor();
55 ToNullableString16Vector(item.documentState(), &state->document_state); 55 ToNullableString16Vector(item.documentState(), &state->document_state);
56 56
57 state->http_body.http_content_type = item.httpContentType(); 57 state->http_body.http_content_type = item.httpContentType();
58 const WebHTTPBody& http_body = item.httpBody(); 58 const WebHTTPBody& http_body = item.httpBody();
59 state->http_body.is_null = http_body.isNull(); 59 if (!http_body.isNull()) {
60 if (!state->http_body.is_null) { 60 state->http_body.request_body = GetRequestBodyForWebHTTPBody(http_body);
61 state->http_body.identifier = http_body.identifier();
62 state->http_body.elements.resize(http_body.elementCount());
63 for (size_t i = 0; i < http_body.elementCount(); ++i) {
64 WebHTTPBody::Element element;
65 http_body.elementAt(i, element);
66 ConvertToHttpBodyElement(element, &state->http_body.elements[i]);
67 }
68 state->http_body.contains_passwords = http_body.containsPasswordData(); 61 state->http_body.contains_passwords = http_body.containsPasswordData();
69 } 62 }
70 } 63 }
71 64
72 void RecursivelyGenerateFrameState( 65 void RecursivelyGenerateFrameState(
73 HistoryEntry::HistoryNode* node, 66 HistoryEntry::HistoryNode* node,
74 ExplodedFrameState* state, 67 ExplodedFrameState* state,
75 std::vector<base::NullableString16>* referenced_files) { 68 std::vector<base::NullableString16>* referenced_files) {
76 GenerateFrameStateFromItem(node->item(), state); 69 GenerateFrameStateFromItem(node->item(), state);
77 ToNullableString16Vector(node->item().getReferencedFilePaths(), 70 ToNullableString16Vector(node->item().getReferencedFilePaths(),
(...skipping 26 matching lines...) Expand all
104 97
105 // These values are generated at WebHistoryItem construction time, and we 98 // These values are generated at WebHistoryItem construction time, and we
106 // only want to override those new values with old values if the old values 99 // only want to override those new values with old values if the old values
107 // are defined. A value of 0 means undefined in this context. 100 // are defined. A value of 0 means undefined in this context.
108 if (state.item_sequence_number) 101 if (state.item_sequence_number)
109 item.setItemSequenceNumber(state.item_sequence_number); 102 item.setItemSequenceNumber(state.item_sequence_number);
110 if (state.document_sequence_number) 103 if (state.document_sequence_number)
111 item.setDocumentSequenceNumber(state.document_sequence_number); 104 item.setDocumentSequenceNumber(state.document_sequence_number);
112 105
113 item.setHTTPContentType(state.http_body.http_content_type); 106 item.setHTTPContentType(state.http_body.http_content_type);
114 if (!state.http_body.is_null) { 107 if (state.http_body.request_body != nullptr) {
115 WebHTTPBody http_body; 108 item.setHTTPBody(
116 http_body.initialize(); 109 GetWebHTTPBodyForRequestBody(state.http_body.request_body));
117 http_body.setIdentifier(state.http_body.identifier);
118 for (size_t i = 0; i < state.http_body.elements.size(); ++i)
119 AppendHttpBodyElement(state.http_body.elements[i], &http_body);
120 item.setHTTPBody(http_body);
121 } 110 }
122 node->set_item(item); 111 node->set_item(item);
123 112
124 for (size_t i = 0; i < state.children.size(); ++i) 113 for (size_t i = 0; i < state.children.size(); ++i)
125 RecursivelyGenerateHistoryItem(state.children[i], node->AddChild()); 114 RecursivelyGenerateHistoryItem(state.children[i], node->AddChild());
126 } 115 }
127 116
128 } // namespace 117 } // namespace
129 118
130 PageState HistoryEntryToPageState(HistoryEntry* entry) { 119 PageState HistoryEntryToPageState(HistoryEntry* entry) {
(...skipping 27 matching lines...) Expand all
158 if (!DecodePageState(page_state.ToEncodedData(), &state)) 147 if (!DecodePageState(page_state.ToEncodedData(), &state))
159 return std::unique_ptr<HistoryEntry>(); 148 return std::unique_ptr<HistoryEntry>();
160 149
161 std::unique_ptr<HistoryEntry> entry(new HistoryEntry()); 150 std::unique_ptr<HistoryEntry> entry(new HistoryEntry());
162 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node()); 151 RecursivelyGenerateHistoryItem(state.top, entry->root_history_node());
163 152
164 return entry; 153 return entry;
165 } 154 }
166 155
167 } // namespace content 156 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/page_state.cc ('k') | content/renderer/http_body_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698