![electron-roller[bot]](/assets/img/avatar_default.png)
* chore: bump chromium in DEPS to 134.0.6998.1 * chore: bump chromium in DEPS to 134.0.6998.5 * chore: bump chromium in DEPS to 134.0.6998.3 * chore: bump chromium to 134.0.6988.0 (main) (#45334) * chore: bump chromium in DEPS to 134.0.6976.0 * chore: update mas_avoid_private_macos_api_usage.patch.patch https://chromium-review.googlesource.com/c/chromium/src/+/6171046 process_info_mac.cc -> process_info_mac.mm * chore: update build_do_not_depend_on_packed_resource_integrity.patch https://chromium-review.googlesource.com/c/chromium/src/+/6196857 * chore: update feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch https://chromium-review.googlesource.com/c/chromium/src/+/6182296 https://chromium-review.googlesource.com/c/chromium/src/+/6183404 https://chromium-review.googlesource.com/c/chromium/src/+/6187853 A lot changed in the upstream implementation. There's a good chance I got this wrong as threading has changed and moved some variables into globals. * chore: remove build_remove_vr_directx_helpers_dependency.patch https://chromium-review.googlesource.com/c/chromium/src/+/6186102 This landed upstream * chore: e patches all * chore: update net::CookieInclusionStatus::ExclusionReason enum https://chromium-review.googlesource.com/c/chromium/src/+/6183252 https://chromium-review.googlesource.com/c/chromium/src/+/6185544 * chore: update content::WebAuthenticationDelegate import https://chromium-review.googlesource.com/c/chromium/src/+/6189769 * Revert "chore: disable focus handling test due to win32/ia32 regression" This reverts commit 1a57ba5d59848d0c841ddda59c9299a4f957452a. * chore: bump chromium in DEPS to 134.0.6978.0 * chore: bump chromium in DEPS to 134.0.6980.0 * chore: bump chromium in DEPS to 134.0.6982.0 * chore: bump chromium in DEPS to 134.0.6984.0 * 6196281: Allow direct embedder IsPdfInternalPluginAllowedOrigin() interaction https://chromium-review.googlesource.com/c/chromium/src/+/6196281 * 6196283: Delete PdfInternalPluginDelegate https://chromium-review.googlesource.com/c/chromium/src/+/6196283 * chore: update patches * chore: bump chromium in DEPS to 134.0.6986.0 * chore: update patches * 6205762: Support option to use window.showSaveFilePicker() in PDF attachment code https://chromium-review.googlesource.com/c/chromium/src/+/6205762 See also: * https://issues.chromium.org/issues/373852607 * 5939153: [PDF] Add PdfUseShowSaveFilePicker feature flag | https://chromium-review.googlesource.com/c/chromium/src/+/5939153 * 6205761: Delete spurious Ink-specific code in pdf_viewer.ts | https://chromium-review.googlesource.com/c/chromium/src/+/6205761 * 6209609: Remove WebVector: Automatic changes https://chromium-review.googlesource.com/c/chromium/src/+/6209609 * 6205488: UI: make QT5 optional https://chromium-review.googlesource.com/c/chromium/src/+/6205488 * 6178281: Rename pak files from branding strings https://chromium-review.googlesource.com/c/chromium/src/+/6178281 * fixup! 6209609: Remove WebVector: Automatic changes https://chromium-review.googlesource.com/c/chromium/src/+/6209609 * 6193249: Switch from safe_browsing::EventResult to enterprise_connectors:EventResult https://chromium-review.googlesource.com/c/chromium/src/+/6193249 * 6197457: Remove Pause/ResumeReadingBodyFromNet IPCs https://chromium-review.googlesource.com/c/chromium/src/+/6197457 * 6191230: Record total time spent on a picture in picture window https://chromium-review.googlesource.com/c/chromium/src/+/6191230 * chore: bump chromium in DEPS to 134.0.6988.0 * chore: update patches * 6215440: Remove base/ranges/. https://chromium-review.googlesource.com/c/chromium/src/+/6215440 * Disable unsafe buffers error Not sure what changed, but we're now seeing unsafe buffer errors in Chromium code, at least when using reclient. Will update this comment if we find out the cause. * 6187853: SelectFileDialogLinuxPortal: Use dbus_xdg::Request and DbusType https://chromium-review.googlesource.com/c/chromium/src/+/6187853 * fix `setDisplayMediaRequestHandler` test Given how this test is written, I would expect this assertion to be false. It seems the oppositue was true before, but that was also acknowledged to be suprising. Seems that the underlying implementation is now fixed and works as expected. * fixup! 6187853: SelectFileDialogLinuxPortal: Use dbus_xdg::Request and DbusType https://chromium-review.googlesource.com/c/chromium/src/+/6187853 * chore: udpate patches * Multiple PRS: https://chromium-review.googlesource.com/c/chromium/src/+/6185544 | https://chromium-review.googlesource.com/c/chromium/src/+/6183252 * fix: cast enum class to numeric type * fix: add 1 to MAX_EXCLUSION_REASON because enum values are zero-based, and we want the total count of reasons. * Reapply "chore: disable focus handling test due to win32/ia32 regression" This reverts commit 760b1a519b5919b483c66bc3096eeefb4d7011f4. * refactor: use ExclusionReasonBitset::kValueCount for size --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Samuel Maddock <smaddock@slack-corp.com> Co-authored-by: clavin <clavin@electronjs.org> Co-authored-by: alice <alice@makenotion.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> (cherry picked from commit 213165a467b84b3fb979a869d9bf10ad21e2d78e) --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
122 lines
4 KiB
C++
122 lines
4 KiB
C++
// Copyright (c) 2019 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_NET_NODE_STREAM_LOADER_H_
|
|
#define ELECTRON_SHELL_BROWSER_NET_NODE_STREAM_LOADER_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "base/memory/raw_ptr.h"
|
|
#include "mojo/public/cpp/bindings/receiver.h"
|
|
#include "mojo/public/cpp/bindings/remote.h"
|
|
#include "services/network/public/mojom/url_loader.mojom.h"
|
|
#include "services/network/public/mojom/url_response_head.mojom.h"
|
|
#include "v8/include/v8-forward.h"
|
|
#include "v8/include/v8-object.h"
|
|
#include "v8/include/v8-persistent-handle.h"
|
|
|
|
namespace mojo {
|
|
class DataPipeProducer;
|
|
template <typename T>
|
|
class PendingReceiver;
|
|
template <typename T>
|
|
class PendingRemote;
|
|
} // namespace mojo
|
|
|
|
namespace electron {
|
|
|
|
// Read data from node Stream and feed it to NetworkService.
|
|
//
|
|
// This class manages its own lifetime and should delete itself when the
|
|
// connection is lost or finished.
|
|
//
|
|
// We use |paused mode| to read data from |Readable| stream, so we don't need to
|
|
// copy data from buffer and hold it in memory, and we only need to make sure
|
|
// the passed |Buffer| is alive while writing data to pipe.
|
|
class NodeStreamLoader : public network::mojom::URLLoader {
|
|
public:
|
|
NodeStreamLoader(network::mojom::URLResponseHeadPtr head,
|
|
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
|
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
|
v8::Isolate* isolate,
|
|
v8::Local<v8::Object> emitter);
|
|
|
|
// disable copy
|
|
NodeStreamLoader(const NodeStreamLoader&) = delete;
|
|
NodeStreamLoader& operator=(const NodeStreamLoader&) = delete;
|
|
|
|
private:
|
|
~NodeStreamLoader() override;
|
|
|
|
using EventCallback = base::RepeatingCallback<void()>;
|
|
|
|
void Start(network::mojom::URLResponseHeadPtr head);
|
|
void NotifyEnd();
|
|
void NotifyError();
|
|
void NotifyReadable();
|
|
void NotifyComplete(int result);
|
|
void ReadMore();
|
|
void DidWrite(MojoResult result);
|
|
|
|
// Subscribe to events of |emitter|.
|
|
void On(const char* event, EventCallback callback);
|
|
|
|
// URLLoader:
|
|
void FollowRedirect(
|
|
const std::vector<std::string>& removed_headers,
|
|
const net::HttpRequestHeaders& modified_headers,
|
|
const net::HttpRequestHeaders& modified_cors_exempt_headers,
|
|
const std::optional<GURL>& new_url) override {}
|
|
void SetPriority(net::RequestPriority priority,
|
|
int32_t intra_priority_value) override {}
|
|
|
|
mojo::Receiver<network::mojom::URLLoader> url_loader_;
|
|
mojo::Remote<network::mojom::URLLoaderClient> client_;
|
|
|
|
raw_ptr<v8::Isolate> isolate_;
|
|
v8::Global<v8::Object> emitter_;
|
|
v8::Global<v8::Value> buffer_;
|
|
|
|
// Mojo data pipe where the data that is being read is written to.
|
|
std::unique_ptr<mojo::DataPipeProducer> producer_;
|
|
|
|
// Whether we are in the middle of write.
|
|
bool is_writing_ = false;
|
|
|
|
// Whether we are in the middle of a stream.read().
|
|
bool is_reading_ = false;
|
|
|
|
size_t bytes_written_ = 0;
|
|
|
|
// When NotifyComplete is called while writing, we will save the result and
|
|
// quit with it after the write is done.
|
|
bool pending_result_ = false;
|
|
int result_ = net::OK;
|
|
|
|
// Set to `true` when we get either `end` or `error` event on the stream.
|
|
// If `false` - we call `stream.destroy()` to finalize the stream.
|
|
bool destroyed_ = false;
|
|
|
|
// When the stream emits the readable event, we only want to start reading
|
|
// data if the stream was not readable before, so we store the state in a
|
|
// flag.
|
|
bool readable_ = false;
|
|
|
|
// It's possible for reads to be queued using nextTick() during read()
|
|
// which will cause 'readable' to emit during ReadMore, so we track if
|
|
// that occurred in a flag.
|
|
bool has_read_waiting_ = false;
|
|
|
|
// Store the V8 callbacks to unsubscribe them later.
|
|
std::map<std::string, v8::Global<v8::Value>> handlers_;
|
|
|
|
base::WeakPtrFactory<NodeStreamLoader> weak_factory_{this};
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_NET_NODE_STREAM_LOADER_H_
|