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

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

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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_RESPONSE_BODY_CONSUMER_H_
6 #define CONTENT_CHILD_URL_RESPONSE_BODY_CONSUMER_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <utility>
12 #include <vector>
13
14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h"
16 #include "content/common/content_export.h"
17 #include "content/common/url_loader.mojom.h"
18 #include "mojo/message_pump/handle_watcher.h"
19 #include "mojo/public/cpp/system/data_pipe.h"
20
21 namespace content {
22
23 class ResourceDispatcher;
24 struct ResourceRequestCompletionStatus;
25
26 // This class pulls data from a data pipe and dispatches it to the
27 // ResourceDispatcher.
kinuko 2016/08/04 16:07:03 nit: also comment that this is used when IPC mode
yhirano 2016/08/05 12:21:40 Done.
28 class CONTENT_EXPORT URLResponseBodyConsumer final
29 : public base::RefCounted<URLResponseBodyConsumer> {
30 public:
31 URLResponseBodyConsumer(int request_id,
32 ResourceDispatcher* resource_dispatcher,
33 mojo::ScopedDataPipeConsumerHandle handle);
34
35 // Sets the completion status. Dispatches the completion status to the
36 // ResourceDispatcher when the both following conditions hold:
37 // 1) The completion status is set by this function, and
kinuko 2016/08/04 16:07:03 I wasn't quite sure what this comment actually mea
yhirano 2016/08/05 12:21:40 No. It means this class stores the completion noti
kinuko 2016/08/08 15:47:25 I see, so it's not really about the behavior of th
yhirano 2016/08/09 06:35:48 Done.
38 // 2) All data is read from the handle.
39 void OnComplete(const ResourceRequestCompletionStatus& status);
40
41 // Cancels watching the handle and dispatches an error to the
42 // ResourceDispatcher. This function does nothing if the reading is already
43 // cancelled or done.
44 void Cancel();
45
46 private:
47 friend class base::RefCounted<URLResponseBodyConsumer>;
48 ~URLResponseBodyConsumer();
49
50 class ReceivedData;
51 void Reclaim(uint32_t size);
52
53 void OnReadable(MojoResult);
54 void StartWatching();
55 void NotifyCompletionIfAppropriate();
56
57 int request_id_;
kinuko 2016/08/04 16:07:03 nit: const
yhirano 2016/08/05 12:21:40 Done.
58 ResourceDispatcher* resource_dispatcher_;
59 mojo::ScopedDataPipeConsumerHandle handle_;
60 mojo::common::HandleWatcher handle_watcher_;
61 ResourceRequestCompletionStatus completion_status_;
62
63 bool has_received_completion_ = false;
64 bool has_been_cancelled_ = false;
65 bool has_seen_end_of_data_;
66
67 DISALLOW_COPY_AND_ASSIGN(URLResponseBodyConsumer);
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_CHILD_URL_RESPONSE_BODY_CONSUMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698