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

Unified Diff: content/child/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: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/child/body_consumer.h
diff --git a/content/child/body_consumer.h b/content/child/body_consumer.h
new file mode 100644
index 0000000000000000000000000000000000000000..caf4c1571d6550fbe85b7c3afc63252b54df14be
--- /dev/null
+++ b/content/child/body_consumer.h
@@ -0,0 +1,59 @@
+// 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_BODY_CONSUMER_H_
+#define CONTENT_CHILD_BODY_CONSUMER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <utility>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "content/common/url_loader.mojom.h"
+#include "mojo/message_pump/handle_watcher.h"
+#include "mojo/public/cpp/system/data_pipe.h"
+
+namespace content {
+
+class ResourceDispatcher;
+
+class BodyConsumer final : public base::RefCounted<BodyConsumer> {
jam 2016/05/13 00:55:06 nit: please document this class and the methods
yhirano 2016/05/17 12:38:49 Done.
+ public:
+ BodyConsumer(int request_id,
+ ResourceDispatcher* resource_dispatcher,
+ mojo::ScopedDataPipeConsumerHandle handle);
+
+ void OnComplete(mojom::URLLoaderStatusPtr status);
+ void Cancel();
+
+ private:
+ friend class base::RefCounted<BodyConsumer>;
+ ~BodyConsumer();
+
+ class ReceivedData;
+ void Reclaim(uint32_t size);
+
+ void OnReadable(MojoResult);
+ void StartWatching();
+ void NotifyCompletionIfAppropriate();
+
+ int request_id_;
+ ResourceDispatcher* resource_dispatcher_;
+ mojo::ScopedDataPipeConsumerHandle handle_;
+ mojo::common::HandleWatcher handle_watcher_;
+ mojom::URLLoaderStatusPtr completion_status_;
+
+ bool has_received_completion_ = false;
+ bool has_been_cancelled_ = false;
+ bool has_seen_end_of_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(BodyConsumer);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_BODY_CONSUMER_H_

Powered by Google App Engine
This is Rietveld 408576698