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

Unified Diff: content/renderer/history_serialization.cc

Issue 1987053002: Deduplicating code performing WebHTTPBody::Element conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/data/test_body/g Created 4 years, 7 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/history_serialization.cc
diff --git a/content/renderer/history_serialization.cc b/content/renderer/history_serialization.cc
index 0a4376c023cab71534f3f22fcde3ef5e989a27c2..ac85324c1c097f5e0294936da7a1a0ef40a0e13b 100644
--- a/content/renderer/history_serialization.cc
+++ b/content/renderer/history_serialization.cc
@@ -6,9 +6,12 @@
#include <stddef.h>
+#include "base/strings/nullable_string16.h"
#include "content/common/page_state_serialization.h"
#include "content/public/common/page_state.h"
#include "content/renderer/history_entry.h"
+#include "content/renderer/http_body_conversions.h"
+#include "third_party/WebKit/public/platform/WebData.h"
#include "third_party/WebKit/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/public/platform/WebHTTPBody.h"
#include "third_party/WebKit/public/platform/WebPoint.h"
@@ -17,6 +20,7 @@
#include "third_party/WebKit/public/web/WebHistoryItem.h"
#include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
+using blink::WebData;
using blink::WebHTTPBody;
using blink::WebHistoryItem;
using blink::WebSerializedScriptValue;
@@ -33,56 +37,6 @@ void ToNullableString16Vector(const WebVector<WebString>& input,
output->push_back(input[i]);
}
-void ToExplodedHttpBodyElement(const WebHTTPBody::Element& input,
- ExplodedHttpBodyElement* output) {
- switch (input.type) {
- case WebHTTPBody::Element::TypeData:
- output->data.assign(input.data.data(), input.data.size());
- break;
- case WebHTTPBody::Element::TypeFile:
- output->file_path = input.filePath;
- output->file_start = input.fileStart;
- output->file_length = input.fileLength;
- output->file_modification_time = input.modificationTime;
- break;
- case WebHTTPBody::Element::TypeFileSystemURL:
- output->filesystem_url = input.fileSystemURL;
- output->file_start = input.fileStart;
- output->file_length = input.fileLength;
- output->file_modification_time = input.modificationTime;
- break;
- case WebHTTPBody::Element::TypeBlob:
- output->blob_uuid = input.blobUUID.utf8();
- break;
- }
-}
-
-void AppendHTTPBodyElement(const ExplodedHttpBodyElement& element,
- WebHTTPBody* http_body) {
- switch (element.type) {
- case WebHTTPBody::Element::TypeData:
- http_body->appendData(element.data);
- break;
- case WebHTTPBody::Element::TypeFile:
- http_body->appendFileRange(
- element.file_path,
- element.file_start,
- element.file_length,
- element.file_modification_time);
- break;
- case WebHTTPBody::Element::TypeFileSystemURL:
- http_body->appendFileSystemURLRange(
- element.filesystem_url,
- element.file_start,
- element.file_length,
- element.file_modification_time);
- break;
- case WebHTTPBody::Element::TypeBlob:
- http_body->appendBlob(WebString::fromUTF8(element.blob_uuid));
- break;
- }
-}
-
void GenerateFrameStateFromItem(const WebHistoryItem& item,
ExplodedFrameState* state) {
state->url_string = item.urlString();
@@ -109,7 +63,7 @@ void GenerateFrameStateFromItem(const WebHistoryItem& item,
for (size_t i = 0; i < http_body.elementCount(); ++i) {
WebHTTPBody::Element element;
http_body.elementAt(i, element);
- ToExplodedHttpBodyElement(element, &state->http_body.elements[i]);
+ ConvertToHttpBodyElement(element, &state->http_body.elements[i]);
}
state->http_body.contains_passwords = http_body.containsPasswordData();
}
@@ -162,7 +116,7 @@ void RecursivelyGenerateHistoryItem(const ExplodedFrameState& state,
http_body.initialize();
http_body.setIdentifier(state.http_body.identifier);
for (size_t i = 0; i < state.http_body.elements.size(); ++i)
- AppendHTTPBodyElement(state.http_body.elements[i], &http_body);
+ AppendHttpBodyElement(state.http_body.elements[i], &http_body);
item.setHTTPBody(http_body);
}
node->set_item(item);
« 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