OLD | NEW |
---|---|
(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 "base/callback_forward.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "content/common/content_export.h" | |
12 #include "content/common/url_loader.mojom.h" | |
13 #include "ipc/ipc_message.h" | |
14 #include "mojo/public/cpp/bindings/associated_binding.h" | |
15 #include "mojo/public/cpp/system/data_pipe.h" | |
16 | |
17 namespace base { | |
18 class SingleThreadTaskRunner; | |
19 } // namespace base | |
20 | |
21 namespace mojo { | |
22 class AssociatedGroup; | |
23 } // namespace mojo | |
24 | |
25 namespace net { | |
26 struct RedirectInfo; | |
27 } // namespace net | |
28 | |
29 namespace content { | |
30 class ResourceDispatcher; | |
31 class URLResponseBodyConsumer; | |
32 struct ResourceRequestCompletionStatus; | |
33 struct ResourceResponseHead; | |
34 | |
35 class CONTENT_EXPORT URLLoaderClientImpl final : public mojom::URLLoaderClient { | |
36 public: | |
37 URLLoaderClientImpl(int request_id, | |
38 ResourceDispatcher* resource_dispatcher, | |
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
40 ~URLLoaderClientImpl() override; | |
41 | |
42 void OnReceiveResponse(const ResourceResponseHead& response_head, | |
43 mojom::DownloadedTempFilePtr downloaded_file) override; | |
44 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, | |
45 const ResourceResponseHead& response_head) override; | |
46 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override; | |
47 void OnTransferSizeUpdated(int32_t transfer_size_diff) override; | |
48 void OnStartLoadingResponseBody( | |
49 mojo::ScopedDataPipeConsumerHandle body) override; | |
50 void OnComplete(const ResourceRequestCompletionStatus& status) override; | |
51 | |
52 void Bind(mojom::URLLoaderClientAssociatedPtrInfo* client_ptr_info, | |
53 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.
| |
54 | |
55 private: | |
56 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.
| |
57 public: | |
58 bool value() const { return value_; } | |
59 void set(bool b) { value_ = b; } | |
60 | |
61 private: | |
62 friend class base::RefCounted<SharedBoolean>; | |
63 ~SharedBoolean() {} | |
64 | |
65 bool value_ = false; | |
66 }; | |
67 | |
68 void Dispatch(const IPC::Message& message); | |
69 | |
70 mojo::AssociatedBinding<mojom::URLLoaderClient> binding_; | |
71 scoped_refptr<URLResponseBodyConsumer> body_consumer_; | |
72 mojom::DownloadedTempFilePtr downloaded_file_; | |
73 const int request_id_; | |
74 bool has_received_response_ = false; | |
75 ResourceDispatcher* const resource_dispatcher_; | |
76 const scoped_refptr<SharedBoolean> is_destroyed_; | |
77 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
78 }; | |
79 | |
80 } // namespace content | |
81 | |
82 #endif // CONTENT_CHILD_URL_LOADER_CLIENT_IMPL_H_ | |
OLD | NEW |