Commit b5ced6e3 authored by rvargas@chromium.org's avatar rvargas@chromium.org

Remove PlatformFile from mhtml_generator

BUG=322664

Review URL: https://codereview.chromium.org/299333002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274463 0039d316-1c4b-4281-b951-d872f2087c98
parent 277857a4
......@@ -4,7 +4,6 @@
#include "content/renderer/mhtml_generator.h"
#include "base/platform_file.h"
#include "content/common/view_messages.h"
#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/public/platform/WebCString.h"
......@@ -13,8 +12,7 @@
namespace content {
MHTMLGenerator::MHTMLGenerator(RenderViewImpl* render_view)
: RenderViewObserver(render_view),
file_(base::kInvalidPlatformFileValue) {
: RenderViewObserver(render_view) {
}
MHTMLGenerator::~MHTMLGenerator() {
......@@ -32,17 +30,14 @@ bool MHTMLGenerator::OnMessageReceived(const IPC::Message& message) {
void MHTMLGenerator::OnSavePageAsMHTML(
int job_id, IPC::PlatformFileForTransit file_for_transit) {
base::PlatformFile file =
IPC::PlatformFileForTransitToPlatformFile(file_for_transit);
file_ = file;
file_ = IPC::PlatformFileForTransitToFile(file_for_transit);
int64 size = GenerateMHTML();
base::ClosePlatformFile(file);
file_.Close();
NotifyBrowser(job_id, size);
}
void MHTMLGenerator::NotifyBrowser(int job_id, int64 data_size) {
render_view()->Send(new ViewHostMsg_SavedPageAsMHTML(job_id, data_size));
file_ = base::kInvalidPlatformFileValue;
}
// TODO(jcivelli): write the chunks in deferred tasks to give a chance to the
......@@ -56,9 +51,8 @@ int64 MHTMLGenerator::GenerateMHTML() {
while (total_bytes_written < mhtml.length()) {
size_t copy_size =
std::min(mhtml.length() - total_bytes_written, chunk_size);
int bytes_written = base::WritePlatformFile(file_, total_bytes_written,
data + total_bytes_written,
copy_size);
int bytes_written = file_.Write(total_bytes_written,
data + total_bytes_written, copy_size);
if (bytes_written == -1)
return -1;
total_bytes_written += bytes_written;
......
......@@ -5,8 +5,8 @@
#ifndef CONTENT_RENDERER_MHTML_GENERATOR_H_
#define CONTENT_RENDERER_MHTML_GENERATOR_H_
#include "base/files/file.h"
#include "content/public/renderer/render_view_observer.h"
#include "ipc/ipc_platform_file.h"
namespace content {
......@@ -28,7 +28,7 @@ class MHTMLGenerator : public RenderViewObserver {
// Returns the size of the generated MHTML, -1 if it failed.
int64 GenerateMHTML();
base::PlatformFile file_;
base::File file_;
DISALLOW_COPY_AND_ASSIGN(MHTMLGenerator);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment