Skip to content

Commit

Permalink
Remove PlatformFile from mhtml_generator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rvargas@chromium.org committed Jun 3, 2014
1 parent 277857a commit b5ced6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 5 additions & 11 deletions content/renderer/mhtml_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -13,8 +12,7 @@
namespace content {

MHTMLGenerator::MHTMLGenerator(RenderViewImpl* render_view)
: RenderViewObserver(render_view),
file_(base::kInvalidPlatformFileValue) {
: RenderViewObserver(render_view) {
}

MHTMLGenerator::~MHTMLGenerator() {
Expand All @@ -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
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions content/renderer/mhtml_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
};
Expand Down

0 comments on commit b5ced6e

Please sign in to comment.