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

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

Issue 1186053004: Cancel loading when body stream reader is detached. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@error-ipc-data-consumer
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | content/child/shared_memory_data_consumer_handle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ 5 #ifndef CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ 6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
7 7
8 #include "base/callback.h"
8 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
11 #include "content/public/child/request_peer.h" 12 #include "content/public/child/request_peer.h"
12 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" 13 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h"
13 14
14 namespace content { 15 namespace content {
15 16
16 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData. 17 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData.
17 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final 18 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 virtual Result read(void* data, size_t size, Flags flags, size_t* readSize); 51 virtual Result read(void* data, size_t size, Flags flags, size_t* readSize);
51 virtual Result beginRead(const void** buffer, 52 virtual Result beginRead(const void** buffer,
52 Flags flags, 53 Flags flags,
53 size_t* available); 54 size_t* available);
54 virtual Result endRead(size_t readSize); 55 virtual Result endRead(size_t readSize);
55 56
56 private: 57 private:
57 scoped_refptr<Context> context_; 58 scoped_refptr<Context> context_;
58 59
59 DISALLOW_COPY_AND_ASSIGN(ReaderImpl); 60 DISALLOW_COPY_AND_ASSIGN(ReaderImpl);
60 }; 61 };
61 62
63 // Creates a handle and a writer associated with the handle. The created
64 // writer should be used on the calling thread.
62 SharedMemoryDataConsumerHandle(BackpressureMode mode, 65 SharedMemoryDataConsumerHandle(BackpressureMode mode,
63 scoped_ptr<Writer>* writer); 66 scoped_ptr<Writer>* writer);
67 // |on_reader_detached| will be called aynchronously on the calling thread
68 // when the reader (including the handle) is detached (i.e. both the handle
69 // and the reader are destructed). The callback will be reset in the internal
70 // context when the writer is detached, i.e. |Close| or |Fail| is called,
71 // and the callback will never be called.
72 SharedMemoryDataConsumerHandle(BackpressureMode mode,
73 const base::Closure& on_reader_detached,
74 scoped_ptr<Writer>* writer);
64 virtual ~SharedMemoryDataConsumerHandle(); 75 virtual ~SharedMemoryDataConsumerHandle();
65 76
66 scoped_ptr<Reader> ObtainReader(Client* client); 77 scoped_ptr<Reader> ObtainReader(Client* client);
67 78
68 private: 79 private:
69 virtual ReaderImpl* obtainReaderInternal(Client* client); 80 virtual ReaderImpl* obtainReaderInternal(Client* client);
70 const char* debugName() const override; 81 const char* debugName() const override;
71 82
72 scoped_refptr<Context> context_; 83 scoped_refptr<Context> context_;
73 84
74 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); 85 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle);
75 }; 86 };
76 87
77 } // namespace content 88 } // namespace content
78 89
79 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ 90 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/shared_memory_data_consumer_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698