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

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

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

Powered by Google App Engine
This is Rietveld 408576698