| Index: content/child/url_loader_client_impl.h
|
| diff --git a/content/child/url_loader_client_impl.h b/content/child/url_loader_client_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8280ab96c85f294bb6deb014c59c139a789282e4
|
| --- /dev/null
|
| +++ b/content/child/url_loader_client_impl.h
|
| @@ -0,0 +1,96 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_
|
| +#define CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_
|
| +
|
| +#include <stdint.h>
|
| +#include <vector>
|
| +#include "base/callback_forward.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/common/url_loader.mojom.h"
|
| +#include "ipc/ipc_message.h"
|
| +#include "mojo/public/cpp/bindings/associated_binding.h"
|
| +#include "mojo/public/cpp/system/data_pipe.h"
|
| +
|
| +namespace base {
|
| +class SingleThreadTaskRunner;
|
| +} // namespace base
|
| +
|
| +namespace mojo {
|
| +class AssociatedGroup;
|
| +} // namespace mojo
|
| +
|
| +namespace net {
|
| +struct RedirectInfo;
|
| +} // namespace net
|
| +
|
| +namespace content {
|
| +class ResourceDispatcher;
|
| +class URLResponseBodyConsumer;
|
| +struct ResourceRequestCompletionStatus;
|
| +struct ResourceResponseHead;
|
| +
|
| +class CONTENT_EXPORT URLLoaderClientImpl final : public mojom::URLLoaderClient {
|
| + public:
|
| + URLLoaderClientImpl(int request_id,
|
| + ResourceDispatcher* resource_dispatcher,
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner);
|
| + ~URLLoaderClientImpl() override;
|
| +
|
| + void OnReceiveResponse(const ResourceResponseHead& response_head,
|
| + mojom::DownloadedTempFilePtr downloaded_file) override;
|
| + void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
|
| + const ResourceResponseHead& response_head) override;
|
| + void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override;
|
| + void OnTransferSizeUpdated(int32_t transfer_size_diff) override;
|
| + void OnStartLoadingResponseBody(
|
| + mojo::ScopedDataPipeConsumerHandle body) override;
|
| + void OnComplete(const ResourceRequestCompletionStatus& status) override;
|
| +
|
| + void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info,
|
| + mojo::AssociatedGroup* associated_group);
|
| +
|
| + // Sets |is_deferred_|. From now, the received messages are not dispatched
|
| + // to clients until UnsetDefersLoading is called.
|
| + void SetDefersLoading();
|
| +
|
| + // Unsets |is_deferred_|.
|
| + void UnsetDefersLoading();
|
| +
|
| + // Disaptches the messages received after SetDefersLoading is called.
|
| + void FlushDeferredMessages();
|
| +
|
| + private:
|
| + class SharedBoolean : public base::RefCounted<SharedBoolean> {
|
| + public:
|
| + bool value() const { return value_; }
|
| + void set(bool b) { value_ = b; }
|
| +
|
| + private:
|
| + friend class base::RefCounted<SharedBoolean>;
|
| + ~SharedBoolean() {}
|
| +
|
| + bool value_ = false;
|
| + };
|
| +
|
| + void Dispatch(const IPC::Message& message);
|
| +
|
| + mojo::AssociatedBinding<mojom::URLLoaderClient> binding_;
|
| + scoped_refptr<URLResponseBodyConsumer> body_consumer_;
|
| + mojom::DownloadedTempFilePtr downloaded_file_;
|
| + std::vector<IPC::Message> deferred_messages_;
|
| + const int request_id_;
|
| + bool has_received_response_ = false;
|
| + bool is_deferred_ = false;
|
| + int32_t accumulated_transfer_size_diff_during_deferred_ = 0;
|
| + ResourceDispatcher* const resource_dispatcher_;
|
| + const scoped_refptr<SharedBoolean> is_destroyed_;
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_
|
|
|