| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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_SHARED_MEMORY_RECEIVED_DATA_FACTORY_H_ |
| 6 #define CONTENT_CHILD_SHARED_MEMORY_RECEIVED_DATA_FACTORY_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/shared_memory.h" |
| 14 #include "content/common/content_export.h" |
| 15 #include "content/public/child/request_peer.h" |
| 16 |
| 17 namespace IPC { |
| 18 class Sender; |
| 19 } // namespace IPC |
| 20 |
| 21 namespace content { |
| 22 |
| 23 class CONTENT_EXPORT SharedMemoryReceivedDataFactory final |
| 24 : public base::RefCounted<SharedMemoryReceivedDataFactory> { |
| 25 public: |
| 26 SharedMemoryReceivedDataFactory(IPC::Sender* message_sender, |
| 27 int request_id, |
| 28 linked_ptr<base::SharedMemory> memory); |
| 29 |
| 30 scoped_ptr<RequestPeer::ReceivedData> Create(int offset, |
| 31 int length, |
| 32 int encoded_length); |
| 33 |
| 34 // Stops this factory. After calling this function, releasing issued data |
| 35 // won't send ack signal to the browser process. |
| 36 void Stop(); |
| 37 |
| 38 private: |
| 39 // Here TicketId is uint32_t, but a factory may issue more data by reusing id. |
| 40 using TicketId = uint32_t; |
| 41 |
| 42 class SharedMemoryReceivedData; |
| 43 // Called by SharedMemoryReceivedData. |
| 44 void Reclaim(TicketId id); |
| 45 |
| 46 class TicketComparator; |
| 47 friend class base::RefCounted<SharedMemoryReceivedDataFactory>; |
| 48 ~SharedMemoryReceivedDataFactory(); |
| 49 |
| 50 void SendAck(size_t count); |
| 51 |
| 52 TicketId id_; |
| 53 TicketId oldest_; |
| 54 std::vector<TicketId> released_tickets_; |
| 55 // We assume that |message_sender_| is valid until |Stop| is called. |
| 56 IPC::Sender* message_sender_; |
| 57 int request_id_; |
| 58 bool is_stopped_; |
| 59 // Just to keep the payload alive while issued data is alive. |
| 60 linked_ptr<base::SharedMemory> memory_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(SharedMemoryReceivedDataFactory); |
| 63 }; |
| 64 |
| 65 } // namespace content |
| 66 |
| 67 #endif // CONTENT_CHILD_SHARED_MEMORY_RECEIVED_DATA_FACTORY_H_ |
| OLD | NEW |