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

Side by Side Diff: content/child/url_loader_client_impl.h

Issue 2597873002: Move URLLoaderClientImpl to a separate file (Closed)
Patch Set: fix Created 3 years, 12 months 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_
6 #define CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_
7
8 #include <stdint.h>
9 #include <vector>
10 #include "base/callback_forward.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/common/content_export.h"
13 #include "content/common/url_loader.mojom.h"
14 #include "ipc/ipc_message.h"
15 #include "mojo/public/cpp/bindings/associated_binding.h"
16 #include "mojo/public/cpp/system/data_pipe.h"
17
18 namespace base {
19 class SingleThreadTaskRunner;
20 } // namespace base
21
22 namespace mojo {
23 class AssociatedGroup;
24 } // namespace mojo
25
26 namespace net {
27 struct RedirectInfo;
28 } // namespace net
29
30 namespace content {
31 class ResourceDispatcher;
32 class URLResponseBodyConsumer;
33 struct ResourceRequestCompletionStatus;
34 struct ResourceResponseHead;
35
36 class CONTENT_EXPORT URLLoaderClientImpl final : public mojom::URLLoaderClient {
37 public:
38 URLLoaderClientImpl(int request_id,
39 ResourceDispatcher* resource_dispatcher,
40 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
41 ~URLLoaderClientImpl() override;
42
43 void OnReceiveResponse(const ResourceResponseHead& response_head,
44 mojom::DownloadedTempFilePtr downloaded_file) override;
45 void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
46 const ResourceResponseHead& response_head) override;
47 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override;
48 void OnTransferSizeUpdated(int32_t transfer_size_diff) override;
49 void OnStartLoadingResponseBody(
50 mojo::ScopedDataPipeConsumerHandle body) override;
51 void OnComplete(const ResourceRequestCompletionStatus& status) override;
52
53 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info,
54 mojo::AssociatedGroup* associated_group);
55
56 // Sets |is_deferred_|. From now, the received messages are not dispatched
57 // to clients until UnsetDefersLoading is called.
58 void SetDefersLoading();
59
60 // Unsets |is_deferred_|.
61 void UnsetDefersLoading();
62
63 // Disaptches the messages received after SetDefersLoading is called.
64 void FlushDeferredMessages();
65
66 private:
67 class SharedBoolean : public base::RefCounted<SharedBoolean> {
68 public:
69 bool value() const { return value_; }
70 void set(bool b) { value_ = b; }
71
72 private:
73 friend class base::RefCounted<SharedBoolean>;
74 ~SharedBoolean() {}
75
76 bool value_ = false;
77 };
78
79 void Dispatch(const IPC::Message& message);
80
81 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_;
82 scoped_refptr<URLResponseBodyConsumer> body_consumer_;
83 mojom::DownloadedTempFilePtr downloaded_file_;
84 std::vector<IPC::Message> deferred_messages_;
85 const int request_id_;
86 bool has_received_response_ = false;
87 bool is_deferred_ = false;
88 int32_t accumulated_transfer_size_diff_during_deferred_ = 0;
89 ResourceDispatcher* const resource_dispatcher_;
90 const scoped_refptr<SharedBoolean> is_destroyed_;
91 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
92 };
93
94 } // namespace content
95
96 #endif // CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698