Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: content/child/url_loader_client_impl.h

Issue 2597873002: Move URLLoaderClientImpl to a separate file (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1dcd8ccd9967785023b4019520da71de1af153bc
--- /dev/null
+++ b/content/child/url_loader_client_impl.h
@@ -0,0 +1,82 @@
+// 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 "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);
kinuko 2016/12/22 07:54:48 nit: maybe have this above the overriding methods
yhirano 2016/12/22 08:03:32 Done.
+
+private:
+ class SharedBoolean : public base::RefCounted<SharedBoolean> {
kinuko 2016/12/22 07:54:48 Hmm... could we instead use base::RefCountedData?
yhirano 2016/12/22 08:03:32 OK, I will address it in the next CL.
+ 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_;
+ const int request_id_;
+ bool has_received_response_ = false;
+ 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_

Powered by Google App Engine
This is Rietveld 408576698