// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_RENDERER_MHTML_HANDLE_WRITER_H_ #define CONTENT_RENDERER_MHTML_HANDLE_WRITER_H_ #include <memory> #include <vector> #include "base/files/file.h" #include "base/functional/callback.h" #include "base/time/time.h" #include "content/common/download/mhtml_file_writer.mojom-forward.h" #include "mojo/public/cpp/system/data_pipe.h" namespace base { class TaskRunner; } namespace blink { class WebThreadSafeData; } namespace mojo { class SimpleWatcher; } namespace content { // TODO(crbug.com/40606905): This class needs unit tests. // Handle wrapper for MHTML serialization to abstract the handle which data // is written to. This is instantiated on the heap and is responsible for // destroying itself after completing its write operation. // Should only live in blocking sequenced threads. class MHTMLHandleWriter { … }; // Wraps a base::File target to write MHTML contents to. // This implementation immediately finishes after writing all MHTML contents // to the file handle. class MHTMLFileHandleWriter : public MHTMLHandleWriter { … }; // Wraps a mojo::ScopedDataPipeProducerHandle target to write MHTML contents to. // This implementation does not immediately finish and destroy itself due to // the limited size of the data pipe buffer. We must ensure all data is // written to the handle before finishing the write operation. class MHTMLProducerHandleWriter : public MHTMLHandleWriter { … }; } // namespace content #endif // CONTENT_RENDERER_MHTML_HANDLE_WRITER_H_