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

Unified Diff: content/child/shared_memory_received_data_factory.h

Issue 1103813002: Make WebURLLoader capable of retaining received buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/shared_memory_received_data_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/shared_memory_received_data_factory.h
diff --git a/content/child/shared_memory_received_data_factory.h b/content/child/shared_memory_received_data_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..3da0926c14c3494210b867b7490573af00411061
--- /dev/null
+++ b/content/child/shared_memory_received_data_factory.h
@@ -0,0 +1,67 @@
+// Copyright 2015 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_SHARED_MEMORY_RECEIVED_DATA_FACTORY_H_
+#define CONTENT_CHILD_SHARED_MEMORY_RECEIVED_DATA_FACTORY_H_
+
+#include <vector>
+
+#include "base/memory/linked_ptr.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/shared_memory.h"
+#include "content/common/content_export.h"
+#include "content/public/child/request_peer.h"
+
+namespace IPC {
+class Sender;
+} // namespace IPC
+
+namespace content {
+
+class CONTENT_EXPORT SharedMemoryReceivedDataFactory final
+ : public base::RefCounted<SharedMemoryReceivedDataFactory> {
+ public:
+ SharedMemoryReceivedDataFactory(IPC::Sender* message_sender,
+ int request_id,
+ linked_ptr<base::SharedMemory> memory);
+
+ scoped_ptr<RequestPeer::ReceivedData> Create(int offset,
+ int length,
+ int encoded_length);
+
+ // Stops this factory. After calling this function, releasing issued data
+ // won't send ack signal to the browser process.
+ void Stop();
+
+ private:
+ // Here TicketId is uint32_t, but a factory may issue more data by reusing id.
+ using TicketId = uint32_t;
+
+ class SharedMemoryReceivedData;
+ // Called by SharedMemoryReceivedData.
+ void Reclaim(TicketId id);
+
+ class TicketComparator;
+ friend class base::RefCounted<SharedMemoryReceivedDataFactory>;
+ ~SharedMemoryReceivedDataFactory();
+
+ void SendAck(size_t count);
+
+ TicketId id_;
+ TicketId oldest_;
+ std::vector<TicketId> released_tickets_;
+ // We assume that |message_sender_| is valid until |Stop| is called.
+ IPC::Sender* message_sender_;
+ int request_id_;
+ bool is_stopped_;
+ // Just to keep the payload alive while issued data is alive.
+ linked_ptr<base::SharedMemory> memory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedMemoryReceivedDataFactory);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_SHARED_MEMORY_RECEIVED_DATA_FACTORY_H_
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/shared_memory_received_data_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698