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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/url_response_body_consumer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/url_response_body_consumer.h
diff --git a/content/child/url_response_body_consumer.h b/content/child/url_response_body_consumer.h
new file mode 100644
index 0000000000000000000000000000000000000000..f7fb232745d1e396845518d5b494a24ab2505e31
--- /dev/null
+++ b/content/child/url_response_body_consumer.h
@@ -0,0 +1,75 @@
+// 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_URL_RESPONSE_BODY_CONSUMER_H_
+#define CONTENT_CHILD_URL_RESPONSE_BODY_CONSUMER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <utility>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "content/common/content_export.h"
+#include "content/common/url_loader.mojom.h"
+#include "mojo/public/cpp/system/data_pipe.h"
+#include "mojo/public/cpp/system/watcher.h"
+
+namespace content {
+
+class ResourceDispatcher;
+struct ResourceRequestCompletionStatus;
+
+// This class pulls data from a data pipe and dispatches it to the
+// ResourceDispatcher. This class is used only for mojo-enabled requests.
+class CONTENT_EXPORT URLResponseBodyConsumer final
+ : public base::RefCounted<URLResponseBodyConsumer>,
+ public base::SupportsWeakPtr<URLResponseBodyConsumer> {
+ public:
+ URLResponseBodyConsumer(int request_id,
+ ResourceDispatcher* resource_dispatcher,
+ mojo::ScopedDataPipeConsumerHandle handle,
+ base::SingleThreadTaskRunner* task_runner);
+
+ // Sets the completion status. The completion status is dispatched to the
+ // ResourceDispatcher when the both following conditions hold:
+ // 1) This function has been called and the completion status is set, and
+ // 2) All data is read from the handle.
+ void OnComplete(const ResourceRequestCompletionStatus& status);
+
+ // Cancels watching the handle and dispatches an error to the
+ // ResourceDispatcher. This function does nothing if the reading is already
+ // cancelled or done.
+ void Cancel();
+
+ private:
+ friend class base::RefCounted<URLResponseBodyConsumer>;
+ ~URLResponseBodyConsumer();
+
+ class ReceivedData;
+ void Reclaim(uint32_t size);
+
+ void OnReadable(MojoResult unused);
+ void NotifyCompletionIfAppropriate();
+
+ const int request_id_;
+ ResourceDispatcher* resource_dispatcher_;
+ mojo::ScopedDataPipeConsumerHandle handle_;
+ mojo::Watcher handle_watcher_;
+ ResourceRequestCompletionStatus completion_status_;
+
+ bool has_received_completion_ = false;
+ bool has_been_cancelled_ = false;
+ bool has_seen_end_of_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(URLResponseBodyConsumer);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_URL_RESPONSE_BODY_CONSUMER_H_
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/url_response_body_consumer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698